From 3a9028302447ad84363c580b2152f30417186667 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 8 Jan 2025 14:33:30 +1300 Subject: Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets --- src/c_fl_widget.cpp | 66 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'src/c_fl_widget.cpp') diff --git a/src/c_fl_widget.cpp b/src/c_fl_widget.cpp index 44c5939..61e5a96 100644 --- a/src/c_fl_widget.cpp +++ b/src/c_fl_widget.cpp @@ -7,38 +7,49 @@ #include #include #include "c_fl_widget.h" -#include "c_fl_type.h" +// Exports from Ada + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +// Non-friend protected access + +class Friend_Widget : Fl_Widget { +public: + // probably expand this later when doing a pass for protected methods + using Fl_Widget::draw_box; +}; + + + + +// Attaching all relevant hooks and friends + class My_Widget : public Fl_Widget { - public: - using Fl_Widget::Fl_Widget; - friend void widget_set_draw_hook(WIDGET w, void * d); - friend void widget_set_handle_hook(WIDGET w, void * h); - friend WIDGET new_fl_widget(int x, int y, int w, int h, char* label); - protected: - void draw(); - int handle(int e); - d_hook_p draw_hook; - h_hook_p handle_hook; +public: + using Fl_Widget::Fl_Widget; + friend WIDGET new_fl_widget(int x, int y, int w, int h, char* label); + + friend void fl_widget_draw(WIDGET w); + friend int fl_widget_handle(WIDGET w, int e); + + void draw(); + int handle(int e); }; void My_Widget::draw() { - (*draw_hook)(this->user_data()); + widget_draw_hook(this->user_data()); } int My_Widget::handle(int e) { - return (*handle_hook)(this->user_data(), e); -} - -void widget_set_draw_hook(WIDGET w, void * d) { - reinterpret_cast(w)->draw_hook = reinterpret_cast(d); -} - -void widget_set_handle_hook(WIDGET w, void * h) { - reinterpret_cast(w)->handle_hook = reinterpret_cast(h); + return widget_handle_hook(this->user_data(), e); } @@ -349,6 +360,14 @@ void fl_widget_set_damage2(WIDGET w, int t, int x, int y, int d, int h) { } } +void fl_widget_draw(WIDGET w) { + // The Fl_Widget draw method doesn't technically exist, so... + (void)(w); + // It is more convenient for this function to exist, however, + // even though it will likely never be called, because it simplifies + // and makes uniform the implementation of the Ada Widget Draw subprogram. +} + void fl_widget_draw_label(WIDGET w, int x, int y, int d, int h, unsigned int a) { reinterpret_cast(w)->draw_label(x,y,d,h,a); } @@ -361,3 +380,8 @@ void fl_widget_redraw_label(WIDGET w) { reinterpret_cast(w)->redraw_label(); } +int fl_widget_handle(WIDGET w, int e) { + return reinterpret_cast(w)->Fl_Widget::handle(e); +} + + -- cgit