From 2cbec01126c34e70fc8e11d77553ef5bfd94cec7 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 18 May 2018 16:21:25 +1000 Subject: Added Choices, Pixmaps, GIFs, XPMs --- src/c_fl_choice.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/c_fl_choice.cpp (limited to 'src/c_fl_choice.cpp') diff --git a/src/c_fl_choice.cpp b/src/c_fl_choice.cpp new file mode 100644 index 0000000..f45ceed --- /dev/null +++ b/src/c_fl_choice.cpp @@ -0,0 +1,85 @@ + + +#include +#include "c_fl_choice.h" +#include "c_fl_type.h" + + + + +class My_Choice : public Fl_Choice { + public: + using Fl_Choice::Fl_Choice; + friend void choice_set_draw_hook(CHOICE n, void * d); + friend void fl_choice_draw(CHOICE n); + friend void choice_set_handle_hook(CHOICE n, void * h); + friend int fl_choice_handle(CHOICE n, int e); + protected: + void draw(); + void real_draw(); + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + h_hook_p handle_hook; +}; + +void My_Choice::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Choice::real_draw() { + Fl_Choice::draw(); +} + +int My_Choice::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Choice::real_handle(int e) { + return Fl_Choice::handle(e); +} + +void choice_set_draw_hook(CHOICE n, void * d) { + reinterpret_cast(n)->draw_hook = reinterpret_cast(d); +} + +void fl_choice_draw(CHOICE n) { + reinterpret_cast(n)->real_draw(); +} + +void choice_set_handle_hook(CHOICE n, void * h) { + reinterpret_cast(n)->handle_hook = reinterpret_cast(h); +} + +int fl_choice_handle(CHOICE n, int e) { + return reinterpret_cast(n)->real_handle(e); +} + + + + +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 reinterpret_cast(b); +} + + + + +int fl_choice_value(CHOICE c) { + return reinterpret_cast(c)->value(); +} + +int fl_choice_set_value(CHOICE c, int p) { + return reinterpret_cast(c)->value(p); +} + +int fl_choice_set_value2(CHOICE c, void * i) { + return reinterpret_cast(c)->value(reinterpret_cast(i)); +} + + -- cgit