From 49f2a539cdc77b504ddef00162625531b659c767 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Mon, 6 Jan 2025 23:46:40 +1300 Subject: Revised Browser subhierarchy, mostly protected method bindings --- src/c_fl_browser.cpp | 114 +++++++++++---------------------------------------- 1 file changed, 23 insertions(+), 91 deletions(-) (limited to 'src/c_fl_browser.cpp') diff --git a/src/c_fl_browser.cpp b/src/c_fl_browser.cpp index ba74715..8bd7c96 100644 --- a/src/c_fl_browser.cpp +++ b/src/c_fl_browser.cpp @@ -37,6 +37,16 @@ extern "C" int widget_handle_hook(void * ud, int e); +// Non-friend protected access + +class Friend_Browser : Fl_Browser { +public: + using Fl_Browser::lineno; +}; + + + + // Attaching all relevant hooks and friends class My_Browser : public Fl_Browser { @@ -56,29 +66,11 @@ public: friend const char * fl_browser_item_text(BROWSER b, void * item); friend void fl_browser_item_draw(BROWSER b, void * item, int x, int y, int w, int h); - friend int fl_browser_lineno(BROWSER b, void * item); - - friend void * fl_browser_selection(BROWSER c); - friend int fl_browser_displayed2(BROWSER c, void * i); - friend void * fl_browser_find_item(BROWSER c, int y); - friend void * fl_browser_top(BROWSER c); - - friend void fl_browser_bbox(BROWSER c, int &x, int &y, int &w, int &h); - friend int fl_browser_leftedge(BROWSER c); - friend void fl_browser_redraw_line(BROWSER c, void * i); - friend void fl_browser_redraw_lines(BROWSER c); - friend int fl_browser_full_width(BROWSER c); friend int fl_browser_full_height(BROWSER c); friend int fl_browser_incr_height(BROWSER c); friend int fl_browser_item_quick_height(BROWSER c, void * i); - friend void fl_browser_new_list(BROWSER b); - friend void fl_browser_inserting(BROWSER b, void * a1, void * a2); - friend void fl_browser_deleting(BROWSER b, void * item); - friend void fl_browser_replacing(BROWSER b, void * a1, void * a2); - friend void fl_browser_swapping(BROWSER b, void * a1, void * a2); - friend void fl_browser_draw(BROWSER b); int handle(int e); @@ -367,58 +359,58 @@ int fl_browser_incr_height(BROWSER c) { int fl_browser_item_width(BROWSER b, void * item) { - return reinterpret_cast(b)->item_width(item); + return reinterpret_cast(b)->Fl_Browser::item_width(item); } int fl_browser_item_height(BROWSER b, void * item) { - return reinterpret_cast(b)->item_height(item); + return reinterpret_cast(b)->Fl_Browser::item_height(item); } void * fl_browser_item_first(BROWSER b) { - return reinterpret_cast(b)->item_first(); + return reinterpret_cast(b)->Fl_Browser::item_first(); } void * fl_browser_item_last(BROWSER b) { - return reinterpret_cast(b)->item_last(); + return reinterpret_cast(b)->Fl_Browser::item_last(); } void * fl_browser_item_next(BROWSER b, void * item) { - return reinterpret_cast(b)->item_next(item); + return reinterpret_cast(b)->Fl_Browser::item_next(item); } void * fl_browser_item_prev(BROWSER b, void * item) { - return reinterpret_cast(b)->item_prev(item); + return reinterpret_cast(b)->Fl_Browser::item_prev(item); } void * fl_browser_item_at(BROWSER b, int index) { - return reinterpret_cast(b)->item_at(index); + return reinterpret_cast(b)->Fl_Browser::item_at(index); } void fl_browser_item_select(BROWSER b, void * item, int val) { - reinterpret_cast(b)->item_select(item, val); + reinterpret_cast(b)->Fl_Browser::item_select(item, val); } int fl_browser_item_selected(BROWSER b, void * item) { - return reinterpret_cast(b)->item_selected(item); + return reinterpret_cast(b)->Fl_Browser::item_selected(item); } void fl_browser_item_swap(BROWSER b, void * x, void * y) { - reinterpret_cast(b)->item_swap(x, y); + reinterpret_cast(b)->Fl_Browser::item_swap(x, y); } const char * fl_browser_item_text(BROWSER b, void * item) { - return reinterpret_cast(b)->item_text(item); + return reinterpret_cast(b)->Fl_Browser::item_text(item); } void fl_browser_item_draw(BROWSER b, void * item, int x, int y, int w, int h) { - reinterpret_cast(b)->item_draw(item, x, y, w, h); + reinterpret_cast(b)->Fl_Browser::item_draw(item, x, y, w, h); } int fl_browser_lineno(BROWSER b, void * item) { - return reinterpret_cast(b)->lineno(item); + return (reinterpret_cast(b)->*(&Friend_Browser::lineno))(item); } @@ -426,43 +418,6 @@ int fl_browser_lineno(BROWSER b, void * item) { // These have to be reimplemented due to relying on custom class extensions -void * fl_browser_selection(BROWSER c) { - return reinterpret_cast(c)->selection(); -} - -int fl_browser_displayed2(BROWSER c, void * i) { - return reinterpret_cast(c)->Fl_Browser_::displayed(i); -} - -void * fl_browser_find_item(BROWSER c, int y) { - return reinterpret_cast(c)->find_item(y); -} - -void * fl_browser_top(BROWSER c) { - return reinterpret_cast(c)->top(); -} - - - - -void fl_browser_bbox(BROWSER c, int &x, int &y, int &w, int &h) { - reinterpret_cast(c)->bbox(x, y, w, h); -} - -int fl_browser_leftedge(BROWSER c) { - return reinterpret_cast(c)->leftedge(); -} - -void fl_browser_redraw_line(BROWSER c, void * i) { - reinterpret_cast(c)->redraw_line(i); -} - -void fl_browser_redraw_lines(BROWSER c) { - reinterpret_cast(c)->redraw_lines(); -} - - - int fl_browser_full_width(BROWSER c) { return reinterpret_cast(c)->Fl_Browser::full_width(); @@ -475,29 +430,6 @@ int fl_browser_item_quick_height(BROWSER c, void * i) { -void fl_browser_new_list(BROWSER b) { - reinterpret_cast(b)->new_list(); -} - -void fl_browser_inserting(BROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->inserting(a1, a2); -} - -void fl_browser_deleting(BROWSER b, void * item) { - reinterpret_cast(b)->deleting(item); -} - -void fl_browser_replacing(BROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->replacing(a1, a2); -} - -void fl_browser_swapping(BROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->swapping(a1, a2); -} - - - - void fl_browser_draw(BROWSER b) { reinterpret_cast(b)->Fl_Browser::draw(); } -- cgit