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_file_browser.cpp | 196 ++++++++++++++++------------------------------ 1 file changed, 67 insertions(+), 129 deletions(-) (limited to 'src/c_fl_file_browser.cpp') diff --git a/src/c_fl_file_browser.cpp b/src/c_fl_file_browser.cpp index 836a991..8b5b632 100644 --- a/src/c_fl_file_browser.cpp +++ b/src/c_fl_file_browser.cpp @@ -5,6 +5,7 @@ #include +#include #include #include "c_fl_file_browser.h" @@ -14,12 +15,12 @@ // Exports from Ada extern "C" int browser_full_width_hook(void * b); -extern "C" int browser_full_height_hook(void * b); -extern "C" int browser_incr_height_hook(void * b); +// extern "C" int browser_full_height_hook(void * b); +// extern "C" int browser_incr_height_hook(void * b); extern "C" int browser_item_quick_height_hook(void * b, void * i); -extern "C" int browser_item_width_hook(void * b, void * i); -extern "C" int browser_item_height_hook(void * b, void * i); +// extern "C" int browser_item_width_hook(void * b, void * i); +// extern "C" int browser_item_height_hook(void * b, void * i); extern "C" void * browser_item_first_hook(void * b); extern "C" void * browser_item_last_hook(void * b); extern "C" void * browser_item_next_hook(void * b, void * i); @@ -29,7 +30,7 @@ extern "C" void browser_item_select_hook(void * b, void * i, int s); extern "C" int browser_item_selected_hook(void * b, void * i); extern "C" void browser_item_swap_hook(void * b, void * one, void * two); extern "C" const char * browser_item_text_hook(void * b, void * i); -extern "C" void browser_item_draw_hook(void * b, void * i, int x, int y, int w, int h); +// extern "C" void browser_item_draw_hook(void * b, void * i, int x, int y, int w, int h); extern "C" void widget_draw_hook(void * ud); extern "C" int widget_handle_hook(void * ud, int e); @@ -37,6 +38,23 @@ extern "C" int widget_handle_hook(void * ud, int e); +// Non-friend protected / private access + +// Should check these in future versions of FLTK to see whether +// it is possible to change them back to being overridden properly. + +class Friend_Browser : Fl_Browser { +public: + using Fl_Browser::full_height; + using Fl_Browser::incr_height; + using Fl_Browser::item_width; + using Fl_Browser::item_height; + using Fl_Browser::item_draw; +}; + + + + // Attaching all relevant hooks and friends class My_File_Browser : public Fl_File_Browser { @@ -56,41 +74,23 @@ public: friend const char * fl_file_browser_item_text(FILEBROWSER b, void * item); friend void fl_file_browser_item_draw(FILEBROWSER b, void * item, int x, int y, int w, int h); - friend int fl_file_browser_lineno(FILEBROWSER b, void * item); - - friend void * fl_file_browser_selection(FILEBROWSER c); - friend int fl_file_browser_displayed2(FILEBROWSER c, void * i); - friend void * fl_file_browser_find_item(FILEBROWSER c, int y); - friend void * fl_file_browser_top(FILEBROWSER c); - - friend void fl_file_browser_bbox(FILEBROWSER c, int &x, int &y, int &w, int &h); - friend int fl_file_browser_leftedge(FILEBROWSER c); - friend void fl_file_browser_redraw_line(FILEBROWSER c, void * i); - friend void fl_file_browser_redraw_lines(FILEBROWSER c); - friend int fl_file_browser_full_width(FILEBROWSER c); friend int fl_file_browser_full_height(FILEBROWSER c); friend int fl_file_browser_incr_height(FILEBROWSER c); friend int fl_file_browser_item_quick_height(FILEBROWSER c, void * i); - friend void fl_file_browser_new_list(FILEBROWSER b); - friend void fl_file_browser_inserting(FILEBROWSER b, void * a1, void * a2); - friend void fl_file_browser_deleting(FILEBROWSER b, void * item); - friend void fl_file_browser_replacing(FILEBROWSER b, void * a1, void * a2); - friend void fl_file_browser_swapping(FILEBROWSER b, void * a1, void * a2); - friend void fl_file_browser_draw(FILEBROWSER b); int handle(int e); protected: int full_width() const; - int full_height() const; - int incr_height() const; + // int full_height() const; + // int incr_height() const; int item_quick_height(void * item) const; - int item_width(void * item) const; - int item_height(void * item) const; + // int item_width(void * item) const; + // int item_height(void * item) const; void * item_first() const; void * item_last() const; void * item_next(void * item) const; @@ -100,7 +100,7 @@ protected: int item_selected(void * item) const; void item_swap(void * a, void * b); const char * item_text(void * item) const; - void item_draw(void * item, int x, int y, int w, int h) const; + // void item_draw(void * item, int x, int y, int w, int h) const; void draw(); }; @@ -110,26 +110,26 @@ int My_File_Browser::full_width() const { return browser_full_width_hook(this->user_data()); } -int My_File_Browser::full_height() const { - return browser_full_height_hook(this->user_data()); -} +// int My_File_Browser::full_height() const { +// return browser_full_height_hook(this->user_data()); +// } -int My_File_Browser::incr_height() const { - return browser_incr_height_hook(this->user_data()); -} +// int My_File_Browser::incr_height() const { +// return browser_incr_height_hook(this->user_data()); +// } int My_File_Browser::item_quick_height(void * item) const { return browser_item_quick_height_hook(this->user_data(), item); } -int My_File_Browser::item_width(void * item) const { - return browser_item_width_hook(this->user_data(), item); -} +// int My_File_Browser::item_width(void * item) const { +// return browser_item_width_hook(this->user_data(), item); +// } -int My_File_Browser::item_height(void * item) const { - return browser_item_height_hook(this->user_data(), item); -} +// int My_File_Browser::item_height(void * item) const { +// return browser_item_height_hook(this->user_data(), item); +// } void * My_File_Browser::item_first() const { return browser_item_first_hook(this->user_data()); @@ -167,9 +167,9 @@ const char * My_File_Browser::item_text(void * item) const { return browser_item_text_hook(this->user_data(), item); } -void My_File_Browser::item_draw(void * item, int x, int y, int w, int h) const { - browser_item_draw_hook(this->user_data(), item, x, y, w, h); -} +// void My_File_Browser::item_draw(void * item, int x, int y, int w, int h) const { +// browser_item_draw_hook(this->user_data(), item, x, y, w, h); +// } void My_File_Browser::draw() { @@ -241,153 +241,91 @@ void fl_file_browser_set_textsize(FILEBROWSER b, int s) { // These have to be reimplemented due to relying on custom class extensions + int fl_file_browser_full_height(FILEBROWSER c) { - return reinterpret_cast(c)->Fl_Browser::full_height(); + // return reinterpret_cast(c)->Fl_File_Browser::full_height(); + return (reinterpret_cast(c)->*(&Friend_Browser::full_height))(); } int fl_file_browser_incr_height(FILEBROWSER c) { - return reinterpret_cast(c)->Fl_Browser::incr_height(); + // return reinterpret_cast(c)->Fl_File_Browser::incr_height(); + return (reinterpret_cast(c)->*(&Friend_Browser::incr_height))(); } int fl_file_browser_item_width(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_width(item); + // return reinterpret_cast(b)->Fl_File_Browser::item_width(item); + return (reinterpret_cast(b)->*(&Friend_Browser::item_width))(item); } int fl_file_browser_item_height(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_height(item); + // return reinterpret_cast(b)->Fl_File_Browser::item_height(item); + return (reinterpret_cast(b)->*(&Friend_Browser::item_height))(item); } void * fl_file_browser_item_first(FILEBROWSER b) { - return reinterpret_cast(b)->item_first(); + return reinterpret_cast(b)->Fl_File_Browser::item_first(); } void * fl_file_browser_item_last(FILEBROWSER b) { - return reinterpret_cast(b)->item_last(); + return reinterpret_cast(b)->Fl_File_Browser::item_last(); } void * fl_file_browser_item_next(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_next(item); + return reinterpret_cast(b)->Fl_File_Browser::item_next(item); } void * fl_file_browser_item_prev(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_prev(item); + return reinterpret_cast(b)->Fl_File_Browser::item_prev(item); } void * fl_file_browser_item_at(FILEBROWSER b, int index) { - return reinterpret_cast(b)->item_at(index); + return reinterpret_cast(b)->Fl_File_Browser::item_at(index); } void fl_file_browser_item_select(FILEBROWSER b, void * item, int val) { - reinterpret_cast(b)->item_select(item, val); + reinterpret_cast(b)->Fl_File_Browser::item_select(item, val); } int fl_file_browser_item_selected(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_selected(item); + return reinterpret_cast(b)->Fl_File_Browser::item_selected(item); } void fl_file_browser_item_swap(FILEBROWSER b, void * x, void * y) { - reinterpret_cast(b)->item_swap(x, y); + reinterpret_cast(b)->Fl_File_Browser::item_swap(x, y); } const char * fl_file_browser_item_text(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->item_text(item); + return reinterpret_cast(b)->Fl_File_Browser::item_text(item); } void fl_file_browser_item_draw(FILEBROWSER b, void * item, int x, int y, int w, int h) { - reinterpret_cast(b)->item_draw(item, x, y, w, h); -} - - - - -int fl_file_browser_lineno(FILEBROWSER b, void * item) { - return reinterpret_cast(b)->lineno(item); -} - - - - -void * fl_file_browser_selection(FILEBROWSER c) { - return reinterpret_cast(c)->selection(); -} - -int fl_file_browser_displayed2(FILEBROWSER c, void * i) { - return reinterpret_cast(c)->Fl_Browser_::displayed(i); -} - -void * fl_file_browser_find_item(FILEBROWSER c, int y) { - return reinterpret_cast(c)->find_item(y); -} - -void * fl_file_browser_top(FILEBROWSER c) { - return reinterpret_cast(c)->top(); -} - - - - -void fl_file_browser_bbox(FILEBROWSER c, int &x, int &y, int &w, int &h) { - reinterpret_cast(c)->bbox(x, y, w, h); -} - -int fl_file_browser_leftedge(FILEBROWSER c) { - return reinterpret_cast(c)->leftedge(); -} - -void fl_file_browser_redraw_line(FILEBROWSER c, void * i) { - reinterpret_cast(c)->redraw_line(i); -} - -void fl_file_browser_redraw_lines(FILEBROWSER c) { - reinterpret_cast(c)->redraw_lines(); + // reinterpret_cast(b)->Fl_File_Browser::item_draw(item, x, y, w, h); + (reinterpret_cast(b)->*(&Friend_Browser::item_draw))(item, x, y, w, h); } int fl_file_browser_full_width(FILEBROWSER c) { - return reinterpret_cast(c)->Fl_Browser::full_width(); + return reinterpret_cast(c)->Fl_File_Browser::full_width(); } int fl_file_browser_item_quick_height(FILEBROWSER c, void * i) { - return reinterpret_cast(c)->Fl_Browser::item_quick_height(i); -} - - - - -void fl_file_browser_new_list(FILEBROWSER b) { - reinterpret_cast(b)->new_list(); -} - -void fl_file_browser_inserting(FILEBROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->inserting(a1, a2); -} - -void fl_file_browser_deleting(FILEBROWSER b, void * item) { - reinterpret_cast(b)->deleting(item); -} - -void fl_file_browser_replacing(FILEBROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->replacing(a1, a2); -} - -void fl_file_browser_swapping(FILEBROWSER b, void * a1, void * a2) { - reinterpret_cast(b)->swapping(a1, a2); + return reinterpret_cast(c)->Fl_File_Browser::item_quick_height(i); } void fl_file_browser_draw(FILEBROWSER b) { - reinterpret_cast(b)->Fl_Browser::draw(); + reinterpret_cast(b)->Fl_File_Browser::draw(); } int fl_file_browser_handle(FILEBROWSER b, int e) { - return reinterpret_cast(b)->Fl_Browser::handle(e); + return reinterpret_cast(b)->Fl_File_Browser::handle(e); } -- cgit