diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
commit | b4438b2fbe895694be98e6e8426103deefc51448 (patch) | |
tree | 760d86cd7c06420a91dad102cc9546aee73146fc /body/c_fl_choice.cpp | |
parent | a4703a65b015140cd4a7a985db66264875ade734 (diff) |
Split public API and private implementation files into different directories
Diffstat (limited to 'body/c_fl_choice.cpp')
-rw-r--r-- | body/c_fl_choice.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/body/c_fl_choice.cpp b/body/c_fl_choice.cpp new file mode 100644 index 0000000..4b03532 --- /dev/null +++ b/body/c_fl_choice.cpp @@ -0,0 +1,82 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#include <FL/Fl_Choice.H> +#include "c_fl_choice.h" + + + + +// Exports from Ada + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +// Attaching all relevant hooks and friends + +class My_Choice : public Fl_Choice { +public: + using Fl_Choice::Fl_Choice; + + friend void fl_choice_draw(CHOICE n); + friend int fl_choice_handle(CHOICE n, int e); + + void draw(); + int handle(int e); +}; + +void My_Choice::draw() { + widget_draw_hook(this->user_data()); +} + +int My_Choice::handle(int e) { + return widget_handle_hook(this->user_data(), e); +} + + + + +// Flattened C API + +CHOICE new_fl_choice(int x, int y, int w, int h, char* label) { + My_Choice *b = new My_Choice(x, y, w, h, label); + return b; +} + +void free_fl_choice(CHOICE b) { + delete static_cast<My_Choice*>(b); +} + + + + +int fl_choice_value(CHOICE c) { + return static_cast<Fl_Choice*>(c)->value(); +} + +int fl_choice_set_value(CHOICE c, void * i) { + return static_cast<Fl_Choice*>(c)->value(static_cast<Fl_Menu_Item*>(i)); +} + +int fl_choice_set_value2(CHOICE c, int p) { + return static_cast<Fl_Choice*>(c)->value(p); +} + + + + +void fl_choice_draw(CHOICE n) { + static_cast<My_Choice*>(n)->Fl_Choice::draw(); +} + +int fl_choice_handle(CHOICE n, int e) { + return static_cast<My_Choice*>(n)->Fl_Choice::handle(e); +} + + |