diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-12 01:14:58 +1300 | 
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-12 01:14:58 +1300 | 
| commit | e93b9bbc02e2791f3a35b6f077fcbb8514c28aed (patch) | |
| tree | 3661530027db6809a9cbad7b2477416009e00787 /src/c_fl_scroll.cpp | |
| parent | 53aa8144851913994b963ed611cca8885b8f9a9e (diff) | |
Refactored draw/handle methods in Widgets hierarchy, improved docs, added a few minor method bindings here and there
Diffstat (limited to 'src/c_fl_scroll.cpp')
| -rw-r--r-- | src/c_fl_scroll.cpp | 70 | 
1 files changed, 32 insertions, 38 deletions
| diff --git a/src/c_fl_scroll.cpp b/src/c_fl_scroll.cpp index 9c1eabf..ab63827 100644 --- a/src/c_fl_scroll.cpp +++ b/src/c_fl_scroll.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Scroll.H>  #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; -}; +//  Exports from Ada -void My_Scroll::draw() { -    (*draw_hook)(this->user_data()); -} +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); -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<My_Scroll*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_scroll_draw(SCROLL s) { -    reinterpret_cast<My_Scroll*>(s)->real_draw(); -} +class My_Scroll : public Fl_Scroll { +public: +    using Fl_Scroll::Fl_Scroll; + +    friend void fl_scroll_draw(SCROLL s); +    friend int fl_scroll_handle(SCROLL s, int e); + +    void draw(); +    int handle(int e); +}; -void scroll_set_handle_hook(SCROLL s, void * h) { -    reinterpret_cast<My_Scroll*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Scroll::draw() { +    widget_draw_hook(this->user_data());  } -int fl_scroll_handle(SCROLL s, int e) { -    return reinterpret_cast<My_Scroll*>(s)->real_handle(e); +int My_Scroll::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  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; @@ -108,3 +90,15 @@ int fl_scroll_yposition(SCROLL s) {      return reinterpret_cast<Fl_Scroll*>(s)->yposition();  } + + + +void fl_scroll_draw(SCROLL s) { +    reinterpret_cast<My_Scroll*>(s)->Fl_Scroll::draw(); +} + +int fl_scroll_handle(SCROLL s, int e) { +    return reinterpret_cast<My_Scroll*>(s)->Fl_Scroll::handle(e); +} + + | 
