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 | |
| 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')
242 files changed, 4830 insertions, 5171 deletions
diff --git a/src/c_fl_adjuster.cpp b/src/c_fl_adjuster.cpp index e57bbea..1b9db8e 100644 --- a/src/c_fl_adjuster.cpp +++ b/src/c_fl_adjuster.cpp @@ -6,62 +6,54 @@  #include <FL/Fl_Adjuster.H>  #include "c_fl_adjuster.h" -#include "c_fl_type.h" -class My_Adjuster : public Fl_Adjuster { -    public: -        using Fl_Adjuster::Fl_Adjuster; -        friend void adjuster_set_draw_hook(ADJUSTER a, void * d); -        friend void fl_adjuster_draw(ADJUSTER a); -        friend void adjuster_set_handle_hook(ADJUSTER a, void * h); -        friend int fl_adjuster_handle(ADJUSTER a, 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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Adjuster : Fl_Adjuster { +public: +    using Fl_Adjuster::value_damage;  }; -void My_Adjuster::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Adjuster::real_draw() { -    Fl_Adjuster::draw(); -} -int My_Adjuster::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Adjuster::real_handle(int e) { -    return Fl_Adjuster::handle(e); -} +//  Attaching all relevant hooks and friends -void adjuster_set_draw_hook(ADJUSTER a, void * d) { -    reinterpret_cast<My_Adjuster*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Adjuster : public Fl_Adjuster { +public: +    using Fl_Adjuster::Fl_Adjuster; -void fl_adjuster_draw(ADJUSTER a) { -    reinterpret_cast<My_Adjuster*>(a)->real_draw(); -} +    friend void fl_adjuster_draw(ADJUSTER a); +    friend int fl_adjuster_handle(ADJUSTER a, int e); -void adjuster_set_handle_hook(ADJUSTER a, void * h) { -    reinterpret_cast<My_Adjuster*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Adjuster::draw() { +    widget_draw_hook(this->user_data());  } -int fl_adjuster_handle(ADJUSTER a, int e) { -    return reinterpret_cast<My_Adjuster*>(a)->real_handle(e); +int My_Adjuster::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  ADJUSTER new_fl_adjuster(int x, int y, int w, int h, char* label) {      My_Adjuster *a = new My_Adjuster(x, y, w, h, label);      return a; @@ -82,3 +74,19 @@ void fl_adjuster_set_soft(ADJUSTER a, int t) {      reinterpret_cast<Fl_Adjuster*>(a)->soft(t);  } + + + +void fl_adjuster_value_damage(ADJUSTER a) { +    (reinterpret_cast<Fl_Adjuster*>(a)->*(&Friend_Adjuster::value_damage))(); +} + +void fl_adjuster_draw(ADJUSTER a) { +    reinterpret_cast<My_Adjuster*>(a)->Fl_Adjuster::draw(); +} + +int fl_adjuster_handle(ADJUSTER a, int e) { +    return reinterpret_cast<My_Adjuster*>(a)->Fl_Adjuster::handle(e); +} + + diff --git a/src/c_fl_adjuster.h b/src/c_fl_adjuster.h index f2fb0a4..fbaa5ec 100644 --- a/src/c_fl_adjuster.h +++ b/src/c_fl_adjuster.h @@ -8,30 +8,22 @@  #define FL_ADJUSTER_GUARD - -  typedef void* ADJUSTER; - - -extern "C" void adjuster_set_draw_hook(ADJUSTER a, void * d); -extern "C" void fl_adjuster_draw(ADJUSTER a); -extern "C" void adjuster_set_handle_hook(ADJUSTER a, void * h); -extern "C" int fl_adjuster_handle(ADJUSTER a, int e); - - - -  extern "C" ADJUSTER new_fl_adjuster(int x, int y, int w, int h, char* label);  extern "C" void free_fl_adjuster(ADJUSTER a); - -  extern "C" int fl_adjuster_is_soft(ADJUSTER a);  extern "C" void fl_adjuster_set_soft(ADJUSTER a, int t); +extern "C" void fl_adjuster_value_damage(ADJUSTER a); +extern "C" void fl_adjuster_draw(ADJUSTER a); +extern "C" int fl_adjuster_handle(ADJUSTER a, int e); + +  #endif + diff --git a/src/c_fl_box.cpp b/src/c_fl_box.cpp index ec1a5de..67b4e0b 100644 --- a/src/c_fl_box.cpp +++ b/src/c_fl_box.cpp @@ -6,68 +6,67 @@  #include <FL/Fl_Box.H>  #include "c_fl_box.h" -#include "c_fl_type.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_Box : public Fl_Box { -    public: -        using Fl_Box::Fl_Box; -        friend void box_set_draw_hook(BOX n, void * d); -        friend void fl_box_draw(BOX n); -        friend void box_set_handle_hook(BOX n, void * h); -        friend int fl_box_handle(BOX 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; +public: +    using Fl_Box::Fl_Box; + +    friend void fl_box_draw(BOX n); +    friend int fl_box_handle(BOX n, int e); + +    void draw(); +    int handle(int e);  };  void My_Box::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Box::real_draw() { -    Fl_Box::draw(); +    widget_draw_hook(this->user_data());  }  int My_Box::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Box::real_handle(int e) { -    return Fl_Box::handle(e); -} -void box_set_draw_hook(BOX n, void * d) { -    reinterpret_cast<My_Box*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_box_draw(BOX n) { -    reinterpret_cast<My_Box*>(n)->real_draw(); + +//  Flattened C API + +BOX new_fl_box(int x, int y, int w, int h, char* label) { +    My_Box *b = new My_Box(x, y, w, h, label); +    return b;  } -void box_set_handle_hook(BOX n, void * h) { -    reinterpret_cast<My_Box*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +BOX new_fl_box2(int k, int x, int y, int w, int h, char * label) { +    My_Box *b = new My_Box(static_cast<Fl_Boxtype>(k), x, y, w, h, label); +    return b;  } -int fl_box_handle(BOX n, int e) { -    return reinterpret_cast<My_Box*>(n)->real_handle(e); +void free_fl_box(BOX b) { +    delete reinterpret_cast<My_Box*>(b);  } -BOX new_fl_box(int x, int y, int w, int h, char* label) { -    My_Box *b = new My_Box(x, y, w, h, label); -    return b; +void fl_box_draw(BOX n) { +    reinterpret_cast<My_Box*>(n)->Fl_Box::draw();  } -void free_fl_box(BOX b) { -    delete reinterpret_cast<My_Box*>(b); +int fl_box_handle(BOX n, int e) { +    return reinterpret_cast<My_Box*>(n)->Fl_Box::handle(e);  } + diff --git a/src/c_fl_box.h b/src/c_fl_box.h index b538a6e..5143c3f 100644 --- a/src/c_fl_box.h +++ b/src/c_fl_box.h @@ -8,24 +8,18 @@  #define FL_BOX_GUARD - -  typedef void* BOX; +extern "C" BOX new_fl_box(int x, int y, int w, int h, char * label); +extern "C" BOX new_fl_box2(int k, int x, int y, int w, int h, char * label); +extern "C" void free_fl_box(BOX b); -extern "C" void box_set_draw_hook(BOX n, void * d);  extern "C" void fl_box_draw(BOX n); -extern "C" void box_set_handle_hook(BOX n, void * h);  extern "C" int fl_box_handle(BOX n, int e); - - -extern "C" BOX new_fl_box(int x, int y, int w, int h, char * label); -extern "C" void free_fl_box(BOX b); - -  #endif + diff --git a/src/c_fl_browser.cpp b/src/c_fl_browser.cpp index 8bd7c96..0a29e22 100644 --- a/src/c_fl_browser.cpp +++ b/src/c_fl_browser.cpp @@ -336,6 +336,13 @@ void fl_browser_hide(BROWSER b) { +void fl_browser_set_size(BROWSER b, int w, int h) { +    reinterpret_cast<Fl_Browser*>(b)->size(w, h); +} + + + +  void fl_browser_set_icon(BROWSER b, int l, void * c) {      reinterpret_cast<Fl_Browser*>(b)->icon(l, reinterpret_cast<Fl_Image*>(c));  } diff --git a/src/c_fl_browser.h b/src/c_fl_browser.h index f1603bc..2729303 100644 --- a/src/c_fl_browser.h +++ b/src/c_fl_browser.h @@ -59,6 +59,9 @@ extern "C" void fl_browser_show(BROWSER b);  extern "C" void fl_browser_hide(BROWSER b); +extern "C" void fl_browser_set_size(BROWSER b, int w, int h); + +  extern "C" void fl_browser_set_icon(BROWSER b, int l, void * c);  extern "C" void fl_browser_remove_icon(BROWSER b, int l); diff --git a/src/c_fl_button.cpp b/src/c_fl_button.cpp index 07d5c64..1cff342 100644 --- a/src/c_fl_button.cpp +++ b/src/c_fl_button.cpp @@ -6,7 +6,6 @@  #include <FL/Fl_Button.H>  #include "c_fl_button.h" -#include "c_fl_type.h" @@ -26,57 +25,50 @@ void fl_button_extra_final(void * adaobj) { -class My_Button : public Fl_Button { -    public: -        using Fl_Button::Fl_Button; -        friend void button_set_draw_hook(BUTTON b, void * d); -        friend void fl_button_draw(BUTTON b); -        friend void button_set_handle_hook(BUTTON b, void * h); -        friend int fl_button_handle(BUTTON b, 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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Button : Fl_Button { +public: +    using Fl_Button::simulate_key_action;  }; -void My_Button::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Button::real_draw() { -    Fl_Button::draw(); -} -int My_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Button::real_handle(int e) { -    return Fl_Button::handle(e); -} +//  Attaching all relevant hooks and friends -void button_set_draw_hook(BUTTON b, void * d) { -    reinterpret_cast<My_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Button : public Fl_Button { +public: +    using Fl_Button::Fl_Button; -void fl_button_draw(BUTTON b) { -    reinterpret_cast<My_Button*>(b)->real_draw(); -} +    friend void fl_button_draw(BUTTON b); +    friend int fl_button_handle(BUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void button_set_handle_hook(BUTTON b, void * h) { -    reinterpret_cast<My_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_button_handle(BUTTON b, int e) { -    return reinterpret_cast<My_Button*>(b)->real_handle(e); +int My_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  BUTTON new_fl_button(int x, int y, int w, int h, char* label) {      My_Button *b = new My_Button(x, y, w, h, label);      return b; @@ -121,3 +113,21 @@ void fl_button_set_shortcut(BUTTON b, int k) {  } + + +void fl_button_draw(BUTTON b) { +    reinterpret_cast<My_Button*>(b)->Fl_Button::draw(); +} + +int fl_button_handle(BUTTON b, int e) { +    return reinterpret_cast<My_Button*>(b)->Fl_Button::handle(e); +} + + + + +void fl_button_simulate_key_action(BUTTON b) { +    (reinterpret_cast<Fl_Button*>(b)->*(&Friend_Button::simulate_key_action))(); +} + + diff --git a/src/c_fl_button.h b/src/c_fl_button.h index 9c3ecad..f644a50 100644 --- a/src/c_fl_button.h +++ b/src/c_fl_button.h @@ -15,12 +15,6 @@ extern "C" void fl_button_extra_final(void * adaobj);  typedef void* BUTTON; -extern "C" void button_set_draw_hook(BUTTON b, void * d); -extern "C" void fl_button_draw(BUTTON b); -extern "C" void button_set_handle_hook(BUTTON b, void * h); -extern "C" int fl_button_handle(BUTTON b, int e); - -  extern "C" BUTTON new_fl_button(int x, int y, int w, int h, char* label);  extern "C" void free_fl_button(BUTTON b); @@ -36,6 +30,13 @@ extern "C" int fl_button_get_shortcut(BUTTON b);  extern "C" void fl_button_set_shortcut(BUTTON b, int k); +extern "C" void fl_button_draw(BUTTON b); +extern "C" int fl_button_handle(BUTTON b, int e); + + +extern "C" void fl_button_simulate_key_action(BUTTON b); + +  #endif diff --git a/src/c_fl_cairo_window.cpp b/src/c_fl_cairo_window.cpp index 59b03ed..39f3031 100644 --- a/src/c_fl_cairo_window.cpp +++ b/src/c_fl_cairo_window.cpp @@ -38,8 +38,6 @@ public:      friend void fl_cairo_window_draw(CAIROWINDOW w);      int handle(int e); - -protected:      void draw();  }; diff --git a/src/c_fl_chart.cpp b/src/c_fl_chart.cpp index c3667a2..56bfb80 100644 --- a/src/c_fl_chart.cpp +++ b/src/c_fl_chart.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Chart.H>  #include "c_fl_chart.h" -#include "c_fl_type.h" -class My_Chart : public Fl_Chart { -    public: -        using Fl_Chart::Fl_Chart; -        friend void chart_set_draw_hook(CHART n, void * d); -        friend void fl_chart_draw(CHART n); -        friend void chart_set_handle_hook(CHART n, void * h); -        friend int fl_chart_handle(CHART 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; -}; +//  Exports from Ada -void My_Chart::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_Chart::real_draw() { -    Fl_Chart::draw(); -} -int My_Chart::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Chart::real_handle(int e) { -    return Fl_Chart::handle(e); -} -void chart_set_draw_hook(CHART n, void * d) { -    reinterpret_cast<My_Chart*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_chart_draw(CHART n) { -    reinterpret_cast<My_Chart*>(n)->real_draw(); -} +class My_Chart : public Fl_Chart { +public: +    using Fl_Chart::Fl_Chart; + +    friend void fl_chart_draw(CHART n); +    friend int fl_chart_handle(CHART n, int e); + +    void draw(); +    int handle(int e); +}; -void chart_set_handle_hook(CHART n, void * h) { -    reinterpret_cast<My_Chart*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Chart::draw() { +    widget_draw_hook(this->user_data());  } -int fl_chart_handle(CHART n, int e) { -    return reinterpret_cast<My_Chart*>(n)->real_handle(e); +int My_Chart::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  CHART new_fl_chart(int x, int y, int w, int h, char* label) {      My_Chart *b = new My_Chart(x, y, w, h, label);      return b; @@ -156,3 +138,14 @@ void fl_chart_set_textsize(CHART b, int s) {  } + + +void fl_chart_draw(CHART n) { +    reinterpret_cast<My_Chart*>(n)->Fl_Chart::draw(); +} + +int fl_chart_handle(CHART n, int e) { +    return reinterpret_cast<My_Chart*>(n)->Fl_Chart::handle(e); +} + + diff --git a/src/c_fl_chart.h b/src/c_fl_chart.h index ec0e034..bd524c3 100644 --- a/src/c_fl_chart.h +++ b/src/c_fl_chart.h @@ -8,27 +8,13 @@  #define FL_CHART_GUARD - -  typedef void* CHART; - - -extern "C" void chart_set_draw_hook(CHART n, void * d); -extern "C" void fl_chart_draw(CHART n); -extern "C" void chart_set_handle_hook(CHART n, void * h); -extern "C" int fl_chart_handle(CHART n, int e); - - - -  extern "C" CHART new_fl_chart(int x, int y, int w, int h, char * label);  extern "C" void free_fl_chart(CHART b); - -  extern "C" void fl_chart_add(CHART b, double v, char * s, unsigned int c);  extern "C" void fl_chart_insert(CHART b, int i, double v, char * s, unsigned int c);  extern "C" void fl_chart_replace(CHART b, int i, double v, char * s, unsigned int c); @@ -55,5 +41,10 @@ extern "C" int fl_chart_get_textsize(CHART b);  extern "C" void fl_chart_set_textsize(CHART b, int s); +extern "C" void fl_chart_draw(CHART n); +extern "C" int fl_chart_handle(CHART n, int e); + +  #endif + diff --git a/src/c_fl_check_button.cpp b/src/c_fl_check_button.cpp index 964c889..2eb61a1 100644 --- a/src/c_fl_check_button.cpp +++ b/src/c_fl_check_button.cpp @@ -6,7 +6,6 @@  #include <FL/Fl_Check_Button.H>  #include "c_fl_check_button.h" -#include "c_fl_type.h" @@ -27,57 +26,40 @@ void fl_check_button_extra_final(void * adaobj) { -class My_Check_Button : public Fl_Check_Button { -    public: -        using Fl_Check_Button::Fl_Check_Button; -        friend void check_button_set_draw_hook(CHECKBUTTON b, void * d); -        friend void fl_check_button_draw(CHECKBUTTON b); -        friend void check_button_set_handle_hook(CHECKBUTTON b, void * h); -        friend int fl_check_button_handle(CHECKBUTTON b, 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_Check_Button::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_Check_Button::real_draw() { -    Fl_Check_Button::draw(); -} -int My_Check_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Check_Button::real_handle(int e) { -    return Fl_Check_Button::handle(e); -} -void check_button_set_draw_hook(CHECKBUTTON b, void * d) { -    reinterpret_cast<My_Check_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_check_button_draw(CHECKBUTTON b) { -    reinterpret_cast<My_Check_Button*>(b)->real_draw(); -} +class My_Check_Button : public Fl_Check_Button { +public: +    using Fl_Check_Button::Fl_Check_Button; + +    friend void fl_check_button_draw(CHECKBUTTON b); +    friend int fl_check_button_handle(CHECKBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void check_button_set_handle_hook(CHECKBUTTON b, void * h) { -    reinterpret_cast<My_Check_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Check_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_check_button_handle(CHECKBUTTON b, int e) { -    return reinterpret_cast<My_Check_Button*>(b)->real_handle(e); +int My_Check_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  CHECKBUTTON new_fl_check_button(int x, int y, int w, int h, char* label) {      My_Check_Button *b = new My_Check_Button(x, y, w, h, label);      return b; @@ -87,3 +69,15 @@ void free_fl_check_button(CHECKBUTTON b) {      delete reinterpret_cast<My_Check_Button*>(b);  } + + + +void fl_check_button_draw(CHECKBUTTON b) { +    reinterpret_cast<My_Check_Button*>(b)->Fl_Check_Button::draw(); +} + +int fl_check_button_handle(CHECKBUTTON b, int e) { +    return reinterpret_cast<My_Check_Button*>(b)->Fl_Check_Button::handle(e); +} + + diff --git a/src/c_fl_check_button.h b/src/c_fl_check_button.h index 2c25387..cfa6bff 100644 --- a/src/c_fl_check_button.h +++ b/src/c_fl_check_button.h @@ -16,16 +16,14 @@ extern "C" void fl_check_button_extra_final(void * adaobj);  typedef void* CHECKBUTTON; -extern "C" void check_button_set_draw_hook(CHECKBUTTON b, void * d); -extern "C" void fl_check_button_draw(CHECKBUTTON b); -extern "C" void check_button_set_handle_hook(CHECKBUTTON b, void * h); -extern "C" int fl_check_button_handle(CHECKBUTTON b, int e); - -  extern "C" CHECKBUTTON new_fl_check_button(int x, int y, int w, int h, char* label);  extern "C" void free_fl_check_button(CHECKBUTTON b); +extern "C" void fl_check_button_draw(CHECKBUTTON b); +extern "C" int fl_check_button_handle(CHECKBUTTON b, int e); + +  #endif diff --git a/src/c_fl_choice.cpp b/src/c_fl_choice.cpp index 6d6a472..e8c8374 100644 --- a/src/c_fl_choice.cpp +++ b/src/c_fl_choice.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Choice.H>  #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; -}; +//  Exports from Ada -void My_Choice::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_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<My_Choice*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_choice_draw(CHOICE n) { -    reinterpret_cast<My_Choice*>(n)->real_draw(); -} +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 choice_set_handle_hook(CHOICE n, void * h) { -    reinterpret_cast<My_Choice*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Choice::draw() { +    widget_draw_hook(this->user_data());  } -int fl_choice_handle(CHOICE n, int e) { -    return reinterpret_cast<My_Choice*>(n)->real_handle(e); +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; @@ -87,3 +69,14 @@ int fl_choice_set_value2(CHOICE c, void * i) {  } + + +void fl_choice_draw(CHOICE n) { +    reinterpret_cast<My_Choice*>(n)->Fl_Choice::draw(); +} + +int fl_choice_handle(CHOICE n, int e) { +    return reinterpret_cast<My_Choice*>(n)->Fl_Choice::handle(e); +} + + diff --git a/src/c_fl_choice.h b/src/c_fl_choice.h index 78c8f55..5d076b1 100644 --- a/src/c_fl_choice.h +++ b/src/c_fl_choice.h @@ -8,31 +8,22 @@  #define FL_CHOICE_GUARD - -  typedef void* CHOICE; - - -extern "C" void choice_set_draw_hook(CHOICE n, void * d); -extern "C" void fl_choice_draw(CHOICE n); -extern "C" void choice_set_handle_hook(CHOICE n, void * h); -extern "C" int fl_choice_handle(CHOICE n, int e); - - - -  extern "C" CHOICE new_fl_choice(int x, int y, int w, int h, char * label);  extern "C" void free_fl_choice(CHOICE b); - -  extern "C" int fl_choice_value(CHOICE c);  extern "C" int fl_choice_set_value(CHOICE c, int p);  extern "C" int fl_choice_set_value2(CHOICE c, void * i); +extern "C" void fl_choice_draw(CHOICE n); +extern "C" int fl_choice_handle(CHOICE n, int e); + +  #endif + diff --git a/src/c_fl_clock.cpp b/src/c_fl_clock.cpp index 0741726..a7e570e 100644 --- a/src/c_fl_clock.cpp +++ b/src/c_fl_clock.cpp @@ -6,69 +6,50 @@  #include <FL/Fl_Clock.H>  #include "c_fl_clock.h" -#include "c_fl_type.h" -class My_Clock : public Fl_Clock { -    public: -        using Fl_Clock::Fl_Clock; -        friend void clock_set_draw_hook(CLOCK c, void * d); -        friend void fl_clock_draw(CLOCK c); -        friend void clock_set_handle_hook(CLOCK c, void * h); -        friend int fl_clock_handle(CLOCK c, int e); -        friend void fl_clock_draw2(CLOCK c, int x, int y, int w, int h); -    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_Clock::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_Clock::real_draw() { -    Fl_Clock::draw(); -} -int My_Clock::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Clock::real_handle(int e) { -    return Fl_Clock::handle(e); -} -void clock_set_draw_hook(CLOCK c, void * d) { -    reinterpret_cast<My_Clock*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_clock_draw(CLOCK c) { -    reinterpret_cast<My_Clock*>(c)->real_draw(); -} +class My_Clock : public Fl_Clock { +public: +    using Fl_Clock::Fl_Clock; -void clock_set_handle_hook(CLOCK c, void * h) { -    reinterpret_cast<My_Clock*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +    friend void fl_clock_draw(CLOCK c); +    friend int fl_clock_handle(CLOCK c, int e); + +    void draw(); +    int handle(int e); +}; + +void My_Clock::draw() { +    widget_draw_hook(this->user_data());  } -int fl_clock_handle(CLOCK c, int e) { -    return reinterpret_cast<My_Clock*>(c)->real_handle(e); +int My_Clock::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  CLOCK new_fl_clock(int x, int y, int w, int h, char* label) {      My_Clock *c = new My_Clock(x, y, w, h, label);      return c;  } -CLOCK new_fl_clock2(uchar k, int x, int y, int w, int h, char* label) { +CLOCK new_fl_clock2(unsigned char k, int x, int y, int w, int h, char* label) {      My_Clock *c = new My_Clock(k,x,y,w,h,label);      return c;  } @@ -80,8 +61,12 @@ void free_fl_clock(CLOCK c) { -void fl_clock_draw2(CLOCK c, int x, int y, int w, int h) { -    reinterpret_cast<My_Clock*>(c)->Fl_Clock::draw(x,y,w,h); +void fl_clock_draw(CLOCK c) { +    reinterpret_cast<My_Clock*>(c)->Fl_Clock::draw(); +} + +int fl_clock_handle(CLOCK c, int e) { +    return reinterpret_cast<My_Clock*>(c)->Fl_Clock::handle(e);  } diff --git a/src/c_fl_clock.h b/src/c_fl_clock.h index bda955f..4b07d7e 100644 --- a/src/c_fl_clock.h +++ b/src/c_fl_clock.h @@ -8,30 +8,18 @@  #define FL_CLOCK_GUARD - -  typedef void* CLOCK; - - -extern "C" void clock_set_draw_hook(CLOCK c, void * d); -extern "C" void fl_clock_draw(CLOCK c); -extern "C" void clock_set_handle_hook(CLOCK c, void * h); -extern "C" int fl_clock_handle(CLOCK c, int e); - - - -  extern "C" CLOCK new_fl_clock(int x, int y, int w, int h, char* label); -extern "C" CLOCK new_fl_clock2(uchar k, int x, int y, int w, int h, char* label); +extern "C" CLOCK new_fl_clock2(unsigned char k, int x, int y, int w, int h, char* label);  extern "C" void free_fl_clock(CLOCK c); - - -extern "C" void fl_clock_draw2(CLOCK c, int x, int y, int w, int h); +extern "C" void fl_clock_draw(CLOCK c); +extern "C" int fl_clock_handle(CLOCK c, int e);  #endif + diff --git a/src/c_fl_clock_output.cpp b/src/c_fl_clock_output.cpp index b2a6546..91aaae4 100644 --- a/src/c_fl_clock_output.cpp +++ b/src/c_fl_clock_output.cpp @@ -6,63 +6,55 @@  #include <FL/Fl_Clock.H>  #include "c_fl_clock_output.h" -#include "c_fl_type.h" -class My_Clock_Output : public Fl_Clock_Output { -    public: -        using Fl_Clock_Output::Fl_Clock_Output; -        friend void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d); -        friend void fl_clock_output_draw(CLOCK_OUTPUT c); -        friend void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h); -        friend int fl_clock_output_handle(CLOCK_OUTPUT c, int e); -        friend void fl_clock_output_draw2(CLOCK_OUTPUT c, int x, int y, int w, int h); -    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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Clock_Output : Fl_Clock_Output { +public: +    //  Really only needed for the (int,int,int,int) version +    using Fl_Clock_Output::draw;  }; -void My_Clock_Output::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Clock_Output::real_draw() { -    Fl_Clock_Output::draw(); -} -int My_Clock_Output::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Clock_Output::real_handle(int e) { -    return Fl_Clock_Output::handle(e); -} +//  Attaching all relevant hooks and friends -void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d) { -    reinterpret_cast<My_Clock_Output*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Clock_Output : public Fl_Clock_Output { +public: +    using Fl_Clock_Output::Fl_Clock_Output; -void fl_clock_output_draw(CLOCK_OUTPUT c) { -    reinterpret_cast<My_Clock_Output*>(c)->real_draw(); -} +    friend void fl_clock_output_draw(CLOCK_OUTPUT c); +    friend int fl_clock_output_handle(CLOCK_OUTPUT c, int e); + +    void draw(); +    int handle(int e); +}; -void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h) { -    reinterpret_cast<My_Clock_Output*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Clock_Output::draw() { +    widget_draw_hook(this->user_data());  } -int fl_clock_output_handle(CLOCK_OUTPUT c, int e) { -    return reinterpret_cast<My_Clock_Output*>(c)->real_handle(e); +int My_Clock_Output::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  CLOCK_OUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label) {      My_Clock_Output *c = new My_Clock_Output(x, y, w, h, label);      return c; @@ -88,11 +80,11 @@ int fl_clock_output_get_second(CLOCK_OUTPUT c) {  } -ulong fl_clock_output_get_value(CLOCK_OUTPUT c) { +unsigned long fl_clock_output_get_value(CLOCK_OUTPUT c) {      return reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value();  } -void fl_clock_output_set_value(CLOCK_OUTPUT c, ulong v) { +void fl_clock_output_set_value(CLOCK_OUTPUT c, unsigned long v) {      reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value(v);  } @@ -103,8 +95,17 @@ void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int s) { +void fl_clock_output_draw(CLOCK_OUTPUT c) { +    reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::draw(); +} +  void fl_clock_output_draw2(CLOCK_OUTPUT c, int x, int y, int w, int h) { -    reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::draw(x,y,w,h); +    void (Fl_Clock_Output::*mydraw)(int,int,int,int) = &Friend_Clock_Output::draw; +    (reinterpret_cast<Fl_Clock_Output*>(c)->*mydraw)(x, y, w, h); +} + +int fl_clock_output_handle(CLOCK_OUTPUT c, int e) { +    return reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::handle(e);  } diff --git a/src/c_fl_clock_output.h b/src/c_fl_clock_output.h index 15c383f..6adb98d 100644 --- a/src/c_fl_clock_output.h +++ b/src/c_fl_clock_output.h @@ -8,39 +8,28 @@  #define FL_CLOCK_OUTPUT_GUARD - -  typedef void* CLOCK_OUTPUT; - - -extern "C" void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d); -extern "C" void fl_clock_output_draw(CLOCK_OUTPUT c); -extern "C" void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h); -extern "C" int fl_clock_output_handle(CLOCK_OUTPUT c, int e); - - - -  extern "C" CLOCK_OUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label);  extern "C" void free_fl_clock_output(CLOCK_OUTPUT c); - -  extern "C" int fl_clock_output_get_hour(CLOCK_OUTPUT c);  extern "C" int fl_clock_output_get_minute(CLOCK_OUTPUT c);  extern "C" int fl_clock_output_get_second(CLOCK_OUTPUT c); -extern "C" ulong fl_clock_output_get_value(CLOCK_OUTPUT c); -extern "C" void fl_clock_output_set_value(CLOCK_OUTPUT c, ulong v); +extern "C" unsigned long fl_clock_output_get_value(CLOCK_OUTPUT c); +extern "C" void fl_clock_output_set_value(CLOCK_OUTPUT c, unsigned long v);  extern "C" void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int s); +extern "C" void fl_clock_output_draw(CLOCK_OUTPUT c);  extern "C" void fl_clock_output_draw2(CLOCK_OUTPUT c, int x, int y, int w, int h); +extern "C" int fl_clock_output_handle(CLOCK_OUTPUT c, int e);  #endif + diff --git a/src/c_fl_color_chooser.cpp b/src/c_fl_color_chooser.cpp index 8846a90..171155d 100644 --- a/src/c_fl_color_chooser.cpp +++ b/src/c_fl_color_chooser.cpp @@ -6,106 +6,88 @@  #include <FL/Fl_Color_Chooser.H>  #include "c_fl_color_chooser.h" -#include "c_fl_type.h" -class My_Color_Chooser : public Fl_Color_Chooser { -    public: -        using Fl_Color_Chooser::Fl_Color_Chooser; -        friend void color_chooser_set_draw_hook(COLOR_CHOOSER n, void * d); -        friend void fl_color_chooser_draw(COLOR_CHOOSER n); -        friend void color_chooser_set_handle_hook(COLOR_CHOOSER n, void * h); -        friend int fl_color_chooser_handle(COLOR_CHOOSER 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; -}; +//  Exports from Ada -void My_Color_Chooser::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_Color_Chooser::real_draw() { -    Fl_Color_Chooser::draw(); -} -int My_Color_Chooser::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Color_Chooser::real_handle(int e) { -    return Fl_Color_Chooser::handle(e); -} -void color_chooser_set_draw_hook(COLOR_CHOOSER n, void * d) { -    reinterpret_cast<My_Color_Chooser*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_color_chooser_draw(COLOR_CHOOSER n) { -    reinterpret_cast<My_Color_Chooser*>(n)->real_draw(); -} +class My_Color_Chooser : public Fl_Color_Chooser { +public: +    using Fl_Color_Chooser::Fl_Color_Chooser; + +    friend void fl_color_chooser_draw(COLORCHOOSER n); +    friend int fl_color_chooser_handle(COLORCHOOSER n, int e); -void color_chooser_set_handle_hook(COLOR_CHOOSER n, void * h) { -    reinterpret_cast<My_Color_Chooser*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Color_Chooser::draw() { +    widget_draw_hook(this->user_data());  } -int fl_color_chooser_handle(COLOR_CHOOSER n, int e) { -    return reinterpret_cast<My_Color_Chooser*>(n)->real_handle(e); +int My_Color_Chooser::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -COLOR_CHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label) { +//  Flattened C API + +COLORCHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label) {      My_Color_Chooser *n = new My_Color_Chooser(x, y, w, h, label);      return n;  } -void free_fl_color_chooser(COLOR_CHOOSER n) { +void free_fl_color_chooser(COLORCHOOSER n) {      delete reinterpret_cast<My_Color_Chooser*>(n);  } -double fl_color_chooser_r(COLOR_CHOOSER n) { +double fl_color_chooser_r(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->r();  } -double fl_color_chooser_g(COLOR_CHOOSER n) { +double fl_color_chooser_g(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->g();  } -double fl_color_chooser_b(COLOR_CHOOSER n) { +double fl_color_chooser_b(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->b();  } -int fl_color_chooser_rgb(COLOR_CHOOSER n, int r, int g, int b) { +int fl_color_chooser_rgb(COLORCHOOSER n, int r, int g, int b) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->rgb(r,g,b);  } -double fl_color_chooser_hue(COLOR_CHOOSER n) { +double fl_color_chooser_hue(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->hue();  } -double fl_color_chooser_saturation(COLOR_CHOOSER n) { +double fl_color_chooser_saturation(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->saturation();  } -double fl_color_chooser_value(COLOR_CHOOSER n) { +double fl_color_chooser_value(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->value();  } -int fl_color_chooser_hsv(COLOR_CHOOSER n, int h, int s, int v) { +int fl_color_chooser_hsv(COLORCHOOSER n, int h, int s, int v) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->hsv(h,s,v);  } @@ -123,12 +105,23 @@ void fl_color_chooser_rgb2hsv(double r, double g, double b, double &h, double &s -int fl_color_chooser_get_mode(COLOR_CHOOSER n) { +int fl_color_chooser_get_mode(COLORCHOOSER n) {      return reinterpret_cast<Fl_Color_Chooser*>(n)->mode();  } -void fl_color_chooser_set_mode(COLOR_CHOOSER n, int m) { +void fl_color_chooser_set_mode(COLORCHOOSER n, int m) {      reinterpret_cast<Fl_Color_Chooser*>(n)->mode(m);  } + + +void fl_color_chooser_draw(COLORCHOOSER n) { +    reinterpret_cast<My_Color_Chooser*>(n)->Fl_Color_Chooser::draw(); +} + +int fl_color_chooser_handle(COLORCHOOSER n, int e) { +    return reinterpret_cast<My_Color_Chooser*>(n)->Fl_Color_Chooser::handle(e); +} + + diff --git a/src/c_fl_color_chooser.h b/src/c_fl_color_chooser.h index b3e4cfb..22f9bc7 100644 --- a/src/c_fl_color_chooser.h +++ b/src/c_fl_color_chooser.h @@ -8,46 +8,39 @@  #define FL_COLOR_CHOOSER_GUARD +typedef void* COLORCHOOSER; -typedef void* COLOR_CHOOSER; +extern "C" COLORCHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label); +extern "C" void free_fl_color_chooser(COLORCHOOSER n); +extern "C" double fl_color_chooser_r(COLORCHOOSER n); +extern "C" double fl_color_chooser_g(COLORCHOOSER n); +extern "C" double fl_color_chooser_b(COLORCHOOSER n); +extern "C" int fl_color_chooser_rgb(COLORCHOOSER n, int r, int g, int b); -extern "C" void color_chooser_set_draw_hook(COLOR_CHOOSER n, void * d); -extern "C" void fl_color_chooser_draw(COLOR_CHOOSER n); -extern "C" void color_chooser_set_handle_hook(COLOR_CHOOSER n, void * h); -extern "C" int fl_color_chooser_handle(COLOR_CHOOSER n, int e); +extern "C" double fl_color_chooser_hue(COLORCHOOSER n); +extern "C" double fl_color_chooser_saturation(COLORCHOOSER n); +extern "C" double fl_color_chooser_value(COLORCHOOSER n); +extern "C" int fl_color_chooser_hsv(COLORCHOOSER n, int h, int s, int v); +extern "C" void fl_color_chooser_hsv2rgb +    (double h, double s, double v, double &r, double &g, double &b); +extern "C" void fl_color_chooser_rgb2hsv +    (double r, double g, double b, double &h, double &s, double &v); -extern "C" COLOR_CHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label); -extern "C" void free_fl_color_chooser(COLOR_CHOOSER n); +extern "C" int fl_color_chooser_get_mode(COLORCHOOSER n); +extern "C" void fl_color_chooser_set_mode(COLORCHOOSER n, int m); - - -extern "C" double fl_color_chooser_r(COLOR_CHOOSER n); -extern "C" double fl_color_chooser_g(COLOR_CHOOSER n); -extern "C" double fl_color_chooser_b(COLOR_CHOOSER n); -extern "C" int fl_color_chooser_rgb(COLOR_CHOOSER n, int r, int g, int b); - - -extern "C" double fl_color_chooser_hue(COLOR_CHOOSER n); -extern "C" double fl_color_chooser_saturation(COLOR_CHOOSER n); -extern "C" double fl_color_chooser_value(COLOR_CHOOSER n); -extern "C" int fl_color_chooser_hsv(COLOR_CHOOSER n, int h, int s, int v); - - -extern "C" void fl_color_chooser_hsv2rgb(double h, double s, double v, double &r, double &g, double &b); -extern "C" void fl_color_chooser_rgb2hsv(double r, double g, double b, double &h, double &s, double &v); - - -extern "C" int fl_color_chooser_get_mode(COLOR_CHOOSER n); -extern "C" void fl_color_chooser_set_mode(COLOR_CHOOSER n, int m); +extern "C" void fl_color_chooser_draw(COLORCHOOSER n); +extern "C" int fl_color_chooser_handle(COLORCHOOSER n, int e);  #endif + diff --git a/src/c_fl_counter.cpp b/src/c_fl_counter.cpp index c91d927..df8130e 100644 --- a/src/c_fl_counter.cpp +++ b/src/c_fl_counter.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Counter.H>  #include "c_fl_counter.h" -#include "c_fl_type.h" -class My_Counter : public Fl_Counter { -    public: -        using Fl_Counter::Fl_Counter; -        friend void counter_set_draw_hook(COUNTER c, void * d); -        friend void fl_counter_draw(COUNTER c); -        friend void counter_set_handle_hook(COUNTER c, void * h); -        friend int fl_counter_handle(COUNTER c, 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_Counter::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_Counter::real_draw() { -    Fl_Counter::draw(); -} -int My_Counter::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Counter::real_handle(int e) { -    return Fl_Counter::handle(e); -} -void counter_set_draw_hook(COUNTER c, void * d) { -    reinterpret_cast<My_Counter*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_counter_draw(COUNTER c) { -    reinterpret_cast<My_Counter*>(c)->real_draw(); -} +class My_Counter : public Fl_Counter { +public: +    using Fl_Counter::Fl_Counter; -void counter_set_handle_hook(COUNTER c, void * h) { -    reinterpret_cast<My_Counter*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +    friend void fl_counter_draw(COUNTER c); +    friend int fl_counter_handle(COUNTER c, int e); + +    void draw(); +    int handle(int e); +}; + +void My_Counter::draw() { +    widget_draw_hook(this->user_data());  } -int fl_counter_handle(COUNTER c, int e) { -    return reinterpret_cast<My_Counter*>(c)->real_handle(e); +int My_Counter::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  COUNTER new_fl_counter(int x, int y, int w, int h, char* label) {      My_Counter *c = new My_Counter(x, y, w, h, label);      return c; @@ -78,7 +60,7 @@ double fl_counter_get_step(COUNTER c) {      return reinterpret_cast<Fl_Counter*>(c)->step();  } -void fl_counter_set_step(COUNTER c, double t) { +void fl_counter_set_step_top(COUNTER c, double t) {      reinterpret_cast<Fl_Counter*>(c)->step(t);  } @@ -86,6 +68,10 @@ void fl_counter_set_lstep(COUNTER c, double t) {      reinterpret_cast<Fl_Counter*>(c)->lstep(t);  } +void fl_counter_set_step_both(COUNTER c, double s, double l) { +    reinterpret_cast<Fl_Counter*>(c)->step(s, l); +} + @@ -113,3 +99,15 @@ void fl_counter_set_textsize(COUNTER c, int t) {      reinterpret_cast<Fl_Counter*>(c)->textsize(t);  } + + + +void fl_counter_draw(COUNTER c) { +    reinterpret_cast<My_Counter*>(c)->Fl_Counter::draw(); +} + +int fl_counter_handle(COUNTER c, int e) { +    return reinterpret_cast<My_Counter*>(c)->Fl_Counter::handle(e); +} + + diff --git a/src/c_fl_counter.h b/src/c_fl_counter.h index 8fdd7ba..b5b4a8b 100644 --- a/src/c_fl_counter.h +++ b/src/c_fl_counter.h @@ -8,30 +8,17 @@  #define FL_COUNTER_GUARD - -  typedef void* COUNTER; - - -extern "C" void counter_set_draw_hook(COUNTER c, void * d); -extern "C" void fl_counter_draw(COUNTER c); -extern "C" void counter_set_handle_hook(COUNTER c, void * h); -extern "C" int fl_counter_handle(COUNTER c, int e); - - - -  extern "C" COUNTER new_fl_counter(int x, int y, int w, int h, char* label);  extern "C" void free_fl_counter(COUNTER c); - -  extern "C" double fl_counter_get_step(COUNTER c); -extern "C" void fl_counter_set_step(COUNTER c, double t); +extern "C" void fl_counter_set_step_top(COUNTER c, double t);  extern "C" void fl_counter_set_lstep(COUNTER c, double t); +extern "C" void fl_counter_set_step_both(COUNTER c, double s, double l);  extern "C" unsigned int fl_counter_get_textcolor(COUNTER c); @@ -42,5 +29,10 @@ extern "C" int fl_counter_get_textsize(COUNTER c);  extern "C" void fl_counter_set_textsize(COUNTER c, int t); +extern "C" void fl_counter_draw(COUNTER c); +extern "C" int fl_counter_handle(COUNTER c, int e); + +  #endif + diff --git a/src/c_fl_dial.cpp b/src/c_fl_dial.cpp index a2f0bdc..8e32820 100644 --- a/src/c_fl_dial.cpp +++ b/src/c_fl_dial.cpp @@ -6,62 +6,56 @@  #include <FL/Fl_Dial.H>  #include "c_fl_dial.h" -#include "c_fl_type.h" -class My_Dial : public Fl_Dial { -    public: -        using Fl_Dial::Fl_Dial; -        friend void dial_set_draw_hook(DIAL v, void * d); -        friend void fl_dial_draw(DIAL v); -        friend void dial_set_handle_hook(DIAL v, void * h); -        friend int fl_dial_handle(DIAL v, 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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Dial : Fl_Dial { +public: +    //  Really only needed for the (int,int,int,int) versions +    using Fl_Dial::draw; +    using Fl_Dial::handle;  }; -void My_Dial::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Dial::real_draw() { -    Fl_Dial::draw(); -} -int My_Dial::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Dial::real_handle(int e) { -    return Fl_Dial::handle(e); -} +//  Attaching all relevant hooks and friends -void dial_set_draw_hook(DIAL v, void * d) { -    reinterpret_cast<My_Dial*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Dial : public Fl_Dial { +public: +    using Fl_Dial::Fl_Dial; -void fl_dial_draw(DIAL v) { -    reinterpret_cast<My_Dial*>(v)->real_draw(); -} +    friend void fl_dial_draw(DIAL v); +    friend int fl_dial_handle(DIAL v, int e); + +    void draw(); +    int handle(int e); +}; -void dial_set_handle_hook(DIAL v, void * h) { -    reinterpret_cast<My_Dial*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Dial::draw() { +    widget_draw_hook(this->user_data());  } -int fl_dial_handle(DIAL v, int e) { -    return reinterpret_cast<My_Dial*>(v)->real_handle(e); +int My_Dial::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  DIAL new_fl_dial(int x, int y, int w, int h, char* label) {      My_Dial *v = new My_Dial(x, y, w, h, label);      return v; @@ -74,34 +68,45 @@ void free_fl_dial(DIAL v) { -int fl_dial_get_type(DIAL v) { -    return reinterpret_cast<Fl_Dial*>(v)->type(); +short fl_dial_get_angle1(DIAL v) { +    return reinterpret_cast<Fl_Dial*>(v)->angle1();  } -void fl_dial_set_type(DIAL v, int t) { -    reinterpret_cast<Fl_Dial*>(v)->type(t); +void fl_dial_set_angle1(DIAL v, short t) { +    reinterpret_cast<Fl_Dial*>(v)->angle1(t);  } +short fl_dial_get_angle2(DIAL v) { +    return reinterpret_cast<Fl_Dial*>(v)->angle2(); +} +void fl_dial_set_angle2(DIAL v, short t) { +    reinterpret_cast<Fl_Dial*>(v)->angle2(t); +} - -int fl_dial_get_angle1(DIAL v) { -    return reinterpret_cast<Fl_Dial*>(v)->angle1(); +void fl_dial_set_angles(DIAL v, short a, short b) { +    reinterpret_cast<Fl_Dial*>(v)->angles(a,b);  } -void fl_dial_set_angle1(DIAL v, int t) { -    reinterpret_cast<Fl_Dial*>(v)->angle1(t); + + + +void fl_dial_draw(DIAL v) { +    reinterpret_cast<My_Dial*>(v)->Fl_Dial::draw();  } -int fl_dial_get_angle2(DIAL v) { -    return reinterpret_cast<Fl_Dial*>(v)->angle2(); +void fl_dial_draw2(DIAL v, int x, int y, int w, int h) { +    void (Fl_Dial::*mydraw)(int,int,int,int) = &Friend_Dial::draw; +    (reinterpret_cast<Fl_Dial*>(v)->*mydraw)(x, y, w, h);  } -void fl_dial_set_angle2(DIAL v, int t) { -    reinterpret_cast<Fl_Dial*>(v)->angle2(t); +int fl_dial_handle(DIAL v, int e) { +    return reinterpret_cast<My_Dial*>(v)->Fl_Dial::handle(e);  } -void fl_dial_set_angles(DIAL v, int a, int b) { -    reinterpret_cast<Fl_Dial*>(v)->angles(a,b); +int fl_dial_handle2(DIAL v, int e, int x, int y, int w, int h) { +    int (Fl_Dial::*myhandle)(int,int,int,int,int) = &Friend_Dial::handle; +    return (reinterpret_cast<Fl_Dial*>(v)->*myhandle)(e, x, y, w, h);  } + diff --git a/src/c_fl_dial.h b/src/c_fl_dial.h index e703365..b642abd 100644 --- a/src/c_fl_dial.h +++ b/src/c_fl_dial.h @@ -8,37 +8,26 @@  #define FL_DIAL_GUARD - -  typedef void* DIAL; - - -extern "C" void dial_set_draw_hook(DIAL v, void * d); -extern "C" void fl_dial_draw(DIAL v); -extern "C" void dial_set_handle_hook(DIAL v, void * h); -extern "C" int fl_dial_handle(DIAL v, int e); - - - -  extern "C" DIAL new_fl_dial(int x, int y, int w, int h, char* label);  extern "C" void free_fl_dial(DIAL v); +extern "C" short fl_dial_get_angle1(DIAL v); +extern "C" void fl_dial_set_angle1(DIAL v, short t); +extern "C" short fl_dial_get_angle2(DIAL v); +extern "C" void fl_dial_set_angle2(DIAL v, short t); +extern "C" void fl_dial_set_angles(DIAL v, short a, short b); -extern "C" int fl_dial_get_type(DIAL v); -extern "C" void fl_dial_set_type(DIAL v, int t); - - -extern "C" int fl_dial_get_angle1(DIAL v); -extern "C" void fl_dial_set_angle1(DIAL v, int t); -extern "C" int fl_dial_get_angle2(DIAL v); -extern "C" void fl_dial_set_angle2(DIAL v, int t); -extern "C" void fl_dial_set_angles(DIAL v, int a, int b); +extern "C" void fl_dial_draw(DIAL v); +extern "C" void fl_dial_draw2(DIAL v, int x, int y, int w, int h); +extern "C" int fl_dial_handle(DIAL v, int e); +extern "C" int fl_dial_handle2(DIAL v, int e, int x, int y, int w, int h);  #endif + diff --git a/src/c_fl_double_window.cpp b/src/c_fl_double_window.cpp index 210f28a..ac949d9 100644 --- a/src/c_fl_double_window.cpp +++ b/src/c_fl_double_window.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Double_Window.H>  #include "c_fl_double_window.h" -#include "c_fl_type.h" -class My_Double_Window : public Fl_Double_Window { -    public: -        using Fl_Double_Window::Fl_Double_Window; -        friend void double_window_set_draw_hook(DOUBLEWINDOW n, void * d); -        friend void fl_double_window_draw(DOUBLEWINDOW n); -        friend void double_window_set_handle_hook(DOUBLEWINDOW n, void * h); -        friend int fl_double_window_handle(DOUBLEWINDOW 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; -}; +//  Exports from Ada -void My_Double_Window::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_Double_Window::real_draw() { -    Fl_Double_Window::draw(); -} -int My_Double_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Double_Window::real_handle(int e) { -    return Fl_Double_Window::handle(e); -} -void double_window_set_draw_hook(DOUBLEWINDOW n, void * d) { -    reinterpret_cast<My_Double_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_double_window_draw(DOUBLEWINDOW n) { -    reinterpret_cast<My_Double_Window*>(n)->real_draw(); -} +class My_Double_Window : public Fl_Double_Window { +public: +    using Fl_Double_Window::Fl_Double_Window; + +    friend void fl_double_window_draw(DOUBLEWINDOW n); +    friend int fl_double_window_handle(DOUBLEWINDOW n, int e); -void double_window_set_handle_hook(DOUBLEWINDOW n, void * h) { -    reinterpret_cast<My_Double_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Double_Window::draw() { +    widget_draw_hook(this->user_data());  } -int fl_double_window_handle(DOUBLEWINDOW n, int e) { -    return reinterpret_cast<My_Double_Window*>(n)->real_handle(e); +int My_Double_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  DOUBLEWINDOW new_fl_double_window(int x, int y, int w, int h, char* label) {      My_Double_Window *d = new My_Double_Window(x, y, w, h, label);      return d; @@ -91,3 +73,22 @@ void fl_double_window_flush(DOUBLEWINDOW d) {      reinterpret_cast<Fl_Double_Window*>(d)->flush();  } + + + +void fl_double_window_resize(DOUBLEWINDOW d, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Double_Window*>(d)->resize(x, y, w, h); +} + + + + +void fl_double_window_draw(DOUBLEWINDOW n) { +    reinterpret_cast<My_Double_Window*>(n)->Fl_Double_Window::draw(); +} + +int fl_double_window_handle(DOUBLEWINDOW n, int e) { +    return reinterpret_cast<My_Double_Window*>(n)->Fl_Double_Window::handle(e); +} + + diff --git a/src/c_fl_double_window.h b/src/c_fl_double_window.h index 765fba4..d518381 100644 --- a/src/c_fl_double_window.h +++ b/src/c_fl_double_window.h @@ -8,32 +8,26 @@  #define FL_DOUBLE_WINDOW_GUARD - -  typedef void* DOUBLEWINDOW; - - -extern "C" void double_window_set_draw_hook(DOUBLEWINDOW n, void * d); -extern "C" void fl_double_window_draw(DOUBLEWINDOW n); -extern "C" void double_window_set_handle_hook(DOUBLEWINDOW n, void * h); -extern "C" int fl_double_window_handle(DOUBLEWINDOW n, int e); - - - -  extern "C" DOUBLEWINDOW new_fl_double_window(int x, int y, int w, int h, char* label);  extern "C" DOUBLEWINDOW new_fl_double_window2(int w, int h, char* label);  extern "C" void free_fl_double_window(DOUBLEWINDOW d); - -  extern "C" void fl_double_window_show(DOUBLEWINDOW d);  extern "C" void fl_double_window_hide(DOUBLEWINDOW d);  extern "C" void fl_double_window_flush(DOUBLEWINDOW d); +extern "C" void fl_double_window_resize(DOUBLEWINDOW d, int x, int y, int w, int h); + + +extern "C" void fl_double_window_draw(DOUBLEWINDOW n); +extern "C" int fl_double_window_handle(DOUBLEWINDOW n, int e); + +  #endif + diff --git a/src/c_fl_fill_dial.cpp b/src/c_fl_fill_dial.cpp index cba6892..43f0167 100644 --- a/src/c_fl_fill_dial.cpp +++ b/src/c_fl_fill_dial.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Fill_Dial.H>  #include "c_fl_fill_dial.h" -#include "c_fl_type.h" -class My_Fill_Dial : public Fl_Fill_Dial { -    public: -        using Fl_Fill_Dial::Fl_Fill_Dial; -        friend void fill_dial_set_draw_hook(FILL_DIAL v, void * d); -        friend void fl_fill_dial_draw(FILL_DIAL v); -        friend void fill_dial_set_handle_hook(FILL_DIAL v, void * h); -        friend int fl_fill_dial_handle(FILL_DIAL v, 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_Fill_Dial::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_Fill_Dial::real_draw() { -    Fl_Fill_Dial::draw(); -} -int My_Fill_Dial::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Fill_Dial::real_handle(int e) { -    return Fl_Fill_Dial::handle(e); -} -void fill_dial_set_draw_hook(FILL_DIAL v, void * d) { -    reinterpret_cast<My_Fill_Dial*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_fill_dial_draw(FILL_DIAL v) { -    reinterpret_cast<My_Fill_Dial*>(v)->real_draw(); -} +class My_Fill_Dial : public Fl_Fill_Dial { +public: +    using Fl_Fill_Dial::Fl_Fill_Dial; + +    friend void fl_fill_dial_draw(FILL_DIAL v); +    friend int fl_fill_dial_handle(FILL_DIAL v, int e); + +    void draw(); +    int handle(int e); +}; -void fill_dial_set_handle_hook(FILL_DIAL v, void * h) { -    reinterpret_cast<My_Fill_Dial*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Fill_Dial::draw() { +    widget_draw_hook(this->user_data());  } -int fl_fill_dial_handle(FILL_DIAL v, int e) { -    return reinterpret_cast<My_Fill_Dial*>(v)->real_handle(e); +int My_Fill_Dial::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  FILL_DIAL new_fl_fill_dial(int x, int y, int w, int h, char* label) {      My_Fill_Dial *v = new My_Fill_Dial(x, y, w, h, label);      return v; @@ -72,3 +54,14 @@ void free_fl_fill_dial(FILL_DIAL v) {  } + + +void fl_fill_dial_draw(FILL_DIAL v) { +    reinterpret_cast<My_Fill_Dial*>(v)->Fl_Fill_Dial::draw(); +} + +int fl_fill_dial_handle(FILL_DIAL v, int e) { +    return reinterpret_cast<My_Fill_Dial*>(v)->Fl_Fill_Dial::handle(e); +} + + diff --git a/src/c_fl_fill_dial.h b/src/c_fl_fill_dial.h index e40eb66..84ecab8 100644 --- a/src/c_fl_fill_dial.h +++ b/src/c_fl_fill_dial.h @@ -8,24 +8,17 @@  #define FL_FILL_DIAL_GUARD - -  typedef void* FILL_DIAL; +extern "C" FILL_DIAL new_fl_fill_dial(int x, int y, int w, int h, char* label); +extern "C" void free_fl_fill_dial(FILL_DIAL v); -extern "C" void fill_dial_set_draw_hook(FILL_DIAL v, void * d);  extern "C" void fl_fill_dial_draw(FILL_DIAL v); -extern "C" void fill_dial_set_handle_hook(FILL_DIAL v, void * h);  extern "C" int fl_fill_dial_handle(FILL_DIAL v, int e); - - -extern "C" FILL_DIAL new_fl_fill_dial(int x, int y, int w, int h, char* label); -extern "C" void free_fl_fill_dial(FILL_DIAL v); - -  #endif + diff --git a/src/c_fl_fill_slider.cpp b/src/c_fl_fill_slider.cpp index d4177e1..d443684 100644 --- a/src/c_fl_fill_slider.cpp +++ b/src/c_fl_fill_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Fill_Slider.H>  #include "c_fl_fill_slider.h" -#include "c_fl_type.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_Fill_Slider : public Fl_Fill_Slider { -    public: -        using Fl_Fill_Slider::Fl_Fill_Slider; -        friend void fill_slider_set_draw_hook(FILL_SLIDER s, void * d); -        friend void fl_fill_slider_draw(FILL_SLIDER s); -        friend void fill_slider_set_handle_hook(FILL_SLIDER s, void * h); -        friend int fl_fill_slider_handle(FILL_SLIDER 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; +public: +    using Fl_Fill_Slider::Fl_Fill_Slider; + +    friend void fl_fill_slider_draw(FILLSLIDER s); +    friend int fl_fill_slider_handle(FILLSLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Fill_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Fill_Slider::real_draw() { -    Fl_Fill_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Fill_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Fill_Slider::real_handle(int e) { -    return Fl_Fill_Slider::handle(e); -} -void fill_slider_set_draw_hook(FILL_SLIDER s, void * d) { -    reinterpret_cast<My_Fill_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_fill_slider_draw(FILL_SLIDER s) { -    reinterpret_cast<My_Fill_Slider*>(s)->real_draw(); -} -void fill_slider_set_handle_hook(FILL_SLIDER s, void * h) { -    reinterpret_cast<My_Fill_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +FILLSLIDER new_fl_fill_slider(int x, int y, int w, int h, char* label) { +    My_Fill_Slider *s = new My_Fill_Slider(x, y, w, h, label); +    return s;  } -int fl_fill_slider_handle(FILL_SLIDER s, int e) { -    return reinterpret_cast<My_Fill_Slider*>(s)->real_handle(e); +void free_fl_fill_slider(FILLSLIDER s) { +    delete reinterpret_cast<My_Fill_Slider*>(s);  } -FILL_SLIDER new_fl_fill_slider(int x, int y, int w, int h, char* label) { -    My_Fill_Slider *s = new My_Fill_Slider(x, y, w, h, label); -    return s; +void fl_fill_slider_draw(FILLSLIDER s) { +    reinterpret_cast<My_Fill_Slider*>(s)->Fl_Fill_Slider::draw();  } -void free_fl_fill_slider(FILL_SLIDER s) { -    delete reinterpret_cast<My_Fill_Slider*>(s); +int fl_fill_slider_handle(FILLSLIDER s, int e) { +    return reinterpret_cast<My_Fill_Slider*>(s)->Fl_Fill_Slider::handle(e);  } diff --git a/src/c_fl_fill_slider.h b/src/c_fl_fill_slider.h index fe60c62..d208d93 100644 --- a/src/c_fl_fill_slider.h +++ b/src/c_fl_fill_slider.h @@ -8,24 +8,17 @@  #define FL_FILL_SLIDER_GUARD +typedef void* FILLSLIDER; -typedef void* FILL_SLIDER; +extern "C" FILLSLIDER new_fl_fill_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_fill_slider(FILLSLIDER s); - - -extern "C" void fill_slider_set_draw_hook(FILL_SLIDER s, void * d); -extern "C" void fl_fill_slider_draw(FILL_SLIDER s); -extern "C" void fill_slider_set_handle_hook(FILL_SLIDER s, void * h); -extern "C" int fl_fill_slider_handle(FILL_SLIDER s, int e); - - - - -extern "C" FILL_SLIDER new_fl_fill_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_fill_slider(FILL_SLIDER s); +extern "C" void fl_fill_slider_draw(FILLSLIDER s); +extern "C" int fl_fill_slider_handle(FILLSLIDER s, int e);  #endif + diff --git a/src/c_fl_gl_window.cpp b/src/c_fl_gl_window.cpp index 534dad6..1bcd616 100644 --- a/src/c_fl_gl_window.cpp +++ b/src/c_fl_gl_window.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Gl_Window.H>  #include "c_fl_gl_window.h" -#include "c_fl_type.h" -class My_Gl_Window : public Fl_Gl_Window { -    public: -        using Fl_Gl_Window::Fl_Gl_Window; -        friend void gl_window_set_draw_hook(GLWINDOW n, void * d); -        friend void fl_gl_window_draw(GLWINDOW n); -        friend void gl_window_set_handle_hook(GLWINDOW n, void * h); -        friend int fl_gl_window_handle(GLWINDOW 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; -}; +//  Exports from Ada -void My_Gl_Window::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_Gl_Window::real_draw() { -    Fl_Gl_Window::draw(); -} -int My_Gl_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Gl_Window::real_handle(int e) { -    return Fl_Gl_Window::handle(e); -} -void gl_window_set_draw_hook(GLWINDOW n, void * d) { -    reinterpret_cast<My_Gl_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_gl_window_draw(GLWINDOW n) { -    reinterpret_cast<My_Gl_Window*>(n)->real_draw(); -} +class My_Gl_Window : public Fl_Gl_Window { +public: +    using Fl_Gl_Window::Fl_Gl_Window; + +    friend void fl_gl_window_draw(GLWINDOW n); +    friend int fl_gl_window_handle(GLWINDOW n, int e); + +    void draw(); +    int handle(int e); +}; -void gl_window_set_handle_hook(GLWINDOW n, void * h) { -    reinterpret_cast<My_Gl_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Gl_Window::draw() { +    widget_draw_hook(this->user_data());  } -int fl_gl_window_handle(GLWINDOW n, int e) { -    return reinterpret_cast<My_Gl_Window*>(n)->real_handle(e); +int My_Gl_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  GLWINDOW new_fl_gl_window(int x, int y, int w, int h, char* label) {      My_Gl_Window *gw = new My_Gl_Window(x, y, w, h, label);      return gw; @@ -110,6 +92,10 @@ float fl_gl_window_pixels_per_unit(GLWINDOW w) {      return reinterpret_cast<Fl_Gl_Window*>(w)->pixels_per_unit();  } +void fl_gl_window_resize(GLWINDOW gw, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Gl_Window*>(gw)->resize(x, y, w, h); +} + @@ -184,3 +170,14 @@ void fl_gl_window_swap_buffers(GLWINDOW w) {  } + + +void fl_gl_window_draw(GLWINDOW n) { +    reinterpret_cast<My_Gl_Window*>(n)->Fl_Gl_Window::draw(); +} + +int fl_gl_window_handle(GLWINDOW n, int e) { +    return reinterpret_cast<My_Gl_Window*>(n)->Fl_Gl_Window::handle(e); +} + + diff --git a/src/c_fl_gl_window.h b/src/c_fl_gl_window.h index 6d91724..0079008 100644 --- a/src/c_fl_gl_window.h +++ b/src/c_fl_gl_window.h @@ -8,28 +8,14 @@  #define FL_GL_WINDOW_GUARD - -  typedef void* GLWINDOW; - - -extern "C" void gl_window_set_draw_hook(GLWINDOW n, void * d); -extern "C" void fl_gl_window_draw(GLWINDOW n); -extern "C" void gl_window_set_handle_hook(GLWINDOW n, void * h); -extern "C" int fl_gl_window_handle(GLWINDOW n, int e); - - - -  extern "C" GLWINDOW new_fl_gl_window(int x, int y, int w, int h, char* label);  extern "C" GLWINDOW new_fl_gl_window2(int w, int h, char* label);  extern "C" void free_fl_gl_window(GLWINDOW w); - -  extern "C" void fl_gl_window_show(GLWINDOW w);  extern "C" void fl_gl_window_hide(GLWINDOW w);  extern "C" void fl_gl_window_hide_overlay(GLWINDOW w); @@ -39,6 +25,7 @@ extern "C" void fl_gl_window_flush(GLWINDOW w);  extern "C" int fl_gl_window_pixel_h(GLWINDOW w);  extern "C" int fl_gl_window_pixel_w(GLWINDOW w);  extern "C" float fl_gl_window_pixels_per_unit(GLWINDOW w); +extern "C" void fl_gl_window_resize(GLWINDOW gw, int x, int y, int w, int h);  extern "C" unsigned int fl_gl_window_get_mode(GLWINDOW w); @@ -63,5 +50,10 @@ extern "C" void fl_gl_window_redraw_overlay(GLWINDOW w);  extern "C" void fl_gl_window_swap_buffers(GLWINDOW w); +extern "C" void fl_gl_window_draw(GLWINDOW n); +extern "C" int fl_gl_window_handle(GLWINDOW n, int e); + +  #endif + diff --git a/src/c_fl_group.cpp b/src/c_fl_group.cpp index f5b0f17..71ae7df 100644 --- a/src/c_fl_group.cpp +++ b/src/c_fl_group.cpp @@ -8,62 +8,44 @@  #include <FL/Fl_Widget.H>  #include "c_fl_group.h"  #include "c_fl_widget.h" -#include "c_fl_type.h" -class My_Group : public Fl_Group { -    public: -        using Fl_Group::Fl_Group; -        friend void group_set_draw_hook(GROUP g, void * d); -        friend void fl_group_draw(GROUP g); -        friend void group_set_handle_hook(GROUP g, void * h); -        friend int fl_group_handle(GROUP g, 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_Group::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_Group::real_draw() { -    Fl_Group::draw(); -} -int My_Group::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Group::real_handle(int e) { -    return Fl_Group::handle(e); -} -void group_set_draw_hook(GROUP g, void * d) { -    reinterpret_cast<My_Group*>(g)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_group_draw(GROUP g) { -    reinterpret_cast<My_Group*>(g)->real_draw(); -} +class My_Group : public Fl_Group { +public: +    using Fl_Group::Fl_Group; + +    friend void fl_group_draw(GROUP g); +    friend int fl_group_handle(GROUP g, int e); + +    void draw(); +    int handle(int e); +}; -void group_set_handle_hook(GROUP g, void * h) { -    reinterpret_cast<My_Group*>(g)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Group::draw() { +    widget_draw_hook(this->user_data());  } -int fl_group_handle(GROUP g, int e) { -    return reinterpret_cast<My_Group*>(g)->real_handle(e); +int My_Group::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  GROUP new_fl_group(int x, int y, int w, int h, char* label) {      My_Group *g = new My_Group(x, y, w, h, label);      return g; @@ -157,3 +139,14 @@ void fl_group_set_current(GROUP g) {  } + + +void fl_group_draw(GROUP g) { +    reinterpret_cast<My_Group*>(g)->Fl_Group::draw(); +} + +int fl_group_handle(GROUP g, int e) { +    return reinterpret_cast<My_Group*>(g)->Fl_Group::handle(e); +} + + diff --git a/src/c_fl_group.h b/src/c_fl_group.h index ab1d7c4..5eaa333 100644 --- a/src/c_fl_group.h +++ b/src/c_fl_group.h @@ -10,27 +10,13 @@  #include "c_fl_widget.h" - -  typedef void* GROUP; - - -extern "C" void group_set_draw_hook(GROUP g, void * d); -extern "C" void fl_group_draw(GROUP g); -extern "C" void group_set_handle_hook(GROUP g, void * h); -extern "C" int fl_group_handle(GROUP g, int e); - - - -  extern "C" GROUP new_fl_group(int x, int y, int w, int h, char* label);  extern "C" void free_fl_group(GROUP g); - -  extern "C" void fl_group_end(GROUP g); @@ -59,5 +45,10 @@ extern "C" void * fl_group_get_current();  extern "C" void fl_group_set_current(GROUP g); +extern "C" void fl_group_draw(GROUP g); +extern "C" int fl_group_handle(GROUP g, int e); + +  #endif + diff --git a/src/c_fl_help_view.cpp b/src/c_fl_help_view.cpp index 33f1e5f..50d5d58 100644 --- a/src/c_fl_help_view.cpp +++ b/src/c_fl_help_view.cpp @@ -8,70 +8,44 @@  #include <FL/Fl_Help_View.H>  #include <FL/Enumerations.H>  #include "c_fl_help_view.h" -#include "c_fl_type.h" -class My_Help_View : public Fl_Help_View { -    public: -        using Fl_Help_View::Fl_Help_View; -        friend void help_view_set_draw_hook(HELPVIEW v, void * d); -        friend void fl_help_view_draw(HELPVIEW v); -        friend void help_view_set_handle_hook(HELPVIEW v, void * h); -        friend int fl_help_view_handle(HELPVIEW v, 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_Help_View::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_Help_View::real_draw() { -    #if FL_ABI_VERSION >= 10303 -    Fl_Help_View::draw(); -    #else -    Fl_Group::draw(); -    #endif -} -int My_Help_View::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Help_View::real_handle(int e) { -    #if FL_ABI_VERSION >= 10303 -    return Fl_Help_View::handle(e); -    #else -    return Fl_Group::handle(e); -    #endif -} -void help_view_set_draw_hook(HELPVIEW v, void * d) { -    reinterpret_cast<My_Help_View*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_help_view_draw(HELPVIEW v) { -    reinterpret_cast<My_Help_View*>(v)->real_draw(); -} +class My_Help_View : public Fl_Help_View { +public: +    using Fl_Help_View::Fl_Help_View; + +    friend void fl_help_view_draw(HELPVIEW v); +    friend int fl_help_view_handle(HELPVIEW v, int e); + +    void draw(); +    int handle(int e); +}; -void help_view_set_handle_hook(HELPVIEW v, void * h) { -    reinterpret_cast<My_Help_View*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Help_View::draw() { +    widget_draw_hook(this->user_data());  } -int fl_help_view_handle(HELPVIEW v, int e) { -    return reinterpret_cast<My_Help_View*>(v)->real_handle(e); +int My_Help_View::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  HELPVIEW new_fl_help_view(int x, int y, int w, int h, char * label) {      My_Help_View *v = new My_Help_View(x, y, w, h, label);      return v; @@ -169,6 +143,10 @@ void fl_help_view_set_size(HELPVIEW v, int w, int h) {      reinterpret_cast<Fl_Help_View*>(v)->size(w, h);  } +void fl_help_view_resize(HELPVIEW v, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Help_View*>(v)->resize(x, y, w, h); +} +  unsigned int fl_help_view_get_textcolor(HELPVIEW v) {      return reinterpret_cast<Fl_Help_View*>(v)->textcolor();  } @@ -194,3 +172,22 @@ void fl_help_view_set_textsize(HELPVIEW v, int s) {  } + + +void fl_help_view_draw(HELPVIEW v) { +    #if FL_ABI_VERSION >= 10303 +    reinterpret_cast<My_Help_View*>(v)->Fl_Help_View::draw(); +    #else +    reinterpret_cast<My_Help_View*>(v)->Fl_Group::draw(); +    #endif +} + +int fl_help_view_handle(HELPVIEW v, int e) { +    #if FL_ABI_VERSION >= 10303 +    return reinterpret_cast<My_Help_View*>(v)->Fl_Help_View::handle(e); +    #else +    return reinterpret_cast<My_Help_View*>(v)->Fl_Group::handle(e); +    #endif +} + + diff --git a/src/c_fl_help_view.h b/src/c_fl_help_view.h index b76d907..b16b344 100644 --- a/src/c_fl_help_view.h +++ b/src/c_fl_help_view.h @@ -8,27 +8,13 @@  #define FL_HELP_VIEW_GUARD - -  typedef void* HELPVIEW; - - -extern "C" void help_view_set_draw_hook(HELPVIEW v, void * d); -extern "C" void fl_help_view_draw(HELPVIEW v); -extern "C" void help_view_set_handle_hook(HELPVIEW v, void * h); -extern "C" int fl_help_view_handle(HELPVIEW v, int e); - - - -  extern "C" HELPVIEW new_fl_help_view(int x, int y, int w, int h, char * label);  extern "C" void free_fl_help_view(HELPVIEW v); - -  extern "C" void fl_help_view_clear_selection(HELPVIEW v);  extern "C" void fl_help_view_select_all(HELPVIEW v); @@ -54,6 +40,7 @@ extern "C" int fl_help_view_get_scrollbar_size(HELPVIEW v);  extern "C" void fl_help_view_set_scrollbar_size(HELPVIEW v, int s);  extern "C" int fl_help_view_get_size(HELPVIEW v);  extern "C" void fl_help_view_set_size(HELPVIEW v, int w, int h); +extern "C" void fl_help_view_resize(HELPVIEW v, int x, int y, int w, int h);  extern "C" unsigned int fl_help_view_get_textcolor(HELPVIEW v);  extern "C" void fl_help_view_set_textcolor(HELPVIEW v, unsigned int c);  extern "C" int fl_help_view_get_textfont(HELPVIEW v); @@ -62,6 +49,10 @@ extern "C" int fl_help_view_get_textsize(HELPVIEW v);  extern "C" void fl_help_view_set_textsize(HELPVIEW v, int s); +extern "C" void fl_help_view_draw(HELPVIEW v); +extern "C" int fl_help_view_handle(HELPVIEW v, int e); + +  #endif diff --git a/src/c_fl_hor_fill_slider.cpp b/src/c_fl_hor_fill_slider.cpp index f12fbd3..d146698 100644 --- a/src/c_fl_hor_fill_slider.cpp +++ b/src/c_fl_hor_fill_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Hor_Fill_Slider.H>  #include "c_fl_hor_fill_slider.h" -#include "c_fl_type.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_Hor_Fill_Slider : public Fl_Hor_Fill_Slider { -    public: -        using Fl_Hor_Fill_Slider::Fl_Hor_Fill_Slider; -        friend void hor_fill_slider_set_draw_hook(HOR_FILL_SLIDER s, void * d); -        friend void fl_hor_fill_slider_draw(HOR_FILL_SLIDER s); -        friend void hor_fill_slider_set_handle_hook(HOR_FILL_SLIDER s, void * h); -        friend int fl_hor_fill_slider_handle(HOR_FILL_SLIDER 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; +public: +    using Fl_Hor_Fill_Slider::Fl_Hor_Fill_Slider; + +    friend void fl_hor_fill_slider_draw(HORFILLSLIDER s); +    friend int fl_hor_fill_slider_handle(HORFILLSLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Hor_Fill_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Hor_Fill_Slider::real_draw() { -    Fl_Hor_Fill_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Hor_Fill_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Hor_Fill_Slider::real_handle(int e) { -    return Fl_Hor_Fill_Slider::handle(e); -} -void hor_fill_slider_set_draw_hook(HOR_FILL_SLIDER s, void * d) { -    reinterpret_cast<My_Hor_Fill_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_hor_fill_slider_draw(HOR_FILL_SLIDER s) { -    reinterpret_cast<My_Hor_Fill_Slider*>(s)->real_draw(); -} -void hor_fill_slider_set_handle_hook(HOR_FILL_SLIDER s, void * h) { -    reinterpret_cast<My_Hor_Fill_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +HORFILLSLIDER new_fl_hor_fill_slider(int x, int y, int w, int h, char* label) { +    My_Hor_Fill_Slider *s = new My_Hor_Fill_Slider(x, y, w, h, label); +    return s;  } -int fl_hor_fill_slider_handle(HOR_FILL_SLIDER s, int e) { -    return reinterpret_cast<My_Hor_Fill_Slider*>(s)->real_handle(e); +void free_fl_hor_fill_slider(HORFILLSLIDER s) { +    delete reinterpret_cast<My_Hor_Fill_Slider*>(s);  } -HOR_FILL_SLIDER new_fl_hor_fill_slider(int x, int y, int w, int h, char* label) { -    My_Hor_Fill_Slider *s = new My_Hor_Fill_Slider(x, y, w, h, label); -    return s; +void fl_hor_fill_slider_draw(HORFILLSLIDER s) { +    reinterpret_cast<My_Hor_Fill_Slider*>(s)->Fl_Hor_Fill_Slider::draw();  } -void free_fl_hor_fill_slider(HOR_FILL_SLIDER s) { -    delete reinterpret_cast<My_Hor_Fill_Slider*>(s); +int fl_hor_fill_slider_handle(HORFILLSLIDER s, int e) { +    return reinterpret_cast<My_Hor_Fill_Slider*>(s)->Fl_Hor_Fill_Slider::handle(e);  } diff --git a/src/c_fl_hor_fill_slider.h b/src/c_fl_hor_fill_slider.h index 5aa3541..d698a93 100644 --- a/src/c_fl_hor_fill_slider.h +++ b/src/c_fl_hor_fill_slider.h @@ -8,24 +8,17 @@  #define FL_HOR_FILL_SLIDER_GUARD +typedef void* HORFILLSLIDER; -typedef void* HOR_FILL_SLIDER; +extern "C" HORFILLSLIDER new_fl_hor_fill_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_hor_fill_slider(HORFILLSLIDER s); - - -extern "C" void hor_fill_slider_set_draw_hook(HOR_FILL_SLIDER s, void * d); -extern "C" void fl_hor_fill_slider_draw(HOR_FILL_SLIDER s); -extern "C" void hor_fill_slider_set_handle_hook(HOR_FILL_SLIDER s, void * h); -extern "C" int fl_hor_fill_slider_handle(HOR_FILL_SLIDER s, int e); - - - - -extern "C" HOR_FILL_SLIDER new_fl_hor_fill_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_hor_fill_slider(HOR_FILL_SLIDER s); +extern "C" void fl_hor_fill_slider_draw(HORFILLSLIDER s); +extern "C" int fl_hor_fill_slider_handle(HORFILLSLIDER s, int e);  #endif + diff --git a/src/c_fl_hor_nice_slider.cpp b/src/c_fl_hor_nice_slider.cpp index c976e26..e3f828f 100644 --- a/src/c_fl_hor_nice_slider.cpp +++ b/src/c_fl_hor_nice_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Hor_Nice_Slider.H>  #include "c_fl_hor_nice_slider.h" -#include "c_fl_type.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_Hor_Nice_Slider : public Fl_Hor_Nice_Slider { -    public: -        using Fl_Hor_Nice_Slider::Fl_Hor_Nice_Slider; -        friend void hor_nice_slider_set_draw_hook(HOR_NICE_SLIDER s, void * d); -        friend void fl_hor_nice_slider_draw(HOR_NICE_SLIDER s); -        friend void hor_nice_slider_set_handle_hook(HOR_NICE_SLIDER s, void * h); -        friend int fl_hor_nice_slider_handle(HOR_NICE_SLIDER 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; +public: +    using Fl_Hor_Nice_Slider::Fl_Hor_Nice_Slider; + +    friend void fl_hor_nice_slider_draw(HORNICESLIDER s); +    friend int fl_hor_nice_slider_handle(HORNICESLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Hor_Nice_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Hor_Nice_Slider::real_draw() { -    Fl_Hor_Nice_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Hor_Nice_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Hor_Nice_Slider::real_handle(int e) { -    return Fl_Hor_Nice_Slider::handle(e); -} -void hor_nice_slider_set_draw_hook(HOR_NICE_SLIDER s, void * d) { -    reinterpret_cast<My_Hor_Nice_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_hor_nice_slider_draw(HOR_NICE_SLIDER s) { -    reinterpret_cast<My_Hor_Nice_Slider*>(s)->real_draw(); -} -void hor_nice_slider_set_handle_hook(HOR_NICE_SLIDER s, void * h) { -    reinterpret_cast<My_Hor_Nice_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +HORNICESLIDER new_fl_hor_nice_slider(int x, int y, int w, int h, char* label) { +    My_Hor_Nice_Slider *s = new My_Hor_Nice_Slider(x, y, w, h, label); +    return s;  } -int fl_hor_nice_slider_handle(HOR_NICE_SLIDER s, int e) { -    return reinterpret_cast<My_Hor_Nice_Slider*>(s)->real_handle(e); +void free_fl_hor_nice_slider(HORNICESLIDER s) { +    delete reinterpret_cast<My_Hor_Nice_Slider*>(s);  } -HOR_NICE_SLIDER new_fl_hor_nice_slider(int x, int y, int w, int h, char* label) { -    My_Hor_Nice_Slider *s = new My_Hor_Nice_Slider(x, y, w, h, label); -    return s; +void fl_hor_nice_slider_draw(HORNICESLIDER s) { +    reinterpret_cast<My_Hor_Nice_Slider*>(s)->Fl_Hor_Nice_Slider::draw();  } -void free_fl_hor_nice_slider(HOR_NICE_SLIDER s) { -    delete reinterpret_cast<My_Hor_Nice_Slider*>(s); +int fl_hor_nice_slider_handle(HORNICESLIDER s, int e) { +    return reinterpret_cast<My_Hor_Nice_Slider*>(s)->Fl_Hor_Nice_Slider::handle(e);  } diff --git a/src/c_fl_hor_nice_slider.h b/src/c_fl_hor_nice_slider.h index 296f364..a4e3bc1 100644 --- a/src/c_fl_hor_nice_slider.h +++ b/src/c_fl_hor_nice_slider.h @@ -8,24 +8,17 @@  #define FL_HOR_NICE_SLIDER_GUARD +typedef void* HORNICESLIDER; -typedef void* HOR_NICE_SLIDER; +extern "C" HORNICESLIDER new_fl_hor_nice_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_hor_nice_slider(HORNICESLIDER s); - - -extern "C" void hor_nice_slider_set_draw_hook(HOR_NICE_SLIDER s, void * d); -extern "C" void fl_hor_nice_slider_draw(HOR_NICE_SLIDER s); -extern "C" void hor_nice_slider_set_handle_hook(HOR_NICE_SLIDER s, void * h); -extern "C" int fl_hor_nice_slider_handle(HOR_NICE_SLIDER s, int e); - - - - -extern "C" HOR_NICE_SLIDER new_fl_hor_nice_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_hor_nice_slider(HOR_NICE_SLIDER s); +extern "C" void fl_hor_nice_slider_draw(HORNICESLIDER s); +extern "C" int fl_hor_nice_slider_handle(HORNICESLIDER s, int e);  #endif + diff --git a/src/c_fl_hor_value_slider.cpp b/src/c_fl_hor_value_slider.cpp index f91a213..0630b12 100644 --- a/src/c_fl_hor_value_slider.cpp +++ b/src/c_fl_hor_value_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Hor_Value_Slider.H>  #include "c_fl_hor_value_slider.h" -#include "c_fl_type.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_Hor_Value_Slider : public Fl_Hor_Value_Slider { -    public: -        using Fl_Hor_Value_Slider::Fl_Hor_Value_Slider; -        friend void hor_value_slider_set_draw_hook(HOR_VALUE_SLIDER s, void * d); -        friend void fl_hor_value_slider_draw(HOR_VALUE_SLIDER s); -        friend void hor_value_slider_set_handle_hook(HOR_VALUE_SLIDER s, void * h); -        friend int fl_hor_value_slider_handle(HOR_VALUE_SLIDER 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; +public: +    using Fl_Hor_Value_Slider::Fl_Hor_Value_Slider; + +    friend void fl_hor_value_slider_draw(HORVALUESLIDER s); +    friend int fl_hor_value_slider_handle(HORVALUESLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Hor_Value_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Hor_Value_Slider::real_draw() { -    Fl_Hor_Value_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Hor_Value_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Hor_Value_Slider::real_handle(int e) { -    return Fl_Hor_Value_Slider::handle(e); -} -void hor_value_slider_set_draw_hook(HOR_VALUE_SLIDER s, void * d) { -    reinterpret_cast<My_Hor_Value_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_hor_value_slider_draw(HOR_VALUE_SLIDER s) { -    reinterpret_cast<My_Hor_Value_Slider*>(s)->real_draw(); -} -void hor_value_slider_set_handle_hook(HOR_VALUE_SLIDER s, void * h) { -    reinterpret_cast<My_Hor_Value_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +HORVALUESLIDER new_fl_hor_value_slider(int x, int y, int w, int h, char* label) { +    My_Hor_Value_Slider *s = new My_Hor_Value_Slider(x, y, w, h, label); +    return s;  } -int fl_hor_value_slider_handle(HOR_VALUE_SLIDER s, int e) { -    return reinterpret_cast<My_Hor_Value_Slider*>(s)->real_handle(e); +void free_fl_hor_value_slider(HORVALUESLIDER s) { +    delete reinterpret_cast<My_Hor_Value_Slider*>(s);  } -HOR_VALUE_SLIDER new_fl_hor_value_slider(int x, int y, int w, int h, char* label) { -    My_Hor_Value_Slider *s = new My_Hor_Value_Slider(x, y, w, h, label); -    return s; +void fl_hor_value_slider_draw(HORVALUESLIDER s) { +    reinterpret_cast<My_Hor_Value_Slider*>(s)->Fl_Hor_Value_Slider::draw();  } -void free_fl_hor_value_slider(HOR_VALUE_SLIDER s) { -    delete reinterpret_cast<My_Hor_Value_Slider*>(s); +int fl_hor_value_slider_handle(HORVALUESLIDER s, int e) { +    return reinterpret_cast<My_Hor_Value_Slider*>(s)->Fl_Hor_Value_Slider::handle(e);  } diff --git a/src/c_fl_hor_value_slider.h b/src/c_fl_hor_value_slider.h index 09a829c..6257313 100644 --- a/src/c_fl_hor_value_slider.h +++ b/src/c_fl_hor_value_slider.h @@ -8,24 +8,17 @@  #define FL_HOR_VALUE_SLIDER_GUARD +typedef void* HORVALUESLIDER; -typedef void* HOR_VALUE_SLIDER; +extern "C" HORVALUESLIDER new_fl_hor_value_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_hor_value_slider(HORVALUESLIDER s); - - -extern "C" void hor_value_slider_set_draw_hook(HOR_VALUE_SLIDER s, void * d); -extern "C" void fl_hor_value_slider_draw(HOR_VALUE_SLIDER s); -extern "C" void hor_value_slider_set_handle_hook(HOR_VALUE_SLIDER s, void * h); -extern "C" int fl_hor_value_slider_handle(HOR_VALUE_SLIDER s, int e); - - - - -extern "C" HOR_VALUE_SLIDER new_fl_hor_value_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_hor_value_slider(HOR_VALUE_SLIDER s); +extern "C" void fl_hor_value_slider_draw(HORVALUESLIDER s); +extern "C" int fl_hor_value_slider_handle(HORVALUESLIDER s, int e);  #endif + diff --git a/src/c_fl_horizontal_slider.cpp b/src/c_fl_horizontal_slider.cpp index 2e52a68..2856a21 100644 --- a/src/c_fl_horizontal_slider.cpp +++ b/src/c_fl_horizontal_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Hor_Slider.H>  #include "c_fl_horizontal_slider.h" -#include "c_fl_type.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_Horizontal_Slider : public Fl_Hor_Slider { -    public: -        using Fl_Hor_Slider::Fl_Hor_Slider; -        friend void horizontal_slider_set_draw_hook(HORIZONTAL_SLIDER s, void * d); -        friend void fl_horizontal_slider_draw(HORIZONTAL_SLIDER s); -        friend void horizontal_slider_set_handle_hook(HORIZONTAL_SLIDER s, void * h); -        friend int fl_horizontal_slider_handle(HORIZONTAL_SLIDER 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; +public: +    using Fl_Hor_Slider::Fl_Hor_Slider; + +    friend void fl_horizontal_slider_draw(HORIZONTALSLIDER s); +    friend int fl_horizontal_slider_handle(HORIZONTALSLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Horizontal_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Horizontal_Slider::real_draw() { -    Fl_Hor_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Horizontal_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Horizontal_Slider::real_handle(int e) { -    return Fl_Hor_Slider::handle(e); -} -void horizontal_slider_set_draw_hook(HORIZONTAL_SLIDER s, void * d) { -    reinterpret_cast<My_Horizontal_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_horizontal_slider_draw(HORIZONTAL_SLIDER s) { -    reinterpret_cast<My_Horizontal_Slider*>(s)->real_draw(); -} -void horizontal_slider_set_handle_hook(HORIZONTAL_SLIDER s, void * h) { -    reinterpret_cast<My_Horizontal_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +HORIZONTALSLIDER new_fl_horizontal_slider(int x, int y, int w, int h, char* label) { +    My_Horizontal_Slider *s = new My_Horizontal_Slider(x, y, w, h, label); +    return s;  } -int fl_horizontal_slider_handle(HORIZONTAL_SLIDER s, int e) { -    return reinterpret_cast<My_Horizontal_Slider*>(s)->real_handle(e); +void free_fl_horizontal_slider(HORIZONTALSLIDER s) { +    delete reinterpret_cast<My_Horizontal_Slider*>(s);  } -HORIZONTAL_SLIDER new_fl_horizontal_slider(int x, int y, int w, int h, char* label) { -    My_Horizontal_Slider *s = new My_Horizontal_Slider(x, y, w, h, label); -    return s; +void fl_horizontal_slider_draw(HORIZONTALSLIDER s) { +    reinterpret_cast<My_Horizontal_Slider*>(s)->Fl_Hor_Slider::draw();  } -void free_fl_horizontal_slider(HORIZONTAL_SLIDER s) { -    delete reinterpret_cast<My_Horizontal_Slider*>(s); +int fl_horizontal_slider_handle(HORIZONTALSLIDER s, int e) { +    return reinterpret_cast<My_Horizontal_Slider*>(s)->Fl_Hor_Slider::handle(e);  } diff --git a/src/c_fl_horizontal_slider.h b/src/c_fl_horizontal_slider.h index 118b834..96dd11a 100644 --- a/src/c_fl_horizontal_slider.h +++ b/src/c_fl_horizontal_slider.h @@ -8,24 +8,17 @@  #define FL_HORIZONTAL_SLIDER_GUARD +typedef void* HORIZONTALSLIDER; -typedef void* HORIZONTAL_SLIDER; +extern "C" HORIZONTALSLIDER new_fl_horizontal_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_horizontal_slider(HORIZONTALSLIDER s); - - -extern "C" void horizontal_slider_set_draw_hook(HORIZONTAL_SLIDER s, void * d); -extern "C" void fl_horizontal_slider_draw(HORIZONTAL_SLIDER s); -extern "C" void horizontal_slider_set_handle_hook(HORIZONTAL_SLIDER s, void * h); -extern "C" int fl_horizontal_slider_handle(HORIZONTAL_SLIDER s, int e); - - - - -extern "C" HORIZONTAL_SLIDER new_fl_horizontal_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_horizontal_slider(HORIZONTAL_SLIDER s); +extern "C" void fl_horizontal_slider_draw(HORIZONTALSLIDER s); +extern "C" int fl_horizontal_slider_handle(HORIZONTALSLIDER s, int e);  #endif + diff --git a/src/c_fl_input_choice.cpp b/src/c_fl_input_choice.cpp index 4418e56..682aed0 100644 --- a/src/c_fl_input_choice.cpp +++ b/src/c_fl_input_choice.cpp @@ -6,146 +6,146 @@  #include <FL/Fl_Input_Choice.H>  #include "c_fl_input_choice.h" -#include "c_fl_type.h" -class My_Input_Choice : public Fl_Input_Choice { -    public: -        using Fl_Input_Choice::Fl_Input_Choice; -        friend void input_choice_set_draw_hook(INPUT_CHOICE n, void * d); -        friend void fl_input_choice_draw(INPUT_CHOICE n); -        friend void input_choice_set_handle_hook(INPUT_CHOICE n, void * h); -        friend int fl_input_choice_handle(INPUT_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; -}; +//  Exports from Ada -void My_Input_Choice::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_Input_Choice::real_draw() { -    Fl_Input_Choice::draw(); -} -int My_Input_Choice::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Input_Choice::real_handle(int e) { -    return Fl_Input_Choice::handle(e); -} -void input_choice_set_draw_hook(INPUT_CHOICE n, void * d) { -    reinterpret_cast<My_Input_Choice*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_input_choice_draw(INPUT_CHOICE n) { -    reinterpret_cast<My_Input_Choice*>(n)->real_draw(); -} +class My_Input_Choice : public Fl_Input_Choice { +public: +    using Fl_Input_Choice::Fl_Input_Choice; + +    friend void fl_input_choice_draw(INPUTCHOICE n); +    friend int fl_input_choice_handle(INPUTCHOICE n, int e); -void input_choice_set_handle_hook(INPUT_CHOICE n, void * h) { -    reinterpret_cast<My_Input_Choice*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Input_Choice::draw() { +    widget_draw_hook(this->user_data());  } -int fl_input_choice_handle(INPUT_CHOICE n, int e) { -    return reinterpret_cast<My_Input_Choice*>(n)->real_handle(e); +int My_Input_Choice::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -INPUT_CHOICE new_fl_input_choice(int x, int y, int w, int h, char* label) { +//  Flattened C API + +INPUTCHOICE new_fl_input_choice(int x, int y, int w, int h, char* label) {      My_Input_Choice *n = new My_Input_Choice(x, y, w, h, label);      return n;  } -void free_fl_input_choice(INPUT_CHOICE n) { +void free_fl_input_choice(INPUTCHOICE n) {      delete reinterpret_cast<My_Input_Choice*>(n);  } -void * fl_input_choice_input(INPUT_CHOICE n) { +void * fl_input_choice_input(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->input();  } -void * fl_input_choice_menubutton(INPUT_CHOICE n) { +void * fl_input_choice_menubutton(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->menubutton();  } -void fl_input_choice_clear(INPUT_CHOICE n) { +void fl_input_choice_clear(INPUTCHOICE n) {      reinterpret_cast<Fl_Input_Choice*>(n)->clear();  } -int fl_input_choice_changed(INPUT_CHOICE n) { +int fl_input_choice_changed(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->changed();  } -void fl_input_choice_clear_changed(INPUT_CHOICE n) { +void fl_input_choice_clear_changed(INPUTCHOICE n) {      reinterpret_cast<Fl_Input_Choice*>(n)->clear_changed();  } -void fl_input_choice_set_changed(INPUT_CHOICE n) { +void fl_input_choice_set_changed(INPUTCHOICE n) {      reinterpret_cast<Fl_Input_Choice*>(n)->set_changed();  } -int fl_input_choice_get_down_box(INPUT_CHOICE n) { +int fl_input_choice_get_down_box(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->down_box();  } -void fl_input_choice_set_down_box(INPUT_CHOICE n, int t) { +void fl_input_choice_set_down_box(INPUTCHOICE n, int t) {      reinterpret_cast<Fl_Input_Choice*>(n)->down_box(static_cast<Fl_Boxtype>(t));  } -unsigned int fl_input_choice_get_textcolor(INPUT_CHOICE n) { +unsigned int fl_input_choice_get_textcolor(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->textcolor();  } -void fl_input_choice_set_textcolor(INPUT_CHOICE n, unsigned int t) { +void fl_input_choice_set_textcolor(INPUTCHOICE n, unsigned int t) {      reinterpret_cast<Fl_Input_Choice*>(n)->textcolor(t);  } -int fl_input_choice_get_textfont(INPUT_CHOICE n) { +int fl_input_choice_get_textfont(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->textfont();  } -void fl_input_choice_set_textfont(INPUT_CHOICE n, int t) { +void fl_input_choice_set_textfont(INPUTCHOICE n, int t) {      reinterpret_cast<Fl_Input_Choice*>(n)->textfont(t);  } -int fl_input_choice_get_textsize(INPUT_CHOICE n) { +int fl_input_choice_get_textsize(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->textsize();  } -void fl_input_choice_set_textsize(INPUT_CHOICE n, int t) { +void fl_input_choice_set_textsize(INPUTCHOICE n, int t) {      reinterpret_cast<Fl_Input_Choice*>(n)->textsize(t);  } -const char * fl_input_choice_get_value(INPUT_CHOICE n) { +const char * fl_input_choice_get_value(INPUTCHOICE n) {      return reinterpret_cast<Fl_Input_Choice*>(n)->value();  } -void fl_input_choice_set_value(INPUT_CHOICE n, const char * t) { +void fl_input_choice_set_value(INPUTCHOICE n, const char * t) {      reinterpret_cast<Fl_Input_Choice*>(n)->value(t);  } -void fl_input_choice_set_value2(INPUT_CHOICE n, int t) { +void fl_input_choice_set_value2(INPUTCHOICE n, int t) {      reinterpret_cast<Fl_Input_Choice*>(n)->value(t);  } + + +void fl_input_choice_resize(INPUTCHOICE n, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Input_Choice*>(n)->resize(x, y, w, h); +} + + + + +void fl_input_choice_draw(INPUTCHOICE n) { +    reinterpret_cast<My_Input_Choice*>(n)->Fl_Input_Choice::draw(); +} + +int fl_input_choice_handle(INPUTCHOICE n, int e) { +    return reinterpret_cast<My_Input_Choice*>(n)->Fl_Input_Choice::handle(e); +} + + diff --git a/src/c_fl_input_choice.h b/src/c_fl_input_choice.h index add7b53..a7ee0c3 100644 --- a/src/c_fl_input_choice.h +++ b/src/c_fl_input_choice.h @@ -8,49 +8,43 @@  #define FL_INPUT_CHOICE_GUARD +typedef void* INPUTCHOICE; -typedef void* INPUT_CHOICE; +extern "C" INPUTCHOICE new_fl_input_choice(int x, int y, int w, int h, char* label); +extern "C" void free_fl_input_choice(INPUTCHOICE n); +extern "C" void * fl_input_choice_input(INPUTCHOICE n); +extern "C" void * fl_input_choice_menubutton(INPUTCHOICE n); -extern "C" void input_choice_set_draw_hook(INPUT_CHOICE n, void * d); -extern "C" void fl_input_choice_draw(INPUT_CHOICE n); -extern "C" void input_choice_set_handle_hook(INPUT_CHOICE n, void * h); -extern "C" int fl_input_choice_handle(INPUT_CHOICE n, int e); +extern "C" void fl_input_choice_clear(INPUTCHOICE n); +extern "C" int fl_input_choice_changed(INPUTCHOICE n); +extern "C" void fl_input_choice_clear_changed(INPUTCHOICE n); +extern "C" void fl_input_choice_set_changed(INPUTCHOICE n); +extern "C" int fl_input_choice_get_down_box(INPUTCHOICE n); +extern "C" void fl_input_choice_set_down_box(INPUTCHOICE n, int t); +extern "C" unsigned int fl_input_choice_get_textcolor(INPUTCHOICE n); +extern "C" void fl_input_choice_set_textcolor(INPUTCHOICE n, unsigned int t); +extern "C" int fl_input_choice_get_textfont(INPUTCHOICE n); +extern "C" void fl_input_choice_set_textfont(INPUTCHOICE n, int t); +extern "C" int fl_input_choice_get_textsize(INPUTCHOICE n); +extern "C" void fl_input_choice_set_textsize(INPUTCHOICE n, int t); +extern "C" const char * fl_input_choice_get_value(INPUTCHOICE n); +extern "C" void fl_input_choice_set_value(INPUTCHOICE n, const char * t); +extern "C" void fl_input_choice_set_value2(INPUTCHOICE n, int t); -extern "C" INPUT_CHOICE new_fl_input_choice(int x, int y, int w, int h, char* label); -extern "C" void free_fl_input_choice(INPUT_CHOICE n); +extern "C" void fl_input_choice_resize(INPUTCHOICE n, int x, int y, int w, int h); - - -extern "C" void * fl_input_choice_input(INPUT_CHOICE n); -extern "C" void * fl_input_choice_menubutton(INPUT_CHOICE n); - - -extern "C" void fl_input_choice_clear(INPUT_CHOICE n); - - -extern "C" int fl_input_choice_changed(INPUT_CHOICE n); -extern "C" void fl_input_choice_clear_changed(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_changed(INPUT_CHOICE n); -extern "C" int fl_input_choice_get_down_box(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_down_box(INPUT_CHOICE n, int t); -extern "C" unsigned int fl_input_choice_get_textcolor(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_textcolor(INPUT_CHOICE n, unsigned int t); -extern "C" int fl_input_choice_get_textfont(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_textfont(INPUT_CHOICE n, int t); -extern "C" int fl_input_choice_get_textsize(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_textsize(INPUT_CHOICE n, int t); -extern "C" const char * fl_input_choice_get_value(INPUT_CHOICE n); -extern "C" void fl_input_choice_set_value(INPUT_CHOICE n, const char * t); -extern "C" void fl_input_choice_set_value2(INPUT_CHOICE n, int t); +extern "C" void fl_input_choice_draw(INPUTCHOICE n); +extern "C" int fl_input_choice_handle(INPUTCHOICE n, int e);  #endif + diff --git a/src/c_fl_label.cpp b/src/c_fl_label.cpp index 71b81ba..1fb5579 100644 --- a/src/c_fl_label.cpp +++ b/src/c_fl_label.cpp @@ -7,7 +7,6 @@  #include <FL/Fl_Widget.H>  #include <FL/Fl_Image.H>  #include "c_fl_label.h" -#include "c_fl_type.h" diff --git a/src/c_fl_label.h b/src/c_fl_label.h index ea69d51..806aa72 100644 --- a/src/c_fl_label.h +++ b/src/c_fl_label.h @@ -8,19 +8,13 @@  #define FL_LABEL_GUARD - -  typedef void* LABEL; - -  extern "C" LABEL new_fl_label(const char * v, int f, int s, unsigned int h, int k, unsigned int p);  extern "C" void free_fl_label(LABEL l); - -  extern "C" void fl_label_set_value(LABEL l, const char * v);  extern "C" int fl_label_get_font(LABEL l);  extern "C" void fl_label_set_font(LABEL l, int f); diff --git a/src/c_fl_light_button.cpp b/src/c_fl_light_button.cpp index ccced36..f8d52a8 100644 --- a/src/c_fl_light_button.cpp +++ b/src/c_fl_light_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Light_Button.H>  #include "c_fl_light_button.h" -#include "c_fl_type.h" -class My_Light_Button : public Fl_Light_Button { -    public: -        using Fl_Light_Button::Fl_Light_Button; -        friend void light_button_set_draw_hook(LIGHTBUTTON b, void * d); -        friend void fl_light_button_draw(LIGHTBUTTON b); -        friend void light_button_set_handle_hook(LIGHTBUTTON b, void * h); -        friend int fl_light_button_handle(LIGHTBUTTON b, 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_Light_Button::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_Light_Button::real_draw() { -    Fl_Light_Button::draw(); -} -int My_Light_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Light_Button::real_handle(int e) { -    return Fl_Light_Button::handle(e); -} -void light_button_set_draw_hook(LIGHTBUTTON b, void * d) { -    reinterpret_cast<My_Light_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_light_button_draw(LIGHTBUTTON b) { -    reinterpret_cast<My_Light_Button*>(b)->real_draw(); -} +class My_Light_Button : public Fl_Light_Button { +public: +    using Fl_Light_Button::Fl_Light_Button; + +    friend void fl_light_button_draw(LIGHTBUTTON b); +    friend int fl_light_button_handle(LIGHTBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void light_button_set_handle_hook(LIGHTBUTTON b, void * h) { -    reinterpret_cast<My_Light_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Light_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_light_button_handle(LIGHTBUTTON b, int e) { -    return reinterpret_cast<My_Light_Button*>(b)->real_handle(e); +int My_Light_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  LIGHTBUTTON new_fl_light_button(int x, int y, int w, int h, char* label) {      My_Light_Button *b = new My_Light_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_light_button(LIGHTBUTTON b) {      delete reinterpret_cast<My_Light_Button*>(b);  } + + + +void fl_light_button_draw(LIGHTBUTTON b) { +    reinterpret_cast<My_Light_Button*>(b)->Fl_Light_Button::draw(); +} + +int fl_light_button_handle(LIGHTBUTTON b, int e) { +    return reinterpret_cast<My_Light_Button*>(b)->Fl_Light_Button::handle(e); +} + + diff --git a/src/c_fl_light_button.h b/src/c_fl_light_button.h index 05aaab3..5d604d2 100644 --- a/src/c_fl_light_button.h +++ b/src/c_fl_light_button.h @@ -8,24 +8,17 @@  #define FL_LIGHT_BUTTON_GUARD - -  typedef void* LIGHTBUTTON; +extern "C" LIGHTBUTTON new_fl_light_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_light_button(LIGHTBUTTON b); -extern "C" void light_button_set_draw_hook(LIGHTBUTTON b, void * d);  extern "C" void fl_light_button_draw(LIGHTBUTTON b); -extern "C" void light_button_set_handle_hook(LIGHTBUTTON b, void * h);  extern "C" int fl_light_button_handle(LIGHTBUTTON b, int e); - - -extern "C" LIGHTBUTTON new_fl_light_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_light_button(LIGHTBUTTON b); - -  #endif + diff --git a/src/c_fl_line_dial.cpp b/src/c_fl_line_dial.cpp index 040fa61..cb0727f 100644 --- a/src/c_fl_line_dial.cpp +++ b/src/c_fl_line_dial.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Line_Dial.H>  #include "c_fl_line_dial.h" -#include "c_fl_type.h" -class My_Line_Dial : public Fl_Line_Dial { -    public: -        using Fl_Line_Dial::Fl_Line_Dial; -        friend void line_dial_set_draw_hook(LINE_DIAL v, void * d); -        friend void fl_line_dial_draw(LINE_DIAL v); -        friend void line_dial_set_handle_hook(LINE_DIAL v, void * h); -        friend int fl_line_dial_handle(LINE_DIAL v, 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_Line_Dial::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_Line_Dial::real_draw() { -    Fl_Line_Dial::draw(); -} -int My_Line_Dial::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Line_Dial::real_handle(int e) { -    return Fl_Line_Dial::handle(e); -} -void line_dial_set_draw_hook(LINE_DIAL v, void * d) { -    reinterpret_cast<My_Line_Dial*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_line_dial_draw(LINE_DIAL v) { -    reinterpret_cast<My_Line_Dial*>(v)->real_draw(); -} +class My_Line_Dial : public Fl_Line_Dial { +public: +    using Fl_Line_Dial::Fl_Line_Dial; + +    friend void fl_line_dial_draw(LINE_DIAL v); +    friend int fl_line_dial_handle(LINE_DIAL v, int e); + +    void draw(); +    int handle(int e); +}; -void line_dial_set_handle_hook(LINE_DIAL v, void * h) { -    reinterpret_cast<My_Line_Dial*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Line_Dial::draw() { +    widget_draw_hook(this->user_data());  } -int fl_line_dial_handle(LINE_DIAL v, int e) { -    return reinterpret_cast<My_Line_Dial*>(v)->real_handle(e); +int My_Line_Dial::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  LINE_DIAL new_fl_line_dial(int x, int y, int w, int h, char* label) {      My_Line_Dial *v = new My_Line_Dial(x, y, w, h, label);      return v; @@ -72,3 +54,14 @@ void free_fl_line_dial(LINE_DIAL v) {  } + + +void fl_line_dial_draw(LINE_DIAL v) { +    reinterpret_cast<My_Line_Dial*>(v)->Fl_Line_Dial::draw(); +} + +int fl_line_dial_handle(LINE_DIAL v, int e) { +    return reinterpret_cast<My_Line_Dial*>(v)->Fl_Line_Dial::handle(e); +} + + diff --git a/src/c_fl_line_dial.h b/src/c_fl_line_dial.h index f28a419..73ffb89 100644 --- a/src/c_fl_line_dial.h +++ b/src/c_fl_line_dial.h @@ -8,24 +8,17 @@  #define FL_LINE_DIAL_GUARD - -  typedef void* LINE_DIAL; +extern "C" LINE_DIAL new_fl_line_dial(int x, int y, int w, int h, char* label); +extern "C" void free_fl_line_dial(LINE_DIAL v); -extern "C" void line_dial_set_draw_hook(LINE_DIAL v, void * d);  extern "C" void fl_line_dial_draw(LINE_DIAL v); -extern "C" void line_dial_set_handle_hook(LINE_DIAL v, void * h);  extern "C" int fl_line_dial_handle(LINE_DIAL v, int e); - - -extern "C" LINE_DIAL new_fl_line_dial(int x, int y, int w, int h, char* label); -extern "C" void free_fl_line_dial(LINE_DIAL v); - -  #endif + diff --git a/src/c_fl_menu.cpp b/src/c_fl_menu.cpp index 0b55e5d..8aa82f2 100644 --- a/src/c_fl_menu.cpp +++ b/src/c_fl_menu.cpp @@ -7,41 +7,43 @@  #include <FL/Fl_Menu_.H>  #include <FL/Fl_Menu_Item.H>  #include "c_fl_menu.h" -#include "c_fl_type.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_Menu : public Fl_Menu_ { -    public: -        using Fl_Menu_::Fl_Menu_; -        friend void menu_set_draw_hook(MENU m, void * d); -        friend void menu_set_handle_hook(MENU m, void * h); -    protected: -        void draw(); -        int handle(int e); -        d_hook_p draw_hook; -        h_hook_p handle_hook; +public: +    using Fl_Menu_::Fl_Menu_; + +    friend void fl_menu_draw(MENU m); +    friend int fl_menu_handle(MENU m, int e); + +    void draw(); +    int handle(int e);  };  void My_Menu::draw() { -    (*draw_hook)(this->user_data()); +    widget_draw_hook(this->user_data());  }  int My_Menu::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -void menu_set_draw_hook(MENU m, void * d) { -    reinterpret_cast<My_Menu*>(m)->draw_hook = reinterpret_cast<d_hook_p>(d); -} - -void menu_set_handle_hook(MENU m, void * h) { -    reinterpret_cast<My_Menu*>(m)->handle_hook = reinterpret_cast<h_hook_p>(h); -} +//  Flattened C API  MENU new_fl_menu(int x, int y, int w, int h, char* label) {      My_Menu *m = new My_Menu(x, y, w, h, label); @@ -59,7 +61,9 @@ int fl_menu_add(MENU m, const char * t, unsigned long s, void * c, void * u, uns      return reinterpret_cast<Fl_Menu_*>(m)->add(t,s,reinterpret_cast<Fl_Callback_p>(c),u,f);  } -int fl_menu_insert(MENU m, int p, const char * t, unsigned long s, void * c, void * u, unsigned long f) { +int fl_menu_insert(MENU m, int p, const char * t, unsigned long s, +    void * c, void * u, unsigned long f) +{      return reinterpret_cast<Fl_Menu_*>(m)->insert(p,t,s,reinterpret_cast<Fl_Callback_p>(c),u,f);  } @@ -221,4 +225,16 @@ void fl_menu_draw_item(MENU m, int i, int x, int y, int w, int h, int s) {      item->draw(x,y,w,h,reinterpret_cast<Fl_Menu_*>(m),s);  } +void fl_menu_draw(MENU m) { +    //  The Fl_Menu_ draw method doesn't technically exist, so... +    (void)(m); +    //  It is more convenient for this function to exist, however, +    //  even though it will likely never be called, because it simplifies +    //  and makes uniform the implementation of the Ada Menu Draw subprogram. +} + +int fl_menu_handle(MENU m, int e) { +    return reinterpret_cast<My_Menu*>(m)->Fl_Menu_::handle(e); +} + diff --git a/src/c_fl_menu.h b/src/c_fl_menu.h index 68463ee..b4265aa 100644 --- a/src/c_fl_menu.h +++ b/src/c_fl_menu.h @@ -8,27 +8,17 @@  #define FL_MENU_GUARD - -  typedef void* MENU; - - -extern "C" void menu_set_draw_hook(MENU m, void * d); -extern "C" void menu_set_handle_hook(MENU m, void * h); - - - -  extern "C" MENU new_fl_menu(int x, int y, int w, int h, char* label);  extern "C" void free_fl_menu(MENU m); - - -extern "C" int fl_menu_add(MENU m, const char * t, unsigned long s, void * c, void * u, unsigned long f); -extern "C" int fl_menu_insert(MENU m, int p, const char * t, unsigned long s, void * c, void * u, unsigned long f); +extern "C" int fl_menu_add(MENU m, const char * t, unsigned long s, +    void * c, void * u, unsigned long f); +extern "C" int fl_menu_insert(MENU m, int p, const char * t, unsigned long s, +    void * c, void * u, unsigned long f);  extern "C" void fl_menu_remove(MENU m, int p);  extern "C" void fl_menu_clear(MENU m); @@ -68,7 +58,10 @@ extern "C" const void * fl_menu_pulldown(MENU m, int x, int y, int w, int h, int  extern "C" void fl_menu_draw_item(MENU m, int i, int x, int y, int w, int h, int s); +extern "C" void fl_menu_draw(MENU m); +extern "C" int fl_menu_handle(MENU m, int e);  #endif + diff --git a/src/c_fl_menu_bar.cpp b/src/c_fl_menu_bar.cpp index ca6797b..1da51e9 100644 --- a/src/c_fl_menu_bar.cpp +++ b/src/c_fl_menu_bar.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Menu_Bar.H>  #include "c_fl_menu_bar.h" -#include "c_fl_type.h" -class My_Menu_Bar : public Fl_Menu_Bar { -    public: -        using Fl_Menu_Bar::Fl_Menu_Bar; -        friend void menu_bar_set_draw_hook(MENUBAR m, void * d); -        friend void fl_menu_bar_draw(MENUBAR m); -        friend void menu_bar_set_handle_hook(MENUBAR m, void * h); -        friend int fl_menu_bar_handle(MENUBAR m, 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_Menu_Bar::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_Menu_Bar::real_draw() { -    Fl_Menu_Bar::draw(); -} -int My_Menu_Bar::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Menu_Bar::real_handle(int e) { -    return Fl_Menu_Bar::handle(e); -} -void menu_bar_set_draw_hook(MENUBAR m, void * d) { -    reinterpret_cast<My_Menu_Bar*>(m)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_menu_bar_draw(MENUBAR m) { -    reinterpret_cast<My_Menu_Bar*>(m)->real_draw(); -} +class My_Menu_Bar : public Fl_Menu_Bar { +public: +    using Fl_Menu_Bar::Fl_Menu_Bar; + +    friend void fl_menu_bar_draw(MENUBAR m); +    friend int fl_menu_bar_handle(MENUBAR m, int e); + +    void draw(); +    int handle(int e); +}; -void menu_bar_set_handle_hook(MENUBAR m, void * h) { -    reinterpret_cast<My_Menu_Bar*>(m)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Menu_Bar::draw() { +    widget_draw_hook(this->user_data());  } -int fl_menu_bar_handle(MENUBAR m, int e) { -    return reinterpret_cast<My_Menu_Bar*>(m)->real_handle(e); +int My_Menu_Bar::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  MENUBAR new_fl_menu_bar(int x, int y, int w, int h, char* label) {      My_Menu_Bar *m = new My_Menu_Bar(x, y, w, h, label);      return m; @@ -71,3 +53,15 @@ void free_fl_menu_bar(MENUBAR m) {      delete reinterpret_cast<My_Menu_Bar*>(m);  } + + + +void fl_menu_bar_draw(MENUBAR m) { +    reinterpret_cast<My_Menu_Bar*>(m)->Fl_Menu_Bar::draw(); +} + +int fl_menu_bar_handle(MENUBAR m, int e) { +    return reinterpret_cast<My_Menu_Bar*>(m)->Fl_Menu_Bar::handle(e); +} + + diff --git a/src/c_fl_menu_bar.h b/src/c_fl_menu_bar.h index 56f7814..ae99467 100644 --- a/src/c_fl_menu_bar.h +++ b/src/c_fl_menu_bar.h @@ -8,24 +8,17 @@  #define FL_MENU_BAR_GUARD - -  typedef void* MENUBAR; +extern "C" MENUBAR new_fl_menu_bar(int x, int y, int w, int h, char* label); +extern "C" void free_fl_menu_bar(MENUBAR m); -extern "C" void menu_bar_set_draw_hook(MENUBAR m, void * d);  extern "C" void fl_menu_bar_draw(MENUBAR m); -extern "C" void menu_bar_set_handle_hook(MENUBAR m, void * h);  extern "C" int fl_menu_bar_handle(MENUBAR m, int e); - - -extern "C" MENUBAR new_fl_menu_bar(int x, int y, int w, int h, char* label); -extern "C" void free_fl_menu_bar(MENUBAR m); - -  #endif + diff --git a/src/c_fl_menu_button.cpp b/src/c_fl_menu_button.cpp index fd78df4..4a32ca6 100644 --- a/src/c_fl_menu_button.cpp +++ b/src/c_fl_menu_button.cpp @@ -6,7 +6,6 @@  #include <FL/Fl_Menu_Button.H>  #include "c_fl_menu_button.h" -#include "c_fl_type.h" @@ -27,57 +26,40 @@ void fl_menu_button_extra_final(void * adaobj) { -class My_Menu_Button : public Fl_Menu_Button { -    public: -        using Fl_Menu_Button::Fl_Menu_Button; -        friend void menu_button_set_draw_hook(MENUBUTTON m, void * d); -        friend void fl_menu_button_draw(MENUBUTTON m); -        friend void menu_button_set_handle_hook(MENUBUTTON m, void * h); -        friend int fl_menu_button_handle(MENUBUTTON m, 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_Menu_Button::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_Menu_Button::real_draw() { -    Fl_Menu_Button::draw(); -} -int My_Menu_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Menu_Button::real_handle(int e) { -    return Fl_Menu_Button::handle(e); -} -void menu_button_set_draw_hook(MENUBUTTON m, void * d) { -    reinterpret_cast<My_Menu_Button*>(m)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_menu_button_draw(MENUBUTTON m) { -    reinterpret_cast<My_Menu_Button*>(m)->real_draw(); -} +class My_Menu_Button : public Fl_Menu_Button { +public: +    using Fl_Menu_Button::Fl_Menu_Button; + +    friend void fl_menu_button_draw(MENUBUTTON m); +    friend int fl_menu_button_handle(MENUBUTTON m, int e); + +    void draw(); +    int handle(int e); +}; -void menu_button_set_handle_hook(MENUBUTTON m, void * h) { -    reinterpret_cast<My_Menu_Button*>(m)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Menu_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_menu_button_handle(MENUBUTTON m, int e) { -    return reinterpret_cast<My_Menu_Button*>(m)->real_handle(e); +int My_Menu_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label) {      My_Menu_Button *m = new My_Menu_Button(x, y, w, h, label);      return m; @@ -99,3 +81,14 @@ const void * fl_menu_button_popup(MENUBUTTON m) {  } + + +void fl_menu_button_draw(MENUBUTTON m) { +    reinterpret_cast<My_Menu_Button*>(m)->Fl_Menu_Button::draw(); +} + +int fl_menu_button_handle(MENUBUTTON m, int e) { +    return reinterpret_cast<My_Menu_Button*>(m)->Fl_Menu_Button::handle(e); +} + + diff --git a/src/c_fl_menu_button.h b/src/c_fl_menu_button.h index 513f6b0..e0e2b00 100644 --- a/src/c_fl_menu_button.h +++ b/src/c_fl_menu_button.h @@ -16,12 +16,6 @@ extern "C" void fl_menu_button_extra_final(void * adaobj);  typedef void* MENUBUTTON; -extern "C" void menu_button_set_draw_hook(MENUBUTTON m, void * d); -extern "C" void fl_menu_button_draw(MENUBUTTON m); -extern "C" void menu_button_set_handle_hook(MENUBUTTON m, void * h); -extern "C" int fl_menu_button_handle(MENUBUTTON m, int e); - -  extern "C" MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label);  extern "C" void free_fl_menu_button(MENUBUTTON m); @@ -30,6 +24,10 @@ extern "C" void fl_menu_button_type(MENUBUTTON m, unsigned int t);  extern "C" const void * fl_menu_button_popup(MENUBUTTON m); +extern "C" void fl_menu_button_draw(MENUBUTTON m); +extern "C" int fl_menu_button_handle(MENUBUTTON m, int e); + +  #endif diff --git a/src/c_fl_menu_window.cpp b/src/c_fl_menu_window.cpp index 86e927a..db03028 100644 --- a/src/c_fl_menu_window.cpp +++ b/src/c_fl_menu_window.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Menu_Window.H>  #include "c_fl_menu_window.h" -#include "c_fl_type.h" -class My_Menu_Window : public Fl_Menu_Window { -    public: -        using Fl_Menu_Window::Fl_Menu_Window; -        friend void menu_window_set_draw_hook(MENUWINDOW n, void * d); -        friend void fl_menu_window_draw(MENUWINDOW n); -        friend void menu_window_set_handle_hook(MENUWINDOW n, void * h); -        friend int fl_menu_window_handle(MENUWINDOW 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; -}; +//  Exports from Ada -void My_Menu_Window::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_Menu_Window::real_draw() { -    Fl_Menu_Window::draw(); -} -int My_Menu_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Menu_Window::real_handle(int e) { -    return Fl_Menu_Window::handle(e); -} -void menu_window_set_draw_hook(MENUWINDOW n, void * d) { -    reinterpret_cast<My_Menu_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_menu_window_draw(MENUWINDOW n) { -    reinterpret_cast<My_Menu_Window*>(n)->real_draw(); -} +class My_Menu_Window : public Fl_Menu_Window { +public: +    using Fl_Menu_Window::Fl_Menu_Window; + +    friend void fl_menu_window_draw(MENUWINDOW n); +    friend int fl_menu_window_handle(MENUWINDOW n, int e); + +    void draw(); +    int handle(int e); +}; -void menu_window_set_handle_hook(MENUWINDOW n, void * h) { -    reinterpret_cast<My_Menu_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Menu_Window::draw() { +    widget_draw_hook(this->user_data());  } -int fl_menu_window_handle(MENUWINDOW n, int e) { -    return reinterpret_cast<My_Menu_Window*>(n)->real_handle(e); +int My_Menu_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  MENUWINDOW new_fl_menu_window(int x, int y, int w, int h, char* label) {      My_Menu_Window *m = new My_Menu_Window(x, y, w, h, label);      return m; @@ -106,3 +88,15 @@ unsigned int fl_menu_window_overlay(MENUWINDOW m) {      return reinterpret_cast<Fl_Menu_Window*>(m)->overlay();  } + + + +void fl_menu_window_draw(MENUWINDOW n) { +    reinterpret_cast<My_Menu_Window*>(n)->Fl_Menu_Window::draw(); +} + +int fl_menu_window_handle(MENUWINDOW n, int e) { +    return reinterpret_cast<My_Menu_Window*>(n)->Fl_Menu_Window::handle(e); +} + + diff --git a/src/c_fl_menu_window.h b/src/c_fl_menu_window.h index d54296b..db8f26f 100644 --- a/src/c_fl_menu_window.h +++ b/src/c_fl_menu_window.h @@ -8,28 +8,14 @@  #define FL_MENU_WINDOW_GUARD - -  typedef void* MENUWINDOW; - - -extern "C" void menu_window_set_draw_hook(MENUWINDOW n, void * d); -extern "C" void fl_menu_window_draw(MENUWINDOW n); -extern "C" void menu_window_set_handle_hook(MENUWINDOW n, void * h); -extern "C" int fl_menu_window_handle(MENUWINDOW n, int e); - - - -  extern "C" MENUWINDOW new_fl_menu_window(int x, int y, int w, int h, char* label);  extern "C" MENUWINDOW new_fl_menu_window2(int w, int h, char* label);  extern "C" void free_fl_menu_window(MENUWINDOW m); - -  extern "C" void fl_menu_window_show(MENUWINDOW m);  extern "C" void fl_menu_window_hide(MENUWINDOW m);  extern "C" void fl_menu_window_flush(MENUWINDOW m); @@ -40,5 +26,10 @@ extern "C" void fl_menu_window_clear_overlay(MENUWINDOW m);  extern "C" unsigned int fl_menu_window_overlay(MENUWINDOW m); +extern "C" void fl_menu_window_draw(MENUWINDOW n); +extern "C" int fl_menu_window_handle(MENUWINDOW n, int e); + +  #endif + diff --git a/src/c_fl_nice_slider.cpp b/src/c_fl_nice_slider.cpp index 819bd45..e4263dd 100644 --- a/src/c_fl_nice_slider.cpp +++ b/src/c_fl_nice_slider.cpp @@ -6,69 +6,62 @@  #include <FL/Fl_Nice_Slider.H>  #include "c_fl_nice_slider.h" -#include "c_fl_type.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_Nice_Slider : public Fl_Nice_Slider { -    public: -        using Fl_Nice_Slider::Fl_Nice_Slider; -        friend void nice_slider_set_draw_hook(NICE_SLIDER s, void * d); -        friend void fl_nice_slider_draw(NICE_SLIDER s); -        friend void nice_slider_set_handle_hook(NICE_SLIDER s, void * h); -        friend int fl_nice_slider_handle(NICE_SLIDER 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; +public: +    using Fl_Nice_Slider::Fl_Nice_Slider; + +    friend void fl_nice_slider_draw(NICESLIDER s); +    friend int fl_nice_slider_handle(NICESLIDER s, int e); + +    void draw(); +    int handle(int e);  };  void My_Nice_Slider::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Nice_Slider::real_draw() { -    Fl_Nice_Slider::draw(); +    widget_draw_hook(this->user_data());  }  int My_Nice_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Nice_Slider::real_handle(int e) { -    return Fl_Nice_Slider::handle(e); -} -void nice_slider_set_draw_hook(NICE_SLIDER s, void * d) { -    reinterpret_cast<My_Nice_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_nice_slider_draw(NICE_SLIDER s) { -    reinterpret_cast<My_Nice_Slider*>(s)->real_draw(); -} -void nice_slider_set_handle_hook(NICE_SLIDER s, void * h) { -    reinterpret_cast<My_Nice_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +//  Flattened C API + +NICESLIDER new_fl_nice_slider(int x, int y, int w, int h, char* label) { +    My_Nice_Slider *s = new My_Nice_Slider(x, y, w, h, label); +    return s;  } -int fl_nice_slider_handle(NICE_SLIDER s, int e) { -    return reinterpret_cast<My_Nice_Slider*>(s)->real_handle(e); +void free_fl_nice_slider(NICESLIDER s) { +    delete reinterpret_cast<My_Nice_Slider*>(s);  } -NICE_SLIDER new_fl_nice_slider(int x, int y, int w, int h, char* label) { -    My_Nice_Slider *s = new My_Nice_Slider(x, y, w, h, label); -    return s; +void fl_nice_slider_draw(NICESLIDER s) { +    reinterpret_cast<My_Nice_Slider*>(s)->Fl_Nice_Slider::draw();  } -void free_fl_nice_slider(NICE_SLIDER s) { -    delete reinterpret_cast<My_Nice_Slider*>(s); +int fl_nice_slider_handle(NICESLIDER s, int e) { +    return reinterpret_cast<My_Nice_Slider*>(s)->Fl_Nice_Slider::handle(e);  } diff --git a/src/c_fl_nice_slider.h b/src/c_fl_nice_slider.h index 79916e6..2da3207 100644 --- a/src/c_fl_nice_slider.h +++ b/src/c_fl_nice_slider.h @@ -8,24 +8,17 @@  #define FL_NICE_SLIDER_GUARD +typedef void* NICESLIDER; -typedef void* NICE_SLIDER; +extern "C" NICESLIDER new_fl_nice_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_nice_slider(NICESLIDER s); - - -extern "C" void nice_slider_set_draw_hook(NICE_SLIDER s, void * d); -extern "C" void fl_nice_slider_draw(NICE_SLIDER s); -extern "C" void nice_slider_set_handle_hook(NICE_SLIDER s, void * h); -extern "C" int fl_nice_slider_handle(NICE_SLIDER s, int e); - - - - -extern "C" NICE_SLIDER new_fl_nice_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_nice_slider(NICE_SLIDER s); +extern "C" void fl_nice_slider_draw(NICESLIDER s); +extern "C" int fl_nice_slider_handle(NICESLIDER s, int e);  #endif + diff --git a/src/c_fl_overlay_window.cpp b/src/c_fl_overlay_window.cpp index be924dc..3ce76a4 100644 --- a/src/c_fl_overlay_window.cpp +++ b/src/c_fl_overlay_window.cpp @@ -6,75 +6,54 @@  #include <FL/Fl_Overlay_Window.H>  #include "c_fl_overlay_window.h" -#include "c_fl_type.h" -class My_Overlay_Window : public Fl_Overlay_Window { -    public: -        using Fl_Overlay_Window::Fl_Overlay_Window; -        friend void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d); -        friend void fl_overlay_window_draw(OVERLAYWINDOW w); -        friend void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d); -        friend void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h); -        friend int fl_overlay_window_handle(OVERLAYWINDOW w, int e); -        friend OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label); -        friend OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label); -    protected: -        void draw(); -        void real_draw(); -        void draw_overlay(); -        int handle(int e); -        int real_handle(int e); -        d_hook_p draw_hook; -        d_hook_p draw_overlay_hook; -        h_hook_p handle_hook; -}; +//  Exports from Ada -void My_Overlay_Window::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_Overlay_Window::real_draw() { -    Fl_Overlay_Window::draw(); -} +extern "C" void overlay_window_draw_overlay_hook(void * ud); -void My_Overlay_Window::draw_overlay() { -    (*draw_overlay_hook)(this->user_data()); -} -int My_Overlay_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Overlay_Window::real_handle(int e) { -    return Fl_Overlay_Window::handle(e); -} -void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d) { -    reinterpret_cast<My_Overlay_Window*>(w)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_overlay_window_draw(OVERLAYWINDOW w) { -    reinterpret_cast<My_Overlay_Window*>(w)->real_draw(); -} +class My_Overlay_Window : public Fl_Overlay_Window { +public: +    using Fl_Overlay_Window::Fl_Overlay_Window; + +    friend OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label); +    friend OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label); + +    friend void fl_overlay_window_draw(OVERLAYWINDOW w); +    friend int fl_overlay_window_handle(OVERLAYWINDOW w, int e); -void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d) { -    reinterpret_cast<My_Overlay_Window*>(w)->draw_overlay_hook = reinterpret_cast<d_hook_p>(d); +    void draw(); +    void draw_overlay(); +    int handle(int e); +}; + +void My_Overlay_Window::draw() { +    widget_draw_hook(this->user_data());  } -void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h) { -    reinterpret_cast<My_Overlay_Window*>(w)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Overlay_Window::draw_overlay() { +    overlay_window_draw_overlay_hook(this->user_data());  } -int fl_overlay_window_handle(OVERLAYWINDOW w, int e) { -    return reinterpret_cast<My_Overlay_Window*>(w)->real_handle(e); +int My_Overlay_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label) {      My_Overlay_Window *ow = new My_Overlay_Window(x, y, w, h, label);      return ow; @@ -96,6 +75,10 @@ int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w) {      return reinterpret_cast<Fl_Overlay_Window*>(w)->can_do_overlay();  } +void fl_overlay_window_resize(OVERLAYWINDOW ow, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Overlay_Window*>(ow)->resize(x, y, w, h); +} + @@ -118,4 +101,12 @@ void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w) {      reinterpret_cast<Fl_Overlay_Window*>(w)->redraw_overlay();  } +void fl_overlay_window_draw(OVERLAYWINDOW w) { +    reinterpret_cast<My_Overlay_Window*>(w)->Fl_Overlay_Window::draw(); +} + +int fl_overlay_window_handle(OVERLAYWINDOW w, int e) { +    return reinterpret_cast<My_Overlay_Window*>(w)->Fl_Overlay_Window::handle(e); +} + diff --git a/src/c_fl_overlay_window.h b/src/c_fl_overlay_window.h index 132487a..781f074 100644 --- a/src/c_fl_overlay_window.h +++ b/src/c_fl_overlay_window.h @@ -8,30 +8,16 @@  #define FL_OVERLAY_WINDOW_GUARD - -  typedef void* OVERLAYWINDOW; - - -extern "C" void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d); -extern "C" void fl_overlay_window_draw(OVERLAYWINDOW w); -extern "C" void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d); -extern "C" void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h); -extern "C" int fl_overlay_window_handle(OVERLAYWINDOW w, int e); - - - -  extern "C" OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label);  extern "C" OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label);  extern "C" void free_fl_overlay_window(OVERLAYWINDOW w); - -  extern "C" int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w); +extern "C" void fl_overlay_window_resize(OVERLAYWINDOW ow, int x, int y, int w, int h);  extern "C" void fl_overlay_window_show(OVERLAYWINDOW w); @@ -40,7 +26,10 @@ extern "C" void fl_overlay_window_flush(OVERLAYWINDOW w);  extern "C" void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w); +extern "C" void fl_overlay_window_draw(OVERLAYWINDOW w); +extern "C" int fl_overlay_window_handle(OVERLAYWINDOW w, int e);  #endif + diff --git a/src/c_fl_pack.cpp b/src/c_fl_pack.cpp index e0a6e9d..2e83b3f 100644 --- a/src/c_fl_pack.cpp +++ b/src/c_fl_pack.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Pack.H>  #include "c_fl_pack.h" -#include "c_fl_type.h" -class My_Pack : public Fl_Pack { -    public: -        using Fl_Pack::Fl_Pack; -        friend void pack_set_draw_hook(PACK n, void * d); -        friend void fl_pack_draw(PACK n); -        friend void pack_set_handle_hook(PACK n, void * h); -        friend int fl_pack_handle(PACK 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; -}; +//  Exports from Ada -void My_Pack::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_Pack::real_draw() { -    Fl_Pack::draw(); -} -int My_Pack::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Pack::real_handle(int e) { -    return Fl_Pack::handle(e); -} -void pack_set_draw_hook(PACK n, void * d) { -    reinterpret_cast<My_Pack*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_pack_draw(PACK n) { -    reinterpret_cast<My_Pack*>(n)->real_draw(); -} +class My_Pack : public Fl_Pack { +public: +    using Fl_Pack::Fl_Pack; + +    friend void fl_pack_draw(PACK n); +    friend int fl_pack_handle(PACK n, int e); + +    void draw(); +    int handle(int e); +}; -void pack_set_handle_hook(PACK n, void * h) { -    reinterpret_cast<My_Pack*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Pack::draw() { +    widget_draw_hook(this->user_data());  } -int fl_pack_handle(PACK n, int e) { -    return reinterpret_cast<My_Pack*>(n)->real_handle(e); +int My_Pack::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  PACK new_fl_pack(int x, int y, int w, int h, char* label) {      My_Pack *b = new My_Pack(x, y, w, h, label);      return b; @@ -83,3 +65,14 @@ void fl_pack_set_spacing(PACK p, int t) {  } + + +void fl_pack_draw(PACK n) { +    reinterpret_cast<My_Pack*>(n)->Fl_Pack::draw(); +} + +int fl_pack_handle(PACK n, int e) { +    return reinterpret_cast<My_Pack*>(n)->Fl_Pack::handle(e); +} + + diff --git a/src/c_fl_pack.h b/src/c_fl_pack.h index b424415..a8bfe75 100644 --- a/src/c_fl_pack.h +++ b/src/c_fl_pack.h @@ -8,30 +8,21 @@  #define FL_PACK_GUARD - -  typedef void* PACK; - - -extern "C" void pack_set_draw_hook(PACK n, void * d); -extern "C" void fl_pack_draw(PACK n); -extern "C" void pack_set_handle_hook(PACK n, void * h); -extern "C" int fl_pack_handle(PACK n, int e); - - - -  extern "C" PACK new_fl_pack(int x, int y, int w, int h, char * label);  extern "C" void free_fl_pack(PACK p); - -  extern "C" int fl_pack_get_spacing(PACK p);  extern "C" void fl_pack_set_spacing(PACK p, int t); +extern "C" void fl_pack_draw(PACK n); +extern "C" int fl_pack_handle(PACK n, int e); + +  #endif + diff --git a/src/c_fl_progress.cpp b/src/c_fl_progress.cpp index 2e49643..9c18300 100644 --- a/src/c_fl_progress.cpp +++ b/src/c_fl_progress.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Progress.H>  #include "c_fl_progress.h" -#include "c_fl_type.h" -class My_Progress : public Fl_Progress { -    public: -        using Fl_Progress::Fl_Progress; -        friend void progress_set_draw_hook(PROGRESS p, void * d); -        friend void fl_progress_draw(PROGRESS p); -        friend void progress_set_handle_hook(PROGRESS p, void * h); -        friend int fl_progress_handle(PROGRESS p, 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_Progress::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_Progress::real_draw() { -    Fl_Progress::draw(); -} -int My_Progress::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Progress::real_handle(int e) { -    return Fl_Progress::handle(e); -} -void progress_set_draw_hook(PROGRESS p, void * d) { -    reinterpret_cast<My_Progress*>(p)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_progress_draw(PROGRESS p) { -    reinterpret_cast<My_Progress*>(p)->real_draw(); -} +class My_Progress : public Fl_Progress { +public: +    using Fl_Progress::Fl_Progress; + +    friend void fl_progress_draw(PROGRESS p); +    friend int fl_progress_handle(PROGRESS p, int e); + +    void draw(); +    int handle(int e); +}; -void progress_set_handle_hook(PROGRESS p, void * h) { -    reinterpret_cast<My_Progress*>(p)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Progress::draw() { +    widget_draw_hook(this->user_data());  } -int fl_progress_handle(PROGRESS p, int e) { -    return reinterpret_cast<My_Progress*>(p)->real_handle(e); +int My_Progress::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  PROGRESS new_fl_progress(int x, int y, int w, int h, char* label) {      My_Progress *p = new My_Progress(x, y, w, h, label);      return p; @@ -98,3 +80,15 @@ void fl_progress_set_value(PROGRESS p, float t) {      reinterpret_cast<Fl_Progress*>(p)->value(t);  } + + + +void fl_progress_draw(PROGRESS p) { +    reinterpret_cast<My_Progress*>(p)->Fl_Progress::draw(); +} + +int fl_progress_handle(PROGRESS p, int e) { +    return reinterpret_cast<My_Progress*>(p)->Fl_Progress::handle(e); +} + + diff --git a/src/c_fl_progress.h b/src/c_fl_progress.h index d701806..d75e136 100644 --- a/src/c_fl_progress.h +++ b/src/c_fl_progress.h @@ -8,27 +8,13 @@  #define FL_PROGRESS_GUARD - -  typedef void* PROGRESS; - - -extern "C" void progress_set_draw_hook(PROGRESS p, void * d); -extern "C" void fl_progress_draw(PROGRESS p); -extern "C" void progress_set_handle_hook(PROGRESS p, void * h); -extern "C" int fl_progress_handle(PROGRESS p, int e); - - - -  extern "C" PROGRESS new_fl_progress(int x, int y, int w, int h, char* label);  extern "C" void free_fl_progress(PROGRESS p); - -  extern "C" float fl_progress_get_minimum(PROGRESS p);  extern "C" void fl_progress_set_minimum(PROGRESS p, float t);  extern "C" float fl_progress_get_maximum(PROGRESS p); @@ -37,5 +23,10 @@ extern "C" float fl_progress_get_value(PROGRESS p);  extern "C" void fl_progress_set_value(PROGRESS p, float t); +extern "C" void fl_progress_draw(PROGRESS p); +extern "C" int fl_progress_handle(PROGRESS p, int e); + +  #endif + diff --git a/src/c_fl_radio_button.cpp b/src/c_fl_radio_button.cpp index d30173e..1813f0d 100644 --- a/src/c_fl_radio_button.cpp +++ b/src/c_fl_radio_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Radio_Button.H>  #include "c_fl_radio_button.h" -#include "c_fl_type.h" -class My_Radio_Button : public Fl_Radio_Button { -    public: -        using Fl_Radio_Button::Fl_Radio_Button; -        friend void radio_button_set_draw_hook(RADIOBUTTON b, void * d); -        friend void fl_radio_button_draw(RADIOBUTTON b); -        friend void radio_button_set_handle_hook(RADIOBUTTON b, void * h); -        friend int fl_radio_button_handle(RADIOBUTTON b, 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_Radio_Button::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_Radio_Button::real_draw() { -    Fl_Radio_Button::draw(); -} -int My_Radio_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Radio_Button::real_handle(int e) { -    return Fl_Radio_Button::handle(e); -} -void radio_button_set_draw_hook(RADIOBUTTON b, void * d) { -    reinterpret_cast<My_Radio_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_radio_button_draw(RADIOBUTTON b) { -    reinterpret_cast<My_Radio_Button*>(b)->real_draw(); -} +class My_Radio_Button : public Fl_Radio_Button { +public: +    using Fl_Radio_Button::Fl_Radio_Button; + +    friend void fl_radio_button_draw(RADIOBUTTON b); +    friend int fl_radio_button_handle(RADIOBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void radio_button_set_handle_hook(RADIOBUTTON b, void * h) { -    reinterpret_cast<My_Radio_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Radio_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_radio_button_handle(RADIOBUTTON b, int e) { -    return reinterpret_cast<My_Radio_Button*>(b)->real_handle(e); +int My_Radio_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  RADIOBUTTON new_fl_radio_button(int x, int y, int w, int h, char* label) {      My_Radio_Button *b = new My_Radio_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_radio_button(RADIOBUTTON b) {      delete reinterpret_cast<My_Radio_Button*>(b);  } + + + +void fl_radio_button_draw(RADIOBUTTON b) { +    reinterpret_cast<My_Radio_Button*>(b)->Fl_Radio_Button::draw(); +} + +int fl_radio_button_handle(RADIOBUTTON b, int e) { +    return reinterpret_cast<My_Radio_Button*>(b)->Fl_Radio_Button::handle(e); +} + + diff --git a/src/c_fl_radio_button.h b/src/c_fl_radio_button.h index e01e8e2..53bdd57 100644 --- a/src/c_fl_radio_button.h +++ b/src/c_fl_radio_button.h @@ -8,24 +8,17 @@  #define FL_RADIO_BUTTON_GUARD - -  typedef void* RADIOBUTTON; +extern "C" RADIOBUTTON new_fl_radio_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_radio_button(RADIOBUTTON b); -extern "C" void radio_button_set_draw_hook(RADIOBUTTON b, void * d);  extern "C" void fl_radio_button_draw(RADIOBUTTON b); -extern "C" void radio_button_set_handle_hook(RADIOBUTTON b, void * h);  extern "C" int fl_radio_button_handle(RADIOBUTTON b, int e); - - -extern "C" RADIOBUTTON new_fl_radio_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_radio_button(RADIOBUTTON b); - -  #endif + diff --git a/src/c_fl_radio_light_button.cpp b/src/c_fl_radio_light_button.cpp index 79ec835..c0a1d90 100644 --- a/src/c_fl_radio_light_button.cpp +++ b/src/c_fl_radio_light_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Radio_Light_Button.H>  #include "c_fl_radio_light_button.h" -#include "c_fl_type.h" -class My_Radio_Light_Button : public Fl_Radio_Light_Button { -    public: -        using Fl_Radio_Light_Button::Fl_Radio_Light_Button; -        friend void radio_light_button_set_draw_hook(RADIOLIGHTBUTTON b, void * d); -        friend void fl_radio_light_button_draw(RADIOLIGHTBUTTON b); -        friend void radio_light_button_set_handle_hook(RADIOLIGHTBUTTON b, void * h); -        friend int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, 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_Radio_Light_Button::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_Radio_Light_Button::real_draw() { -    Fl_Radio_Light_Button::draw(); -} -int My_Radio_Light_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Radio_Light_Button::real_handle(int e) { -    return Fl_Radio_Light_Button::handle(e); -} -void radio_light_button_set_draw_hook(RADIOLIGHTBUTTON b, void * d) { -    reinterpret_cast<My_Radio_Light_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_radio_light_button_draw(RADIOLIGHTBUTTON b) { -    reinterpret_cast<My_Radio_Light_Button*>(b)->real_draw(); -} +class My_Radio_Light_Button : public Fl_Radio_Light_Button { +public: +    using Fl_Radio_Light_Button::Fl_Radio_Light_Button; + +    friend void fl_radio_light_button_draw(RADIOLIGHTBUTTON b); +    friend int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void radio_light_button_set_handle_hook(RADIOLIGHTBUTTON b, void * h) { -    reinterpret_cast<My_Radio_Light_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Radio_Light_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e) { -    return reinterpret_cast<My_Radio_Light_Button*>(b)->real_handle(e); +int My_Radio_Light_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  RADIOLIGHTBUTTON new_fl_radio_light_button(int x, int y, int w, int h, char* label) {      My_Radio_Light_Button *b = new My_Radio_Light_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_radio_light_button(RADIOLIGHTBUTTON b) {      delete reinterpret_cast<My_Radio_Light_Button*>(b);  } + + + +void fl_radio_light_button_draw(RADIOLIGHTBUTTON b) { +    reinterpret_cast<My_Radio_Light_Button*>(b)->Fl_Radio_Light_Button::draw(); +} + +int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e) { +    return reinterpret_cast<My_Radio_Light_Button*>(b)->Fl_Radio_Light_Button::handle(e); +} + + diff --git a/src/c_fl_radio_light_button.h b/src/c_fl_radio_light_button.h index 52d5eab..217bd69 100644 --- a/src/c_fl_radio_light_button.h +++ b/src/c_fl_radio_light_button.h @@ -8,24 +8,17 @@  #define FL_RADIO_LIGHT_BUTTON_GUARD - -  typedef void* RADIOLIGHTBUTTON; +extern "C" RADIOLIGHTBUTTON new_fl_radio_light_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_radio_light_button(RADIOLIGHTBUTTON b); -extern "C" void radio_light_button_set_draw_hook(RADIOLIGHTBUTTON b, void * d);  extern "C" void fl_radio_light_button_draw(RADIOLIGHTBUTTON b); -extern "C" void radio_light_button_set_handle_hook(RADIOLIGHTBUTTON b, void * h);  extern "C" int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e); - - -extern "C" RADIOLIGHTBUTTON new_fl_radio_light_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_radio_light_button(RADIOLIGHTBUTTON b); - -  #endif + diff --git a/src/c_fl_radio_round_button.cpp b/src/c_fl_radio_round_button.cpp index 006bfd5..5ddaa1f 100644 --- a/src/c_fl_radio_round_button.cpp +++ b/src/c_fl_radio_round_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Radio_Round_Button.H>  #include "c_fl_radio_round_button.h" -#include "c_fl_type.h" -class My_Radio_Round_Button : public Fl_Radio_Round_Button { -    public: -        using Fl_Radio_Round_Button::Fl_Radio_Round_Button; -        friend void radio_round_button_set_draw_hook(RADIOROUNDBUTTON b, void * d); -        friend void fl_radio_round_button_draw(RADIOROUNDBUTTON b); -        friend void radio_round_button_set_handle_hook(RADIOROUNDBUTTON b, void * h); -        friend int fl_radio_round_button_handle(RADIOROUNDBUTTON b, 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_Radio_Round_Button::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_Radio_Round_Button::real_draw() { -    Fl_Radio_Round_Button::draw(); -} -int My_Radio_Round_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Radio_Round_Button::real_handle(int e) { -    return Fl_Radio_Round_Button::handle(e); -} -void radio_round_button_set_draw_hook(RADIOROUNDBUTTON b, void * d) { -    reinterpret_cast<My_Radio_Round_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_radio_round_button_draw(RADIOROUNDBUTTON b) { -    reinterpret_cast<My_Radio_Round_Button*>(b)->real_draw(); -} +class My_Radio_Round_Button : public Fl_Radio_Round_Button { +public: +    using Fl_Radio_Round_Button::Fl_Radio_Round_Button; + +    friend void fl_radio_round_button_draw(RADIOROUNDBUTTON b); +    friend int fl_radio_round_button_handle(RADIOROUNDBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void radio_round_button_set_handle_hook(RADIOROUNDBUTTON b, void * h) { -    reinterpret_cast<My_Radio_Round_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Radio_Round_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_radio_round_button_handle(RADIOROUNDBUTTON b, int e) { -    return reinterpret_cast<My_Radio_Round_Button*>(b)->real_handle(e); +int My_Radio_Round_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  RADIOROUNDBUTTON new_fl_radio_round_button(int x, int y, int w, int h, char* label) {      My_Radio_Round_Button *b = new My_Radio_Round_Button(x, y, w, h, label);      return b; @@ -71,3 +53,16 @@ void free_fl_radio_round_button(RADIOROUNDBUTTON b) {      delete reinterpret_cast<My_Radio_Round_Button*>(b);  } + + + + +void fl_radio_round_button_draw(RADIOROUNDBUTTON b) { +    reinterpret_cast<My_Radio_Round_Button*>(b)->Fl_Radio_Round_Button::draw(); +} + +int fl_radio_round_button_handle(RADIOROUNDBUTTON b, int e) { +    return reinterpret_cast<My_Radio_Round_Button*>(b)->Fl_Radio_Round_Button::handle(e); +} + + diff --git a/src/c_fl_radio_round_button.h b/src/c_fl_radio_round_button.h index 73f0ad7..bea7076 100644 --- a/src/c_fl_radio_round_button.h +++ b/src/c_fl_radio_round_button.h @@ -8,24 +8,17 @@  #define FL_RADIO_ROUND_BUTTON_GUARD - -  typedef void* RADIOROUNDBUTTON; +extern "C" RADIOROUNDBUTTON new_fl_radio_round_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_radio_round_button(RADIOROUNDBUTTON b); -extern "C" void radio_round_button_set_draw_hook(RADIOROUNDBUTTON b, void * d);  extern "C" void fl_radio_round_button_draw(RADIOROUNDBUTTON b); -extern "C" void radio_round_button_set_handle_hook(RADIOROUNDBUTTON b, void * h);  extern "C" int fl_radio_round_button_handle(RADIOROUNDBUTTON b, int e); - - -extern "C" RADIOROUNDBUTTON new_fl_radio_round_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_radio_round_button(RADIOROUNDBUTTON b); - -  #endif + diff --git a/src/c_fl_repeat_button.cpp b/src/c_fl_repeat_button.cpp index fbbbf35..7f05235 100644 --- a/src/c_fl_repeat_button.cpp +++ b/src/c_fl_repeat_button.cpp @@ -6,68 +6,69 @@  #include <FL/Fl_Repeat_Button.H>  #include "c_fl_repeat_button.h" -#include "c_fl_type.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_Repeat_Button : public Fl_Repeat_Button { -    public: -        using Fl_Repeat_Button::Fl_Repeat_Button; -        friend void repeat_button_set_draw_hook(REPEATBUTTON b, void * d); -        friend void fl_repeat_button_draw(REPEATBUTTON b); -        friend void repeat_button_set_handle_hook(REPEATBUTTON b, void * h); -        friend int fl_repeat_button_handle(REPEATBUTTON b, 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; +public: +    using Fl_Repeat_Button::Fl_Repeat_Button; + +    friend void fl_repeat_button_draw(REPEATBUTTON b); +    friend int fl_repeat_button_handle(REPEATBUTTON b, int e); + +    void draw(); +    int handle(int e);  };  void My_Repeat_Button::draw() { -    (*draw_hook)(this->user_data()); -} - -void My_Repeat_Button::real_draw() { -    Fl_Repeat_Button::draw(); +    widget_draw_hook(this->user_data());  }  int My_Repeat_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Repeat_Button::real_handle(int e) { -    return Fl_Repeat_Button::handle(e); -} -void repeat_button_set_draw_hook(REPEATBUTTON b, void * d) { -    reinterpret_cast<My_Repeat_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_repeat_button_draw(REPEATBUTTON b) { -    reinterpret_cast<My_Repeat_Button*>(b)->real_draw(); + +//  Flattened C API + +REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label) { +    My_Repeat_Button *b = new My_Repeat_Button(x, y, w, h, label); +    return b;  } -void repeat_button_set_handle_hook(REPEATBUTTON b, void * h) { -    reinterpret_cast<My_Repeat_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void free_fl_repeat_button(REPEATBUTTON b) { +    delete reinterpret_cast<My_Repeat_Button*>(b);  } -int fl_repeat_button_handle(REPEATBUTTON b, int e) { -    return reinterpret_cast<My_Repeat_Button*>(b)->real_handle(e); + + + +void fl_repeat_button_deactivate(REPEATBUTTON b) { +    reinterpret_cast<Fl_Repeat_Button*>(b)->deactivate();  } -REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label) { -    My_Repeat_Button *b = new My_Repeat_Button(x, y, w, h, label); -    return b; +void fl_repeat_button_draw(REPEATBUTTON b) { +    reinterpret_cast<My_Repeat_Button*>(b)->Fl_Repeat_Button::draw();  } -void free_fl_repeat_button(REPEATBUTTON b) { -    delete reinterpret_cast<My_Repeat_Button*>(b); +int fl_repeat_button_handle(REPEATBUTTON b, int e) { +    return reinterpret_cast<My_Repeat_Button*>(b)->Fl_Repeat_Button::handle(e);  } + diff --git a/src/c_fl_repeat_button.h b/src/c_fl_repeat_button.h index fb88e86..5750a60 100644 --- a/src/c_fl_repeat_button.h +++ b/src/c_fl_repeat_button.h @@ -8,24 +8,20 @@  #define FL_REPEAT_BUTTON_GUARD +typedef void* REPEATBUTTON; -typedef void* REPEATBUTTON; +extern "C" REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_repeat_button(REPEATBUTTON b); +extern "C" void fl_repeat_button_deactivate(REPEATBUTTON b); -extern "C" void repeat_button_set_draw_hook(REPEATBUTTON b, void * d);  extern "C" void fl_repeat_button_draw(REPEATBUTTON b); -extern "C" void repeat_button_set_handle_hook(REPEATBUTTON b, void * h);  extern "C" int fl_repeat_button_handle(REPEATBUTTON b, int e); - - -extern "C" REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_repeat_button(REPEATBUTTON b); - -  #endif + diff --git a/src/c_fl_return_button.cpp b/src/c_fl_return_button.cpp index 85e937d..022685c 100644 --- a/src/c_fl_return_button.cpp +++ b/src/c_fl_return_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Return_Button.H>  #include "c_fl_return_button.h" -#include "c_fl_type.h" -class My_Return_Button : public Fl_Return_Button { -    public: -        using Fl_Return_Button::Fl_Return_Button; -        friend void return_button_set_draw_hook(RETURNBUTTON b, void * d); -        friend void fl_return_button_draw(RETURNBUTTON b); -        friend void return_button_set_handle_hook(RETURNBUTTON b, void * h); -        friend int fl_return_button_handle(RETURNBUTTON b, 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_Return_Button::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_Return_Button::real_draw() { -    Fl_Return_Button::draw(); -} -int My_Return_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Return_Button::real_handle(int e) { -    return Fl_Return_Button::handle(e); -} -void return_button_set_draw_hook(RETURNBUTTON b, void * d) { -    reinterpret_cast<My_Return_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_return_button_draw(RETURNBUTTON b) { -    reinterpret_cast<My_Return_Button*>(b)->real_draw(); -} +class My_Return_Button : public Fl_Return_Button { +public: +    using Fl_Return_Button::Fl_Return_Button; + +    friend void fl_return_button_draw(RETURNBUTTON b); +    friend int fl_return_button_handle(RETURNBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void return_button_set_handle_hook(RETURNBUTTON b, void * h) { -    reinterpret_cast<My_Return_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Return_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_return_button_handle(RETURNBUTTON b, int e) { -    return reinterpret_cast<My_Return_Button*>(b)->real_handle(e); +int My_Return_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +// Flattened C API +  RETURNBUTTON new_fl_return_button(int x, int y, int w, int h, char* label) {      My_Return_Button *b = new My_Return_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_return_button(RETURNBUTTON b) {      delete reinterpret_cast<My_Return_Button*>(b);  } + + + +void fl_return_button_draw(RETURNBUTTON b) { +    reinterpret_cast<My_Return_Button*>(b)->Fl_Return_Button::draw(); +} + +int fl_return_button_handle(RETURNBUTTON b, int e) { +    return reinterpret_cast<My_Return_Button*>(b)->Fl_Return_Button::handle(e); +} + + diff --git a/src/c_fl_return_button.h b/src/c_fl_return_button.h index 2c0c52a..c9f4d62 100644 --- a/src/c_fl_return_button.h +++ b/src/c_fl_return_button.h @@ -8,24 +8,17 @@  #define FL_RETURN_BUTTON_GUARD - -  typedef void* RETURNBUTTON; +extern "C" RETURNBUTTON new_fl_return_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_return_button(RETURNBUTTON b); -extern "C" void return_button_set_draw_hook(RETURNBUTTON b, void * d);  extern "C" void fl_return_button_draw(RETURNBUTTON b); -extern "C" void return_button_set_handle_hook(RETURNBUTTON b, void * h);  extern "C" int fl_return_button_handle(RETURNBUTTON b, int e); - - -extern "C" RETURNBUTTON new_fl_return_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_return_button(RETURNBUTTON b); - -  #endif + diff --git a/src/c_fl_roller.cpp b/src/c_fl_roller.cpp index 6a4ebb6..f5c7dd6 100644 --- a/src/c_fl_roller.cpp +++ b/src/c_fl_roller.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Roller.H>  #include "c_fl_roller.h" -#include "c_fl_type.h" -class My_Roller : public Fl_Roller { -    public: -        using Fl_Roller::Fl_Roller; -        friend void roller_set_draw_hook(ROLLER r, void * d); -        friend void fl_roller_draw(ROLLER r); -        friend void roller_set_handle_hook(ROLLER r, void * h); -        friend int fl_roller_handle(ROLLER r, 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_Roller::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_Roller::real_draw() { -    Fl_Roller::draw(); -} -int My_Roller::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Roller::real_handle(int e) { -    return Fl_Roller::handle(e); -} -void roller_set_draw_hook(ROLLER r, void * d) { -    reinterpret_cast<My_Roller*>(r)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_roller_draw(ROLLER r) { -    reinterpret_cast<My_Roller*>(r)->real_draw(); -} +class My_Roller : public Fl_Roller { +public: +    using Fl_Roller::Fl_Roller; + +    friend void fl_roller_draw(ROLLER r); +    friend int fl_roller_handle(ROLLER r, int e); + +    void draw(); +    int handle(int e); +}; -void roller_set_handle_hook(ROLLER r, void * h) { -    reinterpret_cast<My_Roller*>(r)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Roller::draw() { +    widget_draw_hook(this->user_data());  } -int fl_roller_handle(ROLLER r, int e) { -    return reinterpret_cast<My_Roller*>(r)->real_handle(e); +int My_Roller::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  ROLLER new_fl_roller(int x, int y, int w, int h, char* label) {      My_Roller *r = new My_Roller(x, y, w, h, label);      return r; @@ -72,3 +54,14 @@ void free_fl_roller(ROLLER r) {  } + + +void fl_roller_draw(ROLLER r) { +    reinterpret_cast<My_Roller*>(r)->Fl_Roller::draw(); +} + +int fl_roller_handle(ROLLER r, int e) { +    return reinterpret_cast<My_Roller*>(r)->Fl_Roller::handle(e); +} + + diff --git a/src/c_fl_roller.h b/src/c_fl_roller.h index b0aa432..a864d71 100644 --- a/src/c_fl_roller.h +++ b/src/c_fl_roller.h @@ -8,24 +8,17 @@  #define FL_ROLLER_GUARD - -  typedef void* ROLLER; +extern "C" ROLLER new_fl_roller(int x, int y, int w, int h, char* label); +extern "C" void free_fl_roller(ROLLER r); -extern "C" void roller_set_draw_hook(ROLLER r, void * d);  extern "C" void fl_roller_draw(ROLLER r); -extern "C" void roller_set_handle_hook(ROLLER r, void * h);  extern "C" int fl_roller_handle(ROLLER r, int e); - - -extern "C" ROLLER new_fl_roller(int x, int y, int w, int h, char* label); -extern "C" void free_fl_roller(ROLLER r); - -  #endif + diff --git a/src/c_fl_round_button.cpp b/src/c_fl_round_button.cpp index 41507cf..b7c2d12 100644 --- a/src/c_fl_round_button.cpp +++ b/src/c_fl_round_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Round_Button.H>  #include "c_fl_round_button.h" -#include "c_fl_type.h" -class My_Round_Button : public Fl_Round_Button { -    public: -        using Fl_Round_Button::Fl_Round_Button; -        friend void round_button_set_draw_hook(ROUNDBUTTON b, void * d); -        friend void fl_round_button_draw(ROUNDBUTTON b); -        friend void round_button_set_handle_hook(ROUNDBUTTON b, void * h); -        friend int fl_round_button_handle(ROUNDBUTTON b, 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_Round_Button::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_Round_Button::real_draw() { -    Fl_Round_Button::draw(); -} -int My_Round_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Round_Button::real_handle(int e) { -    return Fl_Round_Button::handle(e); -} -void round_button_set_draw_hook(ROUNDBUTTON b, void * d) { -    reinterpret_cast<My_Round_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_round_button_draw(ROUNDBUTTON b) { -    reinterpret_cast<My_Round_Button*>(b)->real_draw(); -} +class My_Round_Button : public Fl_Round_Button { +public: +    using Fl_Round_Button::Fl_Round_Button; + +    friend void fl_round_button_draw(ROUNDBUTTON b); +    friend int fl_round_button_handle(ROUNDBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void round_button_set_handle_hook(ROUNDBUTTON b, void * h) { -    reinterpret_cast<My_Round_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Round_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_round_button_handle(ROUNDBUTTON b, int e) { -    return reinterpret_cast<My_Round_Button*>(b)->real_handle(e); +int My_Round_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  ROUNDBUTTON new_fl_round_button(int x, int y, int w, int h, char* label) {      My_Round_Button *b = new My_Round_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_round_button(ROUNDBUTTON b) {      delete reinterpret_cast<My_Round_Button*>(b);  } + + + +void fl_round_button_draw(ROUNDBUTTON b) { +    reinterpret_cast<My_Round_Button*>(b)->Fl_Round_Button::draw(); +} + +int fl_round_button_handle(ROUNDBUTTON b, int e) { +    return reinterpret_cast<My_Round_Button*>(b)->Fl_Round_Button::handle(e); +} + + diff --git a/src/c_fl_round_button.h b/src/c_fl_round_button.h index 1b37140..cbbaf9f 100644 --- a/src/c_fl_round_button.h +++ b/src/c_fl_round_button.h @@ -8,24 +8,17 @@  #define FL_ROUND_BUTTON_GUARD - -  typedef void* ROUNDBUTTON; +extern "C" ROUNDBUTTON new_fl_round_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_round_button(ROUNDBUTTON b); -extern "C" void round_button_set_draw_hook(ROUNDBUTTON b, void * d);  extern "C" void fl_round_button_draw(ROUNDBUTTON b); -extern "C" void round_button_set_handle_hook(ROUNDBUTTON b, void * h);  extern "C" int fl_round_button_handle(ROUNDBUTTON b, int e); - - -extern "C" ROUNDBUTTON new_fl_round_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_round_button(ROUNDBUTTON b); - -  #endif + diff --git a/src/c_fl_round_clock.cpp b/src/c_fl_round_clock.cpp index 1ce55e7..d2ab087 100644 --- a/src/c_fl_round_clock.cpp +++ b/src/c_fl_round_clock.cpp @@ -6,77 +6,62 @@  #include <FL/Fl_Round_Clock.H>  #include "c_fl_round_clock.h" -#include "c_fl_type.h" -class My_Round_Clock : public Fl_Round_Clock { -    public: -        using Fl_Round_Clock::Fl_Round_Clock; -        friend void round_clock_set_draw_hook(ROUND_CLOCK c, void * d); -        friend void fl_round_clock_draw(ROUND_CLOCK c); -        friend void round_clock_set_handle_hook(ROUND_CLOCK c, void * h); -        friend int fl_round_clock_handle(ROUND_CLOCK c, int e); -        friend void fl_round_clock_draw2(ROUND_CLOCK c, int x, int y, int w, int h); -    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_Round_Clock::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_Round_Clock::real_draw() { -    Fl_Round_Clock::draw(); -} -int My_Round_Clock::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Round_Clock::real_handle(int e) { -    return Fl_Round_Clock::handle(e); -} -void round_clock_set_draw_hook(ROUND_CLOCK c, void * d) { -    reinterpret_cast<My_Round_Clock*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_round_clock_draw(ROUND_CLOCK c) { -    reinterpret_cast<My_Round_Clock*>(c)->real_draw(); -} +class My_Round_Clock : public Fl_Round_Clock { +public: +    using Fl_Round_Clock::Fl_Round_Clock; + +    friend void fl_round_clock_draw(ROUNDCLOCK c); +    friend int fl_round_clock_handle(ROUNDCLOCK c, int e); -void round_clock_set_handle_hook(ROUND_CLOCK c, void * h) { -    reinterpret_cast<My_Round_Clock*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Round_Clock::draw() { +    widget_draw_hook(this->user_data());  } -int fl_round_clock_handle(ROUND_CLOCK c, int e) { -    return reinterpret_cast<My_Round_Clock*>(c)->real_handle(e); +int My_Round_Clock::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -ROUND_CLOCK new_fl_round_clock(int x, int y, int w, int h, char* label) { +//  Flattened C API + +ROUNDCLOCK new_fl_round_clock(int x, int y, int w, int h, char* label) {      My_Round_Clock *c = new My_Round_Clock(x, y, w, h, label);      return c;  } -void free_fl_round_clock(ROUND_CLOCK c) { +void free_fl_round_clock(ROUNDCLOCK c) {      delete reinterpret_cast<My_Round_Clock*>(c);  } -void fl_round_clock_draw2(ROUND_CLOCK c, int x, int y, int w, int h) { -    reinterpret_cast<My_Round_Clock*>(c)->Fl_Round_Clock::draw(x,y,w,h); +void fl_round_clock_draw(ROUNDCLOCK c) { +    reinterpret_cast<My_Round_Clock*>(c)->Fl_Round_Clock::draw(); +} + +int fl_round_clock_handle(ROUNDCLOCK c, int e) { +    return reinterpret_cast<My_Round_Clock*>(c)->Fl_Round_Clock::handle(e);  } diff --git a/src/c_fl_round_clock.h b/src/c_fl_round_clock.h index 60684ad..475a5d0 100644 --- a/src/c_fl_round_clock.h +++ b/src/c_fl_round_clock.h @@ -8,29 +8,17 @@  #define FL_ROUND_CLOCK_GUARD +typedef void* ROUNDCLOCK; -typedef void* ROUND_CLOCK; +extern "C" ROUNDCLOCK new_fl_round_clock(int x, int y, int w, int h, char* label); +extern "C" void free_fl_round_clock(ROUNDCLOCK c); - - -extern "C" void round_clock_set_draw_hook(ROUND_CLOCK c, void * d); -extern "C" void fl_round_clock_draw(ROUND_CLOCK c); -extern "C" void round_clock_set_handle_hook(ROUND_CLOCK c, void * h); -extern "C" int fl_round_clock_handle(ROUND_CLOCK c, int e); - - - - -extern "C" ROUND_CLOCK new_fl_round_clock(int x, int y, int w, int h, char* label); -extern "C" void free_fl_round_clock(ROUND_CLOCK c); - - - - -extern "C" void fl_round_clock_draw2(ROUND_CLOCK c, int x, int y, int w, int h); +extern "C" void fl_round_clock_draw(ROUNDCLOCK c); +extern "C" int fl_round_clock_handle(ROUNDCLOCK c, int e);  #endif + 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); +} + + diff --git a/src/c_fl_scroll.h b/src/c_fl_scroll.h index a4ca175..9bbd749 100644 --- a/src/c_fl_scroll.h +++ b/src/c_fl_scroll.h @@ -8,27 +8,13 @@  #define FL_SCROLL_GUARD - -  typedef void* SCROLL; - - -extern "C" void scroll_set_draw_hook(SCROLL s, void * d); -extern "C" void fl_scroll_draw(SCROLL s); -extern "C" void scroll_set_handle_hook(SCROLL s, void * h); -extern "C" int fl_scroll_handle(SCROLL s, int e); - - - -  extern "C" SCROLL new_fl_scroll(int x, int y, int w, int h, char* label);  extern "C" void free_fl_scroll(SCROLL s); - -  extern "C" void fl_scroll_clear(SCROLL s); @@ -42,5 +28,10 @@ extern "C" int fl_scroll_xposition(SCROLL s);  extern "C" int fl_scroll_yposition(SCROLL s); +extern "C" void fl_scroll_draw(SCROLL s); +extern "C" int fl_scroll_handle(SCROLL s, int e); + +  #endif + diff --git a/src/c_fl_scrollbar.cpp b/src/c_fl_scrollbar.cpp index 848d83f..ae20a25 100644 --- a/src/c_fl_scrollbar.cpp +++ b/src/c_fl_scrollbar.cpp @@ -6,7 +6,6 @@  #include <FL/Fl_Scrollbar.H>  #include "c_fl_scrollbar.h" -#include "c_fl_type.h" @@ -26,57 +25,40 @@ void fl_scrollbar_extra_final(void * adaobj) { -class My_Scrollbar : public Fl_Scrollbar { -    public: -        using Fl_Scrollbar::Fl_Scrollbar; -        friend void scrollbar_set_draw_hook(SCROLLBAR s, void * d); -        friend void fl_scrollbar_draw(SCROLLBAR s); -        friend void scrollbar_set_handle_hook(SCROLLBAR s, void * h); -        friend int fl_scrollbar_handle(SCROLLBAR 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_Scrollbar::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_Scrollbar::real_draw() { -    Fl_Scrollbar::draw(); -} -int My_Scrollbar::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Scrollbar::real_handle(int e) { -    return Fl_Scrollbar::handle(e); -} -void scrollbar_set_draw_hook(SCROLLBAR s, void * d) { -    reinterpret_cast<My_Scrollbar*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_scrollbar_draw(SCROLLBAR s) { -    reinterpret_cast<My_Scrollbar*>(s)->real_draw(); -} +class My_Scrollbar : public Fl_Scrollbar { +public: +    using Fl_Scrollbar::Fl_Scrollbar; + +    friend void fl_scrollbar_draw(SCROLLBAR s); +    friend int fl_scrollbar_handle(SCROLLBAR s, int e); + +    void draw(); +    int handle(int e); +}; -void scrollbar_set_handle_hook(SCROLLBAR s, void * h) { -    reinterpret_cast<My_Scrollbar*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Scrollbar::draw() { +    widget_draw_hook(this->user_data());  } -int fl_scrollbar_handle(SCROLLBAR s, int e) { -    return reinterpret_cast<My_Scrollbar*>(s)->real_handle(e); +int My_Scrollbar::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  SCROLLBAR new_fl_scrollbar(int x, int y, int w, int h, char* label) {      My_Scrollbar *s = new My_Scrollbar(x, y, w, h, label);      return s; @@ -109,3 +91,15 @@ void fl_scrollbar_set_value2(SCROLLBAR s, int p, int w, int f, int t) {      reinterpret_cast<Fl_Scrollbar*>(s)->value(p,w,f,t);  } + + + +void fl_scrollbar_draw(SCROLLBAR s) { +    reinterpret_cast<My_Scrollbar*>(s)->Fl_Scrollbar::draw(); +} + +int fl_scrollbar_handle(SCROLLBAR s, int e) { +    return reinterpret_cast<My_Scrollbar*>(s)->Fl_Scrollbar::handle(e); +} + + diff --git a/src/c_fl_scrollbar.h b/src/c_fl_scrollbar.h index 6f82143..870f256 100644 --- a/src/c_fl_scrollbar.h +++ b/src/c_fl_scrollbar.h @@ -16,12 +16,6 @@ extern "C" void fl_scrollbar_extra_final(void * adaobj);  typedef void* SCROLLBAR; -extern "C" void scrollbar_set_draw_hook(SCROLLBAR s, void * d); -extern "C" void fl_scrollbar_draw(SCROLLBAR s); -extern "C" void scrollbar_set_handle_hook(SCROLLBAR s, void * h); -extern "C" int fl_scrollbar_handle(SCROLLBAR s, int e); - -  extern "C" SCROLLBAR new_fl_scrollbar(int x, int y, int w, int h, char* label);  extern "C" void free_fl_scrollbar(SCROLLBAR s); @@ -33,6 +27,10 @@ extern "C" void fl_scrollbar_set_value(SCROLLBAR s, int t);  extern "C" void fl_scrollbar_set_value2(SCROLLBAR s, int p, int w, int f, int t); +extern "C" void fl_scrollbar_draw(SCROLLBAR s); +extern "C" int fl_scrollbar_handle(SCROLLBAR s, int e); + +  #endif diff --git a/src/c_fl_simple_counter.cpp b/src/c_fl_simple_counter.cpp index 6349f09..891a371 100644 --- a/src/c_fl_simple_counter.cpp +++ b/src/c_fl_simple_counter.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Simple_Counter.H>  #include "c_fl_simple_counter.h" -#include "c_fl_type.h" -class My_Simple_Counter : public Fl_Simple_Counter { -    public: -        using Fl_Simple_Counter::Fl_Simple_Counter; -        friend void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d); -        friend void fl_simple_counter_draw(SIMPLE_COUNTER c); -        friend void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h); -        friend int fl_simple_counter_handle(SIMPLE_COUNTER c, 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_Simple_Counter::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_Simple_Counter::real_draw() { -    Fl_Simple_Counter::draw(); -} -int My_Simple_Counter::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Simple_Counter::real_handle(int e) { -    return Fl_Simple_Counter::handle(e); -} -void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d) { -    reinterpret_cast<My_Simple_Counter*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_simple_counter_draw(SIMPLE_COUNTER c) { -    reinterpret_cast<My_Simple_Counter*>(c)->real_draw(); -} +class My_Simple_Counter : public Fl_Simple_Counter { +public: +    using Fl_Simple_Counter::Fl_Simple_Counter; + +    friend void fl_simple_counter_draw(SIMPLE_COUNTER c); +    friend int fl_simple_counter_handle(SIMPLE_COUNTER c, int e); + +    void draw(); +    int handle(int e); +}; -void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h) { -    reinterpret_cast<My_Simple_Counter*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Simple_Counter::draw() { +    widget_draw_hook(this->user_data());  } -int fl_simple_counter_handle(SIMPLE_COUNTER c, int e) { -    return reinterpret_cast<My_Simple_Counter*>(c)->real_handle(e); +int My_Simple_Counter::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  SIMPLE_COUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label) {      My_Simple_Counter *c = new My_Simple_Counter(x, y, w, h, label);      return c; @@ -72,3 +54,14 @@ void free_fl_simple_counter(SIMPLE_COUNTER c) {  } + + +void fl_simple_counter_draw(SIMPLE_COUNTER c) { +    reinterpret_cast<My_Simple_Counter*>(c)->Fl_Simple_Counter::draw(); +} + +int fl_simple_counter_handle(SIMPLE_COUNTER c, int e) { +    return reinterpret_cast<My_Simple_Counter*>(c)->Fl_Simple_Counter::handle(e); +} + + diff --git a/src/c_fl_simple_counter.h b/src/c_fl_simple_counter.h index 9451ddd..6c45a89 100644 --- a/src/c_fl_simple_counter.h +++ b/src/c_fl_simple_counter.h @@ -8,24 +8,17 @@  #define FL_SIMPLE_COUNTER_GUARD - -  typedef void* SIMPLE_COUNTER; +extern "C" SIMPLE_COUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label); +extern "C" void free_fl_simple_counter(SIMPLE_COUNTER c); -extern "C" void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d);  extern "C" void fl_simple_counter_draw(SIMPLE_COUNTER c); -extern "C" void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h);  extern "C" int fl_simple_counter_handle(SIMPLE_COUNTER c, int e); - - -extern "C" SIMPLE_COUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label); -extern "C" void free_fl_simple_counter(SIMPLE_COUNTER c); - -  #endif + diff --git a/src/c_fl_single_window.cpp b/src/c_fl_single_window.cpp index 0eb6d1c..4968e46 100644 --- a/src/c_fl_single_window.cpp +++ b/src/c_fl_single_window.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Single_Window.H>  #include "c_fl_single_window.h" -#include "c_fl_type.h" -class My_Single_Window : public Fl_Single_Window { -    public: -        using Fl_Single_Window::Fl_Single_Window; -        friend void single_window_set_draw_hook(SINGLEWINDOW n, void * d); -        friend void fl_single_window_draw(SINGLEWINDOW n); -        friend void single_window_set_handle_hook(SINGLEWINDOW n, void * h); -        friend int fl_single_window_handle(SINGLEWINDOW 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; -}; +//  Exports from Ada -void My_Single_Window::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_Single_Window::real_draw() { -    Fl_Single_Window::draw(); -} -int My_Single_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Single_Window::real_handle(int e) { -    return Fl_Single_Window::handle(e); -} -void single_window_set_draw_hook(SINGLEWINDOW n, void * d) { -    reinterpret_cast<My_Single_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_single_window_draw(SINGLEWINDOW n) { -    reinterpret_cast<My_Single_Window*>(n)->real_draw(); -} +class My_Single_Window : public Fl_Single_Window { +public: +    using Fl_Single_Window::Fl_Single_Window; + +    friend void fl_single_window_draw(SINGLEWINDOW n); +    friend int fl_single_window_handle(SINGLEWINDOW n, int e); -void single_window_set_handle_hook(SINGLEWINDOW n, void * h) { -    reinterpret_cast<My_Single_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Single_Window::draw() { +    widget_draw_hook(this->user_data());  } -int fl_single_window_handle(SINGLEWINDOW n, int e) { -    return reinterpret_cast<My_Single_Window*>(n)->real_handle(e); +int My_Single_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  SINGLEWINDOW new_fl_single_window(int x, int y, int w, int h, char* label) {      My_Single_Window *sw = new My_Single_Window(x, y, w, h, label);      return sw; @@ -87,3 +69,22 @@ void fl_single_window_flush(SINGLEWINDOW w) {      reinterpret_cast<Fl_Single_Window*>(w)->flush();  } + + + +void fl_single_window_make_current(SINGLEWINDOW w) { +    reinterpret_cast<Fl_Single_Window*>(w)->Fl_Window::make_current(); +} + + + + +void fl_single_window_draw(SINGLEWINDOW n) { +    reinterpret_cast<My_Single_Window*>(n)->Fl_Single_Window::draw(); +} + +int fl_single_window_handle(SINGLEWINDOW n, int e) { +    return reinterpret_cast<My_Single_Window*>(n)->Fl_Single_Window::handle(e); +} + + diff --git a/src/c_fl_single_window.h b/src/c_fl_single_window.h index 873498b..3179f5a 100644 --- a/src/c_fl_single_window.h +++ b/src/c_fl_single_window.h @@ -8,31 +8,25 @@  #define FL_SINGLE_WINDOW_GUARD - -  typedef void* SINGLEWINDOW; - - -extern "C" void single_window_set_draw_hook(SINGLEWINDOW n, void * d); -extern "C" void fl_single_window_draw(SINGLEWINDOW n); -extern "C" void single_window_set_handle_hook(SINGLEWINDOW n, void * h); -extern "C" int fl_single_window_handle(SINGLEWINDOW n, int e); - - - -  extern "C" SINGLEWINDOW new_fl_single_window(int x, int y, int w, int h, char* label);  extern "C" SINGLEWINDOW new_fl_single_window2(int x, int y, char* label);  extern "C" void free_fl_single_window(SINGLEWINDOW w); - -  extern "C" void fl_single_window_show(SINGLEWINDOW w);  extern "C" void fl_single_window_flush(SINGLEWINDOW w); +extern "C" void fl_single_window_make_current(SINGLEWINDOW w); + + +extern "C" void fl_single_window_draw(SINGLEWINDOW n); +extern "C" int fl_single_window_handle(SINGLEWINDOW n, int e); + +  #endif + diff --git a/src/c_fl_slider.cpp b/src/c_fl_slider.cpp index dc55c90..fcdd32d 100644 --- a/src/c_fl_slider.cpp +++ b/src/c_fl_slider.cpp @@ -6,80 +6,68 @@  #include <FL/Fl_Slider.H>  #include "c_fl_slider.h" -#include "c_fl_type.h" -class My_Slider : public Fl_Slider { -    public: -        using Fl_Slider::Fl_Slider; -        friend void slider_set_draw_hook(SLIDER s, void * d); -        friend void fl_slider_draw(SLIDER s); -        friend void slider_set_handle_hook(SLIDER s, void * h); -        friend int fl_slider_handle(SLIDER 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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Slider : Fl_Slider { +public: +    //  Really only needed for the (int,int,int,int) versions +    using Fl_Slider::draw; +    using Fl_Slider::handle;  }; -void My_Slider::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Slider::real_draw() { -    Fl_Slider::draw(); -} -int My_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Slider::real_handle(int e) { -    return Fl_Slider::handle(e); -} +//  Attaching all relevant hooks and friends -void slider_set_draw_hook(SLIDER s, void * d) { -    reinterpret_cast<My_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Slider : public Fl_Slider { +public: +    using Fl_Slider::Fl_Slider; -void fl_slider_draw(SLIDER s) { -    reinterpret_cast<My_Slider*>(s)->real_draw(); -} +    friend void fl_slider_draw(SLIDER s); +    friend int fl_slider_handle(SLIDER s, int e); -void slider_set_handle_hook(SLIDER s, void * h) { -    reinterpret_cast<My_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Slider::draw() { +    widget_draw_hook(this->user_data());  } -int fl_slider_handle(SLIDER s, int e) { -    return reinterpret_cast<My_Slider*>(s)->real_handle(e); +int My_Slider::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  SLIDER new_fl_slider(int x, int y, int w, int h, char* label) {      My_Slider *s = new My_Slider(x, y, w, h, label);      return s;  } -void free_fl_slider(SLIDER s) { -    delete reinterpret_cast<My_Slider*>(s); -} - - - - -int fl_slider_get_type(SLIDER s) { -    return reinterpret_cast<Fl_Slider*>(s)->type(); +SLIDER new_fl_slider2(unsigned char k, int x, int y, int w, int h, char * label) { +    My_Slider *s = new My_Slider(k, x, y, w, h, label); +    return s;  } -void fl_slider_set_type(SLIDER s, int t) { -    reinterpret_cast<Fl_Slider*>(s)->type(t); +void free_fl_slider(SLIDER s) { +    delete reinterpret_cast<My_Slider*>(s);  } @@ -101,7 +89,7 @@ float fl_slider_get_slider_size(SLIDER s) {      return reinterpret_cast<Fl_Slider*>(s)->slider_size();  } -void fl_slider_set_slider_size(SLIDER s, float t) { +void fl_slider_set_slider_size(SLIDER s, double t) {      reinterpret_cast<Fl_Slider*>(s)->slider_size(t);  } @@ -110,3 +98,24 @@ int fl_slider_scrollvalue(SLIDER s, int p, int z, int f, int t) {  } + + +void fl_slider_draw(SLIDER s) { +    reinterpret_cast<My_Slider*>(s)->Fl_Slider::draw(); +} + +void fl_slider_draw2(SLIDER s, int x, int y, int w, int h) { +    void (Fl_Slider::*mydraw)(int,int,int,int) = &Friend_Slider::draw; +    (reinterpret_cast<Fl_Slider*>(s)->*mydraw)(x, y, w, h); +} + +int fl_slider_handle(SLIDER s, int e) { +    return reinterpret_cast<My_Slider*>(s)->Fl_Slider::handle(e); +} + +int fl_slider_handle2(SLIDER s, int e, int x, int y, int w, int h) { +    int (Fl_Slider::*myhandle)(int,int,int,int,int) = &Friend_Slider::handle; +    return (reinterpret_cast<Fl_Slider*>(s)->*myhandle)(e, x, y, w, h); +} + + diff --git a/src/c_fl_slider.h b/src/c_fl_slider.h index d00f9af..63c6ac3 100644 --- a/src/c_fl_slider.h +++ b/src/c_fl_slider.h @@ -8,38 +8,28 @@  #define FL_SLIDER_GUARD - -  typedef void* SLIDER; - - -extern "C" void slider_set_draw_hook(SLIDER s, void * d); -extern "C" void fl_slider_draw(SLIDER s); -extern "C" void slider_set_handle_hook(SLIDER s, void * h); -extern "C" int fl_slider_handle(SLIDER s, int e); - - - -  extern "C" SLIDER new_fl_slider(int x, int y, int w, int h, char* label); +extern "C" SLIDER new_fl_slider2(unsigned char k, int x, int y, int w, int h, char * label);  extern "C" void free_fl_slider(SLIDER s); - - -extern "C" int fl_slider_get_type(SLIDER s); -extern "C" void fl_slider_set_type(SLIDER s, int t); - -  extern "C" void fl_slider_set_bounds(SLIDER s, double a, double b);  extern "C" int fl_slider_get_slider(SLIDER s);  extern "C" void fl_slider_set_slider(SLIDER s, int t);  extern "C" float fl_slider_get_slider_size(SLIDER s); -extern "C" void fl_slider_set_slider_size(SLIDER s, float t); +extern "C" void fl_slider_set_slider_size(SLIDER s, double t);  extern "C" int fl_slider_scrollvalue(SLIDER s, int p, int z, int f, int t); +extern "C" void fl_slider_draw(SLIDER s); +extern "C" void fl_slider_draw2(SLIDER s, int x, int y, int w, int h); +extern "C" int fl_slider_handle(SLIDER s, int e); +extern "C" int fl_slider_handle2(SLIDER s, int e, int x, int y, int w, int h); + +  #endif + diff --git a/src/c_fl_spinner.cpp b/src/c_fl_spinner.cpp index 1556ddc..a09ed17 100644 --- a/src/c_fl_spinner.cpp +++ b/src/c_fl_spinner.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Spinner.H>  #include "c_fl_spinner.h" -#include "c_fl_type.h" -class My_Spinner : public Fl_Spinner { -    public: -        using Fl_Spinner::Fl_Spinner; -        friend void spinner_set_draw_hook(SPINNER n, void * d); -        friend void fl_spinner_draw(SPINNER n); -        friend void spinner_set_handle_hook(SPINNER n, void * h); -        friend int fl_spinner_handle(SPINNER 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; -}; +//  Exports from Ada -void My_Spinner::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_Spinner::real_draw() { -    Fl_Spinner::draw(); -} -int My_Spinner::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Spinner::real_handle(int e) { -    return Fl_Spinner::handle(e); -} -void spinner_set_draw_hook(SPINNER n, void * d) { -    reinterpret_cast<My_Spinner*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all hooks and friends -void fl_spinner_draw(SPINNER n) { -    reinterpret_cast<My_Spinner*>(n)->real_draw(); -} +class My_Spinner : public Fl_Spinner { +public: +    using Fl_Spinner::Fl_Spinner; + +    friend void fl_spinner_draw(SPINNER n); +    friend int fl_spinner_handle(SPINNER n, int e); -void spinner_set_handle_hook(SPINNER n, void * h) { -    reinterpret_cast<My_Spinner*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Spinner::draw() { +    widget_draw_hook(this->user_data());  } -int fl_spinner_handle(SPINNER n, int e) { -    return reinterpret_cast<My_Spinner*>(n)->real_handle(e); +int My_Spinner::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  SPINNER new_fl_spinner(int x, int y, int w, int h, char* label) {      My_Spinner *n = new My_Spinner(x, y, w, h, label);      return n; @@ -161,3 +143,22 @@ void fl_spinner_set_value(SPINNER n, double t) {      reinterpret_cast<Fl_Spinner*>(n)->value(t);  } + + + +void fl_spinner_resize(SPINNER n, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Spinner*>(n)->resize(x, y, w, h); +} + + + + +void fl_spinner_draw(SPINNER n) { +    reinterpret_cast<My_Spinner*>(n)->Fl_Spinner::draw(); +} + +int fl_spinner_handle(SPINNER n, int e) { +    return reinterpret_cast<My_Spinner*>(n)->Fl_Spinner::handle(e); +} + + diff --git a/src/c_fl_spinner.h b/src/c_fl_spinner.h index 3fce53c..2c5e97d 100644 --- a/src/c_fl_spinner.h +++ b/src/c_fl_spinner.h @@ -8,27 +8,13 @@  #define FL_SPINNER_GUARD - -  typedef void* SPINNER; - - -extern "C" void spinner_set_draw_hook(SPINNER n, void * d); -extern "C" void fl_spinner_draw(SPINNER n); -extern "C" void spinner_set_handle_hook(SPINNER n, void * h); -extern "C" int fl_spinner_handle(SPINNER n, int e); - - - -  extern "C" SPINNER new_fl_spinner(int x, int y, int w, int h, char* label);  extern "C" void free_fl_spinner(SPINNER n); - -  extern "C" unsigned int fl_spinner_get_color(SPINNER n);  extern "C" void fl_spinner_set_color(SPINNER n, unsigned int t);  extern "C" unsigned int fl_spinner_get_selection_color(SPINNER n); @@ -54,5 +40,13 @@ extern "C" double fl_spinner_get_value(SPINNER n);  extern "C" void fl_spinner_set_value(SPINNER n, double t); +extern "C" void fl_spinner_resize(SPINNER n, int x, int y, int w, int h); + + +extern "C" void fl_spinner_draw(SPINNER n); +extern "C" int fl_spinner_handle(SPINNER n, int e); + +  #endif + diff --git a/src/c_fl_tabs.cpp b/src/c_fl_tabs.cpp index 2973502..a3e8581 100644 --- a/src/c_fl_tabs.cpp +++ b/src/c_fl_tabs.cpp @@ -6,62 +6,54 @@  #include <FL/Fl_Tabs.H>  #include "c_fl_tabs.h" -#include "c_fl_type.h" -class My_Tabs : public Fl_Tabs { -    public: -        using Fl_Tabs::Fl_Tabs; -        friend void tabs_set_draw_hook(TABS t, void * d); -        friend void fl_tabs_draw(TABS t); -        friend void tabs_set_handle_hook(TABS t, void * h); -        friend int fl_tabs_handle(TABS t, 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 + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Tabs : Fl_Tabs { +public: +    using Fl_Tabs::redraw_tabs;  }; -void My_Tabs::draw() { -    (*draw_hook)(this->user_data()); -} -void My_Tabs::real_draw() { -    Fl_Tabs::draw(); -} -int My_Tabs::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Tabs::real_handle(int e) { -    return Fl_Tabs::handle(e); -} +//  Attaching all relevant hooks and friends -void tabs_set_draw_hook(TABS t, void * d) { -    reinterpret_cast<My_Tabs*>(t)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +class My_Tabs : public Fl_Tabs { +public: +    using Fl_Tabs::Fl_Tabs; -void fl_tabs_draw(TABS t) { -    reinterpret_cast<My_Tabs*>(t)->real_draw(); -} +    friend void fl_tabs_draw(TABS t); +    friend int fl_tabs_handle(TABS t, int e); -void tabs_set_handle_hook(TABS t, void * h) { -    reinterpret_cast<My_Tabs*>(t)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Tabs::draw() { +    widget_draw_hook(this->user_data());  } -int fl_tabs_handle(TABS t, int e) { -    return reinterpret_cast<My_Tabs*>(t)->real_handle(e); +int My_Tabs::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  TABS new_fl_tabs(int x, int y, int w, int h, char* label) {      My_Tabs *t = new My_Tabs(x, y, w, h, label);      return t; @@ -101,3 +93,19 @@ void * fl_tabs_which(TABS t, int x, int y) {      return reinterpret_cast<Fl_Tabs*>(t)->which(x,y);  } + + + +void fl_tabs_draw(TABS t) { +    reinterpret_cast<My_Tabs*>(t)->Fl_Tabs::draw(); +} + +void fl_tabs_redraw_tabs(TABS t) { +    (reinterpret_cast<Fl_Tabs*>(t)->*(&Friend_Tabs::redraw_tabs))(); +} + +int fl_tabs_handle(TABS t, int e) { +    return reinterpret_cast<My_Tabs*>(t)->Fl_Tabs::handle(e); +} + + diff --git a/src/c_fl_tabs.h b/src/c_fl_tabs.h index 0b205c7..3226b2d 100644 --- a/src/c_fl_tabs.h +++ b/src/c_fl_tabs.h @@ -8,27 +8,13 @@  #define FL_TABS_GUARD - -  typedef void* TABS; - - -extern "C" void tabs_set_draw_hook(TABS t, void * d); -extern "C" void fl_tabs_draw(TABS t); -extern "C" void tabs_set_handle_hook(TABS t, void * h); -extern "C" int fl_tabs_handle(TABS t, int e); - - - -  extern "C" TABS new_fl_tabs(int x, int y, int w, int h, char* label);  extern "C" void free_fl_tabs(TABS t); - -  extern "C" void fl_tabs_client_area(TABS t, int * x, int * y, int * w, int * h, int i); @@ -39,5 +25,11 @@ extern "C" void fl_tabs_set_value(TABS t, void * w);  extern "C" void * fl_tabs_which(TABS t, int x, int y); +extern "C" void fl_tabs_draw(TABS t); +extern "C" void fl_tabs_redraw_tabs(TABS t); +extern "C" int fl_tabs_handle(TABS t, int e); + +  #endif + diff --git a/src/c_fl_text_display.cpp b/src/c_fl_text_display.cpp index 5b507e9..7323049 100644 --- a/src/c_fl_text_display.cpp +++ b/src/c_fl_text_display.cpp @@ -8,62 +8,44 @@  #include <FL/Fl_Text_Buffer.H>  #include "c_fl_text_display.h"  #include "c_fl_text_buffer.h" -#include "c_fl_type.h" -class My_Text_Display : public Fl_Text_Display { -    public: -        using Fl_Text_Display::Fl_Text_Display; -        friend void text_display_set_draw_hook(TEXTDISPLAY td, void * d); -        friend void fl_text_display_draw(TEXTDISPLAY td); -        friend void text_display_set_handle_hook(TEXTDISPLAY td, void * h); -        friend int fl_text_display_handle(TEXTDISPLAY td, 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_Text_Display::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_Text_Display::real_draw() { -    Fl_Text_Display::draw(); -} -int My_Text_Display::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Text_Display::real_handle(int e) { -    return Fl_Text_Display::handle(e); -} -void text_display_set_draw_hook(TEXTDISPLAY td, void * d) { -    reinterpret_cast<My_Text_Display*>(td)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_text_display_draw(TEXTDISPLAY td) { -    reinterpret_cast<My_Text_Display*>(td)->real_draw(); -} +class My_Text_Display : public Fl_Text_Display { +public: +    using Fl_Text_Display::Fl_Text_Display; + +    friend void fl_text_display_draw(TEXTDISPLAY td); +    friend int fl_text_display_handle(TEXTDISPLAY td, int e); + +    void draw(); +    int handle(int e); +}; -void text_display_set_handle_hook(TEXTDISPLAY td, void * h) { -    reinterpret_cast<My_Text_Display*>(td)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Text_Display::draw() { +    widget_draw_hook(this->user_data());  } -int fl_text_display_handle(TEXTDISPLAY td, int e) { -    return reinterpret_cast<My_Text_Display*>(td)->real_handle(e); +int My_Text_Display::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  TEXTDISPLAY new_fl_text_display(int x, int y, int w, int h, char*  label) {      My_Text_Display *td = new My_Text_Display(x, y, w, h, label);      return td; @@ -91,13 +73,18 @@ void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb) {  void fl_text_display_highlight_data(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len) {      reinterpret_cast<Fl_Text_Display*>(td)->highlight_data -        (reinterpret_cast<Fl_Text_Buffer*>(tb), reinterpret_cast<Fl_Text_Display::Style_Table_Entry*>(st), len, 0, 0, 0); +       (reinterpret_cast<Fl_Text_Buffer*>(tb), +        reinterpret_cast<Fl_Text_Display::Style_Table_Entry*>(st), +        len, 0, 0, 0);  } -void fl_text_display_highlight_data2(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len, char us, void * cb, void * a) { +void fl_text_display_highlight_data2(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len, +    char us, void * cb, void * a) +{      reinterpret_cast<Fl_Text_Display*>(td)->highlight_data -       (reinterpret_cast<Fl_Text_Buffer*>(tb), reinterpret_cast<Fl_Text_Display::Style_Table_Entry*>(st), len, -        us, reinterpret_cast<Fl_Text_Display::Unfinished_Style_Cb>(cb), a); +       (reinterpret_cast<Fl_Text_Buffer*>(tb), +        reinterpret_cast<Fl_Text_Display::Style_Table_Entry*>(st), +        len, us, reinterpret_cast<Fl_Text_Display::Unfinished_Style_Cb>(cb), a);  } @@ -339,3 +326,14 @@ void fl_text_display_redisplay_range(TEXTDISPLAY td, int s, int f) {  } + + +void fl_text_display_draw(TEXTDISPLAY td) { +    reinterpret_cast<My_Text_Display*>(td)->Fl_Text_Display::draw(); +} + +int fl_text_display_handle(TEXTDISPLAY td, int e) { +    return reinterpret_cast<My_Text_Display*>(td)->Fl_Text_Display::handle(e); +} + + diff --git a/src/c_fl_text_display.h b/src/c_fl_text_display.h index ceb7f64..ece9a6a 100644 --- a/src/c_fl_text_display.h +++ b/src/c_fl_text_display.h @@ -10,33 +10,20 @@  #include "c_fl_text_buffer.h" - -  typedef void* TEXTDISPLAY; - - -extern "C" void text_display_set_draw_hook(TEXTDISPLAY td, void * d); -extern "C" void fl_text_display_draw(TEXTDISPLAY td); -extern "C" void text_display_set_handle_hook(TEXTDISPLAY td, void * h); -extern "C" int fl_text_display_handle(TEXTDISPLAY td, int e); - - - -  extern "C" TEXTDISPLAY new_fl_text_display(int x, int y, int w, int h, char* label);  extern "C" void free_fl_text_display(TEXTDISPLAY td); - -  extern "C" TEXTBUFFER fl_text_display_get_buffer(TEXTDISPLAY td);  extern "C" void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb);  extern "C" void fl_text_display_highlight_data(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len); -extern "C" void fl_text_display_highlight_data2(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len, char us, void * cb, void * a); +extern "C" void fl_text_display_highlight_data2(TEXTDISPLAY td, TEXTBUFFER tb, void * st, int len, +    char us, void * cb, void * a);  extern "C" double fl_text_display_col_to_x(TEXTDISPLAY td, double c); @@ -111,5 +98,10 @@ extern "C" void fl_text_display_set_scrollbar_width(TEXTDISPLAY td, int w);  extern "C" void fl_text_display_redisplay_range(TEXTDISPLAY td, int s, int f); +extern "C" void fl_text_display_draw(TEXTDISPLAY td); +extern "C" int fl_text_display_handle(TEXTDISPLAY td, int e); + +  #endif + diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp index 41729bd..8c33afa 100644 --- a/src/c_fl_text_editor.cpp +++ b/src/c_fl_text_editor.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Text_Editor.H>  #include "c_fl_text_editor.h" -#include "c_fl_type.h" -class My_Text_Editor : public Fl_Text_Editor { -    public: -        using Fl_Text_Editor::Fl_Text_Editor; -        friend void text_editor_set_draw_hook(TEXTEDITOR te, void * d); -        friend void fl_text_editor_draw(TEXTEDITOR te); -        friend void text_editor_set_handle_hook(TEXTEDITOR te, void * h); -        friend int fl_text_editor_handle(TEXTEDITOR te, 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_Text_Editor::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_Text_Editor::real_draw() { -    Fl_Text_Editor::draw(); -} -int My_Text_Editor::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Text_Editor::real_handle(int e) { -    return Fl_Text_Editor::handle(e); -} -void text_editor_set_draw_hook(TEXTEDITOR te, void * d) { -    reinterpret_cast<My_Text_Editor*>(te)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_text_editor_draw(TEXTEDITOR te) { -    reinterpret_cast<My_Text_Editor*>(te)->real_draw(); -} +class My_Text_Editor : public Fl_Text_Editor { +public: +    using Fl_Text_Editor::Fl_Text_Editor; + +    friend void fl_text_editor_draw(TEXTEDITOR te); +    friend int fl_text_editor_handle(TEXTEDITOR te, int e); + +    void draw(); +    int handle(int e); +}; -void text_editor_set_handle_hook(TEXTEDITOR te, void * h) { -    reinterpret_cast<My_Text_Editor*>(te)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Text_Editor::draw() { +    widget_draw_hook(this->user_data());  } -int fl_text_editor_handle(TEXTEDITOR te, int e) { -    return reinterpret_cast<My_Text_Editor*>(te)->real_handle(e); +int My_Text_Editor::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label) {      My_Text_Editor *te = new My_Text_Editor(x, y, w, h, label);      return te; @@ -305,3 +287,15 @@ void fl_text_editor_set_insert_mode(TEXTEDITOR te, int i) {  //    reinterpret_cast<Fl_Text_Editor*>(te)->tab_nav(t);  //} + + + +void fl_text_editor_draw(TEXTEDITOR te) { +    reinterpret_cast<My_Text_Editor*>(te)->Fl_Text_Editor::draw(); +} + +int fl_text_editor_handle(TEXTEDITOR te, int e) { +    return reinterpret_cast<My_Text_Editor*>(te)->Fl_Text_Editor::handle(e); +} + + diff --git a/src/c_fl_text_editor.h b/src/c_fl_text_editor.h index 80bd4ff..305b04b 100644 --- a/src/c_fl_text_editor.h +++ b/src/c_fl_text_editor.h @@ -8,27 +8,13 @@  #define FL_TEXT_EDITOR_GUARD - -  typedef void* TEXTEDITOR; - - -extern "C" void text_editor_set_draw_hook(TEXTEDITOR te, void * d); -extern "C" void fl_text_editor_draw(TEXTEDITOR te); -extern "C" void text_editor_set_handle_hook(TEXTEDITOR te, void * h); -extern "C" int fl_text_editor_handle(TEXTEDITOR te, int e); - - - -  extern "C" TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label);  extern "C" void free_fl_text_editor(TEXTEDITOR te); - -  extern "C" void fl_text_editor_default(TEXTEDITOR te, int k); @@ -100,5 +86,10 @@ extern "C" void fl_text_editor_set_insert_mode(TEXTEDITOR te, int i);  //extern "C" void fl_text_editor_set_tab_nav(TEXTEDITOR te, int t); +extern "C" void fl_text_editor_draw(TEXTEDITOR te); +extern "C" int fl_text_editor_handle(TEXTEDITOR te, int e); + +  #endif + diff --git a/src/c_fl_tile.cpp b/src/c_fl_tile.cpp index 3214502..2708d55 100644 --- a/src/c_fl_tile.cpp +++ b/src/c_fl_tile.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Tile.H>  #include "c_fl_tile.h" -#include "c_fl_type.h" -class My_Tile : public Fl_Tile { -    public: -        using Fl_Tile::Fl_Tile; -        friend void tile_set_draw_hook(TILE n, void * d); -        friend void fl_tile_draw(TILE n); -        friend void tile_set_handle_hook(TILE n, void * h); -        friend int fl_tile_handle(TILE 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; -}; +//  Exports from Ada -void My_Tile::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_Tile::real_draw() { -    Fl_Tile::draw(); -} -int My_Tile::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Tile::real_handle(int e) { -    return Fl_Tile::handle(e); -} -void tile_set_draw_hook(TILE n, void * d) { -    reinterpret_cast<My_Tile*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_tile_draw(TILE n) { -    reinterpret_cast<My_Tile*>(n)->real_draw(); -} +class My_Tile : public Fl_Tile { +public: +    using Fl_Tile::Fl_Tile; + +    friend void fl_tile_draw(TILE n); +    friend int fl_tile_handle(TILE n, int e); + +    void draw(); +    int handle(int e); +}; -void tile_set_handle_hook(TILE n, void * h) { -    reinterpret_cast<My_Tile*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Tile::draw() { +    widget_draw_hook(this->user_data());  } -int fl_tile_handle(TILE n, int e) { -    return reinterpret_cast<My_Tile*>(n)->real_handle(e); +int My_Tile::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  TILE new_fl_tile(int x, int y, int w, int h, char* label) {      My_Tile *b = new My_Tile(x, y, w, h, label);      return b; @@ -78,4 +60,19 @@ void fl_tile_position(TILE t, int ox, int oy, int nx, int ny) {      reinterpret_cast<Fl_Tile*>(t)->position(ox,oy,nx,ny);  } +void fl_tile_resize(TILE t, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Tile*>(t)->resize(x, y, w, h); +} + + + + +void fl_tile_draw(TILE n) { +    reinterpret_cast<My_Tile*>(n)->Fl_Tile::draw(); +} + +int fl_tile_handle(TILE n, int e) { +    return reinterpret_cast<My_Tile*>(n)->Fl_Tile::handle(e); +} + diff --git a/src/c_fl_tile.h b/src/c_fl_tile.h index 773375f..3254558 100644 --- a/src/c_fl_tile.h +++ b/src/c_fl_tile.h @@ -8,29 +8,21 @@  #define FL_TILE_GUARD - -  typedef void* TILE; - - -extern "C" void tile_set_draw_hook(TILE n, void * d); -extern "C" void fl_tile_draw(TILE n); -extern "C" void tile_set_handle_hook(TILE n, void * h); -extern "C" int fl_tile_handle(TILE n, int e); - - - -  extern "C" TILE new_fl_tile(int x, int y, int w, int h, char * label);  extern "C" void free_fl_tile(TILE t); +extern "C" void fl_tile_position(TILE t, int ox, int oy, int nx, int ny); +extern "C" void fl_tile_resize(TILE t, int x, int y, int w, int h); -extern "C" void fl_tile_position(TILE t, int ox, int oy, int nx, int ny); +extern "C" void fl_tile_draw(TILE n); +extern "C" int fl_tile_handle(TILE n, int e);  #endif + diff --git a/src/c_fl_toggle_button.cpp b/src/c_fl_toggle_button.cpp index a6195af..631fc21 100644 --- a/src/c_fl_toggle_button.cpp +++ b/src/c_fl_toggle_button.cpp @@ -6,62 +6,44 @@  #include <FL/Fl_Toggle_Button.H>  #include "c_fl_toggle_button.h" -#include "c_fl_type.h" -class My_Toggle_Button : public Fl_Toggle_Button { -    public: -        using Fl_Toggle_Button::Fl_Toggle_Button; -        friend void toggle_button_set_draw_hook(TOGGLEBUTTON b, void * d); -        friend void fl_toggle_button_draw(TOGGLEBUTTON b); -        friend void toggle_button_set_handle_hook(TOGGLEBUTTON b, void * h); -        friend int fl_toggle_button_handle(TOGGLEBUTTON b, 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_Toggle_Button::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_Toggle_Button::real_draw() { -    Fl_Toggle_Button::draw(); -} -int My_Toggle_Button::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Toggle_Button::real_handle(int e) { -    return Fl_Toggle_Button::handle(e); -} -void toggle_button_set_draw_hook(TOGGLEBUTTON b, void * d) { -    reinterpret_cast<My_Toggle_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_toggle_button_draw(TOGGLEBUTTON b) { -    reinterpret_cast<My_Toggle_Button*>(b)->real_draw(); -} +class My_Toggle_Button : public Fl_Toggle_Button { +public: +    using Fl_Toggle_Button::Fl_Toggle_Button; + +    friend void fl_toggle_button_draw(TOGGLEBUTTON b); +    friend int fl_toggle_button_handle(TOGGLEBUTTON b, int e); + +    void draw(); +    int handle(int e); +}; -void toggle_button_set_handle_hook(TOGGLEBUTTON b, void * h) { -    reinterpret_cast<My_Toggle_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Toggle_Button::draw() { +    widget_draw_hook(this->user_data());  } -int fl_toggle_button_handle(TOGGLEBUTTON b, int e) { -    return reinterpret_cast<My_Toggle_Button*>(b)->real_handle(e); +int My_Toggle_Button::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  TOGGLEBUTTON new_fl_toggle_button(int x, int y, int w, int h, char* label) {      My_Toggle_Button *b = new My_Toggle_Button(x, y, w, h, label);      return b; @@ -71,3 +53,15 @@ void free_fl_toggle_button(TOGGLEBUTTON b) {      delete reinterpret_cast<My_Toggle_Button*>(b);  } + + + +void fl_toggle_button_draw(TOGGLEBUTTON b) { +    reinterpret_cast<My_Toggle_Button*>(b)->Fl_Toggle_Button::draw(); +} + +int fl_toggle_button_handle(TOGGLEBUTTON b, int e) { +    return reinterpret_cast<My_Toggle_Button*>(b)->Fl_Toggle_Button::handle(e); +} + + diff --git a/src/c_fl_toggle_button.h b/src/c_fl_toggle_button.h index a8a3379..bdb86b1 100644 --- a/src/c_fl_toggle_button.h +++ b/src/c_fl_toggle_button.h @@ -8,24 +8,17 @@  #define FL_TOGGLE_BUTTON_GUARD - -  typedef void* TOGGLEBUTTON; +extern "C" TOGGLEBUTTON new_fl_toggle_button(int x, int y, int w, int h, char* label); +extern "C" void free_fl_toggle_button(TOGGLEBUTTON b); -extern "C" void toggle_button_set_draw_hook(TOGGLEBUTTON b, void * d);  extern "C" void fl_toggle_button_draw(TOGGLEBUTTON b); -extern "C" void toggle_button_set_handle_hook(TOGGLEBUTTON b, void * h);  extern "C" int fl_toggle_button_handle(TOGGLEBUTTON b, int e); - - -extern "C" TOGGLEBUTTON new_fl_toggle_button(int x, int y, int w, int h, char* label); -extern "C" void free_fl_toggle_button(TOGGLEBUTTON b); - -  #endif + diff --git a/src/c_fl_type.h b/src/c_fl_type.h deleted file mode 100644 index 0d449c7..0000000 --- a/src/c_fl_type.h +++ /dev/null @@ -1,20 +0,0 @@ - - -//  Programmed by Jedidiah Barber -//  Released into the public domain - - -#ifndef FL_TYPE_GUARD -#define FL_TYPE_GUARD - - -typedef void (d_hook)(void*); -typedef d_hook* d_hook_p; - - -typedef int (h_hook)(void*,int); -typedef h_hook* h_hook_p; - - -#endif - diff --git a/src/c_fl_valuator.cpp b/src/c_fl_valuator.cpp index 3ee95c5..f70e6dd 100644 --- a/src/c_fl_valuator.cpp +++ b/src/c_fl_valuator.cpp @@ -6,53 +6,55 @@  #include <FL/Fl_Valuator.H>  #include "c_fl_valuator.h" -#include "c_fl_type.h" -class My_Valuator : public Fl_Valuator { -    public: -        using Fl_Valuator::Fl_Valuator; -        friend void valuator_set_draw_hook(VALUATOR v, void * d); -        friend void valuator_set_handle_hook(VALUATOR v, void * h); -        friend int fl_valuator_handle(VALUATOR v, int e); -        friend VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label); -    protected: -        void draw(); -        int handle(int e); -        int real_handle(int e); -        d_hook_p draw_hook; -        h_hook_p handle_hook; +//  Exports from Ada + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +//  Non-friend protected access + +class Friend_Valuator : Fl_Valuator { +public: +    using Fl_Valuator::value_damage;  }; -void My_Valuator::draw() { -    (*draw_hook)(this->user_data()); -} -int My_Valuator::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Valuator::real_handle(int e) { -    return Fl_Valuator::handle(e); -} -void valuator_set_draw_hook(VALUATOR v, void * d) { -    reinterpret_cast<My_Valuator*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends + +class My_Valuator : public Fl_Valuator { +public: +    using Fl_Valuator::Fl_Valuator; +    friend VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label); -void valuator_set_handle_hook(VALUATOR v, void * h) { -    reinterpret_cast<My_Valuator*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h); +    friend void fl_valuator_draw(VALUATOR v); +    friend int fl_valuator_handle(VALUATOR v, int e); + +    void draw(); +    int handle(int e); +}; + +void My_Valuator::draw() { +    widget_draw_hook(this->user_data());  } -int fl_valuator_handle(VALUATOR v, int e) { -    return reinterpret_cast<My_Valuator*>(v)->real_handle(e); +int My_Valuator::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label) {      My_Valuator *v = new My_Valuator(x, y, w, h, label);      return v; @@ -100,10 +102,18 @@ double fl_valuator_get_step(VALUATOR v) {      return reinterpret_cast<Fl_Valuator*>(v)->step();  } -void fl_valuator_set_step(VALUATOR v, double t) { +void fl_valuator_set_step_top(VALUATOR v, double t) {      reinterpret_cast<Fl_Valuator*>(v)->step(t);  } +void fl_valuator_set_step_bottom(VALUATOR v, int b) { +    reinterpret_cast<Fl_Valuator*>(v)->step(b); +} + +void fl_valuator_set_step(VALUATOR v, double t, int b) { +    reinterpret_cast<Fl_Valuator*>(v)->step(t, b); +} +  double fl_valuator_get_value(VALUATOR v) {      return reinterpret_cast<Fl_Valuator*>(v)->value();  } @@ -124,3 +134,23 @@ void fl_valuator_range(VALUATOR v, double a, double b) {      reinterpret_cast<Fl_Valuator*>(v)->range(a,b);  } + + + +void fl_valuator_value_damage(VALUATOR v) { +    (reinterpret_cast<Fl_Valuator*>(v)->*(&Friend_Valuator::value_damage))(); +} + +void fl_valuator_draw(VALUATOR v) { +    //  The Fl_Valuator draw method doesn't technically exist, so... +    (void)(v); +    //  It is more convenient for this function to exist, however, +    //  even though it will likely never be called, because it simplifies +    //  and makes uniform the implementation of the Ada Valuator Draw subprogram. +} + +int fl_valuator_handle(VALUATOR v, int e) { +    return reinterpret_cast<My_Valuator*>(v)->Fl_Valuator::handle(e); +} + + diff --git a/src/c_fl_valuator.h b/src/c_fl_valuator.h index 7bbb831..e3c6959 100644 --- a/src/c_fl_valuator.h +++ b/src/c_fl_valuator.h @@ -8,39 +8,26 @@  #define FL_VALUATOR_GUARD - -  typedef void* VALUATOR; - - -extern "C" void valuator_set_draw_hook(VALUATOR v, void * d); -extern "C" void valuator_set_handle_hook(VALUATOR v, void * h); -extern "C" int fl_valuator_handle(VALUATOR v, int e); - - - -  extern "C" VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label);  extern "C" void free_fl_valuator(VALUATOR v); - -  extern "C" double fl_valuator_clamp(VALUATOR v, double a);  extern "C" double fl_valuator_round(VALUATOR v, double a);  extern "C" double fl_valuator_increment(VALUATOR v, double a, int s); - -  extern "C" double fl_valuator_get_minimum(VALUATOR v);  extern "C" void fl_valuator_set_minimum(VALUATOR v, double t);  extern "C" double fl_valuator_get_maximum(VALUATOR v);  extern "C" void fl_valuator_set_maximum(VALUATOR v, double t);  extern "C" double fl_valuator_get_step(VALUATOR v); -extern "C" void fl_valuator_set_step(VALUATOR v, double t); +extern "C" void fl_valuator_set_step_top(VALUATOR v, double t); +extern "C" void fl_valuator_set_step_bottom(VALUATOR v, int b); +extern "C" void fl_valuator_set_step(VALUATOR v, double t, int b);  extern "C" double fl_valuator_get_value(VALUATOR v);  extern "C" void fl_valuator_set_value(VALUATOR v, double t);  extern "C" void fl_valuator_bounds(VALUATOR v, double a, double b); @@ -48,5 +35,11 @@ extern "C" void fl_valuator_precision(VALUATOR v, int s);  extern "C" void fl_valuator_range(VALUATOR v, double a, double b); +extern "C" void fl_valuator_value_damage(VALUATOR v); +extern "C" void fl_valuator_draw(VALUATOR v); +extern "C" int fl_valuator_handle(VALUATOR v, int e); + +  #endif + diff --git a/src/c_fl_value_input.cpp b/src/c_fl_value_input.cpp index c2910c2..37273a7 100644 --- a/src/c_fl_value_input.cpp +++ b/src/c_fl_value_input.cpp @@ -6,136 +6,136 @@  #include <FL/Fl_Value_Input.H>  #include "c_fl_value_input.h" -#include "c_fl_type.h" -class My_Value_Input : public Fl_Value_Input { -    public: -        using Fl_Value_Input::Fl_Value_Input; -        friend void value_input_set_draw_hook(VALUE_INPUT a, void * d); -        friend void fl_value_input_draw(VALUE_INPUT a); -        friend void value_input_set_handle_hook(VALUE_INPUT a, void * h); -        friend int fl_value_input_handle(VALUE_INPUT a, 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_Value_Input::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_Value_Input::real_draw() { -    Fl_Value_Input::draw(); -} -int My_Value_Input::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Value_Input::real_handle(int e) { -    return Fl_Value_Input::handle(e); -} -void value_input_set_draw_hook(VALUE_INPUT a, void * d) { -    reinterpret_cast<My_Value_Input*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_value_input_draw(VALUE_INPUT a) { -    reinterpret_cast<My_Value_Input*>(a)->real_draw(); -} +class My_Value_Input : public Fl_Value_Input { +public: +    using Fl_Value_Input::Fl_Value_Input; + +    friend void fl_value_input_draw(VALUEINPUT a); +    friend int fl_value_input_handle(VALUEINPUT a, int e); -void value_input_set_handle_hook(VALUE_INPUT a, void * h) { -    reinterpret_cast<My_Value_Input*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Value_Input::draw() { +    widget_draw_hook(this->user_data());  } -int fl_value_input_handle(VALUE_INPUT a, int e) { -    return reinterpret_cast<My_Value_Input*>(a)->real_handle(e); +int My_Value_Input::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -VALUE_INPUT new_fl_value_input(int x, int y, int w, int h, char* label) { +//  Flattened C API + +VALUEINPUT new_fl_value_input(int x, int y, int w, int h, char* label) {      My_Value_Input *a = new My_Value_Input(x, y, w, h, label);      return a;  } -void free_fl_value_input(VALUE_INPUT a) { +void free_fl_value_input(VALUEINPUT a) {      delete reinterpret_cast<My_Value_Input*>(a);  } -void * fl_value_input_get_input(VALUE_INPUT v) { +void * fl_value_input_get_input(VALUEINPUT v) {      return &(reinterpret_cast<Fl_Value_Input*>(v)->input);  } -unsigned int fl_value_input_get_cursor_color(VALUE_INPUT v) { +unsigned int fl_value_input_get_cursor_color(VALUEINPUT v) {      return reinterpret_cast<Fl_Value_Input*>(v)->cursor_color();  } -void fl_value_input_set_cursor_color(VALUE_INPUT v, unsigned int c) { +void fl_value_input_set_cursor_color(VALUEINPUT v, unsigned int c) {      reinterpret_cast<Fl_Value_Input*>(v)->cursor_color(c);  } -int fl_value_input_get_shortcut(VALUE_INPUT v) { +int fl_value_input_get_shortcut(VALUEINPUT v) {      return reinterpret_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut();  } -void fl_value_input_set_shortcut(VALUE_INPUT v, int k) { +void fl_value_input_set_shortcut(VALUEINPUT v, int k) {      reinterpret_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut(k);  } -int fl_value_input_is_soft(VALUE_INPUT a) { +int fl_value_input_is_soft(VALUEINPUT a) {      return reinterpret_cast<Fl_Value_Input*>(a)->soft();  } -void fl_value_input_set_soft(VALUE_INPUT a, int t) { +void fl_value_input_set_soft(VALUEINPUT a, int t) {      reinterpret_cast<Fl_Value_Input*>(a)->soft(t);  } -unsigned int fl_value_input_get_text_color(VALUE_INPUT v) { +unsigned int fl_value_input_get_text_color(VALUEINPUT v) {      return reinterpret_cast<Fl_Value_Input*>(v)->textcolor();  } -void fl_value_input_set_text_color(VALUE_INPUT v, unsigned int c) { +void fl_value_input_set_text_color(VALUEINPUT v, unsigned int c) {      reinterpret_cast<Fl_Value_Input*>(v)->textcolor(static_cast<Fl_Color>(c));  } -int fl_value_input_get_text_font(VALUE_INPUT v) { +int fl_value_input_get_text_font(VALUEINPUT v) {      return reinterpret_cast<Fl_Value_Input*>(v)->textfont();  } -void fl_value_input_set_text_font(VALUE_INPUT v, int f) { +void fl_value_input_set_text_font(VALUEINPUT v, int f) {      reinterpret_cast<Fl_Value_Input*>(v)->textfont(static_cast<Fl_Font>(f));  } -int fl_value_input_get_text_size(VALUE_INPUT v) { +int fl_value_input_get_text_size(VALUEINPUT v) {      return reinterpret_cast<Fl_Value_Input*>(v)->textsize();  } -void fl_value_input_set_text_size(VALUE_INPUT v, int s) { +void fl_value_input_set_text_size(VALUEINPUT v, int s) {      reinterpret_cast<Fl_Value_Input*>(v)->textsize(static_cast<Fl_Fontsize>(s));  } + + +void fl_value_input_resize(VALUEINPUT v, int x, int y, int w, int h) { +    reinterpret_cast<Fl_Value_Input*>(v)->resize(x, y, w, h); +} + + + + +void fl_value_input_draw(VALUEINPUT a) { +    reinterpret_cast<My_Value_Input*>(a)->Fl_Value_Input::draw(); +} + +int fl_value_input_handle(VALUEINPUT a, int e) { +    return reinterpret_cast<My_Value_Input*>(a)->Fl_Value_Input::handle(e); +} + + diff --git a/src/c_fl_value_input.h b/src/c_fl_value_input.h index 0111207..f9eeff2 100644 --- a/src/c_fl_value_input.h +++ b/src/c_fl_value_input.h @@ -8,49 +8,43 @@  #define FL_VALUE_INPUT_GUARD +typedef void* VALUEINPUT; -typedef void* VALUE_INPUT; +extern "C" VALUEINPUT new_fl_value_input(int x, int y, int w, int h, char* label); +extern "C" void free_fl_value_input(VALUEINPUT a); +extern "C" void * fl_value_input_get_input(VALUEINPUT v); -extern "C" void value_input_set_draw_hook(VALUE_INPUT a, void * d); -extern "C" void fl_value_input_draw(VALUE_INPUT a); -extern "C" void value_input_set_handle_hook(VALUE_INPUT a, void * h); -extern "C" int fl_value_input_handle(VALUE_INPUT a, int e); +extern "C" unsigned int fl_value_input_get_cursor_color(VALUEINPUT v); +extern "C" void fl_value_input_set_cursor_color(VALUEINPUT v, unsigned int c); +extern "C" int fl_value_input_get_shortcut(VALUEINPUT v); +extern "C" void fl_value_input_set_shortcut(VALUEINPUT v, int k); -extern "C" VALUE_INPUT new_fl_value_input(int x, int y, int w, int h, char* label); -extern "C" void free_fl_value_input(VALUE_INPUT a); +extern "C" int fl_value_input_is_soft(VALUEINPUT a); +extern "C" void fl_value_input_set_soft(VALUEINPUT a, int t); +extern "C" unsigned int fl_value_input_get_text_color(VALUEINPUT v); +extern "C" void fl_value_input_set_text_color(VALUEINPUT v, unsigned int c); +extern "C" int fl_value_input_get_text_font(VALUEINPUT v); +extern "C" void fl_value_input_set_text_font(VALUEINPUT v, int f); +extern "C" int fl_value_input_get_text_size(VALUEINPUT v); +extern "C" void fl_value_input_set_text_size(VALUEINPUT v, int s); -extern "C" void * fl_value_input_get_input(VALUE_INPUT v); +extern "C" void fl_value_input_resize(VALUEINPUT v, int x, int y, int w, int h); -extern "C" unsigned int fl_value_input_get_cursor_color(VALUE_INPUT v); -extern "C" void fl_value_input_set_cursor_color(VALUE_INPUT v, unsigned int c); - - -extern "C" int fl_value_input_get_shortcut(VALUE_INPUT v); -extern "C" void fl_value_input_set_shortcut(VALUE_INPUT v, int k); - - -extern "C" int fl_value_input_is_soft(VALUE_INPUT a); -extern "C" void fl_value_input_set_soft(VALUE_INPUT a, int t); - - -extern "C" unsigned int fl_value_input_get_text_color(VALUE_INPUT v); -extern "C" void fl_value_input_set_text_color(VALUE_INPUT v, unsigned int c); -extern "C" int fl_value_input_get_text_font(VALUE_INPUT v); -extern "C" void fl_value_input_set_text_font(VALUE_INPUT v, int f); -extern "C" int fl_value_input_get_text_size(VALUE_INPUT v); -extern "C" void fl_value_input_set_text_size(VALUE_INPUT v, int s); +extern "C" void fl_value_input_draw(VALUEINPUT a); +extern "C" int fl_value_input_handle(VALUEINPUT a, int e);  #endif + diff --git a/src/c_fl_value_output.cpp b/src/c_fl_value_output.cpp index 3faa25f..b7cc1d6 100644 --- a/src/c_fl_value_output.cpp +++ b/src/c_fl_value_output.cpp @@ -6,107 +6,100 @@  #include <FL/Fl_Value_Output.H>  #include "c_fl_value_output.h" -#include "c_fl_type.h" -class My_Value_Output : public Fl_Value_Output { -    public: -        using Fl_Value_Output::Fl_Value_Output; -        friend void value_output_set_draw_hook(VALUE_OUTPUT a, void * d); -        friend void fl_value_output_draw(VALUE_OUTPUT a); -        friend void value_output_set_handle_hook(VALUE_OUTPUT a, void * h); -        friend int fl_value_output_handle(VALUE_OUTPUT a, 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_Value_Output::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_Value_Output::real_draw() { -    Fl_Value_Output::draw(); -} -int My_Value_Output::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Value_Output::real_handle(int e) { -    return Fl_Value_Output::handle(e); -} -void value_output_set_draw_hook(VALUE_OUTPUT a, void * d) { -    reinterpret_cast<My_Value_Output*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_value_output_draw(VALUE_OUTPUT a) { -    reinterpret_cast<My_Value_Output*>(a)->real_draw(); -} +class My_Value_Output : public Fl_Value_Output { +public: +    using Fl_Value_Output::Fl_Value_Output; + +    friend void fl_value_output_draw(VALUEOUTPUT a); +    friend int fl_value_output_handle(VALUEOUTPUT a, int e); -void value_output_set_handle_hook(VALUE_OUTPUT a, void * h) { -    reinterpret_cast<My_Value_Output*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Value_Output::draw() { +    widget_draw_hook(this->user_data());  } -int fl_value_output_handle(VALUE_OUTPUT a, int e) { -    return reinterpret_cast<My_Value_Output*>(a)->real_handle(e); +int My_Value_Output::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -VALUE_OUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) { +//  Flattened C API + +VALUEOUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) {      My_Value_Output *a = new My_Value_Output(x, y, w, h, label);      return a;  } -void free_fl_value_output(VALUE_OUTPUT a) { +void free_fl_value_output(VALUEOUTPUT a) {      delete reinterpret_cast<My_Value_Output*>(a);  } -int fl_value_output_is_soft(VALUE_OUTPUT a) { +int fl_value_output_is_soft(VALUEOUTPUT a) {      return reinterpret_cast<Fl_Value_Output*>(a)->soft();  } -void fl_value_output_set_soft(VALUE_OUTPUT a, int t) { +void fl_value_output_set_soft(VALUEOUTPUT a, int t) {      reinterpret_cast<Fl_Value_Output*>(a)->soft(t);  } -unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v) { +unsigned int fl_value_output_get_text_color(VALUEOUTPUT v) {      return reinterpret_cast<Fl_Value_Output*>(v)->textcolor();  } -void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c) { +void fl_value_output_set_text_color(VALUEOUTPUT v, unsigned int c) {      reinterpret_cast<Fl_Value_Output*>(v)->textcolor(static_cast<Fl_Color>(c));  } -int fl_value_output_get_text_font(VALUE_OUTPUT v) { +int fl_value_output_get_text_font(VALUEOUTPUT v) {      return reinterpret_cast<Fl_Value_Output*>(v)->textfont();  } -void fl_value_output_set_text_font(VALUE_OUTPUT v, int f) { +void fl_value_output_set_text_font(VALUEOUTPUT v, int f) {      reinterpret_cast<Fl_Value_Output*>(v)->textfont(static_cast<Fl_Font>(f));  } -int fl_value_output_get_text_size(VALUE_OUTPUT v) { +int fl_value_output_get_text_size(VALUEOUTPUT v) {      return reinterpret_cast<Fl_Value_Output*>(v)->textsize();  } -void fl_value_output_set_text_size(VALUE_OUTPUT v, int s) { +void fl_value_output_set_text_size(VALUEOUTPUT v, int s) {      reinterpret_cast<Fl_Value_Output*>(v)->textsize(static_cast<Fl_Fontsize>(s));  } + + +void fl_value_output_draw(VALUEOUTPUT a) { +    reinterpret_cast<My_Value_Output*>(a)->Fl_Value_Output::draw(); +} + +int fl_value_output_handle(VALUEOUTPUT a, int e) { +    return reinterpret_cast<My_Value_Output*>(a)->Fl_Value_Output::handle(e); +} + + diff --git a/src/c_fl_value_output.h b/src/c_fl_value_output.h index f835674..e333ff8 100644 --- a/src/c_fl_value_output.h +++ b/src/c_fl_value_output.h @@ -8,38 +8,29 @@  #define FL_VALUE_OUTPUT_GUARD +typedef void* VALUEOUTPUT; -typedef void* VALUE_OUTPUT; +extern "C" VALUEOUTPUT new_fl_value_output(int x, int y, int w, int h, char* label); +extern "C" void free_fl_value_output(VALUEOUTPUT a); +extern "C" int fl_value_output_is_soft(VALUEOUTPUT a); +extern "C" void fl_value_output_set_soft(VALUEOUTPUT a, int t); -extern "C" void value_output_set_draw_hook(VALUE_OUTPUT a, void * d); -extern "C" void fl_value_output_draw(VALUE_OUTPUT a); -extern "C" void value_output_set_handle_hook(VALUE_OUTPUT a, void * h); -extern "C" int fl_value_output_handle(VALUE_OUTPUT a, int e); +extern "C" unsigned int fl_value_output_get_text_color(VALUEOUTPUT v); +extern "C" void fl_value_output_set_text_color(VALUEOUTPUT v, unsigned int c); +extern "C" int fl_value_output_get_text_font(VALUEOUTPUT v); +extern "C" void fl_value_output_set_text_font(VALUEOUTPUT v, int f); +extern "C" int fl_value_output_get_text_size(VALUEOUTPUT v); +extern "C" void fl_value_output_set_text_size(VALUEOUTPUT v, int s); - - -extern "C" VALUE_OUTPUT new_fl_value_output(int x, int y, int w, int h, char* label); -extern "C" void free_fl_value_output(VALUE_OUTPUT a); - - - - -extern "C" int fl_value_output_is_soft(VALUE_OUTPUT a); -extern "C" void fl_value_output_set_soft(VALUE_OUTPUT a, int t); - - -extern "C" unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v); -extern "C" void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c); -extern "C" int fl_value_output_get_text_font(VALUE_OUTPUT v); -extern "C" void fl_value_output_set_text_font(VALUE_OUTPUT v, int f); -extern "C" int fl_value_output_get_text_size(VALUE_OUTPUT v); -extern "C" void fl_value_output_set_text_size(VALUE_OUTPUT v, int s); +extern "C" void fl_value_output_draw(VALUEOUTPUT a); +extern "C" int fl_value_output_handle(VALUEOUTPUT a, int e);  #endif + diff --git a/src/c_fl_value_slider.cpp b/src/c_fl_value_slider.cpp index 5fd9d02..b79d7f5 100644 --- a/src/c_fl_value_slider.cpp +++ b/src/c_fl_value_slider.cpp @@ -6,95 +6,89 @@  #include <FL/Fl_Value_Slider.H>  #include "c_fl_value_slider.h" -#include "c_fl_type.h" -class My_Value_Slider : public Fl_Value_Slider { -    public: -        using Fl_Value_Slider::Fl_Value_Slider; -        friend void value_slider_set_draw_hook(VALUE_SLIDER s, void * d); -        friend void fl_value_slider_draw(VALUE_SLIDER s); -        friend void value_slider_set_handle_hook(VALUE_SLIDER s, void * h); -        friend int fl_value_slider_handle(VALUE_SLIDER 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_Value_Slider::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_Value_Slider::real_draw() { -    Fl_Value_Slider::draw(); -} -int My_Value_Slider::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Value_Slider::real_handle(int e) { -    return Fl_Value_Slider::handle(e); -} -void value_slider_set_draw_hook(VALUE_SLIDER s, void * d) { -    reinterpret_cast<My_Value_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_value_slider_draw(VALUE_SLIDER s) { -    reinterpret_cast<My_Value_Slider*>(s)->real_draw(); -} +class My_Value_Slider : public Fl_Value_Slider { +public: +    using Fl_Value_Slider::Fl_Value_Slider; + +    friend void fl_value_slider_draw(VALUESLIDER s); +    friend int fl_value_slider_handle(VALUESLIDER s, int e); -void value_slider_set_handle_hook(VALUE_SLIDER s, void * h) { -    reinterpret_cast<My_Value_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h); +    void draw(); +    int handle(int e); +}; + +void My_Value_Slider::draw() { +    widget_draw_hook(this->user_data());  } -int fl_value_slider_handle(VALUE_SLIDER s, int e) { -    return reinterpret_cast<My_Value_Slider*>(s)->real_handle(e); +int My_Value_Slider::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } -VALUE_SLIDER new_fl_value_slider(int x, int y, int w, int h, char* label) { +//  Flattened C API + +VALUESLIDER new_fl_value_slider(int x, int y, int w, int h, char* label) {      My_Value_Slider *s = new My_Value_Slider(x, y, w, h, label);      return s;  } -void free_fl_value_slider(VALUE_SLIDER s) { +void free_fl_value_slider(VALUESLIDER s) {      delete reinterpret_cast<My_Value_Slider*>(s);  } -unsigned int fl_value_slider_get_textcolor(VALUE_SLIDER s) { +unsigned int fl_value_slider_get_textcolor(VALUESLIDER s) {      return reinterpret_cast<Fl_Value_Slider*>(s)->textcolor();  } -void fl_value_slider_set_textcolor(VALUE_SLIDER s, unsigned int t) { +void fl_value_slider_set_textcolor(VALUESLIDER s, unsigned int t) {      reinterpret_cast<Fl_Value_Slider*>(s)->textcolor(t);  } -int fl_value_slider_get_textfont(VALUE_SLIDER s) { +int fl_value_slider_get_textfont(VALUESLIDER s) {      return reinterpret_cast<Fl_Value_Slider*>(s)->textfont();  } -void fl_value_slider_set_textfont(VALUE_SLIDER s, int t) { +void fl_value_slider_set_textfont(VALUESLIDER s, int t) {      reinterpret_cast<Fl_Value_Slider*>(s)->textfont(t);  } -int fl_value_slider_get_textsize(VALUE_SLIDER s) { +int fl_value_slider_get_textsize(VALUESLIDER s) {      return reinterpret_cast<Fl_Value_Slider*>(s)->textsize();  } -void fl_value_slider_set_textsize(VALUE_SLIDER s, int t) { +void fl_value_slider_set_textsize(VALUESLIDER s, int t) {      reinterpret_cast<Fl_Value_Slider*>(s)->textsize(t);  } + + + +void fl_value_slider_draw(VALUESLIDER s) { +    reinterpret_cast<My_Value_Slider*>(s)->Fl_Value_Slider::draw(); +} + +int fl_value_slider_handle(VALUESLIDER s, int e) { +    return reinterpret_cast<My_Value_Slider*>(s)->Fl_Value_Slider::handle(e); +} + + diff --git a/src/c_fl_value_slider.h b/src/c_fl_value_slider.h index 78e4459..b07a827 100644 --- a/src/c_fl_value_slider.h +++ b/src/c_fl_value_slider.h @@ -8,34 +8,25 @@  #define FL_VALUE_SLIDER_GUARD +typedef void* VALUESLIDER; -typedef void* VALUE_SLIDER; +extern "C" VALUESLIDER new_fl_value_slider(int x, int y, int w, int h, char* label); +extern "C" void free_fl_value_slider(VALUESLIDER s); +extern "C" unsigned int fl_value_slider_get_textcolor(VALUESLIDER s); +extern "C" void fl_value_slider_set_textcolor(VALUESLIDER s, unsigned int t); +extern "C" int fl_value_slider_get_textfont(VALUESLIDER s); +extern "C" void fl_value_slider_set_textfont(VALUESLIDER s, int t); +extern "C" int fl_value_slider_get_textsize(VALUESLIDER s); +extern "C" void fl_value_slider_set_textsize(VALUESLIDER s, int t); -extern "C" void value_slider_set_draw_hook(VALUE_SLIDER s, void * d); -extern "C" void fl_value_slider_draw(VALUE_SLIDER s); -extern "C" void value_slider_set_handle_hook(VALUE_SLIDER s, void * h); -extern "C" int fl_value_slider_handle(VALUE_SLIDER s, int e); - - - - -extern "C" VALUE_SLIDER new_fl_value_slider(int x, int y, int w, int h, char* label); -extern "C" void free_fl_value_slider(VALUE_SLIDER s); - - - - -extern "C" unsigned int fl_value_slider_get_textcolor(VALUE_SLIDER s); -extern "C" void fl_value_slider_set_textcolor(VALUE_SLIDER s, unsigned int t); -extern "C" int fl_value_slider_get_textfont(VALUE_SLIDER s); -extern "C" void fl_value_slider_set_textfont(VALUE_SLIDER s, int t); -extern "C" int fl_value_slider_get_textsize(VALUE_SLIDER s); -extern "C" void fl_value_slider_set_textsize(VALUE_SLIDER s, int t); +extern "C" void fl_value_slider_draw(VALUESLIDER s); +extern "C" int fl_value_slider_handle(VALUESLIDER s, int e);  #endif + diff --git a/src/c_fl_widget.cpp b/src/c_fl_widget.cpp index 61e5a96..db7312d 100644 --- a/src/c_fl_widget.cpp +++ b/src/c_fl_widget.cpp @@ -55,6 +55,8 @@ int My_Widget::handle(int e) { +//  Flattened C API +  WIDGET new_fl_widget(int x, int y, int w, int h, char* label) {      My_Widget *wd = new My_Widget(x, y, w, h, label);      return wd; @@ -340,6 +342,17 @@ void fl_widget_set_deimage(WIDGET w, void * img) { +unsigned char fl_widget_get_type(WIDGET w) { +    return reinterpret_cast<Fl_Widget*>(w)->type(); +} + +void fl_widget_set_type(WIDGET w, unsigned char t) { +    reinterpret_cast<Fl_Widget*>(w)->type(t); +} + + + +  int fl_widget_damage(WIDGET w) {      return reinterpret_cast<Fl_Widget*>(w)->damage();  } diff --git a/src/c_fl_widget.h b/src/c_fl_widget.h index 669ccda..9634ba4 100644 --- a/src/c_fl_widget.h +++ b/src/c_fl_widget.h @@ -97,6 +97,10 @@ extern "C" void fl_widget_set_image(WIDGET w, void * img);  extern "C" void fl_widget_set_deimage(WIDGET w, void * img); +extern "C" unsigned char fl_widget_get_type(WIDGET w); +extern "C" void fl_widget_set_type(WIDGET w, unsigned char t); + +  extern "C" int fl_widget_damage(WIDGET w);  extern "C" void fl_widget_set_damage(WIDGET w, int t);  extern "C" void fl_widget_set_damage2(WIDGET w, int t, int x, int y, int d, int h); @@ -109,3 +113,4 @@ extern "C" int fl_widget_handle(WIDGET w, int e);  #endif + diff --git a/src/c_fl_window.cpp b/src/c_fl_window.cpp index eb54557..37c8a44 100644 --- a/src/c_fl_window.cpp +++ b/src/c_fl_window.cpp @@ -7,62 +7,44 @@  #include <FL/Fl_Window.H>  #include <FL/Fl_RGB_Image.H>  #include "c_fl_window.h" -#include "c_fl_type.h" -class My_Window : public Fl_Window { -    public: -        using Fl_Window::Fl_Window; -        friend void window_set_draw_hook(WINDOW n, void * d); -        friend void fl_window_draw(WINDOW n); -        friend void window_set_handle_hook(WINDOW n, void * h); -        friend int fl_window_handle(WINDOW 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; -}; +//  Exports from Ada -void My_Window::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_Window::real_draw() { -    Fl_Window::draw(); -} -int My_Window::handle(int e) { -    return (*handle_hook)(this->user_data(), e); -} -int My_Window::real_handle(int e) { -    return Fl_Window::handle(e); -} -void window_set_draw_hook(WINDOW n, void * d) { -    reinterpret_cast<My_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +//  Attaching all relevant hooks and friends -void fl_window_draw(WINDOW n) { -    reinterpret_cast<My_Window*>(n)->real_draw(); -} +class My_Window : public Fl_Window { +public: +    using Fl_Window::Fl_Window; + +    friend void fl_window_draw(WINDOW n); +    friend int fl_window_handle(WINDOW n, int e); + +    void draw(); +    int handle(int e); +}; -void window_set_handle_hook(WINDOW n, void * h) { -    reinterpret_cast<My_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Window::draw() { +    widget_draw_hook(this->user_data());  } -int fl_window_handle(WINDOW n, int e) { -    return reinterpret_cast<My_Window*>(n)->real_handle(e); +int My_Window::handle(int e) { +    return widget_handle_hook(this->user_data(), e);  } +//  Flattened C API +  WINDOW new_fl_window(int x, int y, int w, int h, char* label) {      My_Window *n = new My_Window(x, y, w, h, label);      return n; @@ -249,3 +231,15 @@ int fl_window_get_decorated_h(WINDOW n) {      return reinterpret_cast<Fl_Window*>(n)->decorated_h();  } + + + +void fl_window_draw(WINDOW n) { +    reinterpret_cast<My_Window*>(n)->Fl_Window::draw(); +} + +int fl_window_handle(WINDOW n, int e) { +    return reinterpret_cast<My_Window*>(n)->Fl_Window::handle(e); +} + + diff --git a/src/c_fl_window.h b/src/c_fl_window.h index 4a544f1..f17051e 100644 --- a/src/c_fl_window.h +++ b/src/c_fl_window.h @@ -8,28 +8,14 @@  #define FL_WINDOW_GUARD - -  typedef void* WINDOW; - - -extern "C" void window_set_draw_hook(WINDOW n, void * d); -extern "C" void fl_window_draw(WINDOW n); -extern "C" void window_set_handle_hook(WINDOW n, void * h); -extern "C" int fl_window_handle(WINDOW n, int e); - - - -  extern "C" WINDOW new_fl_window(int x, int y, int w, int h, char* label);  extern "C" WINDOW new_fl_window2(int w, int h, char* label);  extern "C" void free_fl_window(WINDOW n); - -  extern "C" void fl_window_show(WINDOW n);  extern "C" void fl_window_hide(WINDOW n);  extern "C" int fl_window_shown(WINDOW n); @@ -80,5 +66,10 @@ extern "C" int fl_window_get_decorated_w(WINDOW n);  extern "C" int fl_window_get_decorated_h(WINDOW n); +extern "C" void fl_window_draw(WINDOW n); +extern "C" int fl_window_handle(WINDOW n, int e); + +  #endif + diff --git a/src/c_fl_wizard.cpp b/src/c_fl_wizard.cpp index 1aeb0e5..d826ca6 100644 --- a/src/c_fl_wizard.cpp +++ b/src/c_fl_wizard.cpp @@ -6,34 +6,37 @@  #include <FL/Fl_Wizard.H>  #include "c_fl_wizard.h" -#include "c_fl_type.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_Wizard : public Fl_Wizard { -    public: -        using Fl_Wizard::Fl_Wizard; -        friend void wizard_set_draw_hook(WIZARD w, void * d); -        friend void fl_wizard_draw(WIZARD w); -        friend void wizard_set_handle_hook(WIZARD w, void * h); -        friend int fl_wizard_handle(WIZARD w, 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; +public: +    using Fl_Wizard::Fl_Wizard; + +    friend void fl_wizard_draw(WIZARD w); +    friend int fl_wizard_handle(WIZARD w, int e); + +    void draw(); +    void real_draw(); +    int handle(int e);  };  void My_Wizard::draw() { -    (*draw_hook)(this->user_data()); +    widget_draw_hook(this->user_data());  }  void My_Wizard::real_draw() { -    //Fl_Wizard::draw(); -      // required because of Fl_Wizard::draw() being private      // probably a bug in FLTK?      Fl_Widget *kid = value(); @@ -50,31 +53,13 @@ void My_Wizard::real_draw() {  }  int My_Wizard::handle(int e) { -    return (*handle_hook)(this->user_data(), e); +    return widget_handle_hook(this->user_data(), e);  } -int My_Wizard::real_handle(int e) { -    return Fl_Wizard::handle(e); -} - -void wizard_set_draw_hook(WIZARD w, void * d) { -    reinterpret_cast<My_Wizard*>(w)->draw_hook = reinterpret_cast<d_hook_p>(d); -} - -void fl_wizard_draw(WIZARD w) { -    reinterpret_cast<My_Wizard*>(w)->real_draw(); -} - -void wizard_set_handle_hook(WIZARD w, void * h) { -    reinterpret_cast<My_Wizard*>(w)->handle_hook = reinterpret_cast<h_hook_p>(h); -} - -int fl_wizard_handle(WIZARD w, int e) { -    return reinterpret_cast<My_Wizard*>(w)->real_handle(e); -} +//  Flattened C API  WIZARD new_fl_wizard(int x, int y, int w, int h, char* label) {      My_Wizard *g = new My_Wizard(x, y, w, h, label); @@ -108,3 +93,14 @@ void fl_wizard_set_visible(WIZARD w, void * i) {  } + + +void fl_wizard_draw(WIZARD w) { +    reinterpret_cast<My_Wizard*>(w)->real_draw(); +} + +int fl_wizard_handle(WIZARD w, int e) { +    return reinterpret_cast<My_Wizard*>(w)->Fl_Wizard::handle(e); +} + + diff --git a/src/c_fl_wizard.h b/src/c_fl_wizard.h index f119eb8..fb710ec 100644 --- a/src/c_fl_wizard.h +++ b/src/c_fl_wizard.h @@ -8,27 +8,13 @@  #define FL_WIZARD_GUARD - -  typedef void* WIZARD; - - -extern "C" void wizard_set_draw_hook(WIZARD w, void * d); -extern "C" void fl_wizard_draw(WIZARD w); -extern "C" void wizard_set_handle_hook(WIZARD w, void * h); -extern "C" int fl_wizard_handle(WIZARD w, int e); - - - -  extern "C" WIZARD new_fl_wizard(int x, int y, int w, int h, char* label);  extern "C" void free_fl_wizard(WIZARD w); - -  extern "C" void fl_wizard_next(WIZARD w);  extern "C" void fl_wizard_prev(WIZARD w); @@ -37,5 +23,10 @@ extern "C" void * fl_wizard_get_visible(WIZARD w);  extern "C" void fl_wizard_set_visible(WIZARD w, void * i); +extern "C" void fl_wizard_draw(WIZARD w); +extern "C" int fl_wizard_handle(WIZARD w, int e); + +  #endif + diff --git a/src/fltk-widgets-boxes.adb b/src/fltk-widgets-boxes.adb index a506fd3..7b4c848 100644 --- a/src/fltk-widgets-boxes.adb +++ b/src/fltk-widgets-boxes.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Boxes is -    procedure box_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, box_set_draw_hook, "box_set_draw_hook"); -    pragma Inline (box_set_draw_hook); - -    procedure box_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, box_set_handle_hook, "box_set_handle_hook"); -    pragma Inline (box_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_box             (X, Y, W, H : in Interfaces.C.int; @@ -32,6 +23,13 @@ package body FLTK.Widgets.Boxes is      pragma Import (C, new_fl_box, "new_fl_box");      pragma Inline (new_fl_box); +    function new_fl_box2 +           (K, X, Y, W, H : in Interfaces.C.int; +            Text          : in Interfaces.C.char_array) +        return Storage.Integer_Address; +    pragma Import (C, new_fl_box2, "new_fl_box2"); +    pragma Inline (new_fl_box2); +      procedure free_fl_box             (B : in Storage.Integer_Address);      pragma Import (C, free_fl_box, "free_fl_box"); @@ -55,6 +53,10 @@ package body FLTK.Widgets.Boxes is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Box) is      begin @@ -75,6 +77,10 @@ package body FLTK.Widgets.Boxes is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Box;              X, Y, W, H : in     Integer; @@ -84,6 +90,14 @@ package body FLTK.Widgets.Boxes is      end Extra_Init; +    procedure Initialize +           (This : in out Box) is +    begin +        This.Draw_Ptr   := fl_box_draw'Address; +        This.Handle_Ptr := fl_box_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -93,14 +107,31 @@ package body FLTK.Widgets.Boxes is          begin              return This : Box do                  This.Void_Ptr := new_fl_box -                       (Interfaces.C.int (X), -                        Interfaces.C.int (Y), -                        Interfaces.C.int (W), -                        Interfaces.C.int (H), -                        Interfaces.C.To_C (Text)); +                   (Interfaces.C.int (X), +                    Interfaces.C.int (Y), +                    Interfaces.C.int (W), +                    Interfaces.C.int (H), +                    Interfaces.C.To_C (Text)); +                Extra_Init (This, X, Y, W, H, Text); +            end return; +        end Create; + + +        function Create +               (Kind       : in Box_Kind; +                X, Y, W, H : in Integer; +                Text       : in String := "") +            return Box is +        begin +            return This : Box do +                This.Void_Ptr := new_fl_box2 +                   (Box_Kind'Pos (Kind), +                    Interfaces.C.int (X), +                    Interfaces.C.int (Y), +                    Interfaces.C.int (W), +                    Interfaces.C.int (H), +                    Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                box_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                box_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -109,10 +140,14 @@ package body FLTK.Widgets.Boxes is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Draw             (This : in out Box) is      begin -        fl_box_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; @@ -121,10 +156,10 @@ package body FLTK.Widgets.Boxes is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_box_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Widget (This).Handle (Event);      end Handle;  end FLTK.Widgets.Boxes; + diff --git a/src/fltk-widgets-boxes.ads b/src/fltk-widgets-boxes.ads index f710011..b0a03dc 100644 --- a/src/fltk-widgets-boxes.ads +++ b/src/fltk-widgets-boxes.ads @@ -22,6 +22,12 @@ package FLTK.Widgets.Boxes is                  Text       : in String := "")              return Box; +        function Create +               (Kind       : in Box_Kind; +                X, Y, W, H : in Integer; +                Text       : in String := "") +            return Box; +      end Forge; @@ -41,6 +47,9 @@ private      type Box is new Widget with null record; +    overriding procedure Initialize +           (This : in out Box); +      overriding procedure Finalize             (This : in out Box); @@ -61,3 +70,4 @@ private  end FLTK.Widgets.Boxes; + diff --git a/src/fltk-widgets-buttons-enter.adb b/src/fltk-widgets-buttons-enter.adb index 20ce598..0053e53 100644 --- a/src/fltk-widgets-buttons-enter.adb +++ b/src/fltk-widgets-buttons-enter.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Enter is -    procedure return_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, return_button_set_draw_hook, "return_button_set_draw_hook"); -    pragma Inline (return_button_set_draw_hook); - -    procedure return_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, return_button_set_handle_hook, "return_button_set_handle_hook"); -    pragma Inline (return_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_return_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Enter is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Enter_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Enter is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Enter_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Enter is      end Extra_Init; +    procedure Initialize +           (This : in out Enter_Button) is +    begin +        This.Draw_Ptr   := fl_return_button_draw'Address; +        This.Handle_Ptr := fl_return_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,10 +106,6 @@ package body FLTK.Widgets.Buttons.Enter is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                return_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                return_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -111,10 +114,14 @@ package body FLTK.Widgets.Buttons.Enter is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Draw             (This : in out Enter_Button) is      begin -        fl_return_button_draw (This.Void_Ptr); +        Button (This).Draw;      end Draw; @@ -123,10 +130,10 @@ package body FLTK.Widgets.Buttons.Enter is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_return_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Button (This).Handle (Event);      end Handle;  end FLTK.Widgets.Buttons.Enter; + diff --git a/src/fltk-widgets-buttons-enter.ads b/src/fltk-widgets-buttons-enter.ads index a8dbc11..0180628 100644 --- a/src/fltk-widgets-buttons-enter.ads +++ b/src/fltk-widgets-buttons-enter.ads @@ -44,6 +44,9 @@ private      type Enter_Button is new Button with null record; +    overriding procedure Initialize +           (This : in out Enter_Button); +      overriding procedure Finalize             (This : in out Enter_Button); @@ -64,3 +67,4 @@ private  end FLTK.Widgets.Buttons.Enter; + diff --git a/src/fltk-widgets-buttons-light-check.adb b/src/fltk-widgets-buttons-light-check.adb index d1596e0..e565461 100644 --- a/src/fltk-widgets-buttons-light-check.adb +++ b/src/fltk-widgets-buttons-light-check.adb @@ -16,19 +16,6 @@ package body FLTK.Widgets.Buttons.Light.Check is      --  Functions From C  --      ------------------------ -    procedure check_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, check_button_set_draw_hook, "check_button_set_draw_hook"); -    pragma Inline (check_button_set_draw_hook); - -    procedure check_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, check_button_set_handle_hook, "check_button_set_handle_hook"); -    pragma Inline (check_button_set_handle_hook); - - - -      function new_fl_check_button             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -136,6 +123,14 @@ package body FLTK.Widgets.Buttons.Light.Check is      end Extra_Init; +    procedure Initialize +           (This : in out Check_Button) is +    begin +        This.Draw_Ptr   := fl_check_button_draw'Address; +        This.Handle_Ptr := fl_check_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -151,38 +146,12 @@ package body FLTK.Widgets.Buttons.Light.Check is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                check_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                check_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    ----------------------- -    --  API Subprograms  -- -    ----------------------- - -    procedure Draw -           (This : in out Check_Button) is -    begin -        fl_check_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Check_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_check_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Light.Check; + diff --git a/src/fltk-widgets-buttons-light-check.ads b/src/fltk-widgets-buttons-light-check.ads index a4f6767..b54d0af 100644 --- a/src/fltk-widgets-buttons-light-check.ads +++ b/src/fltk-widgets-buttons-light-check.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Light.Check is      end Forge; - - -    procedure Draw -           (This : in out Check_Button); - -    function Handle -           (This  : in out Check_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Check_Button is new Light_Button with null record; +    overriding procedure Initialize +           (This : in out Check_Button); +      overriding procedure Finalize             (This : in out Check_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Light.Check; + diff --git a/src/fltk-widgets-buttons-light-radio.adb b/src/fltk-widgets-buttons-light-radio.adb index c7ba63f..754131d 100644 --- a/src/fltk-widgets-buttons-light-radio.adb +++ b/src/fltk-widgets-buttons-light-radio.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Light.Radio is -    procedure radio_light_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, radio_light_button_set_draw_hook, "radio_light_button_set_draw_hook"); -    pragma Inline (radio_light_button_set_draw_hook); - -    procedure radio_light_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, radio_light_button_set_handle_hook, "radio_light_button_set_handle_hook"); -    pragma Inline (radio_light_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_radio_light_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Light.Radio is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Radio_Light_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Light.Radio is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Radio_Light_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Light.Radio is      end Extra_Init; +    procedure Initialize +           (This : in out Radio_Light_Button) is +    begin +        This.Draw_Ptr   := fl_radio_light_button_draw'Address; +        This.Handle_Ptr := fl_radio_light_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Buttons.Light.Radio is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                radio_light_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                radio_light_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Radio_Light_Button) is -    begin -        fl_radio_light_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Radio_Light_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_radio_light_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Light.Radio; + diff --git a/src/fltk-widgets-buttons-light-radio.ads b/src/fltk-widgets-buttons-light-radio.ads index e8cfcb8..5120106 100644 --- a/src/fltk-widgets-buttons-light-radio.ads +++ b/src/fltk-widgets-buttons-light-radio.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Light.Radio is      end Forge; - - -    procedure Draw -           (This : in out Radio_Light_Button); - -    function Handle -           (This  : in out Radio_Light_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Radio_Light_Button is new Light_Button with null record; +    overriding procedure Initialize +           (This : in out Radio_Light_Button); +      overriding procedure Finalize             (This : in out Radio_Light_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Light.Radio; + diff --git a/src/fltk-widgets-buttons-light-round-radio.adb b/src/fltk-widgets-buttons-light-round-radio.adb index 1f1e3f8..f2c7ed8 100644 --- a/src/fltk-widgets-buttons-light-round-radio.adb +++ b/src/fltk-widgets-buttons-light-round-radio.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Light.Round.Radio is -    procedure radio_round_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, radio_round_button_set_draw_hook, "radio_round_button_set_draw_hook"); -    pragma Inline (radio_round_button_set_draw_hook); - -    procedure radio_round_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, radio_round_button_set_handle_hook, "radio_round_button_set_handle_hook"); -    pragma Inline (radio_round_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_radio_round_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Radio_Round_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Radio_Round_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is      end Extra_Init; +    procedure Initialize +           (This : in out Radio_Round_Button) is +    begin +        This.Draw_Ptr   := fl_radio_round_button_draw'Address; +        This.Handle_Ptr := fl_radio_round_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                radio_round_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                radio_round_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Radio_Round_Button) is -    begin -        fl_radio_round_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Radio_Round_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_radio_round_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Light.Round.Radio; + diff --git a/src/fltk-widgets-buttons-light-round-radio.ads b/src/fltk-widgets-buttons-light-round-radio.ads index e16964e..f46f179 100644 --- a/src/fltk-widgets-buttons-light-round-radio.ads +++ b/src/fltk-widgets-buttons-light-round-radio.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Light.Round.Radio is      end Forge; - - -    procedure Draw -           (This : in out Radio_Round_Button); - -    function Handle -           (This  : in out Radio_Round_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Radio_Round_Button is new Round_Button with null record; +    overriding procedure Initialize +           (This : in out Radio_Round_Button); +      overriding procedure Finalize             (This : in out Radio_Round_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Light.Round.Radio; + diff --git a/src/fltk-widgets-buttons-light-round.adb b/src/fltk-widgets-buttons-light-round.adb index 9730413..2e358ea 100644 --- a/src/fltk-widgets-buttons-light-round.adb +++ b/src/fltk-widgets-buttons-light-round.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Light.Round is -    procedure round_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, round_button_set_draw_hook, "round_button_set_draw_hook"); -    pragma Inline (round_button_set_draw_hook); - -    procedure round_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, round_button_set_handle_hook, "round_button_set_handle_hook"); -    pragma Inline (round_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_round_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Light.Round is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Round_Button) is      begin @@ -74,6 +69,10 @@ package body FLTK.Widgets.Buttons.Light.Round is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Round_Button;              X, Y, W, H : in     Integer; @@ -83,6 +82,14 @@ package body FLTK.Widgets.Buttons.Light.Round is      end Extra_Init; +    procedure Initialize +           (This : in out Round_Button) is +    begin +        This.Draw_Ptr   := fl_round_button_draw'Address; +        This.Handle_Ptr := fl_round_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -98,34 +105,12 @@ package body FLTK.Widgets.Buttons.Light.Round is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                round_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                round_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Round_Button) is -    begin -        fl_round_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Round_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_round_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Light.Round; + diff --git a/src/fltk-widgets-buttons-light-round.ads b/src/fltk-widgets-buttons-light-round.ads index 443cf60..606b11d 100644 --- a/src/fltk-widgets-buttons-light-round.ads +++ b/src/fltk-widgets-buttons-light-round.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Light.Round is      end Forge; - - -    procedure Draw -           (This : in out Round_Button); - -    function Handle -           (This  : in out Round_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Round_Button is new Light_Button with null record; +    overriding procedure Initialize +           (This : in out Round_Button); +      overriding procedure Finalize             (This : in out Round_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Light.Round; + diff --git a/src/fltk-widgets-buttons-light.adb b/src/fltk-widgets-buttons-light.adb index 6ab55bb..41b7bd0 100644 --- a/src/fltk-widgets-buttons-light.adb +++ b/src/fltk-widgets-buttons-light.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Light is -    procedure light_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, light_button_set_draw_hook, "light_button_set_draw_hook"); -    pragma Inline (light_button_set_draw_hook); - -    procedure light_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, light_button_set_handle_hook, "light_button_set_handle_hook"); -    pragma Inline (light_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_light_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Light is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Light_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Light is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Light_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Light is      end Extra_Init; +    procedure Initialize +           (This : in out Light_Button) is +    begin +        This.Draw_Ptr   := fl_light_button_draw'Address; +        This.Handle_Ptr := fl_light_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,10 +106,6 @@ package body FLTK.Widgets.Buttons.Light is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                light_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                light_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -111,10 +114,14 @@ package body FLTK.Widgets.Buttons.Light is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Draw             (This : in out Light_Button) is      begin -        fl_light_button_draw (This.Void_Ptr); +        Button (This).Draw;      end Draw; @@ -123,10 +130,10 @@ package body FLTK.Widgets.Buttons.Light is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_light_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Button (This).Handle (Event);      end Handle;  end FLTK.Widgets.Buttons.Light; + diff --git a/src/fltk-widgets-buttons-light.ads b/src/fltk-widgets-buttons-light.ads index 291cc0e..4c3ea95 100644 --- a/src/fltk-widgets-buttons-light.ads +++ b/src/fltk-widgets-buttons-light.ads @@ -41,6 +41,9 @@ private      type Light_Button is new Button with null record; +    overriding procedure Initialize +           (This : in out Light_Button); +      overriding procedure Finalize             (This : in out Light_Button); @@ -61,3 +64,4 @@ private  end FLTK.Widgets.Buttons.Light; + diff --git a/src/fltk-widgets-buttons-radio.adb b/src/fltk-widgets-buttons-radio.adb index 143beeb..f29ce90 100644 --- a/src/fltk-widgets-buttons-radio.adb +++ b/src/fltk-widgets-buttons-radio.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Radio is -    procedure radio_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, radio_button_set_draw_hook, "radio_button_set_draw_hook"); -    pragma Inline (radio_button_set_draw_hook); - -    procedure radio_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, radio_button_set_handle_hook, "radio_button_set_handle_hook"); -    pragma Inline (radio_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_radio_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Radio is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Radio_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Radio is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Radio_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Radio is      end Extra_Init; +    procedure Initialize +           (This : in out Radio_Button) is +    begin +        This.Draw_Ptr   := fl_radio_button_draw'Address; +        This.Handle_Ptr := fl_radio_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Buttons.Radio is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                radio_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                radio_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Radio_Button) is -    begin -        fl_radio_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Radio_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_radio_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Radio; + diff --git a/src/fltk-widgets-buttons-radio.ads b/src/fltk-widgets-buttons-radio.ads index 285f614..557266e 100644 --- a/src/fltk-widgets-buttons-radio.ads +++ b/src/fltk-widgets-buttons-radio.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Radio is      end Forge; - - -    procedure Draw -           (This : in out Radio_Button); - -    function Handle -           (This  : in out Radio_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Radio_Button is new Button with null record; +    overriding procedure Initialize +           (This : in out Radio_Button); +      overriding procedure Finalize             (This : in out Radio_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Radio; + diff --git a/src/fltk-widgets-buttons-repeat.adb b/src/fltk-widgets-buttons-repeat.adb index 9446a22..e3d2d69 100644 --- a/src/fltk-widgets-buttons-repeat.adb +++ b/src/fltk-widgets-buttons-repeat.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Repeat is -    procedure repeat_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, repeat_button_set_draw_hook, "repeat_button_set_draw_hook"); -    pragma Inline (repeat_button_set_draw_hook); - -    procedure repeat_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, repeat_button_set_handle_hook, "repeat_button_set_handle_hook"); -    pragma Inline (repeat_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_repeat_button             (X, Y, W, H : in Interfaces.C.int; @@ -40,6 +31,14 @@ package body FLTK.Widgets.Buttons.Repeat is +    procedure fl_repeat_button_deactivate +           (B : in Storage.Integer_Address); +    pragma Import (C, fl_repeat_button_deactivate, "fl_repeat_button_deactivate"); +    pragma Inline (fl_repeat_button_deactivate); + + + +      procedure fl_repeat_button_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_repeat_button_draw, "fl_repeat_button_draw"); @@ -55,6 +54,10 @@ package body FLTK.Widgets.Buttons.Repeat is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Repeat_Button) is      begin @@ -75,6 +78,10 @@ package body FLTK.Widgets.Buttons.Repeat is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Repeat_Button;              X, Y, W, H : in     Integer; @@ -84,6 +91,14 @@ package body FLTK.Widgets.Buttons.Repeat is      end Extra_Init; +    procedure Initialize +           (This : in out Repeat_Button) is +    begin +        This.Draw_Ptr := fl_repeat_button_draw'Address; +        This.Handle_Ptr := fl_repeat_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,10 +114,6 @@ package body FLTK.Widgets.Buttons.Repeat is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                repeat_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                repeat_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -111,11 +122,17 @@ package body FLTK.Widgets.Buttons.Repeat is -    procedure Draw +    ----------------------- +    --  API Subprograms  -- +    ----------------------- + +    procedure Deactivate             (This : in out Repeat_Button) is      begin -        fl_repeat_button_draw (This.Void_Ptr); -    end Draw; +        fl_repeat_button_deactivate (This.Void_Ptr); +    end Deactivate; + +      function Handle @@ -123,10 +140,10 @@ package body FLTK.Widgets.Buttons.Repeat is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_repeat_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Button (This).Handle (Event);      end Handle;  end FLTK.Widgets.Buttons.Repeat; + diff --git a/src/fltk-widgets-buttons-repeat.ads b/src/fltk-widgets-buttons-repeat.ads index eeb4166..5720f8a 100644 --- a/src/fltk-widgets-buttons-repeat.ads +++ b/src/fltk-widgets-buttons-repeat.ads @@ -27,9 +27,12 @@ package FLTK.Widgets.Buttons.Repeat is -    procedure Draw +    procedure Deactivate             (This : in out Repeat_Button); + + +      function Handle             (This  : in out Repeat_Button;              Event : in     Event_Kind) @@ -41,6 +44,9 @@ private      type Repeat_Button is new Button with null record; +    overriding procedure Initialize +           (This : in out Repeat_Button); +      overriding procedure Finalize             (This : in out Repeat_Button); @@ -55,9 +61,11 @@ private      with Inline; -    pragma Inline (Draw); +    pragma Inline (Deactivate); +      pragma Inline (Handle);  end FLTK.Widgets.Buttons.Repeat; + diff --git a/src/fltk-widgets-buttons-toggle.adb b/src/fltk-widgets-buttons-toggle.adb index a1dcc60..6542aae 100644 --- a/src/fltk-widgets-buttons-toggle.adb +++ b/src/fltk-widgets-buttons-toggle.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Buttons.Toggle is -    procedure toggle_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, toggle_button_set_draw_hook, "toggle_button_set_draw_hook"); -    pragma Inline (toggle_button_set_draw_hook); - -    procedure toggle_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, toggle_button_set_handle_hook, "toggle_button_set_handle_hook"); -    pragma Inline (toggle_button_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_toggle_button             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Buttons.Toggle is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Toggle_Button) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Buttons.Toggle is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Toggle_Button;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Buttons.Toggle is      end Extra_Init; +    procedure Initialize +           (This : in out Toggle_Button) is +    begin +        This.Draw_Ptr   := fl_toggle_button_draw'Address; +        This.Handle_Ptr := fl_toggle_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Buttons.Toggle is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                toggle_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                toggle_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Toggle_Button) is -    begin -        fl_toggle_button_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Toggle_Button; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_toggle_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Buttons.Toggle; + diff --git a/src/fltk-widgets-buttons-toggle.ads b/src/fltk-widgets-buttons-toggle.ads index a218533..2e0c967 100644 --- a/src/fltk-widgets-buttons-toggle.ads +++ b/src/fltk-widgets-buttons-toggle.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Buttons.Toggle is      end Forge; - - -    procedure Draw -           (This : in out Toggle_Button); - -    function Handle -           (This  : in out Toggle_Button; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Toggle_Button is new Button with null record; +    overriding procedure Initialize +           (This : in out Toggle_Button); +      overriding procedure Finalize             (This : in out Toggle_Button); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Buttons.Toggle; + diff --git a/src/fltk-widgets-buttons.adb b/src/fltk-widgets-buttons.adb index e0b5120..c024dd1 100644 --- a/src/fltk-widgets-buttons.adb +++ b/src/fltk-widgets-buttons.adb @@ -16,19 +16,6 @@ package body FLTK.Widgets.Buttons is      --  Functions From C  --      ------------------------ -    procedure button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, button_set_draw_hook, "button_set_draw_hook"); -    pragma Inline (button_set_draw_hook); - -    procedure button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, button_set_handle_hook, "button_set_handle_hook"); -    pragma Inline (button_set_handle_hook); - - - -      function new_fl_button             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -106,6 +93,14 @@ package body FLTK.Widgets.Buttons is +    procedure fl_button_simulate_key_action +           (B : in Storage.Integer_Address); +    pragma Import (C, fl_button_simulate_key_action, "fl_button_simulate_key_action"); +    pragma Inline (fl_button_simulate_key_action); + + + +      -------------------      --  Destructors  --      ------------------- @@ -183,6 +178,14 @@ package body FLTK.Widgets.Buttons is      end Extra_Init; +    procedure Initialize +           (This : in out Button) is +    begin +        This.Draw_Ptr   := fl_button_draw'Address; +        This.Handle_Ptr := fl_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -198,8 +201,6 @@ package body FLTK.Widgets.Buttons is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                button_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                button_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -274,7 +275,7 @@ package body FLTK.Widgets.Buttons is      procedure Draw             (This : in out Button) is      begin -        fl_button_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; @@ -283,10 +284,19 @@ package body FLTK.Widgets.Buttons is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Widget (This).Handle (Event);      end Handle; + + +    procedure Simulate_Key_Action +           (This : in out Button) is +    begin +        fl_button_simulate_key_action (This.Void_Ptr); +    end Simulate_Key_Action; + +  end FLTK.Widgets.Buttons; + diff --git a/src/fltk-widgets-buttons.ads b/src/fltk-widgets-buttons.ads index 18c5026..d4c864f 100644 --- a/src/fltk-widgets-buttons.ads +++ b/src/fltk-widgets-buttons.ads @@ -71,11 +71,20 @@ package FLTK.Widgets.Buttons is          return Event_Outcome; + + +    procedure Simulate_Key_Action +           (This : in out Button); + +  private      type Button is new Widget with null record; +    overriding procedure Initialize +           (This : in out Button); +      overriding procedure Finalize             (This : in out Button); @@ -102,6 +111,9 @@ private      pragma Inline (Draw);      pragma Inline (Handle); +    pragma Inline (Simulate_Key_Action); +  end FLTK.Widgets.Buttons; + diff --git a/src/fltk-widgets-charts.adb b/src/fltk-widgets-charts.adb index e9a0f03..1c84ece 100644 --- a/src/fltk-widgets-charts.adb +++ b/src/fltk-widgets-charts.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Charts is -    procedure chart_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, chart_set_draw_hook, "chart_set_draw_hook"); -    pragma Inline (chart_set_draw_hook); - -    procedure chart_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, chart_set_handle_hook, "chart_set_handle_hook"); -    pragma Inline (chart_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_chart             (X, Y, W, H : in Interfaces.C.int; @@ -186,6 +177,10 @@ package body FLTK.Widgets.Charts is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Chart) is      begin @@ -206,6 +201,10 @@ package body FLTK.Widgets.Charts is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Chart;              X, Y, W, H : in     Integer; @@ -215,6 +214,14 @@ package body FLTK.Widgets.Charts is      end Extra_Init; +    procedure Initialize +           (This : in out Chart) is +    begin +        This.Draw_Ptr   := fl_chart_draw'Address; +        This.Handle_Ptr := fl_chart_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -230,8 +237,6 @@ package body FLTK.Widgets.Charts is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                chart_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                chart_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -240,6 +245,10 @@ package body FLTK.Widgets.Charts is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Add             (This       : in out Chart;              Data_Value : in     Long_Float; @@ -422,19 +431,10 @@ package body FLTK.Widgets.Charts is      procedure Draw             (This : in out Chart) is      begin -        fl_chart_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; -    function Handle -           (This  : in out Chart; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_chart_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Charts; + diff --git a/src/fltk-widgets-charts.ads b/src/fltk-widgets-charts.ads index 71df2f0..1f02dd0 100644 --- a/src/fltk-widgets-charts.ads +++ b/src/fltk-widgets-charts.ads @@ -121,17 +121,15 @@ package FLTK.Widgets.Charts is      procedure Draw             (This : in out Chart); -    function Handle -           (This  : in out Chart; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Chart is new Widget with null record; +    overriding procedure Initialize +           (This : in out Chart); +      overriding procedure Finalize             (This : in out Chart); @@ -169,8 +167,8 @@ private      pragma Inline (Resize);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Charts; + diff --git a/src/fltk-widgets-clocks-updated-round.adb b/src/fltk-widgets-clocks-updated-round.adb index f22b785..effea2c 100644 --- a/src/fltk-widgets-clocks-updated-round.adb +++ b/src/fltk-widgets-clocks-updated-round.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Clocks.Updated.Round is -    procedure round_clock_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, round_clock_set_draw_hook, "round_clock_set_draw_hook"); -    pragma Inline (round_clock_set_draw_hook); - -    procedure round_clock_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, round_clock_set_handle_hook, "round_clock_set_handle_hook"); -    pragma Inline (round_clock_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_round_clock             (X, Y, W, H : in Interfaces.C.int; @@ -45,12 +36,6 @@ package body FLTK.Widgets.Clocks.Updated.Round is      pragma Import (C, fl_round_clock_draw, "fl_round_clock_draw");      pragma Inline (fl_round_clock_draw); -    procedure fl_round_clock_draw2 -           (C          : in Storage.Integer_Address; -            X, Y, W, H : in Interfaces.C.int); -    pragma Import (C, fl_round_clock_draw2, "fl_round_clock_draw2"); -    pragma Inline (fl_round_clock_draw2); -      function fl_round_clock_handle             (W : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -61,6 +46,10 @@ package body FLTK.Widgets.Clocks.Updated.Round is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Round_Clock) is      begin @@ -81,6 +70,10 @@ package body FLTK.Widgets.Clocks.Updated.Round is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Round_Clock;              X, Y, W, H : in     Integer; @@ -90,6 +83,14 @@ package body FLTK.Widgets.Clocks.Updated.Round is      end Extra_Init; +    procedure Initialize +           (This : in out Round_Clock) is +    begin +        This.Draw_Ptr := fl_round_clock_draw'Address; +        This.Handle_Ptr := fl_round_clock_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -105,47 +106,12 @@ package body FLTK.Widgets.Clocks.Updated.Round is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                round_clock_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                round_clock_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Round_Clock) is -    begin -        fl_round_clock_draw (This.Void_Ptr); -    end Draw; - - -    procedure Draw -           (This       : in out Clock; -            X, Y, W, H : in     Integer) is -    begin -        fl_round_clock_draw2 -           (This.Void_Ptr, -            Interfaces.C.int (X), -            Interfaces.C.int (Y), -            Interfaces.C.int (W), -            Interfaces.C.int (H)); -    end Draw; - - -    function Handle -           (This  : in out Round_Clock; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_round_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Clocks.Updated.Round; + diff --git a/src/fltk-widgets-clocks-updated-round.ads b/src/fltk-widgets-clocks-updated-round.ads index fc52031..8576318 100644 --- a/src/fltk-widgets-clocks-updated-round.ads +++ b/src/fltk-widgets-clocks-updated-round.ads @@ -25,26 +25,14 @@ package FLTK.Widgets.Clocks.Updated.Round is      end Forge; - - -    procedure Draw -           (This : in out Round_Clock); - -    procedure Draw -           (This       : in out Clock; -            X, Y, W, H : in     Integer); - -    function Handle -           (This  : in out Round_Clock; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Round_Clock is new Updated_Clock with null record; +    overriding procedure Initialize +           (This : in out Round_Clock); +      overriding procedure Finalize             (This : in out Round_Clock); @@ -59,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Clocks.Updated.Round; + diff --git a/src/fltk-widgets-clocks-updated.adb b/src/fltk-widgets-clocks-updated.adb index b0843b6..7a02052 100644 --- a/src/fltk-widgets-clocks-updated.adb +++ b/src/fltk-widgets-clocks-updated.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Clocks.Updated is -    procedure clock_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, clock_set_draw_hook, "clock_set_draw_hook"); -    pragma Inline (clock_set_draw_hook); - -    procedure clock_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, clock_set_handle_hook, "clock_set_handle_hook"); -    pragma Inline (clock_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_clock             (X, Y, W, H : in Interfaces.C.int; @@ -53,12 +44,6 @@ package body FLTK.Widgets.Clocks.Updated is      pragma Import (C, fl_clock_draw, "fl_clock_draw");      pragma Inline (fl_clock_draw); -    procedure fl_clock_draw2 -           (C          : in Storage.Integer_Address; -            X, Y, W, H : in Interfaces.C.int); -    pragma Import (C, fl_clock_draw2, "fl_clock_draw2"); -    pragma Inline (fl_clock_draw2); -      function fl_clock_handle             (W : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -69,6 +54,10 @@ package body FLTK.Widgets.Clocks.Updated is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Updated_Clock) is      begin @@ -89,6 +78,10 @@ package body FLTK.Widgets.Clocks.Updated is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Updated_Clock;              X, Y, W, H : in     Integer; @@ -98,6 +91,14 @@ package body FLTK.Widgets.Clocks.Updated is      end Extra_Init; +    procedure Initialize +           (This : in out Updated_Clock) is +    begin +        This.Draw_Ptr   := fl_clock_draw'Address; +        This.Handle_Ptr := fl_clock_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -113,8 +114,6 @@ package body FLTK.Widgets.Clocks.Updated is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                clock_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                clock_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -134,8 +133,6 @@ package body FLTK.Widgets.Clocks.Updated is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                clock_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                clock_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -144,35 +141,19 @@ package body FLTK.Widgets.Clocks.Updated is -    procedure Draw -           (This : in out Updated_Clock) is -    begin -        fl_clock_draw (This.Void_Ptr); -    end Draw; - - -    procedure Draw -           (This       : in out Clock; -            X, Y, W, H : in     Integer) is -    begin -        fl_clock_draw2 -           (This.Void_Ptr, -            Interfaces.C.int (X), -            Interfaces.C.int (Y), -            Interfaces.C.int (W), -            Interfaces.C.int (H)); -    end Draw; - +    ----------------------- +    --  API Subprograms  -- +    -----------------------      function Handle             (This  : in out Updated_Clock;              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Clock (This).Handle (Event);      end Handle;  end FLTK.Widgets.Clocks.Updated; + diff --git a/src/fltk-widgets-clocks-updated.ads b/src/fltk-widgets-clocks-updated.ads index c094c55..e25ae18 100644 --- a/src/fltk-widgets-clocks-updated.ads +++ b/src/fltk-widgets-clocks-updated.ads @@ -33,13 +33,6 @@ package FLTK.Widgets.Clocks.Updated is -    procedure Draw -           (This : in out Updated_Clock); - -    procedure Draw -           (This       : in out Clock; -            X, Y, W, H : in     Integer); -      function Handle             (This  : in out Updated_Clock;              Event : in     Event_Kind) @@ -51,6 +44,9 @@ private      type Updated_Clock is new Clock with null record; +    overriding procedure Initialize +           (This : in out Updated_Clock); +      overriding procedure Finalize             (This : in out Updated_Clock); @@ -65,9 +61,9 @@ private      with Inline; -    pragma Inline (Draw);      pragma Inline (Handle);  end FLTK.Widgets.Clocks.Updated; + diff --git a/src/fltk-widgets-clocks.adb b/src/fltk-widgets-clocks.adb index a3cb315..b632336 100644 --- a/src/fltk-widgets-clocks.adb +++ b/src/fltk-widgets-clocks.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Clocks is -    procedure clock_output_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, clock_output_set_draw_hook, "clock_output_set_draw_hook"); -    pragma Inline (clock_output_set_draw_hook); - -    procedure clock_output_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, clock_output_set_handle_hook, "clock_output_set_handle_hook"); -    pragma Inline (clock_output_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_clock_output             (X, Y, W, H : in Interfaces.C.int; @@ -103,6 +94,10 @@ package body FLTK.Widgets.Clocks is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Clock) is      begin @@ -123,6 +118,10 @@ package body FLTK.Widgets.Clocks is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Clock;              X, Y, W, H : in     Integer; @@ -132,6 +131,14 @@ package body FLTK.Widgets.Clocks is      end Extra_Init; +    procedure Initialize +           (This : in out Clock) is +    begin +        This.Draw_Ptr := fl_clock_output_draw'Address; +        This.Handle_Ptr := fl_clock_output_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -147,10 +154,6 @@ package body FLTK.Widgets.Clocks is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                clock_output_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                clock_output_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -159,6 +162,10 @@ package body FLTK.Widgets.Clocks is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Hour             (This : in Clock)          return Hour is @@ -220,7 +227,7 @@ package body FLTK.Widgets.Clocks is      procedure Draw             (This : in out Clock) is      begin -        fl_clock_output_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; @@ -237,15 +244,6 @@ package body FLTK.Widgets.Clocks is      end Draw; -    function Handle -           (This  : in out Clock; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_clock_output_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Clocks; + diff --git a/src/fltk-widgets-clocks.ads b/src/fltk-widgets-clocks.ads index 5117fb1..33edf37 100644 --- a/src/fltk-widgets-clocks.ads +++ b/src/fltk-widgets-clocks.ads @@ -72,17 +72,15 @@ package FLTK.Widgets.Clocks is             (This       : in out Clock;              X, Y, W, H : in     Integer); -    function Handle -           (This  : in out Clock; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Clock is new Widget with null record; +    overriding procedure Initialize +           (This : in out Clock); +      overriding procedure Finalize             (This : in out Clock); @@ -105,8 +103,8 @@ private      pragma Inline (Set_Time);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Clocks; + diff --git a/src/fltk-widgets-groups-browsers-textline.adb b/src/fltk-widgets-groups-browsers-textline.adb index 8c68420..2830732 100644 --- a/src/fltk-widgets-groups-browsers-textline.adb +++ b/src/fltk-widgets-groups-browsers-textline.adb @@ -268,6 +268,15 @@ package body FLTK.Widgets.Groups.Browsers.Textline is +    procedure fl_browser_set_size +           (B    : in Storage.Integer_Address; +            W, H : in Interfaces.C.int); +    pragma Import (C, fl_browser_set_size, "fl_browser_set_size"); +    pragma Inline (fl_browser_set_size); + + + +      procedure fl_browser_set_icon             (B : in Storage.Integer_Address;              L : in Interfaces.C.int; @@ -887,6 +896,19 @@ package body FLTK.Widgets.Groups.Browsers.Textline is +    procedure Resize +           (This : in out Textline_Browser; +            W, H : in     Integer) is +    begin +        fl_browser_set_size +           (This.Void_Ptr, +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + + + +      function Has_Icon             (This : in Textline_Browser;              Line : in Positive) diff --git a/src/fltk-widgets-groups-browsers-textline.ads b/src/fltk-widgets-groups-browsers-textline.ads index dac7ad9..581d2bd 100644 --- a/src/fltk-widgets-groups-browsers-textline.ads +++ b/src/fltk-widgets-groups-browsers-textline.ads @@ -221,6 +221,15 @@ package FLTK.Widgets.Groups.Browsers.Textline is +    --  Resizing + +    procedure Resize +           (This : in out Textline_Browser; +            W, H : in     Integer); + + + +      --  Icons for specific lines      function Has_Icon diff --git a/src/fltk-widgets-groups-color_choosers.adb b/src/fltk-widgets-groups-color_choosers.adb index 9c02667..5c52ce3 100644 --- a/src/fltk-widgets-groups-color_choosers.adb +++ b/src/fltk-widgets-groups-color_choosers.adb @@ -6,6 +6,7 @@  with +    Ada.Assertions,      Interfaces.C;  use type @@ -16,18 +17,14 @@ use type  package body FLTK.Widgets.Groups.Color_Choosers is -    procedure color_chooser_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, color_chooser_set_draw_hook, "color_chooser_set_draw_hook"); -    pragma Inline (color_chooser_set_draw_hook); +    package Chk renames Ada.Assertions; -    procedure color_chooser_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, color_chooser_set_handle_hook, "color_chooser_set_handle_hook"); -    pragma Inline (color_chooser_set_handle_hook); +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_color_chooser             (X, Y, W, H : in Interfaces.C.int; @@ -145,6 +142,10 @@ package body FLTK.Widgets.Groups.Color_Choosers is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Color_Chooser) is      begin @@ -165,6 +166,10 @@ package body FLTK.Widgets.Groups.Color_Choosers is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Color_Chooser;              X, Y, W, H : in     Integer; @@ -174,6 +179,14 @@ package body FLTK.Widgets.Groups.Color_Choosers is      end Extra_Init; +    procedure Initialize +           (This : in out Color_Chooser) is +    begin +        This.Draw_Ptr := fl_color_chooser_draw'Address; +        This.Handle_Ptr := fl_color_chooser_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -189,10 +202,6 @@ package body FLTK.Widgets.Groups.Color_Choosers is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                color_chooser_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                color_chooser_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -201,6 +210,10 @@ package body FLTK.Widgets.Groups.Color_Choosers is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Red             (This : in Color_Chooser)          return Long_Float is @@ -227,13 +240,34 @@ package body FLTK.Widgets.Groups.Color_Choosers is      procedure Set_RGB             (This    : in out Color_Chooser; -            R, G, B : in     Long_Float) is +            R, G, B : in     Long_Float) +    is +        Result : Interfaces.C.int := fl_color_chooser_rgb +           (This.Void_Ptr, +            Interfaces.C.double (R), +            Interfaces.C.double (G), +            Interfaces.C.double (B));      begin -        This.Was_Changed := fl_color_chooser_rgb +        pragma Assert (Result in 0 .. 1); +    exception +    when Chk.Assertion_Error => raise Internal_FLTK_Error; +    end Set_RGB; + + +    function Set_RGB +           (This    : in out Color_Chooser; +            R, G, B : in     Long_Float) +        return Boolean +    is +        Result : Interfaces.C.int := fl_color_chooser_rgb             (This.Void_Ptr,              Interfaces.C.double (R),              Interfaces.C.double (G), -            Interfaces.C.double (B)) /= 0; +            Interfaces.C.double (B)); +    begin +        return Boolean'Val (Result); +    exception +    when Constraint_Error => raise Internal_FLTK_Error;      end Set_RGB; @@ -265,13 +299,34 @@ package body FLTK.Widgets.Groups.Color_Choosers is      procedure Set_HSV             (This    : in out Color_Chooser; -            H, S, V : in     Long_Float) is +            H, S, V : in     Long_Float) +    is +        Result : Interfaces.C.int := fl_color_chooser_hsv +           (This.Void_Ptr, +            Interfaces.C.double (H), +            Interfaces.C.double (S), +            Interfaces.C.double (V));      begin -        This.Was_Changed := fl_color_chooser_hsv +        pragma Assert (Result in 0 .. 1); +    exception +    when Chk.Assertion_Error => raise Internal_FLTK_Error; +    end Set_HSV; + + +    function Set_HSV +           (This    : in out Color_Chooser; +            H, S, V : in     Long_Float) +        return Boolean +    is +        Result : Interfaces.C.int := fl_color_chooser_hsv             (This.Void_Ptr,              Interfaces.C.double (H),              Interfaces.C.double (S), -            Interfaces.C.double (V)) /= 0; +            Interfaces.C.double (V)); +    begin +        return Boolean'Val (Result); +    exception +    when Constraint_Error => raise Internal_FLTK_Error;      end Set_HSV; @@ -307,23 +362,6 @@ package body FLTK.Widgets.Groups.Color_Choosers is -    function Color_Was_Changed -           (This : in Color_Chooser) -        return Boolean is -    begin -        return This.Was_Changed; -    end Color_Was_Changed; - - -    procedure Clear_Changed -           (This : in out Color_Chooser) is -    begin -        This.Was_Changed := False; -    end Clear_Changed; - - - -      function Get_Mode             (This : in Color_Chooser)          return Color_Mode is @@ -340,24 +378,6 @@ package body FLTK.Widgets.Groups.Color_Choosers is      end Set_Mode; - - -    procedure Draw -           (This : in out Color_Chooser) is -    begin -        fl_color_chooser_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Color_Chooser; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_color_chooser_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Groups.Color_Choosers; + diff --git a/src/fltk-widgets-groups-color_choosers.ads b/src/fltk-widgets-groups-color_choosers.ads index badbe24..8ceb1b7 100644 --- a/src/fltk-widgets-groups-color_choosers.ads +++ b/src/fltk-widgets-groups-color_choosers.ads @@ -45,6 +45,11 @@ package FLTK.Widgets.Groups.Color_Choosers is             (This    : in out Color_Chooser;              R, G, B : in     Long_Float); +    function Set_RGB +           (This    : in out Color_Chooser; +            R, G, B : in     Long_Float) +        return Boolean; + @@ -64,6 +69,11 @@ package FLTK.Widgets.Groups.Color_Choosers is             (This    : in out Color_Chooser;              H, S, V : in     Long_Float); +    function Set_HSV +           (This    : in out Color_Chooser; +            H, S, V : in     Long_Float) +        return Boolean; + @@ -78,16 +88,6 @@ package FLTK.Widgets.Groups.Color_Choosers is -    function Color_Was_Changed -           (This : in Color_Chooser) -        return Boolean; - -    procedure Clear_Changed -           (This : in out Color_Chooser); - - - -      function Get_Mode             (This : in Color_Chooser)          return Color_Mode; @@ -97,23 +97,13 @@ package FLTK.Widgets.Groups.Color_Choosers is              To   : in     Color_Mode); - - -    procedure Draw -           (This : in out Color_Chooser); - -    function Handle -           (This  : in out Color_Chooser; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private -    type Color_Chooser is new Group with record -        Was_Changed : Boolean := False; -    end record; +    type Color_Chooser is new Group with null record; + +    overriding procedure Initialize +           (This : in out Color_Chooser);      overriding procedure Finalize             (This : in out Color_Chooser); @@ -142,15 +132,10 @@ private      pragma Inline (HSV_To_RGB);      pragma Inline (RGB_To_HSV); -    pragma Inline (Color_Was_Changed); -    pragma Inline (Clear_Changed); -      pragma Inline (Get_Mode);      pragma Inline (Set_Mode); -    pragma Inline (Draw); -    pragma Inline (Handle); -  end FLTK.Widgets.Groups.Color_Choosers; + diff --git a/src/fltk-widgets-groups-help_views.adb b/src/fltk-widgets-groups-help_views.adb index a5b169c..c6f4602 100644 --- a/src/fltk-widgets-groups-help_views.adb +++ b/src/fltk-widgets-groups-help_views.adb @@ -27,19 +27,6 @@ package body FLTK.Widgets.Groups.Help_Views is      --  Functions From C  --      ------------------------ -    procedure help_view_set_draw_hook -           (V, D : in Storage.Integer_Address); -    pragma Import (C, help_view_set_draw_hook, "help_view_set_draw_hook"); -    pragma Inline (help_view_set_draw_hook); - -    procedure help_view_set_handle_hook -           (V, H : in Storage.Integer_Address); -    pragma Import (C, help_view_set_handle_hook, "help_view_set_handle_hook"); -    pragma Inline (help_view_set_handle_hook); - - - -      function new_fl_help_view             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -178,6 +165,12 @@ package body FLTK.Widgets.Groups.Help_Views is      pragma Import (C, fl_help_view_set_size, "fl_help_view_set_size");      pragma Inline (fl_help_view_set_size); +    procedure fl_help_view_resize +           (V          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_help_view_resize, "fl_help_view_resize"); +    pragma Inline (fl_help_view_resize); +      function fl_help_view_get_textcolor             (V : in Storage.Integer_Address)          return Interfaces.C.unsigned; @@ -269,9 +262,9 @@ package body FLTK.Widgets.Groups.Help_Views is -    ----------------------------------- -    --  Controlled Type Subprograms  -- -    ----------------------------------- +    ------------------- +    --  Destructors  -- +    -------------------      procedure Extra_Final             (This : in out Help_View) is @@ -294,19 +287,28 @@ package body FLTK.Widgets.Groups.Help_Views is -    --------------------- -    --  Help_View API  -- -    --------------------- +    -------------------- +    --  Constructors  -- +    --------------------      procedure Extra_Init             (This       : in out Help_View;              X, Y, W, H : in     Integer;              Text       : in     String) is      begin +        fl_help_view_link (This.Void_Ptr, Storage.To_Integer (Link_Callback_Hook'Address));          Extra_Init (Group (This), X, Y, W, H, Text);      end Extra_Init; +    procedure Initialize +           (This : in out Help_View) is +    begin +        This.Draw_Ptr := fl_help_view_draw'Address; +        This.Handle_Ptr := fl_help_view_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -322,9 +324,6 @@ package body FLTK.Widgets.Groups.Help_Views is                      Interfaces.C.int (H),                      Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                help_view_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                help_view_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address)); -                fl_help_view_link (This.Void_Ptr, Storage.To_Integer (Link_Callback_Hook'Address));              end return;          end Create; @@ -333,6 +332,10 @@ package body FLTK.Widgets.Groups.Help_Views is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Clear_Selection             (This : in out Help_View) is      begin @@ -519,6 +522,19 @@ package body FLTK.Widgets.Groups.Help_Views is      end Resize; +    procedure Resize +           (This       : in out Help_View; +            X, Y, W, H : in     Integer) is +    begin +        fl_help_view_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + +      function Get_Text_Color             (This : in Help_View)          return Color is @@ -572,7 +588,7 @@ package body FLTK.Widgets.Groups.Help_Views is      procedure Draw             (This : in out Help_View) is      begin -        fl_help_view_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; @@ -581,8 +597,7 @@ package body FLTK.Widgets.Groups.Help_Views is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -           (fl_help_view_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle; diff --git a/src/fltk-widgets-groups-help_views.ads b/src/fltk-widgets-groups-help_views.ads index 8bea2a6..03bb6c5 100644 --- a/src/fltk-widgets-groups-help_views.ads +++ b/src/fltk-widgets-groups-help_views.ads @@ -28,10 +28,8 @@ package FLTK.Widgets.Groups.Help_Views is          return String; - -      --  You have no idea how tempting it is to give this -    --  a more tongue in cheek name +    --  a more tongue in cheek name.      Load_Help_Error : exception; @@ -95,7 +93,7 @@ package FLTK.Widgets.Groups.Help_Views is             (This : in Help_View)          return String; -    --  Name here can be either a ftp/http/https/ipp/mailto/news URL or a filename +    --  Name here can be either a ftp/http/https/ipp/mailto/news URL or a filename.      procedure Load             (This : in out Help_View;              Name : in     String); @@ -135,6 +133,10 @@ package FLTK.Widgets.Groups.Help_Views is             (This : in out Help_View;              W, H : in     Integer); +    procedure Resize +           (This       : in out Help_View; +            X, Y, W, H : in     Integer); +      function Get_Text_Color             (This : in Help_View)          return Color; @@ -179,14 +181,16 @@ private          Hilda : Interfaces.C.Strings.chars_ptr;      end record; +    overriding procedure Initialize +           (This : in out Help_View); +      overriding procedure Finalize             (This : in out Help_View);      procedure Extra_Init             (This       : in out Help_View;              X, Y, W, H : in     Integer; -            Text       : in     String) -    with Inline; +            Text       : in     String);      procedure Extra_Final             (This : in out Help_View); diff --git a/src/fltk-widgets-groups-input_choices.adb b/src/fltk-widgets-groups-input_choices.adb index b321dd2..118b9ea 100644 --- a/src/fltk-widgets-groups-input_choices.adb +++ b/src/fltk-widgets-groups-input_choices.adb @@ -21,19 +21,6 @@ package body FLTK.Widgets.Groups.Input_Choices is      --  Functions From C  --      ------------------------ -    procedure input_choice_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, input_choice_set_draw_hook, "input_choice_set_draw_hook"); -    pragma Inline (input_choice_set_draw_hook); - -    procedure input_choice_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, input_choice_set_handle_hook, "input_choice_set_handle_hook"); -    pragma Inline (input_choice_set_handle_hook); - - - -      function new_fl_input_choice             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -157,6 +144,15 @@ package body FLTK.Widgets.Groups.Input_Choices is +    procedure fl_input_choice_resize +           (N          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_input_choice_resize, "fl_input_choice_resize"); +    pragma Inline (fl_input_choice_resize); + + + +      procedure fl_input_choice_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_input_choice_draw, "fl_input_choice_draw"); @@ -261,6 +257,14 @@ package body FLTK.Widgets.Groups.Input_Choices is      end Extra_Init; +    procedure Initialize +           (This : in out Input_Choice) is +    begin +        This.Draw_Ptr   := fl_input_choice_draw'Address; +        This.Handle_Ptr := fl_input_choice_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -276,10 +280,6 @@ package body FLTK.Widgets.Groups.Input_Choices is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                input_choice_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                input_choice_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -288,6 +288,10 @@ package body FLTK.Widgets.Groups.Input_Choices is +    ------------------ +    --  Attributes  -- +    ------------------ +      function Text_Field             (This : in out Input_Choice)          return FLTK.Widgets.Inputs.Text.Text_Input_Reference is @@ -306,6 +310,10 @@ package body FLTK.Widgets.Groups.Input_Choices is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Clear             (This : in out Input_Choice) is      begin @@ -437,22 +445,19 @@ package body FLTK.Widgets.Groups.Input_Choices is -    procedure Draw -           (This : in out Input_Choice) is -    begin -        fl_input_choice_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Input_Choice; -            Event : in     Event_Kind) -        return Event_Outcome is +    procedure Resize +           (This       : in out Input_Choice; +            X, Y, W, H : in     Integer) is      begin -        return Event_Outcome'Val -               (fl_input_choice_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; +        fl_input_choice_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize;  end FLTK.Widgets.Groups.Input_Choices; + diff --git a/src/fltk-widgets-groups-input_choices.ads b/src/fltk-widgets-groups-input_choices.ads index 656fc3a..f97f69a 100644 --- a/src/fltk-widgets-groups-input_choices.ads +++ b/src/fltk-widgets-groups-input_choices.ads @@ -108,13 +108,9 @@ package FLTK.Widgets.Groups.Input_Choices is -    procedure Draw -           (This : in out Input_Choice); - -    function Handle -           (This  : in out Input_Choice; -            Event : in     Event_Kind) -        return Event_Outcome; +    procedure Resize +           (This       : in out Input_Choice; +            X, Y, W, H : in     Integer);  private @@ -125,6 +121,9 @@ private          My_Menu_Button : aliased Menus.Menu_Buttons.Menu_Button;      end record; +    overriding procedure Initialize +           (This : in out Input_Choice); +      overriding procedure Finalize             (This : in out Input_Choice); @@ -154,9 +153,9 @@ private      pragma Inline (Set_Input);      pragma Inline (Set_Item); -    pragma Inline (Draw); -    pragma Inline (Handle); +    pragma Inline (Resize);  end FLTK.Widgets.Groups.Input_Choices; + diff --git a/src/fltk-widgets-groups-packed.adb b/src/fltk-widgets-groups-packed.adb index ef9ab88..421bca1 100644 --- a/src/fltk-widgets-groups-packed.adb +++ b/src/fltk-widgets-groups-packed.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Packed is -    procedure pack_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, pack_set_draw_hook, "pack_set_draw_hook"); -    pragma Inline (pack_set_draw_hook); - -    procedure pack_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, pack_set_handle_hook, "pack_set_handle_hook"); -    pragma Inline (pack_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_pack             (X, Y, W, H : in Interfaces.C.int; @@ -52,6 +43,18 @@ package body FLTK.Widgets.Groups.Packed is      pragma Import (C, fl_pack_set_spacing, "fl_pack_set_spacing");      pragma Inline (fl_pack_set_spacing); +    function fl_widget_get_type +           (P : in Storage.Integer_Address) +        return Interfaces.C.unsigned_char; +    pragma Import (C, fl_widget_get_type, "fl_widget_get_type"); +    pragma Inline (fl_widget_get_type); + +    procedure fl_widget_set_type +           (P : in Storage.Integer_Address; +            T : in Interfaces.C.unsigned_char); +    pragma Import (C, fl_widget_set_type, "fl_widget_set_type"); +    pragma Inline (fl_widget_set_type); + @@ -70,6 +73,10 @@ package body FLTK.Widgets.Groups.Packed is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Packed_Group) is      begin @@ -90,6 +97,10 @@ package body FLTK.Widgets.Groups.Packed is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Packed_Group;              X, Y, W, H : in     Integer; @@ -99,6 +110,14 @@ package body FLTK.Widgets.Groups.Packed is      end Extra_Init; +    procedure Initialize +           (This : in out Packed_Group) is +    begin +        This.Draw_Ptr   := fl_pack_draw'Address; +        This.Handle_Ptr := fl_pack_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -114,8 +133,6 @@ package body FLTK.Widgets.Groups.Packed is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                pack_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                pack_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -124,6 +141,10 @@ package body FLTK.Widgets.Groups.Packed is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Spacing             (This : in Packed_Group)          return Integer is @@ -140,24 +161,33 @@ package body FLTK.Widgets.Groups.Packed is      end Set_Spacing; +    function Get_Pack_Type +           (This : in Packed_Group) +        return Pack_Kind is +    begin +        return Pack_Kind'Val (fl_widget_get_type (This.Void_Ptr)); +    exception +    when Constraint_Error => raise Internal_FLTK_Error; +    end Get_Pack_Type; -    procedure Draw -           (This : in out Packed_Group) is +    procedure Set_Pack_Type +           (This : in out Packed_Group; +            Kind : in     Pack_Kind) is      begin -        fl_pack_draw (This.Void_Ptr); -    end Draw; +        fl_widget_set_type (This.Void_Ptr, Pack_Kind'Pos (Kind)); +    end Set_Pack_Type; -    function Handle -           (This  : in out Packed_Group; -            Event : in     Event_Kind) -        return Event_Outcome is + + +    procedure Draw +           (This : in out Packed_Group) is      begin -        return Event_Outcome'Val -               (fl_pack_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; +        Group (This).Draw; +    end Draw;  end FLTK.Widgets.Groups.Packed; + diff --git a/src/fltk-widgets-groups-packed.ads b/src/fltk-widgets-groups-packed.ads index 8bc134d..3f2587c 100644 --- a/src/fltk-widgets-groups-packed.ads +++ b/src/fltk-widgets-groups-packed.ads @@ -12,6 +12,8 @@ package FLTK.Widgets.Groups.Packed is      type Packed_Group_Reference (Data : not null access Packed_Group'Class) is          limited null record with Implicit_Dereference => Data; +    type Pack_Kind is (Vertical_Pack, Horizontal_Pack); + @@ -35,23 +37,29 @@ package FLTK.Widgets.Groups.Packed is             (This : in out Packed_Group;              To   : in     Integer); +    function Get_Pack_Type +           (This : in Packed_Group) +        return Pack_Kind; + +    procedure Set_Pack_Type +           (This : in out Packed_Group; +            Kind : in     Pack_Kind); +      procedure Draw             (This : in out Packed_Group); -    function Handle -           (This  : in out Packed_Group; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Packed_Group is new Group with null record; +    overriding procedure Initialize +           (This : in out Packed_Group); +      overriding procedure Finalize             (This : in out Packed_Group); @@ -68,10 +76,12 @@ private      pragma Inline (Get_Spacing);      pragma Inline (Set_Spacing); +    pragma Inline (Get_Pack_Type); +    pragma Inline (Set_Pack_Type);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Groups.Packed; + diff --git a/src/fltk-widgets-groups-scrolls.adb b/src/fltk-widgets-groups-scrolls.adb index 9bc6a05..f2adadd 100644 --- a/src/fltk-widgets-groups-scrolls.adb +++ b/src/fltk-widgets-groups-scrolls.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Scrolls is -    procedure scroll_set_draw_hook -           (S, D : in Storage.Integer_Address); -    pragma Import (C, scroll_set_draw_hook, "scroll_set_draw_hook"); -    pragma Inline (scroll_set_draw_hook); - -    procedure scroll_set_handle_hook -           (S, H : in Storage.Integer_Address); -    pragma Import (C, scroll_set_handle_hook, "scroll_set_handle_hook"); -    pragma Inline (scroll_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_scroll             (X, Y, W, H : in Interfaces.C.int; @@ -105,6 +96,10 @@ package body FLTK.Widgets.Groups.Scrolls is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Scroll) is      begin @@ -125,6 +120,10 @@ package body FLTK.Widgets.Groups.Scrolls is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Scroll;              X, Y, W, H : in     Integer; @@ -134,6 +133,14 @@ package body FLTK.Widgets.Groups.Scrolls is      end Extra_Init; +    procedure Initialize +           (This : in out Scroll) is +    begin +        This.Draw_Ptr   := fl_scroll_draw'Address; +        This.Handle_Ptr := fl_scroll_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -149,8 +156,6 @@ package body FLTK.Widgets.Groups.Scrolls is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                scroll_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                scroll_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -159,6 +164,10 @@ package body FLTK.Widgets.Groups.Scrolls is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Clear             (This : in out Scroll) is      begin @@ -223,7 +232,7 @@ package body FLTK.Widgets.Groups.Scrolls is      procedure Draw             (This : in out Scroll) is      begin -        fl_scroll_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; @@ -232,10 +241,10 @@ package body FLTK.Widgets.Groups.Scrolls is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_scroll_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Scrolls; + diff --git a/src/fltk-widgets-groups-scrolls.ads b/src/fltk-widgets-groups-scrolls.ads index f571230..11b7f9a 100644 --- a/src/fltk-widgets-groups-scrolls.ads +++ b/src/fltk-widgets-groups-scrolls.ads @@ -88,6 +88,9 @@ private      type Scroll is new Group with null record; +    overriding procedure Initialize +           (This : in out Scroll); +      overriding procedure Finalize             (This : in out Scroll); @@ -118,3 +121,4 @@ private  end FLTK.Widgets.Groups.Scrolls; + diff --git a/src/fltk-widgets-groups-spinners.adb b/src/fltk-widgets-groups-spinners.adb index 91ed74a..1ddc806 100644 --- a/src/fltk-widgets-groups-spinners.adb +++ b/src/fltk-widgets-groups-spinners.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Groups.Spinners is -    procedure spinner_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, spinner_set_draw_hook, "spinner_set_draw_hook"); -    pragma Inline (spinner_set_draw_hook); - -    procedure spinner_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, spinner_set_handle_hook, "spinner_set_handle_hook"); -    pragma Inline (spinner_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_spinner             (X, Y, W, H : in Interfaces.C.int; @@ -176,6 +167,15 @@ package body FLTK.Widgets.Groups.Spinners is +    procedure fl_spinner_resize +           (S          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_spinner_resize, "fl_spinner_resize"); +    pragma Inline (fl_spinner_resize); + + + +      procedure fl_spinner_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_spinner_draw, "fl_spinner_draw"); @@ -191,6 +191,10 @@ package body FLTK.Widgets.Groups.Spinners is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Spinner) is      begin @@ -211,6 +215,10 @@ package body FLTK.Widgets.Groups.Spinners is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Spinner;              X, Y, W, H : in     Integer; @@ -220,6 +228,14 @@ package body FLTK.Widgets.Groups.Spinners is      end Extra_Init; +    procedure Initialize +           (This : in out Spinner) is +    begin +        This.Draw_Ptr   := fl_spinner_draw'Address; +        This.Handle_Ptr := fl_spinner_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -235,8 +251,6 @@ package body FLTK.Widgets.Groups.Spinners is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                spinner_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                spinner_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -245,6 +259,10 @@ package body FLTK.Widgets.Groups.Spinners is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Background_Color             (This : in Spinner)          return Color is @@ -429,11 +447,19 @@ package body FLTK.Widgets.Groups.Spinners is -    procedure Draw -           (This : in out Spinner) is +    procedure Resize +           (This       : in out Spinner; +            X, Y, W, H : in     Integer) is      begin -        fl_spinner_draw (This.Void_Ptr); -    end Draw; +        fl_spinner_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + +      function Handle @@ -441,10 +467,10 @@ package body FLTK.Widgets.Groups.Spinners is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_spinner_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Spinners; + diff --git a/src/fltk-widgets-groups-spinners.ads b/src/fltk-widgets-groups-spinners.ads index be7b8d9..5c6233e 100644 --- a/src/fltk-widgets-groups-spinners.ads +++ b/src/fltk-widgets-groups-spinners.ads @@ -123,8 +123,12 @@ package FLTK.Widgets.Groups.Spinners is -    procedure Draw -           (This : in out Spinner); +    procedure Resize +           (This       : in out Spinner; +            X, Y, W, H : in     Integer); + + +      function Handle             (This  : in out Spinner; @@ -137,6 +141,9 @@ private      type Spinner is new Group with null record; +    overriding procedure Initialize +           (This : in out Spinner); +      overriding procedure Finalize             (This : in out Spinner); @@ -174,9 +181,11 @@ private      pragma Inline (Get_Value);      pragma Inline (Set_Value); -    pragma Inline (Draw); +    pragma Inline (Resize); +      pragma Inline (Handle);  end FLTK.Widgets.Groups.Spinners; + diff --git a/src/fltk-widgets-groups-tabbed.adb b/src/fltk-widgets-groups-tabbed.adb index cd7684a..37556e5 100644 --- a/src/fltk-widgets-groups-tabbed.adb +++ b/src/fltk-widgets-groups-tabbed.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Tabbed is -    procedure tabs_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, tabs_set_draw_hook, "tabs_set_draw_hook"); -    pragma Inline (tabs_set_draw_hook); - -    procedure tabs_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, tabs_set_handle_hook, "tabs_set_handle_hook"); -    pragma Inline (tabs_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_tabs             (X, Y, W, H : in Interfaces.C.int; @@ -87,6 +78,11 @@ package body FLTK.Widgets.Groups.Tabbed is      pragma Import (C, fl_tabs_draw, "fl_tabs_draw");      pragma Inline (fl_tabs_draw); +    procedure fl_tabs_redraw_tabs +           (T : in Storage.Integer_Address); +    pragma Import (C, fl_tabs_redraw_tabs, "fl_tabs_redraw_tabs"); +    pragma Inline (fl_tabs_redraw_tabs); +      function fl_tabs_handle             (W : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -97,6 +93,10 @@ package body FLTK.Widgets.Groups.Tabbed is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Tabbed_Group) is      begin @@ -117,6 +117,10 @@ package body FLTK.Widgets.Groups.Tabbed is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Tabbed_Group;              X, Y, W, H : in     Integer; @@ -126,6 +130,14 @@ package body FLTK.Widgets.Groups.Tabbed is      end Extra_Init; +    procedure Initialize +           (This : in out Tabbed_Group) is +    begin +        This.Draw_Ptr := fl_tabs_draw'Address; +        This.Handle_Ptr := fl_tabs_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -141,8 +153,6 @@ package body FLTK.Widgets.Groups.Tabbed is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                tabs_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                tabs_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -151,6 +161,10 @@ package body FLTK.Widgets.Groups.Tabbed is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Get_Client_Area             (This       : in     Tabbed_Group;              Tab_Height : in     Natural; @@ -229,19 +243,26 @@ package body FLTK.Widgets.Groups.Tabbed is      procedure Draw             (This : in out Tabbed_Group) is      begin -        fl_tabs_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; +    procedure Redraw_Tabs +           (This : in out Tabbed_Group) is +    begin +        fl_tabs_redraw_tabs (This.Void_Ptr); +    end Redraw_Tabs; + +      function Handle             (This  : in out Tabbed_Group;              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_tabs_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Tabbed; + diff --git a/src/fltk-widgets-groups-tabbed.ads b/src/fltk-widgets-groups-tabbed.ads index cadd144..136c66e 100644 --- a/src/fltk-widgets-groups-tabbed.ads +++ b/src/fltk-widgets-groups-tabbed.ads @@ -62,6 +62,9 @@ package FLTK.Widgets.Groups.Tabbed is      procedure Draw             (This : in out Tabbed_Group); +    procedure Redraw_Tabs +           (This : in out Tabbed_Group); +      function Handle             (This  : in out Tabbed_Group;              Event : in     Event_Kind) @@ -73,6 +76,9 @@ private      type Tabbed_Group is new Group with null record; +    overriding procedure Initialize +           (This : in out Tabbed_Group); +      overriding procedure Finalize             (This : in out Tabbed_Group); @@ -96,8 +102,10 @@ private      pragma Inline (Get_Which);      pragma Inline (Draw); +    pragma Inline (Redraw_Tabs);      pragma Inline (Handle);  end FLTK.Widgets.Groups.Tabbed; + diff --git a/src/fltk-widgets-groups-text_displays-text_editors.adb b/src/fltk-widgets-groups-text_displays-text_editors.adb index 2ff5afc..3cb60de 100644 --- a/src/fltk-widgets-groups-text_displays-text_editors.adb +++ b/src/fltk-widgets-groups-text_displays-text_editors.adb @@ -17,18 +17,9 @@ use type  package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is -    procedure text_editor_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, text_editor_set_draw_hook, "text_editor_set_draw_hook"); -    pragma Inline (text_editor_set_draw_hook); - -    procedure text_editor_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, text_editor_set_handle_hook, "text_editor_set_handle_hook"); -    pragma Inline (text_editor_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_text_editor             (X, Y, W, H : in Interfaces.C.int; @@ -356,6 +347,10 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is +    ---------------------- +    --  Callback Hooks  -- +    ---------------------- +      function Key_Func_Hook             (K : in Interfaces.C.int;              E : in Storage.Integer_Address) @@ -384,6 +379,10 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Text_Editor) is      begin @@ -435,6 +434,12 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is      --          (Escape_Key,       -1)); + + +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Text_Editor;              X, Y, W, H : in     Integer; @@ -481,6 +486,14 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is      end Extra_Init; +    procedure Initialize +           (This : in out Text_Editor) is +    begin +        This.Draw_Ptr   := fl_text_editor_draw'Address; +        This.Handle_Ptr := fl_text_editor_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -498,10 +511,6 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                text_editor_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                text_editor_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -510,6 +519,10 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Default             (This : in out Text_Editor'Class;              Key  : in     Key_Combo) is @@ -988,22 +1001,15 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is -    procedure Draw -           (This : in out Text_Editor) is -    begin -        fl_text_editor_draw (This.Void_Ptr); -    end Draw; - -      function Handle             (This  : in out Text_Editor;              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_text_editor_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Text_Display (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Text_Displays.Text_Editors; + diff --git a/src/fltk-widgets-groups-text_displays-text_editors.ads b/src/fltk-widgets-groups-text_displays-text_editors.ads index 8eb604a..6520d69 100644 --- a/src/fltk-widgets-groups-text_displays-text_editors.ads +++ b/src/fltk-widgets-groups-text_displays-text_editors.ads @@ -320,9 +320,6 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is -    procedure Draw -           (This : in out Text_Editor); -      function Handle             (This  : in out Text_Editor;              Event : in     Event_Kind) @@ -341,6 +338,9 @@ private          Default_Func : Default_Key_Func;      end record; +    overriding procedure Initialize +           (This : in out Text_Editor); +      overriding procedure Finalize             (This : in out Text_Editor); @@ -424,9 +424,9 @@ private      --  pragma Inline (Get_Tab_Nav_Mode);      --  pragma Inline (Set_Tab_Nav_Mode); -    pragma Inline (Draw);      pragma Inline (Handle);  end FLTK.Widgets.Groups.Text_Displays.Text_Editors; + diff --git a/src/fltk-widgets-groups-text_displays.adb b/src/fltk-widgets-groups-text_displays.adb index 563fbbf..170ed51 100644 --- a/src/fltk-widgets-groups-text_displays.adb +++ b/src/fltk-widgets-groups-text_displays.adb @@ -17,18 +17,9 @@ use type  package body FLTK.Widgets.Groups.Text_Displays is -    procedure text_display_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, text_display_set_draw_hook, "text_display_set_draw_hook"); -    pragma Inline (text_display_set_draw_hook); - -    procedure text_display_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, text_display_set_handle_hook, "text_display_set_handle_hook"); -    pragma Inline (text_display_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_text_display             (X, Y, W, H : in Interfaces.C.int; @@ -449,6 +440,10 @@ package body FLTK.Widgets.Groups.Text_Displays is +    ---------------------- +    --  Callback Hooks  -- +    ---------------------- +      procedure Style_Hook             (C : in Interfaces.C.int;              D : in Storage.Integer_Address) @@ -466,6 +461,10 @@ package body FLTK.Widgets.Groups.Text_Displays is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Text_Display) is      begin @@ -487,6 +486,10 @@ package body FLTK.Widgets.Groups.Text_Displays is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Text_Display;              X, Y, W, H : in     Integer; @@ -496,6 +499,14 @@ package body FLTK.Widgets.Groups.Text_Displays is      end Extra_Init; +    procedure Initialize +           (This : in out Text_Display) is +    begin +        This.Draw_Ptr   := fl_text_display_draw'Address; +        This.Handle_Ptr := fl_text_display_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -511,10 +522,6 @@ package body FLTK.Widgets.Groups.Text_Displays is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                text_display_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                text_display_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -523,6 +530,10 @@ package body FLTK.Widgets.Groups.Text_Displays is +    ---------------------- +    --  Child Packages  -- +    ---------------------- +      package body Styles is          function Item @@ -546,6 +557,10 @@ package body FLTK.Widgets.Groups.Text_Displays is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Buffer             (This : in Text_Display)          return FLTK.Text_Buffers.Text_Buffer_Reference is @@ -1105,7 +1120,7 @@ package body FLTK.Widgets.Groups.Text_Displays is      procedure Draw             (This : in out Text_Display) is      begin -        fl_text_display_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; @@ -1114,10 +1129,10 @@ package body FLTK.Widgets.Groups.Text_Displays is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_text_display_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Text_Displays; + diff --git a/src/fltk-widgets-groups-text_displays.ads b/src/fltk-widgets-groups-text_displays.ads index bf7d662..f4ffd43 100644 --- a/src/fltk-widgets-groups-text_displays.ads +++ b/src/fltk-widgets-groups-text_displays.ads @@ -26,6 +26,7 @@ package FLTK.Widgets.Groups.Text_Displays is      type Cursor_Style is (Normal, Caret, Dim, Block, Heavy, Simple); +      Bounds_Error : exception; @@ -220,13 +221,13 @@ package FLTK.Widgets.Groups.Text_Displays is -    --  takes into account word wrap +    --  Takes into account word wrap      function Line_Start             (This : in Text_Display;              Pos  : in Natural)          return Natural; -    --  takes into account word wrap +    --  Takes into account word wrap      function Line_End             (This                    : in Text_Display;              Pos                     : in Natural; @@ -239,14 +240,14 @@ package FLTK.Widgets.Groups.Text_Displays is              Start_Pos_Is_Line_Start : in Boolean := False)          return Natural; -    --  takes into account word wrap as well as newline characters +    --  Takes into account word wrap as well as newline characters      function Skip_Lines             (This                    : in Text_Display;              Start, Lines            : in Natural;              Start_Pos_Is_Line_Start : in Boolean := False)          return Natural; -    --  takes into account word wrap as well as newline characters +    --  Takes into account word wrap as well as newline characters      function Rewind_Lines             (This         : in Text_Display;              Start, Lines : in Natural) @@ -367,6 +368,9 @@ private              Style_Callback : Styles.Unfinished_Style_Callback;          end record; +    overriding procedure Initialize +           (This : in out Text_Display); +      overriding procedure Finalize             (This : in out Text_Display); @@ -469,3 +473,4 @@ private  end FLTK.Widgets.Groups.Text_Displays; + diff --git a/src/fltk-widgets-groups-tiled.adb b/src/fltk-widgets-groups-tiled.adb index 05dcd61..bf3950c 100644 --- a/src/fltk-widgets-groups-tiled.adb +++ b/src/fltk-widgets-groups-tiled.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Tiled is -    procedure tile_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, tile_set_draw_hook, "tile_set_draw_hook"); -    pragma Inline (tile_set_draw_hook); - -    procedure tile_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, tile_set_handle_hook, "tile_set_handle_hook"); -    pragma Inline (tile_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_tile             (X, Y, W, H : in Interfaces.C.int; @@ -46,6 +37,12 @@ package body FLTK.Widgets.Groups.Tiled is      pragma Import (C, fl_tile_position, "fl_tile_position");      pragma Inline (fl_tile_position); +    procedure fl_tile_resize +           (T          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_tile_resize, "fl_tile_resize"); +    pragma Inline (fl_tile_resize); + @@ -64,6 +61,10 @@ package body FLTK.Widgets.Groups.Tiled is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Tiled_Group) is      begin @@ -84,6 +85,10 @@ package body FLTK.Widgets.Groups.Tiled is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Tiled_Group;              X, Y, W, H : in     Integer; @@ -93,6 +98,14 @@ package body FLTK.Widgets.Groups.Tiled is      end Extra_Init; +    procedure Initialize +           (This : in out Tiled_Group) is +    begin +        This.Draw_Ptr := fl_tile_draw'Address; +        This.Handle_Ptr := fl_tile_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -108,8 +121,6 @@ package body FLTK.Widgets.Groups.Tiled is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                tile_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                tile_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -118,6 +129,10 @@ package body FLTK.Widgets.Groups.Tiled is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Position             (This         : in out Tiled_Group;              Old_X, Old_Y : in     Integer; @@ -130,13 +145,19 @@ package body FLTK.Widgets.Groups.Tiled is      end Position; +    procedure Resize +           (This       : in out Tiled_Group; +            X, Y, W, H : in     Integer) is +    begin +        fl_tile_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; -    procedure Draw -           (This : in out Tiled_Group) is -    begin -        fl_tile_draw (This.Void_Ptr); -    end Draw;      function Handle @@ -144,10 +165,10 @@ package body FLTK.Widgets.Groups.Tiled is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_tile_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Tiled; + diff --git a/src/fltk-widgets-groups-tiled.ads b/src/fltk-widgets-groups-tiled.ads index 7dc3d0d..1580464 100644 --- a/src/fltk-widgets-groups-tiled.ads +++ b/src/fltk-widgets-groups-tiled.ads @@ -32,11 +32,12 @@ package FLTK.Widgets.Groups.Tiled is              Old_X, Old_Y : in     Integer;              New_X, New_Y : in     Integer); +    procedure Resize +           (This       : in out Tiled_Group; +            X, Y, W, H : in     Integer); -    procedure Draw -           (This : in out Tiled_Group);      function Handle             (This  : in out Tiled_Group; @@ -49,6 +50,9 @@ private      type Tiled_Group is new Group with null record; +    overriding procedure Initialize +           (This : in out Tiled_Group); +      overriding procedure Finalize             (This : in out Tiled_Group); @@ -64,10 +68,11 @@ private      pragma Inline (Position); +    pragma Inline (Resize); -    pragma Inline (Draw);      pragma Inline (Handle);  end FLTK.Widgets.Groups.Tiled; + diff --git a/src/fltk-widgets-groups-windows-double-cairo.adb b/src/fltk-widgets-groups-windows-double-cairo.adb index 61ea232..eeeab90 100644 --- a/src/fltk-widgets-groups-windows-double-cairo.adb +++ b/src/fltk-widgets-groups-windows-double-cairo.adb @@ -134,6 +134,14 @@ package body FLTK.Widgets.Groups.Windows.Double.Cairo is      end Extra_Init; +    procedure Initialize +           (This : in out Cairo_Window) is +    begin +        This.Draw_Ptr := fl_cairo_window_draw'Address; +        This.Handle_Ptr := fl_cairo_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -202,20 +210,10 @@ package body FLTK.Widgets.Groups.Windows.Double.Cairo is      procedure Draw             (This : in out Cairo_Window) is      begin -        fl_cairo_window_draw (This.Void_Ptr); +        Double_Window (This).Draw;      end Draw; -    function Handle -           (This  : in out Cairo_Window; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -           (fl_cairo_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Groups.Windows.Double.Cairo; diff --git a/src/fltk-widgets-groups-windows-double-cairo.ads b/src/fltk-widgets-groups-windows-double-cairo.ads index 111f7ac..02a1dbf 100644 --- a/src/fltk-widgets-groups-windows-double-cairo.ads +++ b/src/fltk-widgets-groups-windows-double-cairo.ads @@ -65,11 +65,6 @@ package FLTK.Widgets.Groups.Windows.Double.Cairo is      procedure Draw             (This : in out Cairo_Window); -    function Handle -           (This  : in out Cairo_Window; -            Event : in     Event_Kind) -        return Event_Outcome; -  private @@ -78,6 +73,9 @@ private          My_Func : Cairo_Callback;      end record; +    overriding procedure Initialize +           (This : in out Cairo_Window); +      overriding procedure Finalize             (This : in out Cairo_Window); @@ -93,7 +91,6 @@ private      pragma Inline (Set_Cairo_Draw);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Groups.Windows.Double.Cairo; diff --git a/src/fltk-widgets-groups-windows-double-overlay.adb b/src/fltk-widgets-groups-windows-double-overlay.adb index 90f4754..33a2f92 100644 --- a/src/fltk-widgets-groups-windows-double-overlay.adb +++ b/src/fltk-widgets-groups-windows-double-overlay.adb @@ -17,24 +17,9 @@ use type  package body FLTK.Widgets.Groups.Windows.Double.Overlay is -    procedure overlay_window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, overlay_window_set_draw_hook, "overlay_window_set_draw_hook"); -    pragma Inline (overlay_window_set_draw_hook); - -    procedure overlay_window_set_draw_overlay_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, overlay_window_set_draw_overlay_hook, -        "overlay_window_set_draw_overlay_hook"); -    pragma Inline (overlay_window_set_draw_overlay_hook); - -    procedure overlay_window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, overlay_window_set_handle_hook, "overlay_window_set_handle_hook"); -    pragma Inline (overlay_window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_overlay_window             (X, Y, W, H : in Interfaces.C.int; @@ -82,6 +67,12 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is      pragma Import (C, fl_overlay_window_can_do_overlay, "fl_overlay_window_can_do_overlay");      pragma Inline (fl_overlay_window_can_do_overlay); +    procedure fl_overlay_window_resize +           (OW         : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_overlay_window_resize, "fl_overlay_window_resize"); +    pragma Inline (fl_overlay_window_resize); + @@ -105,20 +96,31 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is +    ---------------------- +    --  Exported Hooks  -- +    ---------------------- +      package Over_Convert is new System.Address_To_Access_Conversions (Overlay_Window'Class); +    procedure Overlay_Window_Draw_Overlay_Hook +           (U : in Storage.Integer_Address); +    pragma Export (C, Overlay_Window_Draw_Overlay_Hook, "overlay_window_draw_overlay_hook"); -    procedure Draw_Overlay_Hook +    procedure Overlay_Window_Draw_Overlay_Hook             (U : in Storage.Integer_Address)      is          Overlay_Widget : access Overlay_Window'Class :=              Over_Convert.To_Pointer (Storage.To_Address (U));      begin          Overlay_Widget.Draw_Overlay; -    end Draw_Overlay_Hook; +    end Overlay_Window_Draw_Overlay_Hook; + +    ------------------- +    --  Destructors  -- +    -------------------      procedure Extra_Final             (This : in out Overlay_Window) is @@ -153,6 +155,14 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is      end Extra_Init; +    procedure Initialize +           (This : in out Overlay_Window) is +    begin +        This.Draw_Ptr   := fl_overlay_window_draw'Address; +        This.Handle_Ptr := fl_overlay_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -168,12 +178,6 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is                      Interfaces.C.int (H),                      Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                overlay_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                overlay_window_set_draw_overlay_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Overlay_Hook'Address)); -                overlay_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -189,12 +193,6 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is                      Interfaces.C.int (H),                      Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                overlay_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                overlay_window_set_draw_overlay_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Overlay_Hook'Address)); -                overlay_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -242,17 +240,30 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is      end Can_Do_Overlay; +    procedure Resize +           (This       : in out Overlay_Window; +            X, Y, W, H : in     Integer) is +    begin +        fl_overlay_window_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + +      ----------------------------------      --  Drawing and Event Handling  --      ---------------------------------- -    procedure Draw +    procedure Draw_Overlay             (This : in out Overlay_Window) is      begin -        fl_overlay_window_draw (This.Void_Ptr); -    end Draw; +        raise Program_Error with "You must override Draw_Overlay"; +    end Draw_Overlay;      procedure Redraw_Overlay @@ -262,15 +273,6 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is      end Redraw_Overlay; -    function Handle -           (This  : in out Overlay_Window; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -            (fl_overlay_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Groups.Windows.Double.Overlay; + diff --git a/src/fltk-widgets-groups-windows-double-overlay.ads b/src/fltk-widgets-groups-windows-double-overlay.ads index 097abb8..082087c 100644 --- a/src/fltk-widgets-groups-windows-double-overlay.ads +++ b/src/fltk-widgets-groups-windows-double-overlay.ads @@ -7,10 +7,6 @@  package FLTK.Widgets.Groups.Windows.Double.Overlay is -    ------------- -    --  Types  -- -    ------------- -      type Overlay_Window is new Double_Window with private;      type Overlay_Window_Reference (Data : not null access Overlay_Window'Class) is @@ -19,10 +15,6 @@ package FLTK.Widgets.Groups.Windows.Double.Overlay is -    -------------------- -    --  Constructors  -- -    -------------------- -      package Forge is          function Create @@ -40,10 +32,6 @@ package FLTK.Widgets.Groups.Windows.Double.Overlay is -    --------------- -    --  Display  -- -    --------------- -      procedure Show             (This : in out Overlay_Window); @@ -56,41 +44,33 @@ package FLTK.Widgets.Groups.Windows.Double.Overlay is -    ------------- -    --  Other  -- -    ------------- -      function Can_Do_Overlay             (This : in Overlay_Window)          return Boolean; +    procedure Resize +           (This       : in out Overlay_Window; +            X, Y, W, H : in     Integer); -    ---------------------------------- -    --  Drawing and Event Handling  -- -    ---------------------------------- - -    procedure Draw -           (This : in out Overlay_Window); +    --  You must override this subprogram      procedure Draw_Overlay -           (This : in out Overlay_Window) is null; +           (This : in out Overlay_Window);      procedure Redraw_Overlay             (This : in out Overlay_Window); -    function Handle -           (This  : in out Overlay_Window; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Overlay_Window is new Double_Window with null record; +    overriding procedure Initialize +           (This : in out Overlay_Window); +      overriding procedure Finalize             (This : in out Overlay_Window); @@ -110,11 +90,11 @@ private      pragma Inline (Flush);      pragma Inline (Can_Do_Overlay); +    pragma Inline (Resize); -    pragma Inline (Draw);      pragma Inline (Redraw_Overlay); -    pragma Inline (Handle);  end FLTK.Widgets.Groups.Windows.Double.Overlay; + diff --git a/src/fltk-widgets-groups-windows-double.adb b/src/fltk-widgets-groups-windows-double.adb index 24ee93d..cff5c5c 100644 --- a/src/fltk-widgets-groups-windows-double.adb +++ b/src/fltk-widgets-groups-windows-double.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Windows.Double is -    procedure double_window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, double_window_set_draw_hook, "double_window_set_draw_hook"); -    pragma Inline (double_window_set_draw_hook); - -    procedure double_window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, double_window_set_handle_hook, "double_window_set_handle_hook"); -    pragma Inline (double_window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_double_window             (X, Y, W, H : in Interfaces.C.int; @@ -65,6 +56,15 @@ package body FLTK.Widgets.Groups.Windows.Double is +    procedure fl_double_window_resize +           (DW         : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_double_window_resize, "fl_double_window_resize"); +    pragma Inline (fl_double_window_resize); + + + +      procedure fl_double_window_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_double_window_draw, "fl_double_window_draw"); @@ -80,6 +80,10 @@ package body FLTK.Widgets.Groups.Windows.Double is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Double_Window) is      begin @@ -100,6 +104,10 @@ package body FLTK.Widgets.Groups.Windows.Double is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Double_Window;              X, Y, W, H : in     Integer; @@ -109,6 +117,14 @@ package body FLTK.Widgets.Groups.Windows.Double is      end Extra_Init; +    procedure Initialize +           (This : in out Double_Window) is +    begin +        This.Draw_Ptr   := fl_double_window_draw'Address; +        This.Handle_Ptr := fl_double_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -124,10 +140,6 @@ package body FLTK.Widgets.Groups.Windows.Double is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                double_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                double_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -143,10 +155,6 @@ package body FLTK.Widgets.Groups.Windows.Double is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                double_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                double_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -155,6 +163,10 @@ package body FLTK.Widgets.Groups.Windows.Double is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Show             (This : in out Double_Window) is      begin @@ -178,22 +190,19 @@ package body FLTK.Widgets.Groups.Windows.Double is -    procedure Draw -           (This : in out Double_Window) is -    begin -        fl_double_window_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Double_Window; -            Event : in     Event_Kind) -        return Event_Outcome is +    procedure Resize +           (This       : in out Double_Window; +            X, Y, W, H : in     Integer) is      begin -        return Event_Outcome'Val -               (fl_double_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; +        fl_double_window_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize;  end FLTK.Widgets.Groups.Windows.Double; + diff --git a/src/fltk-widgets-groups-windows-double.ads b/src/fltk-widgets-groups-windows-double.ads index a72c090..f4e7089 100644 --- a/src/fltk-widgets-groups-windows-double.ads +++ b/src/fltk-widgets-groups-windows-double.ads @@ -14,6 +14,7 @@ package FLTK.Widgets.Groups.Windows.Double is +      package Forge is          function Create @@ -43,13 +44,9 @@ package FLTK.Widgets.Groups.Windows.Double is -    procedure Draw -           (This : in out Double_Window); - -    function Handle -           (This  : in out Double_Window; -            Event : in     Event_Kind) -        return Event_Outcome; +    procedure Resize +           (This       : in out Double_Window; +            X, Y, W, H : in     Integer);  private @@ -57,6 +54,9 @@ private      type Double_Window is new Window with null record; +    overriding procedure Initialize +           (This : in out Double_Window); +      overriding procedure Finalize             (This : in out Double_Window); @@ -75,9 +75,9 @@ private      pragma Inline (Hide);      pragma Inline (Flush); -    pragma Inline (Draw); -    pragma Inline (Handle); +    pragma Inline (Resize);  end FLTK.Widgets.Groups.Windows.Double; + diff --git a/src/fltk-widgets-groups-windows-opengl.adb b/src/fltk-widgets-groups-windows-opengl.adb index fd43bc0..04a4b65 100644 --- a/src/fltk-widgets-groups-windows-opengl.adb +++ b/src/fltk-widgets-groups-windows-opengl.adb @@ -19,18 +19,9 @@ use type  package body FLTK.Widgets.Groups.Windows.OpenGL is -    procedure gl_window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, gl_window_set_draw_hook, "gl_window_set_draw_hook"); -    pragma Inline (gl_window_set_draw_hook); - -    procedure gl_window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, gl_window_set_handle_hook, "gl_window_set_handle_hook"); -    pragma Inline (gl_window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_gl_window             (X, Y, W, H : in Interfaces.C.int; @@ -95,6 +86,12 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is      pragma Import (C, fl_gl_window_pixels_per_unit, "fl_gl_window_pixels_per_unit");      pragma Inline (fl_gl_window_pixels_per_unit); +    procedure fl_gl_window_resize +           (G          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_gl_window_resize, "fl_gl_window_resize"); +    pragma Inline (fl_gl_window_resize); + @@ -210,6 +207,10 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out GL_Window) is      begin @@ -243,6 +244,14 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is      end Extra_Init; +    procedure Initialize +           (This : in out GL_Window) is +    begin +        This.Draw_Ptr   := fl_gl_window_draw'Address; +        This.Handle_Ptr := fl_gl_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -258,8 +267,6 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is                      Interfaces.C.int (H),                      Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                gl_window_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                gl_window_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -275,8 +282,6 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is                      Interfaces.C.int (H),                      Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                gl_window_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                gl_window_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -347,6 +352,19 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is      end Pixels_Per_Unit; +    procedure Resize +           (This       : in out GL_Window; +            X, Y, W, H : in     Integer) is +    begin +        fl_gl_window_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + +      -------------------- @@ -493,7 +511,7 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is      procedure Draw             (This : in out GL_Window) is      begin -        fl_gl_window_draw (This.Void_Ptr); +        Window (This).Draw;      end Draw; @@ -502,10 +520,10 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_gl_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Window (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Windows.OpenGL; + diff --git a/src/fltk-widgets-groups-windows-opengl.ads b/src/fltk-widgets-groups-windows-opengl.ads index 63762fb..9c8d1c9 100644 --- a/src/fltk-widgets-groups-windows-opengl.ads +++ b/src/fltk-widgets-groups-windows-opengl.ads @@ -16,10 +16,6 @@ private with  package FLTK.Widgets.Groups.Windows.OpenGL is -    ------------- -    --  Types  -- -    ------------- -      type GL_Window is new Window with private;      type GL_Window_Reference (Data : not null access GL_Window'Class) is @@ -44,10 +40,6 @@ package FLTK.Widgets.Groups.Windows.OpenGL is -    -------------------- -    --  Constructors  -- -    -------------------- -      package Forge is          function Create @@ -100,6 +92,10 @@ package FLTK.Widgets.Groups.Windows.OpenGL is             (This : in GL_Window)          return Float; +    procedure Resize +           (This       : in out GL_Window; +            X, Y, W, H : in     Integer); + @@ -195,6 +191,9 @@ private      type GL_Window is new Window with null record; +    overriding procedure Initialize +           (This : in out GL_Window); +      overriding procedure Finalize             (This : in out GL_Window); @@ -260,3 +259,4 @@ private  end FLTK.Widgets.Groups.Windows.OpenGL; + diff --git a/src/fltk-widgets-groups-windows-single-menu.adb b/src/fltk-widgets-groups-windows-single-menu.adb index fa2c9b3..7448c3b 100644 --- a/src/fltk-widgets-groups-windows-single-menu.adb +++ b/src/fltk-widgets-groups-windows-single-menu.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Groups.Windows.Single.Menu is -    procedure menu_window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, menu_window_set_draw_hook, "menu_window_set_draw_hook"); -    pragma Inline (menu_window_set_draw_hook); - -    procedure menu_window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, menu_window_set_handle_hook, "menu_window_set_handle_hook"); -    pragma Inline (menu_window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_menu_window             (X, Y, W, H : in Interfaces.C.int; @@ -103,6 +94,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Menu_Window) is      begin @@ -123,6 +118,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Menu_Window;              X, Y, W, H : in     Integer; @@ -132,6 +131,14 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is      end Extra_Init; +    procedure Initialize +           (This : in out Menu_Window) is +    begin +        This.Draw_Ptr   := fl_menu_window_draw'Address; +        This.Handle_Ptr := fl_menu_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -147,10 +154,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                menu_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                menu_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -166,10 +169,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                menu_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                menu_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -178,6 +177,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Show             (This : in out Menu_Window) is      begin @@ -221,24 +224,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is      end Set_Overlay; - - -    procedure Draw -           (This : in out Menu_Window) is -    begin -        fl_menu_window_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Menu_Window; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_menu_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Groups.Windows.Single.Menu; + diff --git a/src/fltk-widgets-groups-windows-single-menu.ads b/src/fltk-widgets-groups-windows-single-menu.ads index d380141..1908d72 100644 --- a/src/fltk-widgets-groups-windows-single-menu.ads +++ b/src/fltk-widgets-groups-windows-single-menu.ads @@ -53,22 +53,14 @@ package FLTK.Widgets.Groups.Windows.Single.Menu is              Value : in     Boolean); - - -    procedure Draw -           (This : in out Menu_Window); - -    function Handle -           (This  : in out Menu_Window; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Menu_Window is new Single_Window with null record; +    overriding procedure Initialize +           (This : in out Menu_Window); +      overriding procedure Finalize             (This : in out Menu_Window); @@ -90,9 +82,7 @@ private      pragma Inline (Is_Overlay);      pragma Inline (Set_Overlay); -    pragma Inline (Draw); -    pragma Inline (Handle); -  end FLTK.Widgets.Groups.Windows.Single.Menu; + diff --git a/src/fltk-widgets-groups-windows-single.adb b/src/fltk-widgets-groups-windows-single.adb index 1c90ba3..720ce28 100644 --- a/src/fltk-widgets-groups-windows-single.adb +++ b/src/fltk-widgets-groups-windows-single.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Windows.Single is -    procedure single_window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, single_window_set_draw_hook, "single_window_set_draw_hook"); -    pragma Inline (single_window_set_draw_hook); - -    procedure single_window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, single_window_set_handle_hook, "single_window_set_handle_hook"); -    pragma Inline (single_window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_single_window             (X, Y, W, H : in Interfaces.C.int; @@ -60,6 +51,14 @@ package body FLTK.Widgets.Groups.Windows.Single is +    procedure fl_single_window_make_current +           (S : in Storage.Integer_Address); +    pragma Import (C, fl_single_window_make_current, "fl_single_window_make_current"); +    pragma Inline (fl_single_window_make_current); + + + +      procedure fl_single_window_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_single_window_draw, "fl_single_window_draw"); @@ -75,6 +74,10 @@ package body FLTK.Widgets.Groups.Windows.Single is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Single_Window) is      begin @@ -95,6 +98,10 @@ package body FLTK.Widgets.Groups.Windows.Single is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Single_Window;              X, Y, W, H : in     Integer; @@ -104,6 +111,14 @@ package body FLTK.Widgets.Groups.Windows.Single is      end Extra_Init; +    procedure Initialize +           (This : in out Single_Window) is +    begin +        This.Draw_Ptr   := fl_single_window_draw'Address; +        This.Handle_Ptr := fl_single_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -119,10 +134,6 @@ package body FLTK.Widgets.Groups.Windows.Single is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                single_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                single_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -138,10 +149,6 @@ package body FLTK.Widgets.Groups.Windows.Single is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                single_window_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                single_window_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -150,6 +157,10 @@ package body FLTK.Widgets.Groups.Windows.Single is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Show             (This : in out Single_Window) is      begin @@ -166,22 +177,13 @@ package body FLTK.Widgets.Groups.Windows.Single is -    procedure Draw +    procedure Make_Current             (This : in out Single_Window) is      begin -        fl_single_window_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Single_Window; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_single_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; +        fl_single_window_make_current (This.Void_Ptr); +    end Make_Current;  end FLTK.Widgets.Groups.Windows.Single; + diff --git a/src/fltk-widgets-groups-windows-single.ads b/src/fltk-widgets-groups-windows-single.ads index 0dfa262..73b2620 100644 --- a/src/fltk-widgets-groups-windows-single.ads +++ b/src/fltk-widgets-groups-windows-single.ads @@ -41,20 +41,18 @@ package FLTK.Widgets.Groups.Windows.Single is -    procedure Draw +    procedure Make_Current             (This : in out Single_Window); -    function Handle -           (This  : in out Single_Window; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Single_Window is new Window with null record; +    overriding procedure Initialize +           (This : in out Single_Window); +      overriding procedure Finalize             (This : in out Single_Window); @@ -72,9 +70,9 @@ private      pragma Inline (Show);      pragma Inline (Flush); -    pragma Inline (Draw); -    pragma Inline (Handle); +    pragma Inline (Make_Current);  end FLTK.Widgets.Groups.Windows.Single; + diff --git a/src/fltk-widgets-groups-windows.adb b/src/fltk-widgets-groups-windows.adb index 0c02f6c..090def8 100644 --- a/src/fltk-widgets-groups-windows.adb +++ b/src/fltk-widgets-groups-windows.adb @@ -19,18 +19,9 @@ use type  package body FLTK.Widgets.Groups.Windows is -    procedure window_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, window_set_draw_hook, "window_set_draw_hook"); -    pragma Inline (window_set_draw_hook); - -    procedure window_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, window_set_handle_hook, "window_set_handle_hook"); -    pragma Inline (window_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_window             (X, Y, W, H : in Interfaces.C.int; @@ -300,6 +291,10 @@ package body FLTK.Widgets.Groups.Windows is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Window) is      begin @@ -320,6 +315,10 @@ package body FLTK.Widgets.Groups.Windows is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Window;              X, Y, W, H : in     Integer; @@ -329,6 +328,14 @@ package body FLTK.Widgets.Groups.Windows is      end Extra_Init; +    procedure Initialize +           (This : in out Window) is +    begin +        This.Draw_Ptr   := fl_window_draw'Address; +        This.Handle_Ptr := fl_window_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -344,8 +351,6 @@ package body FLTK.Widgets.Groups.Windows is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                window_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                window_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -361,8 +366,6 @@ package body FLTK.Widgets.Groups.Windows is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); -                window_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                window_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -371,6 +374,10 @@ package body FLTK.Widgets.Groups.Windows is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Show             (This : in out Window) is      begin @@ -727,7 +734,7 @@ package body FLTK.Widgets.Groups.Windows is      procedure Draw             (This : in out Window) is      begin -        fl_window_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; @@ -736,10 +743,10 @@ package body FLTK.Widgets.Groups.Windows is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Group (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups.Windows; + diff --git a/src/fltk-widgets-groups-windows.ads b/src/fltk-widgets-groups-windows.ads index f64bb40..a419fbb 100644 --- a/src/fltk-widgets-groups-windows.ads +++ b/src/fltk-widgets-groups-windows.ads @@ -215,6 +215,9 @@ private      type Window is new Group with null record; +    overriding procedure Initialize +           (This : in out Window); +      overriding procedure Finalize             (This : in out Window); @@ -277,3 +280,4 @@ private  end FLTK.Widgets.Groups.Windows; + diff --git a/src/fltk-widgets-groups-wizards.adb b/src/fltk-widgets-groups-wizards.adb index df0d653..658bf55 100644 --- a/src/fltk-widgets-groups-wizards.adb +++ b/src/fltk-widgets-groups-wizards.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Groups.Wizards is -    procedure wizard_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, wizard_set_draw_hook, "wizard_set_draw_hook"); -    pragma Inline (wizard_set_draw_hook); - -    procedure wizard_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, wizard_set_handle_hook, "wizard_set_handle_hook"); -    pragma Inline (wizard_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_wizard             (X, Y, W, H : in Interfaces.C.int; @@ -82,6 +73,10 @@ package body FLTK.Widgets.Groups.Wizards is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Wizard) is      begin @@ -102,6 +97,10 @@ package body FLTK.Widgets.Groups.Wizards is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Wizard;              X, Y, W, H : in     Integer; @@ -111,6 +110,14 @@ package body FLTK.Widgets.Groups.Wizards is      end Extra_Init; +    procedure Initialize +           (This : in out Wizard) is +    begin +        This.Draw_Ptr   := fl_wizard_draw'Address; +        This.Handle_Ptr := fl_wizard_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -126,8 +133,6 @@ package body FLTK.Widgets.Groups.Wizards is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                wizard_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                wizard_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -136,6 +141,10 @@ package body FLTK.Widgets.Groups.Wizards is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Next             (This : in out Wizard) is      begin @@ -178,19 +187,10 @@ package body FLTK.Widgets.Groups.Wizards is      procedure Draw             (This : in out Wizard) is      begin -        fl_wizard_draw (This.Void_Ptr); +        Group (This).Draw;      end Draw; -    function Handle -           (This  : in out Wizard; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_wizard_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Groups.Wizards; + diff --git a/src/fltk-widgets-groups-wizards.ads b/src/fltk-widgets-groups-wizards.ads index 9464a0f..4473c54 100644 --- a/src/fltk-widgets-groups-wizards.ads +++ b/src/fltk-widgets-groups-wizards.ads @@ -50,17 +50,15 @@ package FLTK.Widgets.Groups.Wizards is      procedure Draw             (This : in out Wizard); -    function Handle -           (This  : in out Wizard; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Wizard is new Group with null record; +    overriding procedure Initialize +           (This : in out Wizard); +      overriding procedure Finalize             (This : in out Wizard); @@ -82,8 +80,8 @@ private      pragma Inline (Set_Visible);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Groups.Wizards; + diff --git a/src/fltk-widgets-groups.adb b/src/fltk-widgets-groups.adb index 17cb4fa..491bd0d 100644 --- a/src/fltk-widgets-groups.adb +++ b/src/fltk-widgets-groups.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Groups is -    procedure group_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, group_set_draw_hook, "group_set_draw_hook"); -    pragma Inline (group_set_draw_hook); - -    procedure group_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, group_set_handle_hook, "group_set_handle_hook"); -    pragma Inline (group_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_group             (X, Y, W, H : in Interfaces.C.int; @@ -166,6 +157,10 @@ package body FLTK.Widgets.Groups is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Group) is      begin @@ -187,6 +182,10 @@ package body FLTK.Widgets.Groups is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Group;              X, Y, W, H : in     Integer; @@ -197,6 +196,14 @@ package body FLTK.Widgets.Groups is      end Extra_Init; +    procedure Initialize +           (This : in out Group) is +    begin +        This.Draw_Ptr   := fl_group_draw'Address; +        This.Handle_Ptr := fl_group_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -212,8 +219,6 @@ package body FLTK.Widgets.Groups is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                group_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                group_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -222,6 +227,10 @@ package body FLTK.Widgets.Groups is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Add             (This : in out Group;              Item : in out Widget'Class) is @@ -477,7 +486,7 @@ package body FLTK.Widgets.Groups is      procedure Draw             (This : in out Group) is      begin -        fl_group_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; @@ -486,10 +495,10 @@ package body FLTK.Widgets.Groups is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_group_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Widget (This).Handle (Event);      end Handle;  end FLTK.Widgets.Groups; + diff --git a/src/fltk-widgets-groups.ads b/src/fltk-widgets-groups.ads index 194ceca..f7b2173 100644 --- a/src/fltk-widgets-groups.ads +++ b/src/fltk-widgets-groups.ads @@ -164,6 +164,9 @@ private      type Group is new Widget with null record; +    overriding procedure Initialize +           (This : in out Group); +      overriding procedure Finalize             (This : in out Group); @@ -235,3 +238,4 @@ private  end FLTK.Widgets.Groups; + diff --git a/src/fltk-widgets-inputs-text-whole_number.adb b/src/fltk-widgets-inputs-text-whole_number.adb index 4d71d44..ae3ad7d 100644 --- a/src/fltk-widgets-inputs-text-whole_number.adb +++ b/src/fltk-widgets-inputs-text-whole_number.adb @@ -80,7 +80,7 @@ package body FLTK.Widgets.Inputs.Text.Whole_Number is      procedure Extra_Init             (This       : in out Integer_Input; -            X, Y, W, H : in     Standard.Integer; +            X, Y, W, H : in     Integer;              Text       : in     String) is      begin          Extra_Init (Input (This), X, Y, W, H, Text); @@ -98,7 +98,7 @@ package body FLTK.Widgets.Inputs.Text.Whole_Number is      package body Forge is          function Create -               (X, Y, W, H : in Standard.Integer; +               (X, Y, W, H : in Integer;                  Text       : in String := "")              return Integer_Input is          begin diff --git a/src/fltk-widgets-inputs-text-whole_number.ads b/src/fltk-widgets-inputs-text-whole_number.ads index 0b774a6..0d2695f 100644 --- a/src/fltk-widgets-inputs-text-whole_number.ads +++ b/src/fltk-widgets-inputs-text-whole_number.ads @@ -18,7 +18,7 @@ package FLTK.Widgets.Inputs.Text.Whole_Number is      package Forge is          function Create -               (X, Y, W, H : in Standard.Integer; +               (X, Y, W, H : in Integer;                  Text       : in String := "")              return Integer_Input; @@ -45,7 +45,7 @@ private      procedure Extra_Init             (This       : in out Integer_Input; -            X, Y, W, H : in     Standard.Integer; +            X, Y, W, H : in     Integer;              Text       : in     String)      with Inline; diff --git a/src/fltk-widgets-menus-choices.adb b/src/fltk-widgets-menus-choices.adb index fc60efc..f0fb03a 100644 --- a/src/fltk-widgets-menus-choices.adb +++ b/src/fltk-widgets-menus-choices.adb @@ -17,18 +17,9 @@ use type  package body FLTK.Widgets.Menus.Choices is -    procedure choice_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, choice_set_draw_hook, "choice_set_draw_hook"); -    pragma Inline (choice_set_draw_hook); - -    procedure choice_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, choice_set_handle_hook, "choice_set_handle_hook"); -    pragma Inline (choice_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_choice             (X, Y, W, H : in Interfaces.C.int; @@ -82,12 +73,17 @@ package body FLTK.Widgets.Menus.Choices is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Choice) is      begin          Extra_Final (Menu (This));      end Extra_Final; +      procedure Finalize             (This : in out Choice) is      begin @@ -101,6 +97,10 @@ package body FLTK.Widgets.Menus.Choices is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Choice;              X, Y, W, H : in     Integer; @@ -110,6 +110,14 @@ package body FLTK.Widgets.Menus.Choices is      end Extra_Init; +    procedure Initialize +           (This : in out Choice) is +    begin +        This.Draw_Ptr := fl_choice_draw'Address; +        This.Handle_Ptr := fl_choice_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -125,8 +133,6 @@ package body FLTK.Widgets.Menus.Choices is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                choice_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                choice_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -135,12 +141,16 @@ package body FLTK.Widgets.Menus.Choices is -    function Chosen +    ----------------------- +    --  API Subprograms  -- +    ----------------------- + +    function Get_Chosen             (This : in Choice)          return FLTK.Menu_Items.Menu_Item_Reference is      begin          return (Data => This.My_Items.Element (This.Chosen_Index)); -    end Chosen; +    end Get_Chosen;      function Chosen_Index @@ -176,7 +186,7 @@ package body FLTK.Widgets.Menus.Choices is      procedure Draw             (This : in out Choice) is      begin -        fl_choice_draw (This.Void_Ptr); +        Menu (This).Draw;      end Draw; @@ -185,10 +195,10 @@ package body FLTK.Widgets.Menus.Choices is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_choice_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Menu (This).Handle (Event);      end Handle;  end FLTK.Widgets.Menus.Choices; + diff --git a/src/fltk-widgets-menus-choices.ads b/src/fltk-widgets-menus-choices.ads index ec73836..86ddd60 100644 --- a/src/fltk-widgets-menus-choices.ads +++ b/src/fltk-widgets-menus-choices.ads @@ -27,7 +27,7 @@ package FLTK.Widgets.Menus.Choices is -    function Chosen +    function Get_Chosen             (This : in Choice)          return FLTK.Menu_Items.Menu_Item_Reference; @@ -60,6 +60,9 @@ private      type Choice is new Menu with null record; +    overriding procedure Initialize +           (This : in out Choice); +      overriding procedure Finalize             (This : in out Choice); @@ -84,3 +87,4 @@ private  end FLTK.Widgets.Menus.Choices; + diff --git a/src/fltk-widgets-menus-menu_bars.adb b/src/fltk-widgets-menus-menu_bars.adb index f0c9569..0548936 100644 --- a/src/fltk-widgets-menus-menu_bars.adb +++ b/src/fltk-widgets-menus-menu_bars.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Menus.Menu_Bars is -    procedure menu_bar_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, menu_bar_set_draw_hook, "menu_bar_set_draw_hook"); -    pragma Inline (menu_bar_set_draw_hook); - -    procedure menu_bar_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, menu_bar_set_handle_hook, "menu_bar_set_handle_hook"); -    pragma Inline (menu_bar_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_menu_bar             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Menus.Menu_Bars is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Menu_Bar) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Menus.Menu_Bars is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Menu_Bar;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Menus.Menu_Bars is      end Extra_Init; +    procedure Initialize +           (This : in out Menu_Bar) is +    begin +        This.Draw_Ptr   := fl_menu_bar_draw'Address; +        This.Handle_Ptr := fl_menu_bar_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,8 +106,6 @@ package body FLTK.Widgets.Menus.Menu_Bars is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                menu_bar_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                menu_bar_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -109,10 +114,14 @@ package body FLTK.Widgets.Menus.Menu_Bars is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Draw             (This : in out Menu_Bar) is      begin -        fl_menu_bar_draw (This.Void_Ptr); +        Menu (This).Draw;      end Draw; @@ -121,10 +130,10 @@ package body FLTK.Widgets.Menus.Menu_Bars is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_menu_bar_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Menu (This).Handle (Event);      end Handle;  end FLTK.Widgets.Menus.Menu_Bars; + diff --git a/src/fltk-widgets-menus-menu_bars.ads b/src/fltk-widgets-menus-menu_bars.ads index 2071bff..53603b0 100644 --- a/src/fltk-widgets-menus-menu_bars.ads +++ b/src/fltk-widgets-menus-menu_bars.ads @@ -41,6 +41,9 @@ private      type Menu_Bar is new Menu with null record; +    overriding procedure Initialize +           (This : in out Menu_Bar); +      overriding procedure Finalize             (This : in out Menu_Bar); @@ -61,3 +64,4 @@ private  end FLTK.Widgets.Menus.Menu_Bars; + diff --git a/src/fltk-widgets-menus-menu_buttons.adb b/src/fltk-widgets-menus-menu_buttons.adb index 95ebb8b..ae9ae75 100644 --- a/src/fltk-widgets-menus-menu_buttons.adb +++ b/src/fltk-widgets-menus-menu_buttons.adb @@ -16,19 +16,6 @@ package body FLTK.Widgets.Menus.Menu_Buttons is      --  Functions From C  --      ------------------------ -    procedure menu_button_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, menu_button_set_draw_hook, "menu_button_set_draw_hook"); -    pragma Inline (menu_button_set_draw_hook); - -    procedure menu_button_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, menu_button_set_handle_hook, "menu_button_set_handle_hook"); -    pragma Inline (menu_button_set_handle_hook); - - - -      function new_fl_menu_button             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -157,6 +144,14 @@ package body FLTK.Widgets.Menus.Menu_Buttons is      end Extra_Init; +    procedure Initialize +           (This : in out Menu_Button) is +    begin +        This.Draw_Ptr   := fl_menu_button_draw'Address; +        This.Handle_Ptr := fl_menu_button_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -172,10 +167,6 @@ package body FLTK.Widgets.Menus.Menu_Buttons is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                menu_button_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                menu_button_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -212,7 +203,7 @@ package body FLTK.Widgets.Menus.Menu_Buttons is      procedure Draw             (This : in out Menu_Button) is      begin -        fl_menu_button_draw (This.Void_Ptr); +        Menu (This).Draw;      end Draw; @@ -221,10 +212,10 @@ package body FLTK.Widgets.Menus.Menu_Buttons is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_menu_button_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Menu (This).Handle (Event);      end Handle;  end FLTK.Widgets.Menus.Menu_Buttons; + diff --git a/src/fltk-widgets-menus-menu_buttons.ads b/src/fltk-widgets-menus-menu_buttons.ads index e71310f..4ba09a3 100644 --- a/src/fltk-widgets-menus-menu_buttons.ads +++ b/src/fltk-widgets-menus-menu_buttons.ads @@ -17,7 +17,7 @@ package FLTK.Widgets.Menus.Menu_Buttons is      type Menu_Button_Reference (Data : access Menu_Button'Class) is limited null record          with Implicit_Dereference => Data; -    --  signifies which mouse buttons cause the menu to appear +    --  Signifies which mouse buttons cause the menu to appear      type Popup_Buttons is (No_Popup, Popup1, Popup2, Popup12, Popup3, Popup13, Popup23, Popup123); @@ -60,6 +60,9 @@ private      type Menu_Button is new Menu with null record; +    overriding procedure Initialize +           (This : in out Menu_Button); +      overriding procedure Finalize             (This : in out Menu_Button); @@ -83,3 +86,4 @@ private  end FLTK.Widgets.Menus.Menu_Buttons; + diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb index 4476332..be46a72 100644 --- a/src/fltk-widgets-menus.adb +++ b/src/fltk-widgets-menus.adb @@ -19,18 +19,9 @@ use type  package body FLTK.Widgets.Menus is -    procedure menu_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, menu_set_draw_hook, "menu_set_draw_hook"); -    pragma Inline (menu_set_draw_hook); - -    procedure menu_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, menu_set_handle_hook, "menu_set_handle_hook"); -    pragma Inline (menu_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_menu             (X, Y, W, H : in Interfaces.C.int; @@ -259,9 +250,25 @@ package body FLTK.Widgets.Menus is      pragma Import (C, fl_menu_draw_item, "fl_menu_draw_item");      pragma Inline (fl_menu_draw_item); +    procedure fl_menu_draw +           (M : in Storage.Integer_Address); +    pragma Import (C, fl_menu_draw, "fl_menu_draw"); +    pragma Inline (fl_menu_draw); + +    function fl_menu_handle +           (M : in Storage.Integer_Address; +            E : in Interfaces.C.int) +        return Interfaces.C.int; +    pragma Import (C, fl_menu_handle, "fl_menu_handle"); +    pragma Inline (fl_menu_handle); + +    ---------------------- +    --  Callback Hooks  -- +    ---------------------- +      procedure Item_Hook             (M, U : in Storage.Integer_Address)      is @@ -275,6 +282,10 @@ package body FLTK.Widgets.Menus is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Free_Item is new Ada.Unchecked_Deallocation          (Object => FLTK.Menu_Items.Menu_Item, Name => Item_Access); @@ -302,6 +313,10 @@ package body FLTK.Widgets.Menus is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Menu;              X, Y, W, H : in     Integer; @@ -311,6 +326,14 @@ package body FLTK.Widgets.Menus is      end Extra_Init; +    procedure Initialize +           (This : in out Menu) is +    begin +        This.Draw_Ptr := fl_menu_draw'Address; +        This.Handle_Ptr := fl_menu_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -326,8 +349,6 @@ package body FLTK.Widgets.Menus is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                menu_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                menu_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -336,6 +357,10 @@ package body FLTK.Widgets.Menus is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Add             (This     : in out Menu;              Text     : in     String; @@ -799,14 +824,6 @@ package body FLTK.Widgets.Menus is      end Draw_Item; -    function Handle -           (This  : in out Menu; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Not_Handled; -    end Handle; - -  end FLTK.Widgets.Menus; + diff --git a/src/fltk-widgets-menus.ads b/src/fltk-widgets-menus.ads index c0e0ed4..1d7b55b 100644 --- a/src/fltk-widgets-menus.ads +++ b/src/fltk-widgets-menus.ads @@ -220,20 +220,12 @@ package FLTK.Widgets.Menus is -    procedure Draw -           (This : in out Menu) is null; -      procedure Draw_Item             (This       : in out Menu;              Item       : in     Index;              X, Y, W, H : in     Integer;              Selected   : in     Boolean := False); -    function Handle -           (This  : in out Menu; -            Event : in     Event_Kind) -        return Event_Outcome; -  private @@ -253,6 +245,9 @@ private          My_Items : Item_Vectors.Vector;      end record; +    overriding procedure Initialize +           (This : in out Menu); +      overriding procedure Finalize             (This : in out Menu); @@ -326,10 +321,9 @@ private      pragma Inline (Popup);      pragma Inline (Pulldown); -    pragma Inline (Draw);      pragma Inline (Draw_Item); -    pragma Inline (Handle);  end FLTK.Widgets.Menus; + diff --git a/src/fltk-widgets-progress_bars.adb b/src/fltk-widgets-progress_bars.adb index 39b2b2d..7e25c85 100644 --- a/src/fltk-widgets-progress_bars.adb +++ b/src/fltk-widgets-progress_bars.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Progress_Bars is -    procedure progress_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, progress_set_draw_hook, "progress_set_draw_hook"); -    pragma Inline (progress_set_draw_hook); - -    procedure progress_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, progress_set_handle_hook, "progress_set_handle_hook"); -    pragma Inline (progress_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_progress             (X, Y, W, H : in Interfaces.C.int; @@ -94,6 +85,10 @@ package body FLTK.Widgets.Progress_Bars is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Progress_Bar) is      begin @@ -114,6 +109,10 @@ package body FLTK.Widgets.Progress_Bars is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Progress_Bar;              X, Y, W, H : in     Integer; @@ -123,6 +122,14 @@ package body FLTK.Widgets.Progress_Bars is      end Extra_Init; +    procedure Initialize +           (This : in out Progress_Bar) is +    begin +        This.Draw_Ptr := fl_progress_draw'Address; +        This.Handle_Ptr := fl_progress_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -138,8 +145,6 @@ package body FLTK.Widgets.Progress_Bars is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                progress_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                progress_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -148,6 +153,9 @@ package body FLTK.Widgets.Progress_Bars is +    ----------------------- +    --  API Subprograms  -- +    -----------------------      function Get_Minimum             (This : in Progress_Bar) @@ -202,19 +210,10 @@ package body FLTK.Widgets.Progress_Bars is      procedure Draw             (This : in out Progress_Bar) is      begin -        fl_progress_draw (This.Void_Ptr); +        Widget (This).Draw;      end Draw; -    function Handle -           (This  : in out Progress_Bar; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_progress_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Progress_Bars; + diff --git a/src/fltk-widgets-progress_bars.ads b/src/fltk-widgets-progress_bars.ads index 2eb57f3..71b0b92 100644 --- a/src/fltk-widgets-progress_bars.ads +++ b/src/fltk-widgets-progress_bars.ads @@ -57,17 +57,15 @@ package FLTK.Widgets.Progress_Bars is      procedure Draw             (This : in out Progress_Bar); -    function Handle -           (This  : in out Progress_Bar; -            Event : in     Event_Kind) -        return Event_Outcome; -  private      type Progress_Bar is new Widget with null record; +    overriding procedure Initialize +           (This : in out Progress_Bar); +      overriding procedure Finalize             (This : in out Progress_Bar); @@ -90,8 +88,8 @@ private      pragma Inline (Set_Value);      pragma Inline (Draw); -    pragma Inline (Handle);  end FLTK.Widgets.Progress_Bars; + diff --git a/src/fltk-widgets-valuators-adjusters.adb b/src/fltk-widgets-valuators-adjusters.adb index 0c96332..b4a8bc3 100644 --- a/src/fltk-widgets-valuators-adjusters.adb +++ b/src/fltk-widgets-valuators-adjusters.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Valuators.Adjusters is -    procedure adjuster_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, adjuster_set_draw_hook, "adjuster_set_draw_hook"); -    pragma Inline (adjuster_set_draw_hook); - -    procedure adjuster_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, adjuster_set_handle_hook, "adjuster_set_handle_hook"); -    pragma Inline (adjuster_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_adjuster             (X, Y, W, H : in Interfaces.C.int; @@ -59,6 +50,11 @@ package body FLTK.Widgets.Valuators.Adjusters is +    procedure fl_adjuster_value_damage +           (A : in Storage.Integer_Address); +    pragma Import (C, fl_adjuster_value_damage, "fl_adjuster_value_damage"); +    pragma Inline (fl_adjuster_value_damage); +      procedure fl_adjuster_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_adjuster_draw, "fl_adjuster_draw"); @@ -74,6 +70,10 @@ package body FLTK.Widgets.Valuators.Adjusters is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Adjuster) is      begin @@ -94,6 +94,10 @@ package body FLTK.Widgets.Valuators.Adjusters is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Adjuster;              X, Y, W, H : in     Integer; @@ -103,6 +107,14 @@ package body FLTK.Widgets.Valuators.Adjusters is      end Extra_Init; +    procedure Initialize +           (This : in out Adjuster) is +    begin +        This.Draw_Ptr   := fl_adjuster_draw'Address; +        This.Handle_Ptr := fl_adjuster_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -118,8 +130,6 @@ package body FLTK.Widgets.Valuators.Adjusters is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                adjuster_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                adjuster_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -128,6 +138,10 @@ package body FLTK.Widgets.Valuators.Adjusters is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Is_Soft             (This : in Adjuster)          return Boolean is @@ -146,10 +160,17 @@ package body FLTK.Widgets.Valuators.Adjusters is +    procedure Value_Damage +           (This : in out Adjuster) is +    begin +        fl_adjuster_value_damage (This.Void_Ptr); +    end Value_Damage; + +      procedure Draw             (This : in out Adjuster) is      begin -        fl_adjuster_draw (This.Void_Ptr); +        Valuator (This).Draw;      end Draw; @@ -158,10 +179,10 @@ package body FLTK.Widgets.Valuators.Adjusters is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_adjuster_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Adjusters; + diff --git a/src/fltk-widgets-valuators-adjusters.ads b/src/fltk-widgets-valuators-adjusters.ads index df19f28..6211e99 100644 --- a/src/fltk-widgets-valuators-adjusters.ads +++ b/src/fltk-widgets-valuators-adjusters.ads @@ -38,6 +38,9 @@ package FLTK.Widgets.Valuators.Adjusters is +    procedure Value_Damage +           (This : in out Adjuster); +      procedure Draw             (This : in out Adjuster); @@ -52,6 +55,9 @@ private      type Adjuster is new Valuator with null record; +    overriding procedure Initialize +           (This : in out Adjuster); +      overriding procedure Finalize             (This : in out Adjuster); @@ -69,9 +75,11 @@ private      pragma Inline (Is_Soft);      pragma Inline (Set_Soft); +    pragma Inline (Value_Damage);      pragma Inline (Draw);      pragma Inline (Handle);  end FLTK.Widgets.Valuators.Adjusters; + diff --git a/src/fltk-widgets-valuators-counters-simple.adb b/src/fltk-widgets-valuators-counters-simple.adb index d811722..294a076 100644 --- a/src/fltk-widgets-valuators-counters-simple.adb +++ b/src/fltk-widgets-valuators-counters-simple.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Counters.Simple is -    procedure simple_counter_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, simple_counter_set_draw_hook, "simple_counter_set_draw_hook"); -    pragma Inline (simple_counter_set_draw_hook); - -    procedure simple_counter_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, simple_counter_set_handle_hook, "simple_counter_set_handle_hook"); -    pragma Inline (simple_counter_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_simple_counter             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Counters.Simple is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Simple_Counter) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Counters.Simple is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Simple_Counter;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Counters.Simple is      end Extra_Init; +    procedure Initialize +           (This : in out Simple_Counter) is +    begin +        This.Draw_Ptr   := fl_simple_counter_draw'Address; +        This.Handle_Ptr := fl_simple_counter_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Counters.Simple is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                simple_counter_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                simple_counter_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Simple_Counter) is -    begin -        fl_simple_counter_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Simple_Counter; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_simple_counter_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Counters.Simple; + diff --git a/src/fltk-widgets-valuators-counters-simple.ads b/src/fltk-widgets-valuators-counters-simple.ads index 99e4bee..9ff57fe 100644 --- a/src/fltk-widgets-valuators-counters-simple.ads +++ b/src/fltk-widgets-valuators-counters-simple.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Counters.Simple is      end Forge; - - -    procedure Draw -           (This : in out Simple_Counter); - -    function Handle -           (This  : in out Simple_Counter; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Simple_Counter is new Counter with null record; +    overriding procedure Initialize +           (This : in out Simple_Counter); +      overriding procedure Finalize             (This : in out Simple_Counter); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Counters.Simple; + diff --git a/src/fltk-widgets-valuators-counters.adb b/src/fltk-widgets-valuators-counters.adb index fd0619e..30001a8 100644 --- a/src/fltk-widgets-valuators-counters.adb +++ b/src/fltk-widgets-valuators-counters.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Counters is -    procedure counter_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, counter_set_draw_hook, "counter_set_draw_hook"); -    pragma Inline (counter_set_draw_hook); - -    procedure counter_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, counter_set_handle_hook, "counter_set_handle_hook"); -    pragma Inline (counter_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_counter             (X, Y, W, H : in Interfaces.C.int; @@ -46,11 +37,11 @@ package body FLTK.Widgets.Valuators.Counters is      pragma Import (C, fl_counter_get_step, "fl_counter_get_step");      pragma Inline (fl_counter_get_step); -    procedure fl_counter_set_step +    procedure fl_counter_set_step_top             (C : in Storage.Integer_Address;              T : in Interfaces.C.double); -    pragma Import (C, fl_counter_set_step, "fl_counter_set_step"); -    pragma Inline (fl_counter_set_step); +    pragma Import (C, fl_counter_set_step_top, "fl_counter_set_step_top"); +    pragma Inline (fl_counter_set_step_top);      procedure fl_counter_set_lstep             (C : in Storage.Integer_Address; @@ -58,6 +49,12 @@ package body FLTK.Widgets.Valuators.Counters is      pragma Import (C, fl_counter_set_lstep, "fl_counter_set_lstep");      pragma Inline (fl_counter_set_lstep); +    procedure fl_counter_set_step_both +           (C    : in Storage.Integer_Address; +            S, L : in Interfaces.C.double); +    pragma Import (C, fl_counter_set_step_both, "fl_counter_set_step_both"); +    pragma Inline (fl_counter_set_step_both); + @@ -115,6 +112,10 @@ package body FLTK.Widgets.Valuators.Counters is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Counter) is      begin @@ -135,6 +136,10 @@ package body FLTK.Widgets.Valuators.Counters is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Counter;              X, Y, W, H : in     Integer; @@ -144,6 +149,14 @@ package body FLTK.Widgets.Valuators.Counters is      end Extra_Init; +    procedure Initialize +           (This : in out Counter) is +    begin +        This.Draw_Ptr   := fl_counter_draw'Address; +        This.Handle_Ptr := fl_counter_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -159,8 +172,6 @@ package body FLTK.Widgets.Valuators.Counters is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                counter_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                counter_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -169,6 +180,10 @@ package body FLTK.Widgets.Valuators.Counters is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Step             (This : in Counter)          return Long_Float is @@ -177,12 +192,12 @@ package body FLTK.Widgets.Valuators.Counters is      end Get_Step; -    procedure Set_Step +    procedure Set_Step_Top             (This : in out Counter;              To   : in     Long_Float) is      begin -        fl_counter_set_step (This.Void_Ptr, Interfaces.C.double (To)); -    end Set_Step; +        fl_counter_set_step_top (This.Void_Ptr, Interfaces.C.double (To)); +    end Set_Step_Top;      function Get_Long_Step @@ -202,6 +217,17 @@ package body FLTK.Widgets.Valuators.Counters is      end Set_Long_Step; +    procedure Set_Step_Both +           (This        : in out Counter; +            Short, Long : in     Long_Float) is +    begin +        fl_counter_set_step_both +           (This.Void_Ptr, +            Interfaces.C.double (Short), +            Interfaces.C.double (Long)); +    end Set_Step_Both; + +      function Get_Text_Color @@ -257,7 +283,7 @@ package body FLTK.Widgets.Valuators.Counters is      procedure Draw             (This : in out Counter) is      begin -        fl_counter_draw (This.Void_Ptr); +        Valuator (This).Draw;      end Draw; @@ -266,10 +292,10 @@ package body FLTK.Widgets.Valuators.Counters is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_counter_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Counters; + diff --git a/src/fltk-widgets-valuators-counters.ads b/src/fltk-widgets-valuators-counters.ads index 7119923..0b2b31c 100644 --- a/src/fltk-widgets-valuators-counters.ads +++ b/src/fltk-widgets-valuators-counters.ads @@ -31,7 +31,7 @@ package FLTK.Widgets.Valuators.Counters is             (This : in Counter)          return Long_Float; -    procedure Set_Step +    procedure Set_Step_Top             (This : in out Counter;              To   : in     Long_Float); @@ -43,6 +43,10 @@ package FLTK.Widgets.Valuators.Counters is             (This : in out Counter;              To   : in     Long_Float); +    procedure Set_Step_Both +           (This        : in out Counter; +            Short, Long : in     Long_Float); + @@ -91,6 +95,9 @@ private          Long_Step : Long_Float := 1.0;      end record; +    overriding procedure Initialize +           (This : in out Counter); +      overriding procedure Finalize             (This : in out Counter); @@ -123,3 +130,4 @@ private  end FLTK.Widgets.Valuators.Counters; + diff --git a/src/fltk-widgets-valuators-dials-fill.adb b/src/fltk-widgets-valuators-dials-fill.adb index cb7d025..9b01946 100644 --- a/src/fltk-widgets-valuators-dials-fill.adb +++ b/src/fltk-widgets-valuators-dials-fill.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Dials.Fill is -    procedure fill_dial_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, fill_dial_set_draw_hook, "fill_dial_set_draw_hook"); -    pragma Inline (fill_dial_set_draw_hook); - -    procedure fill_dial_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, fill_dial_set_handle_hook, "fill_dial_set_handle_hook"); -    pragma Inline (fill_dial_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_fill_dial             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Dials.Fill is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Fill_Dial) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Dials.Fill is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Fill_Dial;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Dials.Fill is      end Extra_Init; +    procedure Initialize +           (This : in out Fill_Dial) is +    begin +        This.Draw_Ptr   := fl_fill_dial_draw'Address; +        This.Handle_Ptr := fl_fill_dial_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,32 +106,12 @@ package body FLTK.Widgets.Valuators.Dials.Fill is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                fill_dial_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                fill_dial_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Fill_Dial) is -    begin -        fl_fill_dial_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Fill_Dial; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_fill_dial_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Dials.Fill; + diff --git a/src/fltk-widgets-valuators-dials-fill.ads b/src/fltk-widgets-valuators-dials-fill.ads index c1f6f06..a09582e 100644 --- a/src/fltk-widgets-valuators-dials-fill.ads +++ b/src/fltk-widgets-valuators-dials-fill.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Dials.Fill is      end Forge; - - -    procedure Draw -           (This : in out Fill_Dial); - -    function Handle -           (This  : in out Fill_Dial; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Fill_Dial is new Dial with null record; +    overriding procedure Initialize +           (This : in out Fill_Dial); +      overriding procedure Finalize             (This : in out Fill_Dial); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Dials.Fill; + diff --git a/src/fltk-widgets-valuators-dials-line.adb b/src/fltk-widgets-valuators-dials-line.adb index 7ee67ce..16f9bef 100644 --- a/src/fltk-widgets-valuators-dials-line.adb +++ b/src/fltk-widgets-valuators-dials-line.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Dials.Line is -    procedure line_dial_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, line_dial_set_draw_hook, "line_dial_set_draw_hook"); -    pragma Inline (line_dial_set_draw_hook); - -    procedure line_dial_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, line_dial_set_handle_hook, "line_dial_set_handle_hook"); -    pragma Inline (line_dial_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_line_dial             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Dials.Line is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Line_Dial) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Dials.Line is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Line_Dial;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Dials.Line is      end Extra_Init; +    procedure Initialize +           (This : in out Line_Dial) is +    begin +        This.Draw_Ptr   := fl_line_dial_draw'Address; +        This.Handle_Ptr := fl_line_dial_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,32 +106,12 @@ package body FLTK.Widgets.Valuators.Dials.Line is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                line_dial_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                line_dial_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Line_Dial) is -    begin -        fl_line_dial_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Line_Dial; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_line_dial_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Dials.Line; + diff --git a/src/fltk-widgets-valuators-dials-line.ads b/src/fltk-widgets-valuators-dials-line.ads index d0a955d..be8f554 100644 --- a/src/fltk-widgets-valuators-dials-line.ads +++ b/src/fltk-widgets-valuators-dials-line.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Dials.Line is      end Forge; - - -    procedure Draw -           (This : in out Line_Dial); - -    function Handle -           (This  : in out Line_Dial; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Line_Dial is new Dial with null record; +    overriding procedure Initialize +           (This : in out Line_Dial); +      overriding procedure Finalize             (This : in out Line_Dial); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Dials.Line; + diff --git a/src/fltk-widgets-valuators-dials.adb b/src/fltk-widgets-valuators-dials.adb index 588b8ec..02106f1 100644 --- a/src/fltk-widgets-valuators-dials.adb +++ b/src/fltk-widgets-valuators-dials.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Dials is -    procedure dial_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, dial_set_draw_hook, "dial_set_draw_hook"); -    pragma Inline (dial_set_draw_hook); - -    procedure dial_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, dial_set_handle_hook, "dial_set_handle_hook"); -    pragma Inline (dial_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_dial             (X, Y, W, H : in Interfaces.C.int; @@ -40,48 +31,33 @@ package body FLTK.Widgets.Valuators.Dials is -    function fl_dial_get_type -           (D : in Storage.Integer_Address) -        return Interfaces.C.int; -    pragma Import (C, fl_dial_get_type, "fl_dial_get_type"); -    pragma Inline (fl_dial_get_type); - -    procedure fl_dial_set_type -           (D : in Storage.Integer_Address; -            T : in Interfaces.C.int); -    pragma Import (C, fl_dial_set_type, "fl_dial_set_type"); -    pragma Inline (fl_dial_set_type); - - - -      function fl_dial_get_angle1             (D : in Storage.Integer_Address) -        return Interfaces.C.int; +        return Interfaces.C.short;      pragma Import (C, fl_dial_get_angle1, "fl_dial_get_angle1");      pragma Inline (fl_dial_get_angle1);      procedure fl_dial_set_angle1             (D : in Storage.Integer_Address; -            T : in Interfaces.C.int); +            T : in Interfaces.C.short);      pragma Import (C, fl_dial_set_angle1, "fl_dial_set_angle1");      pragma Inline (fl_dial_set_angle1);      function fl_dial_get_angle2             (D : in Storage.Integer_Address) -        return Interfaces.C.int; +        return Interfaces.C.short;      pragma Import (C, fl_dial_get_angle2, "fl_dial_get_angle2");      pragma Inline (fl_dial_get_angle2);      procedure fl_dial_set_angle2             (D : in Storage.Integer_Address; -            T : in Interfaces.C.int); +            T : in Interfaces.C.short);      pragma Import (C, fl_dial_set_angle2, "fl_dial_set_angle2");      pragma Inline (fl_dial_set_angle2);      procedure fl_dial_set_angles             (D    : in Storage.Integer_Address; -            A, B : in Interfaces.C.int); +            A, B : in Interfaces.C.short);      pragma Import (C, fl_dial_set_angles, "fl_dial_set_angles");      pragma Inline (fl_dial_set_angles); @@ -93,6 +69,12 @@ package body FLTK.Widgets.Valuators.Dials is      pragma Import (C, fl_dial_draw, "fl_dial_draw");      pragma Inline (fl_dial_draw); +    procedure fl_dial_draw2 +           (D          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_dial_draw2, "fl_dial_draw2"); +    pragma Inline (fl_dial_draw2); +      function fl_dial_handle             (W : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -100,9 +82,35 @@ package body FLTK.Widgets.Valuators.Dials is      pragma Import (C, fl_dial_handle, "fl_dial_handle");      pragma Inline (fl_dial_handle); +    function fl_dial_handle2 +           (D             : in Storage.Integer_Address; +            E, X, Y, W, H : in Interfaces.C.int) +        return Interfaces.C.int; +    pragma Import (C, fl_dial_handle2, "fl_dial_handle2"); +    pragma Inline (fl_dial_handle2); + + + + +    function fl_widget_get_type +           (D : in Storage.Integer_Address) +        return Interfaces.C.unsigned_char; +    pragma Import (C, fl_widget_get_type, "fl_widget_get_type"); +    pragma Inline (fl_widget_get_type); + +    procedure fl_widget_set_type +           (D : in Storage.Integer_Address; +            T : in Interfaces.C.unsigned_char); +    pragma Import (C, fl_widget_set_type, "fl_widget_set_type"); +    pragma Inline (fl_widget_set_type); + +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Dial) is      begin @@ -123,6 +131,10 @@ package body FLTK.Widgets.Valuators.Dials is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Dial;              X, Y, W, H : in     Integer; @@ -132,6 +144,14 @@ package body FLTK.Widgets.Valuators.Dials is      end Extra_Init; +    procedure Initialize +           (This : in out Dial) is +    begin +        This.Draw_Ptr   := fl_dial_draw'Address; +        This.Handle_Ptr := fl_dial_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -147,8 +167,6 @@ package body FLTK.Widgets.Valuators.Dials is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                dial_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                dial_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -157,51 +175,50 @@ package body FLTK.Widgets.Valuators.Dials is -    function Get_Dial_Type -           (This : in Dial) -        return Dial_Kind is -    begin -        return Dial_Kind'Val (fl_dial_get_type (This.Void_Ptr)); -    end Get_Dial_Type; - +    ----------------------- +    --  API Subprograms  -- +    -----------------------      function Get_First_Angle             (This : in Dial) -        return Integer is +        return Short_Integer is      begin -        return Integer (fl_dial_get_angle1 (This.Void_Ptr)); +        return Short_Integer (fl_dial_get_angle1 (This.Void_Ptr));      end Get_First_Angle;      procedure Set_First_Angle             (This : in out Dial; -            To   : in     Integer) is +            To   : in     Short_Integer) is      begin -        fl_dial_set_angle1 (This.Void_Ptr, Interfaces.C.int (To)); +        fl_dial_set_angle1 (This.Void_Ptr, Interfaces.C.short (To));      end Set_First_Angle;      function Get_Second_Angle             (This : in Dial) -        return Integer is +        return Short_Integer is      begin -        return Integer (fl_dial_get_angle2 (This.Void_Ptr)); +        return Short_Integer (fl_dial_get_angle2 (This.Void_Ptr));      end Get_Second_Angle;      procedure Set_Second_Angle             (This : in out Dial; -            To   : in     Integer) is +            To   : in     Short_Integer) is      begin -        fl_dial_set_angle2 (This.Void_Ptr, Interfaces.C.int (To)); +        fl_dial_set_angle2 (This.Void_Ptr, Interfaces.C.short (To));      end Set_Second_Angle;      procedure Set_Angles             (This     : in out Dial; -            One, Two : in     Integer) is +            One, Two : in     Short_Integer) is      begin -        fl_dial_set_angles (This.Void_Ptr, Interfaces.C.int (One), Interfaces.C.int (Two)); +        fl_dial_set_angles +           (This.Void_Ptr, +            Interfaces.C.short (One), +            Interfaces.C.short (Two));      end Set_Angles; @@ -210,7 +227,20 @@ package body FLTK.Widgets.Valuators.Dials is      procedure Draw             (This : in out Dial) is      begin -        fl_dial_draw (This.Void_Ptr); +        Valuator (This).Draw; +    end Draw; + + +    procedure Draw +           (This       : in out Dial; +            X, Y, W, H : in     Integer) is +    begin +        fl_dial_draw2 +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H));      end Draw; @@ -219,20 +249,47 @@ package body FLTK.Widgets.Valuators.Dials is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_dial_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event); +    end Handle; + + +    function Handle +           (This       : in out Dial; +            Event      : in     Event_Kind; +            X, Y, W, H : in     Integer) +        return Event_Outcome is +    begin +        return Event_Outcome'Val (fl_dial_handle2 +           (This.Void_Ptr, +            Event_Kind'Pos (Event), +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H))); +    exception +    when Constraint_Error => raise Internal_FLTK_Error;      end Handle; +    function Get_Dial_Type +           (This : in Dial) +        return Dial_Kind is +    begin +        return Dial_Kind'Val (fl_widget_get_type (This.Void_Ptr)); +    exception +    when Constraint_Error => raise Internal_FLTK_Error; +    end Get_Dial_Type; + +      package body Extra is          procedure Set_Dial_Type                 (This : in out Dial;                  To   : in     Dial_Kind) is          begin -            fl_dial_set_type (This.Void_Ptr, Dial_Kind'Pos (To)); +            fl_widget_set_type (This.Void_Ptr, Dial_Kind'Pos (To));          end Set_Dial_Type;          pragma Inline (Set_Dial_Type); @@ -242,3 +299,4 @@ package body FLTK.Widgets.Valuators.Dials is  end FLTK.Widgets.Valuators.Dials; + diff --git a/src/fltk-widgets-valuators-dials.ads b/src/fltk-widgets-valuators-dials.ads index 9cd4d49..f3c2b69 100644 --- a/src/fltk-widgets-valuators-dials.ads +++ b/src/fltk-widgets-valuators-dials.ads @@ -29,29 +29,25 @@ package FLTK.Widgets.Valuators.Dials is -    function Get_Dial_Type -           (This : in Dial) -        return Dial_Kind; -      function Get_First_Angle             (This : in Dial) -        return Integer; +        return Short_Integer;      procedure Set_First_Angle             (This : in out Dial; -            To   : in     Integer); +            To   : in     Short_Integer);      function Get_Second_Angle             (This : in Dial) -        return Integer; +        return Short_Integer;      procedure Set_Second_Angle             (This : in out Dial; -            To   : in     Integer); +            To   : in     Short_Integer);      procedure Set_Angles             (This     : in out Dial; -            One, Two : in     Integer); +            One, Two : in     Short_Integer); @@ -59,14 +55,28 @@ package FLTK.Widgets.Valuators.Dials is      procedure Draw             (This : in out Dial); +    procedure Draw +           (This       : in out Dial; +            X, Y, W, H : in     Integer); +      function Handle             (This  : in out Dial;              Event : in     Event_Kind)          return Event_Outcome; +    function Handle +           (This       : in out Dial; +            Event      : in     Event_Kind; +            X, Y, W, H : in     Integer) +        return Event_Outcome; + +    function Get_Dial_Type +           (This : in Dial) +        return Dial_Kind; +      package Extra is          procedure Set_Dial_Type @@ -81,6 +91,9 @@ private      type Dial is new Valuator with null record; +    overriding procedure Initialize +           (This : in out Dial); +      overriding procedure Finalize             (This : in out Dial); @@ -95,8 +108,6 @@ private      with Inline; -    pragma Inline (Get_Dial_Type); -      pragma Inline (Get_First_Angle);      pragma Inline (Set_First_Angle);      pragma Inline (Get_Second_Angle); @@ -106,6 +117,9 @@ private      pragma Inline (Draw);      pragma Inline (Handle); +    pragma Inline (Get_Dial_Type); +  end FLTK.Widgets.Valuators.Dials; + diff --git a/src/fltk-widgets-valuators-rollers.adb b/src/fltk-widgets-valuators-rollers.adb index 520a816..a3966e5 100644 --- a/src/fltk-widgets-valuators-rollers.adb +++ b/src/fltk-widgets-valuators-rollers.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Rollers is -    procedure roller_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, roller_set_draw_hook, "roller_set_draw_hook"); -    pragma Inline (roller_set_draw_hook); - -    procedure roller_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, roller_set_handle_hook, "roller_set_handle_hook"); -    pragma Inline (roller_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_roller             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Rollers is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Roller) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Rollers is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Roller;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Rollers is      end Extra_Init; +    procedure Initialize +           (This : in out Roller) is +    begin +        This.Draw_Ptr   := fl_roller_draw'Address; +        This.Handle_Ptr := fl_roller_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,8 +106,6 @@ package body FLTK.Widgets.Valuators.Rollers is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                roller_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                roller_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -109,10 +114,14 @@ package body FLTK.Widgets.Valuators.Rollers is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      procedure Draw             (This : in out Roller) is      begin -        fl_roller_draw (This.Void_Ptr); +        Valuator (This).Draw;      end Draw; @@ -121,10 +130,10 @@ package body FLTK.Widgets.Valuators.Rollers is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_roller_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Rollers; + diff --git a/src/fltk-widgets-valuators-rollers.ads b/src/fltk-widgets-valuators-rollers.ads index 266072f..aa9a9a5 100644 --- a/src/fltk-widgets-valuators-rollers.ads +++ b/src/fltk-widgets-valuators-rollers.ads @@ -41,6 +41,9 @@ private      type Roller is new Valuator with null record; +    overriding procedure Initialize +           (This : in out Roller); +      overriding procedure Finalize             (This : in out Roller); @@ -61,3 +64,4 @@ private  end FLTK.Widgets.Valuators.Rollers; + diff --git a/src/fltk-widgets-valuators-sliders-fill.adb b/src/fltk-widgets-valuators-sliders-fill.adb index 3568838..504e390 100644 --- a/src/fltk-widgets-valuators-sliders-fill.adb +++ b/src/fltk-widgets-valuators-sliders-fill.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Fill is -    procedure fill_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, fill_slider_set_draw_hook, "fill_slider_set_draw_hook"); -    pragma Inline (fill_slider_set_draw_hook); - -    procedure fill_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, fill_slider_set_handle_hook, "fill_slider_set_handle_hook"); -    pragma Inline (fill_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_fill_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Sliders.Fill is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Fill_Slider) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Sliders.Fill is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Fill_Slider;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Sliders.Fill is      end Extra_Init; +    procedure Initialize +           (This : in out Fill_Slider) is +    begin +        This.Draw_Ptr   := fl_fill_slider_draw'Address; +        This.Handle_Ptr := fl_fill_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Fill is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                fill_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                fill_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Fill_Slider) is -    begin -        fl_fill_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Fill_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_fill_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Fill; + diff --git a/src/fltk-widgets-valuators-sliders-fill.ads b/src/fltk-widgets-valuators-sliders-fill.ads index 27c69b2..d13e604 100644 --- a/src/fltk-widgets-valuators-sliders-fill.ads +++ b/src/fltk-widgets-valuators-sliders-fill.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Sliders.Fill is      end Forge; - - -    procedure Draw -           (This : in out Fill_Slider); - -    function Handle -           (This  : in out Fill_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Fill_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Fill_Slider); +      overriding procedure Finalize             (This : in out Fill_Slider); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Fill; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal.adb b/src/fltk-widgets-valuators-sliders-horizontal.adb index b4d7035..1abde1b 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal.adb +++ b/src/fltk-widgets-valuators-sliders-horizontal.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Horizontal is -    procedure horizontal_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, horizontal_slider_set_draw_hook, "horizontal_slider_set_draw_hook"); -    pragma Inline (horizontal_slider_set_draw_hook); - -    procedure horizontal_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, horizontal_slider_set_handle_hook, "horizontal_slider_set_handle_hook"); -    pragma Inline (horizontal_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_horizontal_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Horizontal_Slider) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Horizontal_Slider;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal is      end Extra_Init; +    procedure Initialize +           (This : in out Horizontal_Slider) is +    begin +        This.Draw_Ptr   := fl_horizontal_slider_draw'Address; +        This.Handle_Ptr := fl_horizontal_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                horizontal_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                horizontal_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Slider) is -    begin -        fl_horizontal_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Horizontal_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_horizontal_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Horizontal; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal.ads b/src/fltk-widgets-valuators-sliders-horizontal.ads index c6cc2e6..3002f31 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal.ads +++ b/src/fltk-widgets-valuators-sliders-horizontal.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Sliders.Horizontal is      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Slider); - -    function Handle -           (This  : in out Horizontal_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Horizontal_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Horizontal_Slider); +      overriding procedure Finalize             (This : in out Horizontal_Slider); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Horizontal; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal_fill.adb b/src/fltk-widgets-valuators-sliders-horizontal_fill.adb index e14e230..2376474 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal_fill.adb +++ b/src/fltk-widgets-valuators-sliders-horizontal_fill.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is -    procedure hor_fill_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, hor_fill_slider_set_draw_hook, "hor_fill_slider_set_draw_hook"); -    pragma Inline (hor_fill_slider_set_draw_hook); - -    procedure hor_fill_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, hor_fill_slider_set_handle_hook, "hor_fill_slider_set_handle_hook"); -    pragma Inline (hor_fill_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_hor_fill_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Horizontal_Fill_Slider) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Horizontal_Fill_Slider;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is      end Extra_Init; +    procedure Initialize +           (This : in out Horizontal_Fill_Slider) is +    begin +        This.Draw_Ptr   := fl_hor_fill_slider_draw'Address; +        This.Handle_Ptr := fl_hor_fill_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                hor_fill_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                hor_fill_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Fill_Slider) is -    begin -        fl_hor_fill_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Horizontal_Fill_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_hor_fill_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Horizontal_Fill; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal_fill.ads b/src/fltk-widgets-valuators-sliders-horizontal_fill.ads index 9047552..e6e8938 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal_fill.ads +++ b/src/fltk-widgets-valuators-sliders-horizontal_fill.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Fill_Slider); - -    function Handle -           (This  : in out Horizontal_Fill_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Horizontal_Fill_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Horizontal_Fill_Slider); +      overriding procedure Finalize             (This : in out Horizontal_Fill_Slider); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Horizontal_Fill; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal_nice.adb b/src/fltk-widgets-valuators-sliders-horizontal_nice.adb index f6b8e90..d0a8fa8 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal_nice.adb +++ b/src/fltk-widgets-valuators-sliders-horizontal_nice.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is -    procedure hor_nice_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, hor_nice_slider_set_draw_hook, "hor_nice_slider_set_draw_hook"); -    pragma Inline (hor_nice_slider_set_draw_hook); - -    procedure hor_nice_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, hor_nice_slider_set_handle_hook, "hor_nice_slider_set_handle_hook"); -    pragma Inline (hor_nice_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_hor_nice_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Horizontal_Nice_Slider) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Horizontal_Nice_Slider;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is      end Extra_Init; +    procedure Initialize +           (This : in out Horizontal_Nice_Slider) is +    begin +        This.Draw_Ptr   := fl_hor_nice_slider_draw'Address; +        This.Handle_Ptr := fl_hor_nice_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                hor_nice_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                hor_nice_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Nice_Slider) is -    begin -        fl_hor_nice_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Horizontal_Nice_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_hor_nice_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Horizontal_Nice; + diff --git a/src/fltk-widgets-valuators-sliders-horizontal_nice.ads b/src/fltk-widgets-valuators-sliders-horizontal_nice.ads index f2af349..a71d8f2 100644 --- a/src/fltk-widgets-valuators-sliders-horizontal_nice.ads +++ b/src/fltk-widgets-valuators-sliders-horizontal_nice.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is      end Forge; - - -    procedure Draw -           (This : in out Horizontal_Nice_Slider); - -    function Handle -           (This  : in out Horizontal_Nice_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Horizontal_Nice_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Horizontal_Nice_Slider); +      overriding procedure Finalize             (This : in out Horizontal_Nice_Slider); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Horizontal_Nice; + diff --git a/src/fltk-widgets-valuators-sliders-nice.adb b/src/fltk-widgets-valuators-sliders-nice.adb index 73fc2c3..ba99a62 100644 --- a/src/fltk-widgets-valuators-sliders-nice.adb +++ b/src/fltk-widgets-valuators-sliders-nice.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Nice is -    procedure nice_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, nice_slider_set_draw_hook, "nice_slider_set_draw_hook"); -    pragma Inline (nice_slider_set_draw_hook); - -    procedure nice_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, nice_slider_set_handle_hook, "nice_slider_set_handle_hook"); -    pragma Inline (nice_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_nice_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,6 +46,10 @@ package body FLTK.Widgets.Valuators.Sliders.Nice is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Nice_Slider) is      begin @@ -75,6 +70,10 @@ package body FLTK.Widgets.Valuators.Sliders.Nice is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Nice_Slider;              X, Y, W, H : in     Integer; @@ -84,6 +83,14 @@ package body FLTK.Widgets.Valuators.Sliders.Nice is      end Extra_Init; +    procedure Initialize +           (This : in out Nice_Slider) is +    begin +        This.Draw_Ptr   := fl_nice_slider_draw'Address; +        This.Handle_Ptr := fl_nice_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Nice is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                nice_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                nice_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Nice_Slider) is -    begin -        fl_nice_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Nice_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_nice_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Nice; + diff --git a/src/fltk-widgets-valuators-sliders-nice.ads b/src/fltk-widgets-valuators-sliders-nice.ads index 742f1ce..c835ccf 100644 --- a/src/fltk-widgets-valuators-sliders-nice.ads +++ b/src/fltk-widgets-valuators-sliders-nice.ads @@ -25,22 +25,14 @@ package FLTK.Widgets.Valuators.Sliders.Nice is      end Forge; - - -    procedure Draw -           (This : in out Nice_Slider); - -    function Handle -           (This  : in out Nice_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private      type Nice_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Nice_Slider); +      overriding procedure Finalize             (This : in out Nice_Slider); @@ -55,9 +47,6 @@ private      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Nice; + diff --git a/src/fltk-widgets-valuators-sliders-scrollbars.adb b/src/fltk-widgets-valuators-sliders-scrollbars.adb index 84a0cc6..d27c4fa 100644 --- a/src/fltk-widgets-valuators-sliders-scrollbars.adb +++ b/src/fltk-widgets-valuators-sliders-scrollbars.adb @@ -16,19 +16,6 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is      --  Functions From C  --      ------------------------ -    procedure scrollbar_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, scrollbar_set_draw_hook, "scrollbar_set_draw_hook"); -    pragma Inline (scrollbar_set_draw_hook); - -    procedure scrollbar_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, scrollbar_set_handle_hook, "scrollbar_set_handle_hook"); -    pragma Inline (scrollbar_set_handle_hook); - - - -      function new_fl_scrollbar             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -169,6 +156,14 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is      end Extra_Init; +    procedure Initialize +           (This : in out Scrollbar) is +    begin +        This.Draw_Ptr   := fl_scrollbar_draw'Address; +        This.Handle_Ptr := fl_scrollbar_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -184,8 +179,6 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                scrollbar_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                scrollbar_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -251,7 +244,7 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is      procedure Draw             (This : in out Scrollbar) is      begin -        fl_scrollbar_draw (This.Void_Ptr); +        Slider (This).Draw;      end Draw; @@ -260,10 +253,10 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_scrollbar_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Slider (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Sliders.Scrollbars; + diff --git a/src/fltk-widgets-valuators-sliders-scrollbars.ads b/src/fltk-widgets-valuators-sliders-scrollbars.ads index 5a87e86..307e19b 100644 --- a/src/fltk-widgets-valuators-sliders-scrollbars.ads +++ b/src/fltk-widgets-valuators-sliders-scrollbars.ads @@ -67,6 +67,9 @@ private      type Scrollbar is new Slider with null record; +    overriding procedure Initialize +           (This : in out Scrollbar); +      overriding procedure Finalize             (This : in out Scrollbar); @@ -93,3 +96,4 @@ private  end FLTK.Widgets.Valuators.Sliders.Scrollbars; + diff --git a/src/fltk-widgets-valuators-sliders-value-horizontal.adb b/src/fltk-widgets-valuators-sliders-value-horizontal.adb index bac9b5d..d60e46a 100644 --- a/src/fltk-widgets-valuators-sliders-value-horizontal.adb +++ b/src/fltk-widgets-valuators-sliders-value-horizontal.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is -    procedure hor_value_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, hor_value_slider_set_draw_hook, "hor_value_slider_set_draw_hook"); -    pragma Inline (hor_value_slider_set_draw_hook); - -    procedure hor_value_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, hor_value_slider_set_handle_hook, "hor_value_slider_set_handle_hook"); -    pragma Inline (hor_value_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_hor_value_slider             (X, Y, W, H : in Interfaces.C.int; @@ -55,15 +46,19 @@ package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final -           (This : in out Hor_Value_Slider) is +           (This : in out Horizontal_Value_Slider) is      begin          Extra_Final (Value_Slider (This));      end Extra_Final;      procedure Finalize -           (This : in out Hor_Value_Slider) is +           (This : in out Horizontal_Value_Slider) is      begin          Extra_Final (This);          if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then @@ -75,8 +70,12 @@ package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init -           (This       : in out Hor_Value_Slider; +           (This       : in out Horizontal_Value_Slider;              X, Y, W, H : in     Integer;              Text       : in     String) is      begin @@ -84,14 +83,22 @@ package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is      end Extra_Init; +    procedure Initialize +           (This : in out Horizontal_Value_Slider) is +    begin +        This.Draw_Ptr   := fl_hor_value_slider_draw'Address; +        This.Handle_Ptr := fl_hor_value_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create                 (X, Y, W, H : in Integer;                  Text       : in String := "") -            return Hor_Value_Slider is +            return Horizontal_Value_Slider is          begin -            return This : Hor_Value_Slider do +            return This : Horizontal_Value_Slider do                  This.Void_Ptr := new_fl_hor_value_slider                         (Interfaces.C.int (X),                          Interfaces.C.int (Y), @@ -99,34 +106,12 @@ package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                hor_value_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                hor_value_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create;      end Forge; - - -    procedure Draw -           (This : in out Hor_Value_Slider) is -    begin -        fl_hor_value_slider_draw (This.Void_Ptr); -    end Draw; - - -    function Handle -           (This  : in out Hor_Value_Slider; -            Event : in     Event_Kind) -        return Event_Outcome is -    begin -        return Event_Outcome'Val -               (fl_hor_value_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; - -  end FLTK.Widgets.Valuators.Sliders.Value.Horizontal; + diff --git a/src/fltk-widgets-valuators-sliders-value-horizontal.ads b/src/fltk-widgets-valuators-sliders-value-horizontal.ads index 911d2e0..c666a4d 100644 --- a/src/fltk-widgets-valuators-sliders-value-horizontal.ads +++ b/src/fltk-widgets-valuators-sliders-value-horizontal.ads @@ -7,9 +7,9 @@  package FLTK.Widgets.Valuators.Sliders.Value.Horizontal is -    type Hor_Value_Slider is new Value_Slider with private; +    type Horizontal_Value_Slider is new Value_Slider with private; -    type Hor_Value_Slider_Reference (Data : not null access Hor_Value_Slider'Class) is +    type Horizontal_Value_Slider_Reference (Data : not null access Horizontal_Value_Slider'Class) is          limited null record with Implicit_Dereference => Data; @@ -20,44 +20,33 @@ package FLTK.Widgets.Valuators.Sliders.Value.Horizontal is          function Create                 (X, Y, W, H : in Integer;                  Text       : in String := "") -            return Hor_Value_Slider; +            return Horizontal_Value_Slider;      end Forge; - - -    procedure Draw -           (This : in out Hor_Value_Slider); - -    function Handle -           (This  : in out Hor_Value_Slider; -            Event : in     Event_Kind) -        return Event_Outcome; - -  private -    type Hor_Value_Slider is new Value_Slider with null record; +    type Horizontal_Value_Slider is new Value_Slider with null record; + +    overriding procedure Initialize +           (This : in out Horizontal_Value_Slider);      overriding procedure Finalize -           (This : in out Hor_Value_Slider); +           (This : in out Horizontal_Value_Slider);      procedure Extra_Init -           (This       : in out Hor_Value_Slider; +           (This       : in out Horizontal_Value_Slider;              X, Y, W, H : in     Integer;              Text       : in     String)      with Inline;      procedure Extra_Final -           (This : in out Hor_Value_Slider) +           (This : in out Horizontal_Value_Slider)      with Inline; -    pragma Inline (Draw); -    pragma Inline (Handle); - -  end FLTK.Widgets.Valuators.Sliders.Value.Horizontal; + diff --git a/src/fltk-widgets-valuators-sliders-value.adb b/src/fltk-widgets-valuators-sliders-value.adb index 40f935b..54188b3 100644 --- a/src/fltk-widgets-valuators-sliders-value.adb +++ b/src/fltk-widgets-valuators-sliders-value.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders.Value is -    procedure value_slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, value_slider_set_draw_hook, "value_slider_set_draw_hook"); -    pragma Inline (value_slider_set_draw_hook); - -    procedure value_slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, value_slider_set_handle_hook, "value_slider_set_handle_hook"); -    pragma Inline (value_slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_value_slider             (X, Y, W, H : in Interfaces.C.int; @@ -94,6 +85,10 @@ package body FLTK.Widgets.Valuators.Sliders.Value is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Value_Slider) is      begin @@ -114,6 +109,10 @@ package body FLTK.Widgets.Valuators.Sliders.Value is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Value_Slider;              X, Y, W, H : in     Integer; @@ -123,6 +122,14 @@ package body FLTK.Widgets.Valuators.Sliders.Value is      end Extra_Init; +    procedure Initialize +           (This : in out Value_Slider) is +    begin +        This.Draw_Ptr := fl_value_slider_draw'Address; +        This.Handle_Ptr := fl_value_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -138,10 +145,6 @@ package body FLTK.Widgets.Valuators.Sliders.Value is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                value_slider_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                value_slider_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -150,6 +153,10 @@ package body FLTK.Widgets.Valuators.Sliders.Value is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Text_Color             (This : in Value_Slider)          return Color is @@ -203,7 +210,7 @@ package body FLTK.Widgets.Valuators.Sliders.Value is      procedure Draw             (This : in out Value_Slider) is      begin -        fl_value_slider_draw (This.Void_Ptr); +        Slider (This).Draw;      end Draw; @@ -212,10 +219,10 @@ package body FLTK.Widgets.Valuators.Sliders.Value is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_value_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Slider (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Sliders.Value; + diff --git a/src/fltk-widgets-valuators-sliders-value.ads b/src/fltk-widgets-valuators-sliders-value.ads index 4a2e461..ac49524 100644 --- a/src/fltk-widgets-valuators-sliders-value.ads +++ b/src/fltk-widgets-valuators-sliders-value.ads @@ -68,6 +68,9 @@ private      type Value_Slider is new Slider with null record; +    overriding procedure Initialize +           (This : in out Value_Slider); +      overriding procedure Finalize             (This : in out Value_Slider); @@ -95,3 +98,4 @@ private  end FLTK.Widgets.Valuators.Sliders.Value; + diff --git a/src/fltk-widgets-valuators-sliders.adb b/src/fltk-widgets-valuators-sliders.adb index 4c99cca..bac5378 100644 --- a/src/fltk-widgets-valuators-sliders.adb +++ b/src/fltk-widgets-valuators-sliders.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators.Sliders is -    procedure slider_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, slider_set_draw_hook, "slider_set_draw_hook"); -    pragma Inline (slider_set_draw_hook); - -    procedure slider_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, slider_set_handle_hook, "slider_set_handle_hook"); -    pragma Inline (slider_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_slider             (X, Y, W, H : in Interfaces.C.int; @@ -32,6 +23,14 @@ package body FLTK.Widgets.Valuators.Sliders is      pragma Import (C, new_fl_slider, "new_fl_slider");      pragma Inline (new_fl_slider); +    function new_fl_slider2 +           (K          : in Interfaces.C.unsigned_char; +            X, Y, W, H : in Interfaces.C.int; +            Text       : in Interfaces.C.char_array) +        return Storage.Integer_Address; +    pragma Import (C, new_fl_slider2, "new_fl_slider2"); +    pragma Inline (new_fl_slider2); +      procedure free_fl_slider             (D : in Storage.Integer_Address);      pragma Import (C, free_fl_slider, "free_fl_slider"); @@ -40,21 +39,6 @@ package body FLTK.Widgets.Valuators.Sliders is -    function fl_slider_get_type -           (S : in Storage.Integer_Address) -        return Interfaces.C.int; -    pragma Import (C, fl_slider_get_type, "fl_slider_get_type"); -    pragma Inline (fl_slider_get_type); - -    procedure fl_slider_set_type -           (S : in Storage.Integer_Address; -            T : in Interfaces.C.int); -    pragma Import (C, fl_slider_set_type, "fl_slider_set_type"); -    pragma Inline (fl_slider_set_type); - - - -      procedure fl_slider_set_bounds             (S    : in Storage.Integer_Address;              A, B : in Interfaces.C.double); @@ -81,7 +65,7 @@ package body FLTK.Widgets.Valuators.Sliders is      procedure fl_slider_set_slider_size             (S : in Storage.Integer_Address; -            T : in Interfaces.C.C_float); +            T : in Interfaces.C.double);      pragma Import (C, fl_slider_set_slider_size, "fl_slider_set_slider_size");      pragma Inline (fl_slider_set_slider_size); @@ -100,6 +84,12 @@ package body FLTK.Widgets.Valuators.Sliders is      pragma Import (C, fl_slider_draw, "fl_slider_draw");      pragma Inline (fl_slider_draw); +    procedure fl_slider_draw2 +           (S          : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_slider_draw2, "fl_slider_draw2"); +    pragma Inline (fl_slider_draw2); +      function fl_slider_handle             (W : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -107,9 +97,35 @@ package body FLTK.Widgets.Valuators.Sliders is      pragma Import (C, fl_slider_handle, "fl_slider_handle");      pragma Inline (fl_slider_handle); +    function fl_slider_handle2 +           (S             : in Storage.Integer_Address; +            E, X, Y, W, H : in Interfaces.C.int) +        return Interfaces.C.int; +    pragma Import (C, fl_slider_handle2, "fl_slider_handle2"); +    pragma Inline (fl_slider_handle2); + + + + +    function fl_widget_get_type +           (S : in Storage.Integer_Address) +        return Interfaces.C.unsigned_char; +    pragma Import (C, fl_widget_get_type, "fl_widget_get_type"); +    pragma Inline (fl_widget_get_type); + +    procedure fl_widget_set_type +           (S : in Storage.Integer_Address; +            T : in Interfaces.C.unsigned_char); +    pragma Import (C, fl_widget_set_type, "fl_widget_set_type"); +    pragma Inline (fl_widget_set_type); + +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Slider) is      begin @@ -130,6 +146,10 @@ package body FLTK.Widgets.Valuators.Sliders is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Slider;              X, Y, W, H : in     Integer; @@ -139,6 +159,14 @@ package body FLTK.Widgets.Valuators.Sliders is      end Extra_Init; +    procedure Initialize +           (This : in out Slider) is +    begin +        This.Draw_Ptr   := fl_slider_draw'Address; +        This.Handle_Ptr := fl_slider_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -154,23 +182,36 @@ package body FLTK.Widgets.Valuators.Sliders is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                slider_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                slider_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; -    end Forge; +        function Create +               (Kind       : in Slider_Kind; +                X, Y, W, H : in Integer; +                Text       : in String := "") +            return Slider is +        begin +            return This : Slider do +                This.Void_Ptr := new_fl_slider2 +                   (Slider_Kind'Pos (Kind), +                    Interfaces.C.int (X), +                    Interfaces.C.int (Y), +                    Interfaces.C.int (W), +                    Interfaces.C.int (H), +                    Interfaces.C.To_C (Text)); +                Extra_Init (This, X, Y, W, H, Text); +            end return; +        end Create; + +    end Forge; -    function Get_Slider_Type -           (This : in Slider) -        return Slider_Kind is -    begin -        return Slider_Kind'Val (fl_slider_get_type (This.Void_Ptr)); -    end Get_Slider_Type; +    ----------------------- +    --  API Subprograms  -- +    -----------------------      procedure Set_Bounds             (This     : in out Slider; @@ -209,9 +250,9 @@ package body FLTK.Widgets.Valuators.Sliders is      procedure Set_Slide_Size             (This : in out Slider; -            To   : in     Float) is +            To   : in     Long_Float) is      begin -        fl_slider_set_slider_size (This.Void_Ptr, Interfaces.C.C_float (To)); +        fl_slider_set_slider_size (This.Void_Ptr, Interfaces.C.double (To));      end Set_Slide_Size; @@ -238,7 +279,20 @@ package body FLTK.Widgets.Valuators.Sliders is      procedure Draw             (This : in out Slider) is      begin -        fl_slider_draw (This.Void_Ptr); +        Valuator (This).Draw; +    end Draw; + + +    procedure Draw +           (This       : in out Slider; +            X, Y, W, H : in     Integer) is +    begin +        fl_slider_draw2 +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H));      end Draw; @@ -247,20 +301,45 @@ package body FLTK.Widgets.Valuators.Sliders is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_slider_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event); +    end Handle; + + +    function Handle +           (This       : in out Slider; +            Event      : in     Event_Kind; +            X, Y, W, H : in     Integer) +        return Event_Outcome is +    begin +        return Event_Outcome'Val (fl_slider_handle2 +           (This.Void_Ptr, +            Event_Kind'Pos (Event), +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)));      end Handle; +    function Get_Slider_Type +           (This : in Slider) +        return Slider_Kind is +    begin +        return Slider_Kind'Val (fl_widget_get_type (This.Void_Ptr)); +    exception +    when Constraint_Error => raise Internal_FLTK_Error; +    end Get_Slider_Type; + +      package body Extra is          procedure Set_Slider_Type                 (This : in out Slider;                  To   : in     Slider_Kind) is          begin -            fl_slider_set_type (This.Void_Ptr, Slider_Kind'Pos (To)); +            fl_widget_set_type (This.Void_Ptr, Slider_Kind'Pos (To));          end Set_Slider_Type;          pragma Inline (Set_Slider_Type); @@ -270,3 +349,4 @@ package body FLTK.Widgets.Valuators.Sliders is  end FLTK.Widgets.Valuators.Sliders; + diff --git a/src/fltk-widgets-valuators-sliders.ads b/src/fltk-widgets-valuators-sliders.ads index cbe7222..c89cb56 100644 --- a/src/fltk-widgets-valuators-sliders.ads +++ b/src/fltk-widgets-valuators-sliders.ads @@ -27,15 +27,17 @@ package FLTK.Widgets.Valuators.Sliders is                  Text       : in String := "")              return Slider; +        function Create +               (Kind       : in Slider_Kind; +                X, Y, W, H : in Integer; +                Text       : in String := "") +            return Slider; +      end Forge; -    function Get_Slider_Type -           (This : in Slider) -        return Slider_Kind; -      procedure Set_Bounds             (This     : in out Slider;              Min, Max : in     Long_Float); @@ -54,7 +56,7 @@ package FLTK.Widgets.Valuators.Sliders is      procedure Set_Slide_Size             (This : in out Slider; -            To   : in     Float); +            To   : in     Long_Float);      procedure Set_Scrollvalue             (This            : in out Slider; @@ -69,13 +71,27 @@ package FLTK.Widgets.Valuators.Sliders is      procedure Draw             (This : in out Slider); +    procedure Draw +           (This       : in out Slider; +            X, Y, W, H : in     Integer); +      function Handle             (This  : in out Slider;              Event : in     Event_Kind)          return Event_Outcome; +    function Handle +           (This       : in out Slider; +            Event      : in     Event_Kind; +            X, Y, W, H : in     Integer) +        return Event_Outcome; + + +    function Get_Slider_Type +           (This : in Slider) +        return Slider_Kind;      package Extra is @@ -91,6 +107,9 @@ private      type Slider is new Valuator with null record; +    overriding procedure Initialize +           (This : in out Slider); +      overriding procedure Finalize             (This : in out Slider); @@ -105,7 +124,6 @@ private      with Inline; -    pragma Inline (Get_Slider_Type);      pragma Inline (Set_Bounds);      pragma Inline (Get_Box);      pragma Inline (Set_Box); @@ -116,6 +134,9 @@ private      pragma Inline (Draw);      pragma Inline (Handle); +    pragma Inline (Get_Slider_Type); +  end FLTK.Widgets.Valuators.Sliders; + diff --git a/src/fltk-widgets-valuators-value_inputs.adb b/src/fltk-widgets-valuators-value_inputs.adb index fbb2e0a..01f51bd 100644 --- a/src/fltk-widgets-valuators-value_inputs.adb +++ b/src/fltk-widgets-valuators-value_inputs.adb @@ -20,19 +20,6 @@ package body FLTK.Widgets.Valuators.Value_Inputs is      --  Functions From C  --      ------------------------ -    procedure value_input_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, value_input_set_draw_hook, "value_input_set_draw_hook"); -    pragma Inline (value_input_set_draw_hook); - -    procedure value_input_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, value_input_set_handle_hook, "value_input_set_handle_hook"); -    pragma Inline (value_input_set_handle_hook); - - - -      function new_fl_value_input             (X, Y, W, H : in Interfaces.C.int;              Text       : in Interfaces.C.char_array) @@ -141,6 +128,15 @@ package body FLTK.Widgets.Valuators.Value_Inputs is +    procedure fl_value_input_resize +           (TD         : in Storage.Integer_Address; +            X, Y, W, H : in Interfaces.C.int); +    pragma Import (C, fl_value_input_resize, "fl_value_input_resize"); +    pragma Inline (fl_value_input_resize); + + + +      procedure fl_value_input_draw             (W : in Storage.Integer_Address);      pragma Import (C, fl_value_input_draw, "fl_value_input_draw"); @@ -219,6 +215,14 @@ package body FLTK.Widgets.Valuators.Value_Inputs is      end Extra_Init; +    procedure Initialize +           (This : in out Value_Input) is +    begin +        This.Draw_Ptr   := fl_value_input_draw'Address; +        This.Handle_Ptr := fl_value_input_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -234,10 +238,6 @@ package body FLTK.Widgets.Valuators.Value_Inputs is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                value_input_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                value_input_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -246,6 +246,10 @@ package body FLTK.Widgets.Valuators.Value_Inputs is +    ------------------ +    --  Attributes  -- +    ------------------ +      function Text_Field             (This : in out Value_Input)          return FLTK.Widgets.Inputs.Text.Text_Input_Reference is @@ -256,6 +260,10 @@ package body FLTK.Widgets.Valuators.Value_Inputs is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Get_Cursor_Color             (This : in Value_Input)          return Color is @@ -360,10 +368,25 @@ package body FLTK.Widgets.Valuators.Value_Inputs is +    procedure Resize +           (This       : in out Value_Input; +            X, Y, W, H : in     Integer) is +    begin +        fl_value_input_resize +           (This.Void_Ptr, +            Interfaces.C.int (X), +            Interfaces.C.int (Y), +            Interfaces.C.int (W), +            Interfaces.C.int (H)); +    end Resize; + + + +      procedure Draw             (This : in out Value_Input) is      begin -        fl_value_input_draw (This.Void_Ptr); +        Valuator (This).Draw;      end Draw; @@ -372,10 +395,10 @@ package body FLTK.Widgets.Valuators.Value_Inputs is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_value_input_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Value_Inputs; + diff --git a/src/fltk-widgets-valuators-value_inputs.ads b/src/fltk-widgets-valuators-value_inputs.ads index 10a5824..384d387 100644 --- a/src/fltk-widgets-valuators-value_inputs.ads +++ b/src/fltk-widgets-valuators-value_inputs.ads @@ -99,6 +99,13 @@ package FLTK.Widgets.Valuators.Value_Inputs is +    procedure Resize +           (This       : in out Value_Input; +            X, Y, W, H : in     Integer); + + + +      procedure Draw             (This : in out Value_Input); @@ -115,6 +122,9 @@ private          My_Input : aliased Inputs.Text.Text_Input;      end record; +    overriding procedure Initialize +           (This : in out Value_Input); +      overriding procedure Finalize             (This : in out Value_Input); @@ -146,9 +156,12 @@ private      pragma Inline (Get_Text_Size);      pragma Inline (Set_Text_Size); +    pragma Inline (Resize); +      pragma Inline (Draw);      pragma Inline (Handle);  end FLTK.Widgets.Valuators.Value_Inputs; + diff --git a/src/fltk-widgets-valuators-value_outputs.adb b/src/fltk-widgets-valuators-value_outputs.adb index dcd763d..de6adf7 100644 --- a/src/fltk-widgets-valuators-value_outputs.adb +++ b/src/fltk-widgets-valuators-value_outputs.adb @@ -16,18 +16,9 @@ use type  package body FLTK.Widgets.Valuators.Value_Outputs is -    procedure value_output_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, value_output_set_draw_hook, "value_output_set_draw_hook"); -    pragma Inline (value_output_set_draw_hook); - -    procedure value_output_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, value_output_set_handle_hook, "value_output_set_handle_hook"); -    pragma Inline (value_output_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_value_output             (X, Y, W, H : in Interfaces.C.int; @@ -113,6 +104,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Value_Output) is      begin @@ -133,6 +128,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Value_Output;              X, Y, W, H : in     Integer; @@ -142,6 +141,14 @@ package body FLTK.Widgets.Valuators.Value_Outputs is      end Extra_Init; +    procedure Initialize +           (This : in out Value_Output) is +    begin +        This.Draw_Ptr := fl_value_output_draw'Address; +        This.Handle_Ptr := fl_value_output_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -157,10 +164,6 @@ package body FLTK.Widgets.Valuators.Value_Outputs is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                value_output_set_draw_hook -                    (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                value_output_set_handle_hook -                    (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -169,6 +172,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Is_Soft             (This : in Value_Output)          return Boolean is @@ -240,7 +247,7 @@ package body FLTK.Widgets.Valuators.Value_Outputs is      procedure Draw             (This : in out Value_Output) is      begin -        fl_value_output_draw (This.Void_Ptr); +        Valuator (This).Draw;      end Draw; @@ -249,10 +256,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is              Event : in     Event_Kind)          return Event_Outcome is      begin -        return Event_Outcome'Val -               (fl_value_output_handle (This.Void_Ptr, Event_Kind'Pos (Event))); +        return Valuator (This).Handle (Event);      end Handle;  end FLTK.Widgets.Valuators.Value_Outputs; + diff --git a/src/fltk-widgets-valuators-value_outputs.ads b/src/fltk-widgets-valuators-value_outputs.ads index 099743b..c5e383d 100644 --- a/src/fltk-widgets-valuators-value_outputs.ads +++ b/src/fltk-widgets-valuators-value_outputs.ads @@ -79,6 +79,9 @@ private      type Value_Output is new Valuator with null record; +    overriding procedure Initialize +           (This : in out Value_Output); +      overriding procedure Finalize             (This : in out Value_Output); @@ -109,3 +112,4 @@ private  end FLTK.Widgets.Valuators.Value_Outputs; + diff --git a/src/fltk-widgets-valuators.adb b/src/fltk-widgets-valuators.adb index 79b576c..197111f 100644 --- a/src/fltk-widgets-valuators.adb +++ b/src/fltk-widgets-valuators.adb @@ -12,18 +12,9 @@ with  package body FLTK.Widgets.Valuators is -    procedure valuator_set_draw_hook -           (W, D : in Storage.Integer_Address); -    pragma Import (C, valuator_set_draw_hook, "valuator_set_draw_hook"); -    pragma Inline (valuator_set_draw_hook); - -    procedure valuator_set_handle_hook -           (W, H : in Storage.Integer_Address); -    pragma Import (C, valuator_set_handle_hook, "valuator_set_handle_hook"); -    pragma Inline (valuator_set_handle_hook); - - - +    ------------------------ +    --  Functions From C  -- +    ------------------------      function new_fl_valuator             (X, Y, W, H : in Interfaces.C.int; @@ -95,9 +86,22 @@ package body FLTK.Widgets.Valuators is      pragma Import (C, fl_valuator_get_step, "fl_valuator_get_step");      pragma Inline (fl_valuator_get_step); -    procedure fl_valuator_set_step +    procedure fl_valuator_set_step_top             (V : in Storage.Integer_Address;              T : in Interfaces.C.double); +    pragma Import (C, fl_valuator_set_step_top, "fl_valuator_set_step_top"); +    pragma Inline (fl_valuator_set_step_top); + +    procedure fl_valuator_set_step_bottom +           (V : in Storage.Integer_Address; +            B : in Interfaces.C.int); +    pragma Import (C, fl_valuator_set_step_bottom, "fl_valuator_set_step_bottom"); +    pragma Inline (fl_valuator_set_step_bottom); + +    procedure fl_valuator_set_step +           (V : in Storage.Integer_Address; +            T : in Interfaces.C.double; +            B : in Interfaces.C.int);      pragma Import (C, fl_valuator_set_step, "fl_valuator_set_step");      pragma Inline (fl_valuator_set_step); @@ -134,6 +138,16 @@ package body FLTK.Widgets.Valuators is +    procedure fl_valuator_value_damage +           (V : in Storage.Integer_Address); +    pragma Import (C, fl_valuator_value_damage, "fl_valuator_value_damage"); +    pragma Inline (fl_valuator_value_damage); + +    procedure fl_valuator_draw +           (V : in Storage.Integer_Address); +    pragma Import (C, fl_valuator_draw, "fl_valuator_draw"); +    pragma Inline (fl_valuator_draw); +      function fl_valuator_handle             (V : in Storage.Integer_Address;              E : in Interfaces.C.int) @@ -144,6 +158,10 @@ package body FLTK.Widgets.Valuators is +    ------------------- +    --  Destructors  -- +    ------------------- +      procedure Extra_Final             (This : in out Valuator) is      begin @@ -164,6 +182,10 @@ package body FLTK.Widgets.Valuators is +    -------------------- +    --  Constructors  -- +    -------------------- +      procedure Extra_Init             (This       : in out Valuator;              X, Y, W, H : in     Integer; @@ -173,6 +195,14 @@ package body FLTK.Widgets.Valuators is      end Extra_Init; +    procedure Initialize +           (This : in out Valuator) is +    begin +        This.Draw_Ptr   := fl_valuator_draw'Address; +        This.Handle_Ptr := fl_valuator_handle'Address; +    end Initialize; + +      package body Forge is          function Create @@ -188,8 +218,6 @@ package body FLTK.Widgets.Valuators is                          Interfaces.C.int (H),                          Interfaces.C.To_C (Text));                  Extra_Init (This, X, Y, W, H, Text); -                valuator_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); -                valuator_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));              end return;          end Create; @@ -198,6 +226,10 @@ package body FLTK.Widgets.Valuators is +    ----------------------- +    --  API Subprograms  -- +    ----------------------- +      function Clamp             (This  : in Valuator;              Input : in Long_Float) @@ -271,11 +303,35 @@ package body FLTK.Widgets.Valuators is      end Get_Step; -    procedure Set_Step +    procedure Set_Step_Top             (This : in out Valuator;              To   : in     Long_Float) is      begin -        fl_valuator_set_step (This.Void_Ptr, Interfaces.C.double (To)); +        fl_valuator_set_step_top +           (This.Void_Ptr, +            Interfaces.C.double (To)); +    end Set_Step_Top; + + +    procedure Set_Step_Bottom +           (This : in out Valuator; +            To   : in     Integer) is +    begin +        fl_valuator_set_step_bottom +           (This.Void_Ptr, +            Interfaces.C.int (To)); +    end Set_Step_Bottom; + + +    procedure Set_Step +           (This   : in out Valuator; +            Top    : in     Long_Float; +            Bottom : in     Integer) is +    begin +        fl_valuator_set_step +           (This.Void_Ptr, +            Interfaces.C.double (Top), +            Interfaces.C.int (Bottom));      end Set_Step; @@ -327,15 +383,13 @@ package body FLTK.Widgets.Valuators is -    function Handle -           (This  : in out Valuator; -            Event : in     Event_Kind) -        return Event_Outcome is +    procedure Value_Damage +           (This : in out Valuator) is      begin -        return Event_Outcome'Val -               (fl_valuator_handle (This.Void_Ptr, Event_Kind'Pos (Event))); -    end Handle; +        fl_valuator_value_damage (This.Void_Ptr); +    end Value_Damage;  end FLTK.Widgets.Valuators; + diff --git a/src/fltk-widgets-valuators.ads b/src/fltk-widgets-valuators.ads index ccf2a49..83df44f 100644 --- a/src/fltk-widgets-valuators.ads +++ b/src/fltk-widgets-valuators.ads @@ -66,10 +66,19 @@ package FLTK.Widgets.Valuators is             (This : in Valuator)          return Long_Float; -    procedure Set_Step +    procedure Set_Step_Top             (This : in out Valuator;              To   : in     Long_Float); +    procedure Set_Step_Bottom +           (This : in out Valuator; +            To   : in     Integer); + +    procedure Set_Step +           (This   : in out Valuator; +            Top    : in     Long_Float; +            Bottom : in     Integer); +      function Get_Value             (This : in Valuator)          return Long_Float; @@ -93,10 +102,8 @@ package FLTK.Widgets.Valuators is -    function Handle -           (This  : in out Valuator; -            Event : in     Event_Kind) -        return Event_Outcome; +    procedure Value_Damage +           (This : in out Valuator);  private @@ -104,6 +111,9 @@ private      type Valuator is new Widget with null record; +    overriding procedure Initialize +           (This : in out Valuator); +      overriding procedure Finalize             (This : in out Valuator); @@ -127,6 +137,8 @@ private      pragma Inline (Get_Maximum);      pragma Inline (Set_Maximum);      pragma Inline (Get_Step); +    pragma Inline (Set_Step_Top); +    pragma Inline (Set_Step_Bottom);      pragma Inline (Set_Step);      pragma Inline (Get_Value);      pragma Inline (Set_Value); @@ -134,8 +146,9 @@ private      pragma Inline (Set_Precision);      pragma Inline (Set_Range); -    pragma Inline (Handle); +    pragma Inline (Value_Damage);  end FLTK.Widgets.Valuators; +  | 
