From 106316bcedec72c5380a7544c27be6a5c117e57a Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 15 Jan 2025 23:52:50 +1300 Subject: Filled holes in Fl_Menu_ and Fl_Menu_Item bound APIs, fixed a few irritating bugs, damn the treacherous C++ API --- src/c_fl_menuitem.cpp | 158 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 95 insertions(+), 63 deletions(-) (limited to 'src/c_fl_menuitem.cpp') diff --git a/src/c_fl_menuitem.cpp b/src/c_fl_menuitem.cpp index 217b3bd..cb4ebee 100644 --- a/src/c_fl_menuitem.cpp +++ b/src/c_fl_menuitem.cpp @@ -6,157 +6,189 @@ #include #include +#include #include "c_fl_menuitem.h" +// Exports from Ada + +extern "C" void menu_item_callback_hook(void * cobj, void * ud); + + + + +// Flattened C API + +void * null_fl_menu_item() { + Fl_Menu_Item *mi = new Fl_Menu_Item; + mi->label(0); + return mi; +} + void * new_fl_menu_item(char * t, void * c, unsigned long s, unsigned long f) { Fl_Menu_Item *mi = new Fl_Menu_Item; - mi->callback(reinterpret_cast(c)); + mi->callback(c==0?0:reinterpret_cast(&menu_item_callback_hook), c); mi->flags = static_cast(f); mi->shortcut(static_cast(s)); mi->label(t); return mi; } -void free_fl_menu_item(MENU_ITEM mi) { - delete reinterpret_cast(mi); +void free_fl_menu_item(MENUITEM mi) { + delete static_cast(mi); } -void * fl_menu_item_get_user_data(MENU_ITEM mi) { - return reinterpret_cast(mi)->user_data(); +void * fl_menu_item_get_user_data(MENUITEM mi) { + return static_cast(mi)->user_data(); } -void fl_menu_item_set_user_data(MENU_ITEM mi, void * c) { - reinterpret_cast(mi)->user_data(c); +void fl_menu_item_set_callback(MENUITEM mi, void * c) { + static_cast(mi)->callback + (c==0?0:reinterpret_cast(&menu_item_callback_hook), c); } -void fl_menu_item_do_callback(MENU_ITEM mi, void * w) { - reinterpret_cast(mi)->do_callback(reinterpret_cast(w)); +void fl_menu_item_do_callback(MENUITEM mi, void * w) { + static_cast(mi)->do_callback(static_cast(w)); } -int fl_menu_item_checkbox(MENU_ITEM mi) { - return reinterpret_cast(mi)->checkbox(); +int fl_menu_item_checkbox(MENUITEM mi) { + return static_cast(mi)->checkbox(); } -int fl_menu_item_radio(MENU_ITEM mi) { - return reinterpret_cast(mi)->radio(); +int fl_menu_item_radio(MENUITEM mi) { + return static_cast(mi)->radio(); } -int fl_menu_item_value(MENU_ITEM mi) { - return reinterpret_cast(mi)->value(); +int fl_menu_item_submenu(MENUITEM mi) { + return static_cast(mi)->submenu(); } -void fl_menu_item_set(MENU_ITEM mi) { - reinterpret_cast(mi)->set(); +int fl_menu_item_value(MENUITEM mi) { + return static_cast(mi)->value(); } -void fl_menu_item_clear(MENU_ITEM mi) { - reinterpret_cast(mi)->clear(); +void fl_menu_item_set(MENUITEM mi) { + static_cast(mi)->set(); } -void fl_menu_item_setonly(MENU_ITEM mi) { - reinterpret_cast(mi)->setonly(); +void fl_menu_item_clear(MENUITEM mi) { + static_cast(mi)->clear(); +} + +void fl_menu_item_setonly(MENUITEM mi) { + static_cast(mi)->setonly(); } -const char * fl_menu_item_get_label(MENU_ITEM mi) { - return reinterpret_cast(mi)->label(); +const char * fl_menu_item_get_label(MENUITEM mi) { + return static_cast(mi)->label(); } -void fl_menu_item_set_label(MENU_ITEM mi, const char *t) { - reinterpret_cast(mi)->label(t); +void fl_menu_item_set_label(MENUITEM mi, const char *t) { + static_cast(mi)->label(t); } -unsigned int fl_menu_item_get_labelcolor(MENU_ITEM mi) { - return reinterpret_cast(mi)->labelcolor(); +void fl_menu_item_set_label2(MENUITEM mi, int k, const char * t) { + static_cast(mi)->label(static_cast(k), t); } -void fl_menu_item_set_labelcolor(MENU_ITEM mi, unsigned int c) { - reinterpret_cast(mi)->labelcolor(c); +unsigned int fl_menu_item_get_labelcolor(MENUITEM mi) { + return static_cast(mi)->labelcolor(); } -int fl_menu_item_get_labelfont(MENU_ITEM mi) { - return reinterpret_cast(mi)->labelfont(); +void fl_menu_item_set_labelcolor(MENUITEM mi, unsigned int c) { + static_cast(mi)->labelcolor(c); } -void fl_menu_item_set_labelfont(MENU_ITEM mi, int f) { - reinterpret_cast(mi)->labelfont(f); +int fl_menu_item_get_labelfont(MENUITEM mi) { + return static_cast(mi)->labelfont(); } -int fl_menu_item_get_labelsize(MENU_ITEM mi) { - return reinterpret_cast(mi)->labelsize(); +void fl_menu_item_set_labelfont(MENUITEM mi, int f) { + static_cast(mi)->labelfont(f); } -void fl_menu_item_set_labelsize(MENU_ITEM mi, int s) { - reinterpret_cast(mi)->labelsize(s); +int fl_menu_item_get_labelsize(MENUITEM mi) { + return static_cast(mi)->labelsize(); } -int fl_menu_item_get_labeltype(MENU_ITEM mi) { - return reinterpret_cast(mi)->labeltype(); +void fl_menu_item_set_labelsize(MENUITEM mi, int s) { + static_cast(mi)->labelsize(s); } -void fl_menu_item_set_labeltype(MENU_ITEM mi, int t) { - reinterpret_cast(mi)->labeltype(static_cast(t)); +int fl_menu_item_get_labeltype(MENUITEM mi) { + return static_cast(mi)->labeltype(); } +void fl_menu_item_set_labeltype(MENUITEM mi, int t) { + static_cast(mi)->labeltype(static_cast(t)); +} -int fl_menu_item_get_shortcut(MENU_ITEM mi) { - return reinterpret_cast(mi)->shortcut(); + +int fl_menu_item_get_shortcut(MENUITEM mi) { + return static_cast(mi)->shortcut(); } -void fl_menu_item_set_shortcut(MENU_ITEM mi, int s) { - reinterpret_cast(mi)->shortcut(s); +void fl_menu_item_set_shortcut(MENUITEM mi, int s) { + static_cast(mi)->shortcut(s); } -unsigned long fl_menu_item_get_flags(MENU_ITEM mi) { - return reinterpret_cast(mi)->flags; +unsigned long fl_menu_item_get_flags(MENUITEM mi) { + return static_cast(mi)->flags; } -void fl_menu_item_set_flags(MENU_ITEM mi, unsigned long f) { - reinterpret_cast(mi)->flags = f; +void fl_menu_item_set_flags(MENUITEM mi, unsigned long f) { + static_cast(mi)->flags = f; +} + + + + +void fl_menu_item_image(MENUITEM mi, void * i) { + static_cast(mi)->image(static_cast(i)); } -void fl_menu_item_activate(MENU_ITEM mi) { - reinterpret_cast(mi)->activate(); +void fl_menu_item_activate(MENUITEM mi) { + static_cast(mi)->activate(); } -void fl_menu_item_deactivate(MENU_ITEM mi) { - reinterpret_cast(mi)->deactivate(); +void fl_menu_item_deactivate(MENUITEM mi) { + static_cast(mi)->deactivate(); } -void fl_menu_item_show(MENU_ITEM mi) { - reinterpret_cast(mi)->show(); +void fl_menu_item_show(MENUITEM mi) { + static_cast(mi)->show(); } -void fl_menu_item_hide(MENU_ITEM mi) { - reinterpret_cast(mi)->hide(); +void fl_menu_item_hide(MENUITEM mi) { + static_cast(mi)->hide(); } -int fl_menu_item_active(MENU_ITEM mi) { - return reinterpret_cast(mi)->active(); +int fl_menu_item_active(MENUITEM mi) { + return static_cast(mi)->active(); } -int fl_menu_item_visible(MENU_ITEM mi) { - return reinterpret_cast(mi)->visible(); +int fl_menu_item_visible(MENUITEM mi) { + return static_cast(mi)->visible(); } -int fl_menu_item_activevisible(MENU_ITEM mi) { - return reinterpret_cast(mi)->activevisible(); +int fl_menu_item_activevisible(MENUITEM mi) { + return static_cast(mi)->activevisible(); } -- cgit