From b2aed4668c563b5649614938b22bf417b0b7f0bc Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Wed, 31 May 2017 21:16:34 +1000 Subject: Scroll widgets added --- src/c_fl_scroll.cpp | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/c_fl_scroll.cpp (limited to 'src/c_fl_scroll.cpp') diff --git a/src/c_fl_scroll.cpp b/src/c_fl_scroll.cpp new file mode 100644 index 0000000..999c3a4 --- /dev/null +++ b/src/c_fl_scroll.cpp @@ -0,0 +1,110 @@ + + +#include +#include "c_fl_scroll.h" +#include "c_fl_type.h" + + + + +class My_Scroll : public Fl_Scroll { + public: + using Fl_Scroll::Fl_Scroll; + friend void scroll_set_draw_hook(SCROLL s, void * d); + friend void fl_scroll_draw(SCROLL s); + friend void scroll_set_handle_hook(SCROLL s, void * h); + friend int fl_scroll_handle(SCROLL s, 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_Scroll::draw() { + (*draw_hook)(this->user_data()); +} + + +void My_Scroll::real_draw() { + Fl_Scroll::draw(); +} + + +int My_Scroll::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + + +int My_Scroll::real_handle(int e) { + return Fl_Scroll::handle(e); +} + + +void scroll_set_draw_hook(SCROLL s, void * d) { + reinterpret_cast(s)->draw_hook = reinterpret_cast(d); +} + + +void fl_scroll_draw(SCROLL s) { + reinterpret_cast(s)->real_draw(); +} + + +void scroll_set_handle_hook(SCROLL s, void * h) { + reinterpret_cast(s)->handle_hook = reinterpret_cast(h); +} + + +int fl_scroll_handle(SCROLL s, int e) { + return reinterpret_cast(s)->real_handle(e); +} + + + + +SCROLL new_fl_scroll(int x, int y, int w, int h, char* label) { + My_Scroll *s = new My_Scroll(x, y, w, h, label); + return s; +} + + +void free_fl_scroll(SCROLL s) { + delete reinterpret_cast(s); +} + + + + +void fl_scroll_to(SCROLL s, int x, int y) { + reinterpret_cast(s)->scroll_to(x, y); +} + + +int fl_scroll_get_size(SCROLL s) { + return reinterpret_cast(s)->scrollbar_size(); +} + + +void fl_scroll_set_size(SCROLL s, int t) { + reinterpret_cast(s)->scrollbar_size(t); +} + + +int fl_scroll_xposition(SCROLL s) { + return reinterpret_cast(s)->xposition(); +} + + +int fl_scroll_yposition(SCROLL s) { + return reinterpret_cast(s)->yposition(); +} + + +void fl_scroll_set_type(SCROLL s, int t) { + reinterpret_cast(s)->type(t); +} + -- cgit