diff options
241 files changed, 7427 insertions, 3479 deletions
diff --git a/body/c_fl.cpp b/body/c_fl.cpp index a9e6d16..7bfc444 100644 --- a/body/c_fl.cpp +++ b/body/c_fl.cpp @@ -6,6 +6,7 @@ #include <FL/Enumerations.H> #include <FL/Fl.H> +#include <FL/Fl_Widget.H> #include "c_fl.h" @@ -51,88 +52,174 @@ size_t c_pointer_size() { -unsigned int fl_enum_rgb_color(unsigned char r, unsigned char g, unsigned char b) { - return fl_rgb_color(r, g, b); +const int fl_enum_num_red = FL_NUM_RED; +const int fl_enum_num_green = FL_NUM_GREEN; +const int fl_enum_num_blue = FL_NUM_BLUE; +const int fl_enum_num_gray = FL_NUM_GRAY; + + + + +const unsigned int fl_enum_button1 = FL_BUTTON1; +const unsigned int fl_enum_button2 = FL_BUTTON2; +const unsigned int fl_enum_button3 = FL_BUTTON3; +#if FL_API_VERSION >= 10310 +const unsigned int fl_enum_button4 = FL_BUTTON4; +const unsigned int fl_enum_button5 = FL_BUTTON5; +#else +// woo, limited backwards compatibility +const unsigned int fl_enum_button4 = 8; +const unsigned int fl_enum_button5 = 16; +#endif +const unsigned int fl_enum_buttons = FL_BUTTONS; + + + + +const int fl_enum_left_mouse = FL_LEFT_MOUSE; +const int fl_enum_middle_mouse = FL_MIDDLE_MOUSE; +const int fl_enum_right_mouse = FL_RIGHT_MOUSE; +#if FL_API_VERSION >= 10310 +const int fl_enum_back_mouse = FL_BACK_MOUSE; +const int fl_enum_forward_mouse = FL_FORWARD_MOUSE; +#else +// woo, limited backwards compatibility +const int fl_enum_back_mouse = 4; +const int fl_enum_forward_mouse = 5; +#endif + + + + +unsigned int fl_enum_rgb_color2(unsigned char l) { + return static_cast<unsigned int>(fl_rgb_color(l)); } -unsigned int fl_enum_contrast(unsigned int f, unsigned int b) { - return fl_contrast(f, b); +unsigned int fl_enum_rgb_color(unsigned char r, unsigned char g, unsigned char b) { + return static_cast<unsigned int>(fl_rgb_color(r, g, b)); } +unsigned int fl_enum_color_cube(int r, int g, int b) { + return static_cast<unsigned int>(fl_color_cube(r, g, b)); +} +unsigned int fl_enum_gray_ramp(int l) { + return static_cast<unsigned int>(fl_gray_ramp(l)); +} +unsigned int fl_enum_darker(unsigned int c) { + return static_cast<unsigned int>(fl_darker(static_cast<Fl_Color>(c))); +} -int fl_abi_check(int v) { - return Fl::abi_check(v); +unsigned int fl_enum_lighter(unsigned int c) { + return static_cast<unsigned int>(fl_lighter(static_cast<Fl_Color>(c))); } -int fl_abi_version() { - return Fl::abi_version(); +unsigned int fl_enum_contrast(unsigned int f, unsigned int b) { + return static_cast<unsigned int>(fl_contrast + (static_cast<Fl_Color>(f), static_cast<Fl_Color>(b))); } -int fl_api_version() { - return Fl::api_version(); +unsigned int fl_enum_inactive(unsigned int c) { + return static_cast<unsigned int>(fl_inactive(static_cast<Fl_Color>(c))); } -double fl_version() { - return Fl::version(); +unsigned int fl_enum_color_average(unsigned int c1, unsigned int c2, float w) { + return static_cast<unsigned int>(fl_color_average + (static_cast<Fl_Color>(c1), static_cast<Fl_Color>(c2), w)); } -void fl_awake() { - Fl::awake(); +int fl_enum_box(int b) { + return static_cast<int>(fl_box(static_cast<Fl_Boxtype>(b))); } -void fl_lock() { - Fl::lock(); +int fl_enum_frame(int b) { + return static_cast<int>(fl_frame(static_cast<Fl_Boxtype>(b))); } -void fl_unlock() { - Fl::unlock(); +int fl_enum_down(int b) { + return static_cast<int>(fl_down(static_cast<Fl_Boxtype>(b))); } -int fl_get_damage() { - return Fl::damage(); +const char * const fl_clip_image_char_ptr = Fl::clipboard_image; + +const char * const fl_clip_plain_text_char_ptr = Fl::clipboard_plain_text; + + + + +int fl_abi_check(int v) { + return Fl::abi_check(v); } -void fl_set_damage(int v) { - Fl::damage(v); +int fl_abi_version() { + return Fl::abi_version(); } -void fl_flush() { - Fl::flush(); +int fl_api_version() { + return Fl::api_version(); } -void fl_redraw() { - Fl::redraw(); +double fl_version() { + return Fl::version(); +} + + + + +short fl_inside_callback = 0; + +void fl_delete_widget(void * w) { + Fl::delete_widget(static_cast<Fl_Widget*>(w)); } int fl_check() { - return Fl::check(); + short temp = fl_inside_callback; + fl_inside_callback = 1; + int ret = Fl::check(); + fl_inside_callback = temp; + return ret; } int fl_ready() { - return Fl::ready(); + short temp = fl_inside_callback; + fl_inside_callback = 1; + int ret = Fl::ready(); + fl_inside_callback = temp; + return ret; } int fl_wait() { - return Fl::wait(); + short temp = fl_inside_callback; + fl_inside_callback = 1; + int ret = Fl::wait(); + fl_inside_callback = temp; + return ret; } -int fl_wait2(double s) { - return Fl::wait(s); +double fl_wait2(double s) { + short temp = fl_inside_callback; + fl_inside_callback = 1; + double ret = Fl::wait(s); + fl_inside_callback = temp; + return ret; } int fl_run() { - return Fl::run(); + short temp = fl_inside_callback; + fl_inside_callback = 1; + int ret = Fl::run(); + fl_inside_callback = temp; + return ret; } diff --git a/body/c_fl.h b/body/c_fl.h index 51dbedb..2149640 100644 --- a/body/c_fl.h +++ b/body/c_fl.h @@ -8,6 +8,9 @@ #define FL_GUARD +#include <cstddef> + + extern "C" const short fl_align_center; extern "C" const short fl_align_top; extern "C" const short fl_align_bottom; @@ -40,8 +43,45 @@ extern "C" const short fl_mod_command; extern "C" size_t c_pointer_size(); +extern "C" const int fl_enum_num_red; +extern "C" const int fl_enum_num_green; +extern "C" const int fl_enum_num_blue; +extern "C" const int fl_enum_num_gray; + + +extern "C" const unsigned int fl_enum_button1; +extern "C" const unsigned int fl_enum_button2; +extern "C" const unsigned int fl_enum_button3; +extern "C" const unsigned int fl_enum_button4; +extern "C" const unsigned int fl_enum_button5; +extern "C" const unsigned int fl_enum_buttons; + + +extern "C" const int fl_enum_left_mouse; +extern "C" const int fl_enum_middle_mouse; +extern "C" const int fl_enum_right_mouse; +extern "C" const int fl_enum_back_mouse; +extern "C" const int fl_enum_forward_mouse; + + +extern "C" unsigned int fl_enum_rgb_color2(unsigned char l); extern "C" unsigned int fl_enum_rgb_color(unsigned char r, unsigned char g, unsigned char b); +extern "C" unsigned int fl_enum_color_cube(int r, int g, int b); +extern "C" unsigned int fl_enum_gray_ramp(int l); +extern "C" unsigned int fl_enum_darker(unsigned int c); +extern "C" unsigned int fl_enum_lighter(unsigned int c); extern "C" unsigned int fl_enum_contrast(unsigned int f, unsigned int b); +extern "C" unsigned int fl_enum_inactive(unsigned int c); +extern "C" unsigned int fl_enum_color_average(unsigned int c1, unsigned int c2, float w); + + +extern "C" int fl_enum_box(int b); +extern "C" int fl_enum_frame(int b); +extern "C" int fl_enum_down(int b); + + +extern "C" const char * const fl_clip_image_char_ptr; +extern "C" const char * const fl_clip_plain_text_char_ptr; extern "C" int fl_abi_check(int v); @@ -50,21 +90,14 @@ extern "C" int fl_api_version(); extern "C" double fl_version(); -extern "C" void fl_awake(); -extern "C" void fl_lock(); -extern "C" void fl_unlock(); - - -extern "C" int fl_get_damage(); -extern "C" void fl_set_damage(int v); -extern "C" void fl_flush(); -extern "C" void fl_redraw(); +extern "C" short fl_inside_callback; +extern "C" void fl_delete_widget(void * w); extern "C" int fl_check(); extern "C" int fl_ready(); extern "C" int fl_wait(); -extern "C" int fl_wait2(double s); +extern "C" double fl_wait2(double s); extern "C" int fl_run(); diff --git a/body/c_fl_adjuster.cpp b/body/c_fl_adjuster.cpp index 37a52cd..5550250 100644 --- a/body/c_fl_adjuster.cpp +++ b/body/c_fl_adjuster.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Adjuster.H> #include "c_fl_adjuster.h" +#include "c_fl.h" @@ -67,7 +68,11 @@ ADJUSTER new_fl_adjuster(int x, int y, int w, int h, char* label) { } void free_fl_adjuster(ADJUSTER a) { - delete static_cast<My_Adjuster*>(a); + if (fl_inside_callback) { + fl_delete_widget(a); + } else { + delete static_cast<My_Adjuster*>(a); + } } diff --git a/body/c_fl_box.cpp b/body/c_fl_box.cpp index e9c170d..22ef21e 100644 --- a/body/c_fl_box.cpp +++ b/body/c_fl_box.cpp @@ -6,6 +6,17 @@ #include <FL/Fl_Box.H> #include "c_fl_box.h" +#include "c_fl.h" + + + + +// Telprot stopover + +extern "C" void box_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l); +void fl_box_extra_init(void * adaobj, int x, int y, int w, int h, const char * label) { + box_extra_init_hook(adaobj, x, y, w, h, label); +} @@ -55,7 +66,11 @@ BOX new_fl_box2(int k, int x, int y, int w, int h, char * label) { } void free_fl_box(BOX b) { - delete static_cast<My_Box*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Box*>(b); + } } diff --git a/body/c_fl_box.h b/body/c_fl_box.h index 5143c3f..f0f8352 100644 --- a/body/c_fl_box.h +++ b/body/c_fl_box.h @@ -8,6 +8,9 @@ #define FL_BOX_GUARD +extern "C" void fl_box_extra_init(void * adaobj, int x, int y, int w, int h, const char * label); + + typedef void* BOX; diff --git a/body/c_fl_browser.cpp b/body/c_fl_browser.cpp index bf700b7..b76c496 100644 --- a/body/c_fl_browser.cpp +++ b/body/c_fl_browser.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Browser.H> #include <FL/Fl_Image.H> #include "c_fl_browser.h" +#include "c_fl.h" @@ -183,7 +184,11 @@ BROWSER new_fl_browser(int x, int y, int w, int h, char * label) { } void free_fl_browser(BROWSER b) { - delete static_cast<My_Browser*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Browser*>(b); + } } diff --git a/body/c_fl_browser_.cpp b/body/c_fl_browser_.cpp index 58eaa3d..df65818 100644 --- a/body/c_fl_browser_.cpp +++ b/body/c_fl_browser_.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Browser_.H> #include "c_fl_browser_.h" +#include "c_fl.h" @@ -190,7 +191,11 @@ ABSTRACTBROWSER new_fl_abstract_browser(int x, int y, int w, int h, char * label } void free_fl_abstract_browser(ABSTRACTBROWSER b) { - delete static_cast<My_Browser_*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Browser_*>(b); + } } diff --git a/body/c_fl_button.cpp b/body/c_fl_button.cpp index 409b190..ba08bc9 100644 --- a/body/c_fl_button.cpp +++ b/body/c_fl_button.cpp @@ -6,22 +6,18 @@ #include <FL/Fl_Button.H> #include "c_fl_button.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void button_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l); void fl_button_extra_init(void * adaobj, int x, int y, int w, int h, const char * label) { button_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void button_extra_final_hook(void * aobj); -void fl_button_extra_final(void * adaobj) { - button_extra_final_hook(adaobj); -} - @@ -75,7 +71,11 @@ BUTTON new_fl_button(int x, int y, int w, int h, char* label) { } void free_fl_button(BUTTON b) { - delete static_cast<My_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Button*>(b); + } } diff --git a/body/c_fl_button.h b/body/c_fl_button.h index f644a50..dfc0631 100644 --- a/body/c_fl_button.h +++ b/body/c_fl_button.h @@ -9,7 +9,6 @@ extern "C" void fl_button_extra_init(void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_button_extra_final(void * adaobj); typedef void* BUTTON; diff --git a/body/c_fl_cairo_window.cpp b/body/c_fl_cairo_window.cpp index 4bf75f0..b4891c6 100644 --- a/body/c_fl_cairo_window.cpp +++ b/body/c_fl_cairo_window.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Cairo_Window.H> #include <FL/Fl_Double_Window.H> #include "c_fl_cairo_window.h" +#include "c_fl.h" @@ -61,7 +62,11 @@ CAIROWINDOW new_fl_cairo_window(int w, int h) { } void free_fl_cairo_window(CAIROWINDOW w) { - delete static_cast<My_Cairo_Window*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Cairo_Window*>(w); + } } diff --git a/body/c_fl_chart.cpp b/body/c_fl_chart.cpp index c065327..351841f 100644 --- a/body/c_fl_chart.cpp +++ b/body/c_fl_chart.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Chart.H> #include "c_fl_chart.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ CHART new_fl_chart(int x, int y, int w, int h, char* label) { } void free_fl_chart(CHART b) { - delete static_cast<My_Chart*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Chart*>(b); + } } diff --git a/body/c_fl_check_browser.cpp b/body/c_fl_check_browser.cpp index 947dc63..11fafa4 100644 --- a/body/c_fl_check_browser.cpp +++ b/body/c_fl_check_browser.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Check_Browser.H> #include <FL/Fl_Browser_.H> #include "c_fl_check_browser.h" +#include "c_fl.h" @@ -197,7 +198,11 @@ CHECKBROWSER new_fl_check_browser(int x, int y, int w, int h, char * label) { } void free_fl_check_browser(CHECKBROWSER c) { - delete static_cast<My_Check_Browser*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Check_Browser*>(c); + } } diff --git a/body/c_fl_check_button.cpp b/body/c_fl_check_button.cpp index 8dab449..f590aa0 100644 --- a/body/c_fl_check_button.cpp +++ b/body/c_fl_check_button.cpp @@ -6,11 +6,12 @@ #include <FL/Fl_Check_Button.H> #include "c_fl_check_button.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void check_button_extra_init_hook (void * aobj, int x, int y, int w, int h, const char * l); @@ -18,11 +19,6 @@ void fl_check_button_extra_init (void * adaobj, int x, int y, int w, int h, cons check_button_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void check_button_extra_final_hook(void * aobj); -void fl_check_button_extra_final(void * adaobj) { - check_button_extra_final_hook(adaobj); -} - @@ -66,7 +62,11 @@ CHECKBUTTON new_fl_check_button(int x, int y, int w, int h, char* label) { } void free_fl_check_button(CHECKBUTTON b) { - delete static_cast<My_Check_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Check_Button*>(b); + } } diff --git a/body/c_fl_check_button.h b/body/c_fl_check_button.h index cfa6bff..88f1a00 100644 --- a/body/c_fl_check_button.h +++ b/body/c_fl_check_button.h @@ -10,7 +10,6 @@ extern "C" void fl_check_button_extra_init (void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_check_button_extra_final(void * adaobj); typedef void* CHECKBUTTON; diff --git a/body/c_fl_choice.cpp b/body/c_fl_choice.cpp index 4b03532..e4471e5 100644 --- a/body/c_fl_choice.cpp +++ b/body/c_fl_choice.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Choice.H> #include "c_fl_choice.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ CHOICE new_fl_choice(int x, int y, int w, int h, char* label) { } void free_fl_choice(CHOICE b) { - delete static_cast<My_Choice*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Choice*>(b); + } } diff --git a/body/c_fl_clock.cpp b/body/c_fl_clock.cpp index e2df99c..2828f9e 100644 --- a/body/c_fl_clock.cpp +++ b/body/c_fl_clock.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Clock.H> #include "c_fl_clock.h" +#include "c_fl.h" @@ -55,7 +56,11 @@ CLOCK new_fl_clock2(unsigned char k, int x, int y, int w, int h, char* label) { } void free_fl_clock(CLOCK c) { - delete static_cast<My_Clock*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Clock*>(c); + } } diff --git a/body/c_fl_clock_output.cpp b/body/c_fl_clock_output.cpp index a34b1c4..7e977f3 100644 --- a/body/c_fl_clock_output.cpp +++ b/body/c_fl_clock_output.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Clock.H> #include "c_fl_clock_output.h" +#include "c_fl.h" @@ -61,7 +62,11 @@ CLOCKOUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label) { } void free_fl_clock_output(CLOCKOUTPUT c) { - delete static_cast<My_Clock_Output*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Clock_Output*>(c); + } } diff --git a/body/c_fl_color_chooser.cpp b/body/c_fl_color_chooser.cpp index 31551b8..8f54437 100644 --- a/body/c_fl_color_chooser.cpp +++ b/body/c_fl_color_chooser.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Color_Chooser.H> #include "c_fl_color_chooser.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ COLORCHOOSER new_fl_color_chooser(int x, int y, int w, int h, char* label) { } void free_fl_color_chooser(COLORCHOOSER n) { - delete static_cast<My_Color_Chooser*>(n); + if (fl_inside_callback) { + fl_delete_widget(n); + } else { + delete static_cast<My_Color_Chooser*>(n); + } } diff --git a/body/c_fl_counter.cpp b/body/c_fl_counter.cpp index 9fe5d20..086a41d 100644 --- a/body/c_fl_counter.cpp +++ b/body/c_fl_counter.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Counter.H> #include "c_fl_counter.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ COUNTER new_fl_counter(int x, int y, int w, int h, char* label) { } void free_fl_counter(COUNTER c) { - delete static_cast<My_Counter*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Counter*>(c); + } } diff --git a/body/c_fl_dial.cpp b/body/c_fl_dial.cpp index af83c21..6bc5368 100644 --- a/body/c_fl_dial.cpp +++ b/body/c_fl_dial.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Dial.H> #include "c_fl_dial.h" +#include "c_fl.h" @@ -69,7 +70,11 @@ DIAL new_fl_dial(int x, int y, int w, int h, char* label) { } void free_fl_dial(DIAL v) { - delete static_cast<My_Dial*>(v); + if (fl_inside_callback) { + fl_delete_widget(v); + } else { + delete static_cast<My_Dial*>(v); + } } diff --git a/body/c_fl_double_window.cpp b/body/c_fl_double_window.cpp index 67db73b..bc9c48f 100644 --- a/body/c_fl_double_window.cpp +++ b/body/c_fl_double_window.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Double_Window.H> #include "c_fl_double_window.h" +#include "c_fl.h" @@ -66,7 +67,11 @@ DOUBLEWINDOW new_fl_double_window2(int w, int h, char* label) { } void free_fl_double_window(DOUBLEWINDOW d) { - delete static_cast<My_Double_Window*>(d); + if (fl_inside_callback) { + fl_delete_widget(d); + } else { + delete static_cast<My_Double_Window*>(d); + } } diff --git a/body/c_fl_event.cpp b/body/c_fl_event.cpp index 59a22df..7bfb466 100644 --- a/body/c_fl_event.cpp +++ b/body/c_fl_event.cpp @@ -16,10 +16,29 @@ void fl_event_add_handler(void * f) { Fl::add_handler(reinterpret_cast<Fl_Event_Handler>(f)); } -void fl_event_set_event_dispatch(void * f) { +void fl_event_remove_handler(void * f) { + Fl::remove_handler(reinterpret_cast<Fl_Event_Handler>(f)); +} + +void fl_event_add_system_handler(void * h, void * f) { + Fl::add_system_handler(reinterpret_cast<Fl_System_Handler>(h), f); +} + +void fl_event_remove_system_handler(void * h) { + Fl::remove_system_handler(reinterpret_cast<Fl_System_Handler>(h)); +} + + + + +void fl_event_set_dispatch(void * f) { Fl::event_dispatch(reinterpret_cast<Fl_Event_Dispatch>(f)); } +int fl_event_handle_dispatch(int e, void * w) { + return Fl::handle(e, static_cast<Fl_Window*>(w)); +} + int fl_event_handle(int e, void * w) { return Fl::handle_(e, static_cast<Fl_Window*>(w)); } @@ -59,6 +78,25 @@ void fl_event_set_focus(void * w) { Fl::focus(static_cast<Fl_Widget*>(w)); } +int fl_event_get_visible_focus() { + return Fl::visible_focus(); +} + +void fl_event_set_visible_focus(int f) { + Fl::visible_focus(f); +} + + + + +const char * fl_event_clipboard_text() { + return static_cast<const char*>(Fl::event_clipboard()); +} + +const char * fl_event_clipboard_type() { + return Fl::event_clipboard_type(); +} + @@ -78,6 +116,10 @@ int fl_event_length() { return Fl::event_length(); } +int fl_event_test_shortcut(unsigned int s) { + return Fl::test_shortcut(static_cast<Fl_Shortcut>(s)); +} + @@ -128,7 +170,11 @@ int fl_event_is_click() { return Fl::event_is_click(); } -int fl_event_is_clicks() { +void fl_event_set_click(int c) { + Fl::event_is_click(c); +} + +int fl_event_get_clicks() { return Fl::event_clicks(); } @@ -152,6 +198,30 @@ int fl_event_button3() { return Fl::event_button3(); } +int fl_event_button4() { +#if FL_API_VERSION >= 10310 + return Fl::event_button4(); +#else + return 0; +#endif +} + +int fl_event_button5() { +#if FL_API_VERSION >= 10310 + return Fl::event_button5(); +#else + return 0; +#endif +} + +int fl_event_buttons() { + return Fl::event_buttons(); +} + +int fl_event_inside2(void * c) { + return Fl::event_inside(static_cast<Fl_Widget*>(c)); +} + int fl_event_inside(int x, int y, int w, int h) { return Fl::event_inside(x, y, w, h); } diff --git a/body/c_fl_event.h b/body/c_fl_event.h index cc1f930..4cb87cb 100644 --- a/body/c_fl_event.h +++ b/body/c_fl_event.h @@ -9,7 +9,13 @@ extern "C" void fl_event_add_handler(void * f); -extern "C" void fl_event_set_event_dispatch(void * f); +extern "C" void fl_event_remove_handler(void * f); +extern "C" void fl_event_add_system_handler(void * h, void * f); +extern "C" void fl_event_remove_system_handler(void * h); + + +extern "C" void fl_event_set_dispatch(void * f); +extern "C" int fl_event_handle_dispatch(int e, void * w); extern "C" int fl_event_handle(int e, void * w); @@ -21,12 +27,19 @@ extern "C" void * fl_event_get_belowmouse(); extern "C" void fl_event_set_belowmouse(void * w); extern "C" void * fl_event_get_focus(); extern "C" void fl_event_set_focus(void * w); +extern "C" int fl_event_get_visible_focus(); +extern "C" void fl_event_set_visible_focus(int f); + + +extern "C" const char * fl_event_clipboard_text(); +extern "C" const char * fl_event_clipboard_type(); extern "C" int fl_event_compose(int &d); extern "C" void fl_event_compose_reset(); extern "C" const char * fl_event_text(); extern "C" int fl_event_length(); +extern "C" int fl_event_test_shortcut(unsigned int s); extern "C" int fl_event_get(); @@ -42,12 +55,17 @@ extern "C" int fl_event_dx(); extern "C" int fl_event_dy(); extern "C" void fl_event_get_mouse(int &x, int &y); extern "C" int fl_event_is_click(); -extern "C" int fl_event_is_clicks(); +extern "C" void fl_event_set_click(int c); +extern "C" int fl_event_get_clicks(); extern "C" void fl_event_set_clicks(int c); extern "C" int fl_event_button(); extern "C" int fl_event_button1(); extern "C" int fl_event_button2(); extern "C" int fl_event_button3(); +extern "C" int fl_event_button4(); +extern "C" int fl_event_button5(); +extern "C" int fl_event_buttons(); +extern "C" int fl_event_inside2(void * c); extern "C" int fl_event_inside(int x, int y, int w, int h); diff --git a/body/c_fl_file_browser.cpp b/body/c_fl_file_browser.cpp index 2e4f4c9..dfe45a8 100644 --- a/body/c_fl_file_browser.cpp +++ b/body/c_fl_file_browser.cpp @@ -8,6 +8,7 @@ #include <FL/Fl_Browser.H> #include <FL/filename.H> #include "c_fl_file_browser.h" +#include "c_fl.h" @@ -191,7 +192,11 @@ FILEBROWSER new_fl_file_browser(int x, int y, int w, int h, char * label) { } void free_fl_file_browser(FILEBROWSER b) { - delete static_cast<My_File_Browser*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_File_Browser*>(b); + } } diff --git a/body/c_fl_file_input.cpp b/body/c_fl_file_input.cpp index 8d0b15f..0fbea0a 100644 --- a/body/c_fl_file_input.cpp +++ b/body/c_fl_file_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_File_Input.H> #include "c_fl_file_input.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ FILEINPUT new_fl_file_input(int x, int y, int w, int h, char* label) { } void free_fl_file_input(FILEINPUT i) { - delete static_cast<My_File_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_File_Input*>(i); + } } diff --git a/body/c_fl_fill_dial.cpp b/body/c_fl_fill_dial.cpp index 47833c1..b29d581 100644 --- a/body/c_fl_fill_dial.cpp +++ b/body/c_fl_fill_dial.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Fill_Dial.H> #include "c_fl_fill_dial.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ FILLDIAL new_fl_fill_dial(int x, int y, int w, int h, char* label) { } void free_fl_fill_dial(FILLDIAL v) { - delete static_cast<My_Fill_Dial*>(v); + if (fl_inside_callback) { + fl_delete_widget(v); + } else { + delete static_cast<My_Fill_Dial*>(v); + } } diff --git a/body/c_fl_fill_slider.cpp b/body/c_fl_fill_slider.cpp index 49834d4..309960a 100644 --- a/body/c_fl_fill_slider.cpp +++ b/body/c_fl_fill_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Fill_Slider.H> #include "c_fl_fill_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ FILLSLIDER new_fl_fill_slider(int x, int y, int w, int h, char* label) { } void free_fl_fill_slider(FILLSLIDER s) { - delete static_cast<My_Fill_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Fill_Slider*>(s); + } } diff --git a/body/c_fl_float_input.cpp b/body/c_fl_float_input.cpp index eedfa36..ca8337a 100644 --- a/body/c_fl_float_input.cpp +++ b/body/c_fl_float_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Float_Input.H> #include "c_fl_float_input.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ FLOATINPUT new_fl_float_input(int x, int y, int w, int h, char* label) { } void free_fl_float_input(FLOATINPUT i) { - delete static_cast<My_Float_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Float_Input*>(i); + } } diff --git a/body/c_fl_gl_window.cpp b/body/c_fl_gl_window.cpp index 3d6cbd5..adc33d3 100644 --- a/body/c_fl_gl_window.cpp +++ b/body/c_fl_gl_window.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Gl_Window.H> #include "c_fl_gl_window.h" +#include "c_fl.h" @@ -55,7 +56,11 @@ GLWINDOW new_fl_gl_window2(int w, int h, char* label) { } void free_fl_gl_window(GLWINDOW w) { - delete static_cast<My_Gl_Window*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Gl_Window*>(w); + } } diff --git a/body/c_fl_group.cpp b/body/c_fl_group.cpp index 62bee03..dde521c 100644 --- a/body/c_fl_group.cpp +++ b/body/c_fl_group.cpp @@ -8,6 +8,7 @@ #include <FL/Fl_Widget.H> #include "c_fl_group.h" #include "c_fl_widget.h" +#include "c_fl.h" @@ -65,7 +66,11 @@ GROUP new_fl_group(int x, int y, int w, int h, char* label) { } void free_fl_group(GROUP g) { - delete static_cast<My_Group*>(g); + if (fl_inside_callback) { + fl_delete_widget(g); + } else { + delete static_cast<My_Group*>(g); + } } diff --git a/body/c_fl_help_view.cpp b/body/c_fl_help_view.cpp index aa2fd65..db7807e 100644 --- a/body/c_fl_help_view.cpp +++ b/body/c_fl_help_view.cpp @@ -8,6 +8,7 @@ #include <FL/Fl_Help_View.H> #include <FL/Enumerations.H> #include "c_fl_help_view.h" +#include "c_fl.h" @@ -52,7 +53,11 @@ HELPVIEW new_fl_help_view(int x, int y, int w, int h, char * label) { } void free_fl_help_view(HELPVIEW v) { - delete static_cast<My_Help_View*>(v); + if (fl_inside_callback) { + fl_delete_widget(v); + } else { + delete static_cast<My_Help_View*>(v); + } } diff --git a/body/c_fl_hold_browser.cpp b/body/c_fl_hold_browser.cpp index 023e9ec..f5c2268 100644 --- a/body/c_fl_hold_browser.cpp +++ b/body/c_fl_hold_browser.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Hold_Browser.H> #include "c_fl_hold_browser.h" +#include "c_fl.h" @@ -172,7 +173,11 @@ HOLDBROWSER new_fl_hold_browser(int x, int y, int w, int h, char * label) { } void free_fl_hold_browser(HOLDBROWSER b) { - delete static_cast<My_Hold_Browser*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Hold_Browser*>(b); + } } diff --git a/body/c_fl_hor_fill_slider.cpp b/body/c_fl_hor_fill_slider.cpp index 9cd6ae2..1b35cf3 100644 --- a/body/c_fl_hor_fill_slider.cpp +++ b/body/c_fl_hor_fill_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Hor_Fill_Slider.H> #include "c_fl_hor_fill_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ HORFILLSLIDER new_fl_hor_fill_slider(int x, int y, int w, int h, char* label) { } void free_fl_hor_fill_slider(HORFILLSLIDER s) { - delete static_cast<My_Hor_Fill_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Hor_Fill_Slider*>(s); + } } diff --git a/body/c_fl_hor_nice_slider.cpp b/body/c_fl_hor_nice_slider.cpp index 29b271d..508d28b 100644 --- a/body/c_fl_hor_nice_slider.cpp +++ b/body/c_fl_hor_nice_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Hor_Nice_Slider.H> #include "c_fl_hor_nice_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ HORNICESLIDER new_fl_hor_nice_slider(int x, int y, int w, int h, char* label) { } void free_fl_hor_nice_slider(HORNICESLIDER s) { - delete static_cast<My_Hor_Nice_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Hor_Nice_Slider*>(s); + } } diff --git a/body/c_fl_hor_value_slider.cpp b/body/c_fl_hor_value_slider.cpp index cff16f6..341eb60 100644 --- a/body/c_fl_hor_value_slider.cpp +++ b/body/c_fl_hor_value_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Hor_Value_Slider.H> #include "c_fl_hor_value_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ HORVALUESLIDER new_fl_hor_value_slider(int x, int y, int w, int h, char* label) } void free_fl_hor_value_slider(HORVALUESLIDER s) { - delete static_cast<My_Hor_Value_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Hor_Value_Slider*>(s); + } } diff --git a/body/c_fl_horizontal_slider.cpp b/body/c_fl_horizontal_slider.cpp index 6a0ac22..6433a73 100644 --- a/body/c_fl_horizontal_slider.cpp +++ b/body/c_fl_horizontal_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Hor_Slider.H> #include "c_fl_horizontal_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ HORIZONTALSLIDER new_fl_horizontal_slider(int x, int y, int w, int h, char* labe } void free_fl_horizontal_slider(HORIZONTALSLIDER s) { - delete static_cast<My_Horizontal_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Horizontal_Slider*>(s); + } } diff --git a/body/c_fl_input.cpp b/body/c_fl_input.cpp index 6fa6b2d..73517a7 100644 --- a/body/c_fl_input.cpp +++ b/body/c_fl_input.cpp @@ -6,22 +6,18 @@ #include <FL/Fl_Input.H> #include "c_fl_input.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void text_input_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l); void fl_text_input_extra_init(void * adaobj, int x, int y, int w, int h, const char * label) { text_input_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void text_input_extra_final_hook(void * aobj); -void fl_text_input_extra_final(void * adaobj) { - text_input_extra_final_hook(adaobj); -} - @@ -65,7 +61,11 @@ TEXTINPUT new_fl_text_input(int x, int y, int w, int h, char * label) { } void free_fl_text_input(TEXTINPUT t) { - delete static_cast<My_Text_Input*>(t); + if (fl_inside_callback) { + fl_delete_widget(t); + } else { + delete static_cast<My_Text_Input*>(t); + } } diff --git a/body/c_fl_input.h b/body/c_fl_input.h index 06a8a0c..dec6265 100644 --- a/body/c_fl_input.h +++ b/body/c_fl_input.h @@ -10,7 +10,6 @@ extern "C" void fl_text_input_extra_init (void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_text_input_extra_final(void * adaobj); typedef void* TEXTINPUT; diff --git a/body/c_fl_input_.cpp b/body/c_fl_input_.cpp index 7fe0556..087a4a1 100644 --- a/body/c_fl_input_.cpp +++ b/body/c_fl_input_.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Input_.H> #include "c_fl_input_.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ INPUT new_fl_input(int x, int y, int w, int h, char* label) { } void free_fl_input(INPUT i) { - delete static_cast<My_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Input*>(i); + } } diff --git a/body/c_fl_input_choice.cpp b/body/c_fl_input_choice.cpp index 247e8eb..dea3023 100644 --- a/body/c_fl_input_choice.cpp +++ b/body/c_fl_input_choice.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Input_Choice.H> #include "c_fl_input_choice.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ INPUTCHOICE new_fl_input_choice(int x, int y, int w, int h, char* label) { } void free_fl_input_choice(INPUTCHOICE n) { - delete static_cast<My_Input_Choice*>(n); + if (fl_inside_callback) { + fl_delete_widget(n); + } else { + delete static_cast<My_Input_Choice*>(n); + } } diff --git a/body/c_fl_int_input.cpp b/body/c_fl_int_input.cpp index 8f780d7..ff96560 100644 --- a/body/c_fl_int_input.cpp +++ b/body/c_fl_int_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Int_Input.H> #include "c_fl_int_input.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ INTINPUT new_fl_int_input(int x, int y, int w, int h, char* label) { } void free_fl_int_input(INTINPUT i) { - delete static_cast<My_Int_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Int_Input*>(i); + } } diff --git a/body/c_fl_label.cpp b/body/c_fl_label.cpp index 2200c51..b80d3d3 100644 --- a/body/c_fl_label.cpp +++ b/body/c_fl_label.cpp @@ -29,6 +29,10 @@ void free_fl_label(LABEL l) { +const char * fl_label_get_value(LABEL l) { + return static_cast<Fl_Label*>(l)->value; +} + void fl_label_set_value(LABEL l, const char * v) { static_cast<Fl_Label*>(l)->value = v; } diff --git a/body/c_fl_label.h b/body/c_fl_label.h index 806aa72..6da3aca 100644 --- a/body/c_fl_label.h +++ b/body/c_fl_label.h @@ -15,6 +15,7 @@ extern "C" LABEL new_fl_label(const char * v, int f, int s, unsigned int h, int extern "C" void free_fl_label(LABEL l); +extern "C" const char * fl_label_get_value(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/body/c_fl_light_button.cpp b/body/c_fl_light_button.cpp index e11ce64..6c59730 100644 --- a/body/c_fl_light_button.cpp +++ b/body/c_fl_light_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Light_Button.H> #include "c_fl_light_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ LIGHTBUTTON new_fl_light_button(int x, int y, int w, int h, char* label) { } void free_fl_light_button(LIGHTBUTTON b) { - delete static_cast<My_Light_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Light_Button*>(b); + } } diff --git a/body/c_fl_line_dial.cpp b/body/c_fl_line_dial.cpp index 388264f..92059f2 100644 --- a/body/c_fl_line_dial.cpp +++ b/body/c_fl_line_dial.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Line_Dial.H> #include "c_fl_line_dial.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ LINEDIAL new_fl_line_dial(int x, int y, int w, int h, char* label) { } void free_fl_line_dial(LINEDIAL v) { - delete static_cast<My_Line_Dial*>(v); + if (fl_inside_callback) { + fl_delete_widget(v); + } else { + delete static_cast<My_Line_Dial*>(v); + } } diff --git a/body/c_fl_menu.cpp b/body/c_fl_menu.cpp index e42e985..2ef9402 100644 --- a/body/c_fl_menu.cpp +++ b/body/c_fl_menu.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Menu_.H> #include <FL/Fl_Menu_Item.H> #include "c_fl_menu.h" +#include "c_fl.h" @@ -53,7 +54,11 @@ MENU new_fl_menu(int x, int y, int w, int h, char* label) { } void free_fl_menu(MENU m) { - delete static_cast<My_Menu*>(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast<My_Menu*>(m); + } } diff --git a/body/c_fl_menu_bar.cpp b/body/c_fl_menu_bar.cpp index 5e73675..8419df6 100644 --- a/body/c_fl_menu_bar.cpp +++ b/body/c_fl_menu_bar.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Menu_Bar.H> #include "c_fl_menu_bar.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ MENUBAR new_fl_menu_bar(int x, int y, int w, int h, char* label) { } void free_fl_menu_bar(MENUBAR m) { - delete static_cast<My_Menu_Bar*>(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast<My_Menu_Bar*>(m); + } } diff --git a/body/c_fl_menu_button.cpp b/body/c_fl_menu_button.cpp index abe9712..4537e8d 100644 --- a/body/c_fl_menu_button.cpp +++ b/body/c_fl_menu_button.cpp @@ -6,11 +6,12 @@ #include <FL/Fl_Menu_Button.H> #include "c_fl_menu_button.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void menu_button_extra_init_hook (void * aobj, int x, int y, int w, int h, const char * l); @@ -18,11 +19,6 @@ void fl_menu_button_extra_init(void * adaobj, int x, int y, int w, int h, const menu_button_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void menu_button_extra_final_hook(void * aobj); -void fl_menu_button_extra_final(void * adaobj) { - menu_button_extra_final_hook(adaobj); -} - @@ -66,7 +62,11 @@ MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label) { } void free_fl_menu_button(MENUBUTTON m) { - delete static_cast<My_Menu_Button*>(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast<My_Menu_Button*>(m); + } } diff --git a/body/c_fl_menu_button.h b/body/c_fl_menu_button.h index d567e4f..f8f721b 100644 --- a/body/c_fl_menu_button.h +++ b/body/c_fl_menu_button.h @@ -10,7 +10,6 @@ extern "C" void fl_menu_button_extra_init (void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_menu_button_extra_final(void * adaobj); typedef void* MENUBUTTON; diff --git a/body/c_fl_menu_window.cpp b/body/c_fl_menu_window.cpp index cae1bf9..30020c6 100644 --- a/body/c_fl_menu_window.cpp +++ b/body/c_fl_menu_window.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Menu_Window.H> #include "c_fl_menu_window.h" +#include "c_fl.h" @@ -55,7 +56,11 @@ MENUWINDOW new_fl_menu_window2(int w, int h, char* label) { } void free_fl_menu_window(MENUWINDOW m) { - delete static_cast<My_Menu_Window*>(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast<My_Menu_Window*>(m); + } } diff --git a/body/c_fl_multi_browser.cpp b/body/c_fl_multi_browser.cpp index 18bf5e8..ce0b077 100644 --- a/body/c_fl_multi_browser.cpp +++ b/body/c_fl_multi_browser.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Multi_Browser.H> #include "c_fl_multi_browser.h" +#include "c_fl.h" @@ -172,7 +173,11 @@ MULTIBROWSER new_fl_multi_browser(int x, int y, int w, int h, char * label) { } void free_fl_multi_browser(MULTIBROWSER b) { - delete static_cast<My_Multi_Browser*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Multi_Browser*>(b); + } } diff --git a/body/c_fl_multiline_input.cpp b/body/c_fl_multiline_input.cpp index ee99a13..2e193f2 100644 --- a/body/c_fl_multiline_input.cpp +++ b/body/c_fl_multiline_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Multiline_Input.H> #include "c_fl_multiline_input.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ MULTILINEINPUT new_fl_multiline_input(int x, int y, int w, int h, char* label) { } void free_fl_multiline_input(MULTILINEINPUT i) { - delete static_cast<My_Multiline_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Multiline_Input*>(i); + } } diff --git a/body/c_fl_multiline_output.cpp b/body/c_fl_multiline_output.cpp index 2401fc7..e5c8f05 100644 --- a/body/c_fl_multiline_output.cpp +++ b/body/c_fl_multiline_output.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Multiline_Output.H> #include "c_fl_multiline_output.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ MULTILINEOUTPUT new_fl_multiline_output(int x, int y, int w, int h, char* label) } void free_fl_multiline_output(MULTILINEOUTPUT i) { - delete static_cast<My_Multiline_Output*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Multiline_Output*>(i); + } } diff --git a/body/c_fl_nice_slider.cpp b/body/c_fl_nice_slider.cpp index 082bbfc..5e34190 100644 --- a/body/c_fl_nice_slider.cpp +++ b/body/c_fl_nice_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Nice_Slider.H> #include "c_fl_nice_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ NICESLIDER new_fl_nice_slider(int x, int y, int w, int h, char* label) { } void free_fl_nice_slider(NICESLIDER s) { - delete static_cast<My_Nice_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Nice_Slider*>(s); + } } diff --git a/body/c_fl_output.cpp b/body/c_fl_output.cpp index 2e937dd..9fa36a1 100644 --- a/body/c_fl_output.cpp +++ b/body/c_fl_output.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Output.H> #include "c_fl_output.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ OUTPUTT new_fl_output(int x, int y, int w, int h, char* label) { } void free_fl_output(OUTPUTT i) { - delete static_cast<My_Output*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Output*>(i); + } } diff --git a/body/c_fl_overlay_window.cpp b/body/c_fl_overlay_window.cpp index 0d434c3..fa92eed 100644 --- a/body/c_fl_overlay_window.cpp +++ b/body/c_fl_overlay_window.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Overlay_Window.H> #include "c_fl_overlay_window.h" +#include "c_fl.h" @@ -65,7 +66,11 @@ OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label) { } void free_fl_overlay_window(OVERLAYWINDOW w) { - delete static_cast<My_Overlay_Window*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Overlay_Window*>(w); + } } diff --git a/body/c_fl_pack.cpp b/body/c_fl_pack.cpp index e7cace9..48fa505 100644 --- a/body/c_fl_pack.cpp +++ b/body/c_fl_pack.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Pack.H> #include "c_fl_pack.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ PACK new_fl_pack(int x, int y, int w, int h, char* label) { } void free_fl_pack(PACK p) { - delete static_cast<My_Pack*>(p); + if (fl_inside_callback) { + fl_delete_widget(p); + } else { + delete static_cast<My_Pack*>(p); + } } diff --git a/body/c_fl_positioner.cpp b/body/c_fl_positioner.cpp index ce23b64..6a070d7 100644 --- a/body/c_fl_positioner.cpp +++ b/body/c_fl_positioner.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Positioner.H> #include "c_fl_positioner.h" +#include "c_fl.h" @@ -62,7 +63,11 @@ POSITIONER new_fl_positioner(int x, int y, int w, int h, char* label) { } void free_fl_positioner(POSITIONER p) { - delete static_cast<My_Positioner*>(p); + if (fl_inside_callback) { + fl_delete_widget(p); + } else { + delete static_cast<My_Positioner*>(p); + } } diff --git a/body/c_fl_progress.cpp b/body/c_fl_progress.cpp index 21a7a2d..7b13a48 100644 --- a/body/c_fl_progress.cpp +++ b/body/c_fl_progress.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Progress.H> #include "c_fl_progress.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ PROGRESS new_fl_progress(int x, int y, int w, int h, char* label) { } void free_fl_progress(PROGRESS p) { - delete static_cast<My_Progress*>(p); + if (fl_inside_callback) { + fl_delete_widget(p); + } else { + delete static_cast<My_Progress*>(p); + } } diff --git a/body/c_fl_radio_button.cpp b/body/c_fl_radio_button.cpp index 486c354..40c8fd5 100644 --- a/body/c_fl_radio_button.cpp +++ b/body/c_fl_radio_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Radio_Button.H> #include "c_fl_radio_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ RADIOBUTTON new_fl_radio_button(int x, int y, int w, int h, char* label) { } void free_fl_radio_button(RADIOBUTTON b) { - delete static_cast<My_Radio_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Radio_Button*>(b); + } } diff --git a/body/c_fl_radio_light_button.cpp b/body/c_fl_radio_light_button.cpp index f6da99e..ce57982 100644 --- a/body/c_fl_radio_light_button.cpp +++ b/body/c_fl_radio_light_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Radio_Light_Button.H> #include "c_fl_radio_light_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ RADIOLIGHTBUTTON new_fl_radio_light_button(int x, int y, int w, int h, char* lab } void free_fl_radio_light_button(RADIOLIGHTBUTTON b) { - delete static_cast<My_Radio_Light_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Radio_Light_Button*>(b); + } } diff --git a/body/c_fl_radio_round_button.cpp b/body/c_fl_radio_round_button.cpp index b09e1f3..62dc8e5 100644 --- a/body/c_fl_radio_round_button.cpp +++ b/body/c_fl_radio_round_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Radio_Round_Button.H> #include "c_fl_radio_round_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ RADIOROUNDBUTTON new_fl_radio_round_button(int x, int y, int w, int h, char* lab } void free_fl_radio_round_button(RADIOROUNDBUTTON b) { - delete static_cast<My_Radio_Round_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Radio_Round_Button*>(b); + } } diff --git a/body/c_fl_repeat_button.cpp b/body/c_fl_repeat_button.cpp index c3eb582..562a72d 100644 --- a/body/c_fl_repeat_button.cpp +++ b/body/c_fl_repeat_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Repeat_Button.H> #include "c_fl_repeat_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label) { } void free_fl_repeat_button(REPEATBUTTON b) { - delete static_cast<My_Repeat_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Repeat_Button*>(b); + } } diff --git a/body/c_fl_return_button.cpp b/body/c_fl_return_button.cpp index 2c315d1..3211b7f 100644 --- a/body/c_fl_return_button.cpp +++ b/body/c_fl_return_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Return_Button.H> #include "c_fl_return_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ RETURNBUTTON new_fl_return_button(int x, int y, int w, int h, char* label) { } void free_fl_return_button(RETURNBUTTON b) { - delete static_cast<My_Return_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Return_Button*>(b); + } } diff --git a/body/c_fl_roller.cpp b/body/c_fl_roller.cpp index 1c65422..9f6753c 100644 --- a/body/c_fl_roller.cpp +++ b/body/c_fl_roller.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Roller.H> #include "c_fl_roller.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ ROLLER new_fl_roller(int x, int y, int w, int h, char* label) { } void free_fl_roller(ROLLER r) { - delete static_cast<My_Roller*>(r); + if (fl_inside_callback) { + fl_delete_widget(r); + } else { + delete static_cast<My_Roller*>(r); + } } diff --git a/body/c_fl_round_button.cpp b/body/c_fl_round_button.cpp index e6a9c43..3c9550e 100644 --- a/body/c_fl_round_button.cpp +++ b/body/c_fl_round_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Round_Button.H> #include "c_fl_round_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ ROUNDBUTTON new_fl_round_button(int x, int y, int w, int h, char* label) { } void free_fl_round_button(ROUNDBUTTON b) { - delete static_cast<My_Round_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Round_Button*>(b); + } } diff --git a/body/c_fl_round_clock.cpp b/body/c_fl_round_clock.cpp index 0036c00..85774c8 100644 --- a/body/c_fl_round_clock.cpp +++ b/body/c_fl_round_clock.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Round_Clock.H> #include "c_fl_round_clock.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ ROUNDCLOCK new_fl_round_clock(int x, int y, int w, int h, char* label) { } void free_fl_round_clock(ROUNDCLOCK c) { - delete static_cast<My_Round_Clock*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Round_Clock*>(c); + } } diff --git a/body/c_fl_screen.cpp b/body/c_fl_screen.cpp index 88550bd..7a5fc2f 100644 --- a/body/c_fl_screen.cpp +++ b/body/c_fl_screen.cpp @@ -8,6 +8,27 @@ #include "c_fl_screen.h" + + +const int fl_enum_mode_rgb = FL_RGB; +const int fl_enum_mode_rgb8 = FL_RGB8; +const int fl_enum_mode_double = FL_DOUBLE; +const int fl_enum_mode_index = FL_INDEX; + + + + +void fl_screen_display(const char * v) { + Fl::display(v); +} + +int fl_screen_visual(int mode) { + return Fl::visual(mode); +} + + + + int fl_screen_x() { return Fl::x(); } @@ -82,3 +103,22 @@ void fl_screen_xywh4(int &x, int &y, int &w, int &h, int px, int py, int pw, int } + + +int fl_screen_get_damage() { + return Fl::damage(); +} + +void fl_screen_set_damage(int v) { + Fl::damage(v); +} + +void fl_screen_flush() { + Fl::flush(); +} + +void fl_screen_redraw() { + Fl::redraw(); +} + + diff --git a/body/c_fl_screen.h b/body/c_fl_screen.h index 9b4d4ec..c2b0e98 100644 --- a/body/c_fl_screen.h +++ b/body/c_fl_screen.h @@ -8,6 +8,16 @@ #define FL_SCREEN_GUARD +extern "C" const int fl_enum_mode_rgb; +extern "C" const int fl_enum_mode_rgb8; +extern "C" const int fl_enum_mode_double; +extern "C" const int fl_enum_mode_index; + + +extern "C" void fl_screen_display(const char * v); +extern "C" int fl_screen_visual(int mode); + + extern "C" int fl_screen_x(); extern "C" int fl_screen_y(); extern "C" int fl_screen_w(); @@ -33,6 +43,12 @@ extern "C" void fl_screen_xywh3(int &x, int &y, int &w, int &h); extern "C" void fl_screen_xywh4(int &x, int &y, int &w, int &h, int px, int py, int pw, int ph); +extern "C" int fl_screen_get_damage(); +extern "C" void fl_screen_set_damage(int v); +extern "C" void fl_screen_flush(); +extern "C" void fl_screen_redraw(); + + #endif diff --git a/body/c_fl_scroll.cpp b/body/c_fl_scroll.cpp index a240139..325d8cf 100644 --- a/body/c_fl_scroll.cpp +++ b/body/c_fl_scroll.cpp @@ -6,22 +6,18 @@ #include <FL/Fl_Scroll.H> #include "c_fl_scroll.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void scroll_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l); void fl_scroll_extra_init(void * adaobj, int x, int y, int w, int h, const char * label) { scroll_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void scroll_extra_final_hook(void * aobj); -void fl_scroll_extra_final(void * adaobj) { - scroll_extra_final_hook(adaobj); -} - @@ -75,7 +71,11 @@ SCROLL new_fl_scroll(int x, int y, int w, int h, char* label) { } void free_fl_scroll(SCROLL s) { - delete static_cast<My_Scroll*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Scroll*>(s); + } } diff --git a/body/c_fl_scroll.h b/body/c_fl_scroll.h index 17dec0f..e39e469 100644 --- a/body/c_fl_scroll.h +++ b/body/c_fl_scroll.h @@ -9,7 +9,6 @@ extern "C" void fl_scroll_extra_init(void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_scroll_extra_final(void * adaobj); typedef void* SCROLL; diff --git a/body/c_fl_scrollbar.cpp b/body/c_fl_scrollbar.cpp index 2ebdb27..bf5ceaa 100644 --- a/body/c_fl_scrollbar.cpp +++ b/body/c_fl_scrollbar.cpp @@ -6,22 +6,18 @@ #include <FL/Fl_Scrollbar.H> #include "c_fl_scrollbar.h" +#include "c_fl.h" -// Telprot stopovers +// Telprot stopover extern "C" void scrollbar_extra_init_hook(void * aobj, int x, int y, int w, int h, const char * l); void fl_scrollbar_extra_init (void * adaobj, int x, int y, int w, int h, const char * label) { scrollbar_extra_init_hook(adaobj, x, y, w, h, label); } -extern "C" void scrollbar_extra_final_hook(void * aobj); -void fl_scrollbar_extra_final(void * adaobj) { - scrollbar_extra_final_hook(adaobj); -} - @@ -72,7 +68,11 @@ SCROLLBAR new_fl_scrollbar(int x, int y, int w, int h, char* label) { } void free_fl_scrollbar(SCROLLBAR s) { - delete static_cast<My_Scrollbar*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Scrollbar*>(s); + } } diff --git a/body/c_fl_scrollbar.h b/body/c_fl_scrollbar.h index 870f256..6dd599d 100644 --- a/body/c_fl_scrollbar.h +++ b/body/c_fl_scrollbar.h @@ -10,7 +10,6 @@ extern "C" void fl_scrollbar_extra_init (void * adaobj, int x, int y, int w, int h, const char * label); -extern "C" void fl_scrollbar_extra_final(void * adaobj); typedef void* SCROLLBAR; diff --git a/body/c_fl_secret_input.cpp b/body/c_fl_secret_input.cpp index b3205cb..4ef4720 100644 --- a/body/c_fl_secret_input.cpp +++ b/body/c_fl_secret_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Secret_Input.H> #include "c_fl_secret_input.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ SECRETINPUT new_fl_secret_input(int x, int y, int w, int h, char* label) { } void free_fl_secret_input(SECRETINPUT i) { - delete static_cast<My_Secret_Input*>(i); + if (fl_inside_callback) { + fl_delete_widget(i); + } else { + delete static_cast<My_Secret_Input*>(i); + } } diff --git a/body/c_fl_select_browser.cpp b/body/c_fl_select_browser.cpp index 5993703..a0173fc 100644 --- a/body/c_fl_select_browser.cpp +++ b/body/c_fl_select_browser.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Select_Browser.H> #include "c_fl_select_browser.h" +#include "c_fl.h" @@ -172,7 +173,11 @@ SELECTBROWSER new_fl_select_browser(int x, int y, int w, int h, char * label) { } void free_fl_select_browser(SELECTBROWSER b) { - delete static_cast<My_Select_Browser*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Select_Browser*>(b); + } } diff --git a/body/c_fl_simple_counter.cpp b/body/c_fl_simple_counter.cpp index cf42d03..53aafab 100644 --- a/body/c_fl_simple_counter.cpp +++ b/body/c_fl_simple_counter.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Simple_Counter.H> #include "c_fl_simple_counter.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ SIMPLECOUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label) { } void free_fl_simple_counter(SIMPLECOUNTER c) { - delete static_cast<My_Simple_Counter*>(c); + if (fl_inside_callback) { + fl_delete_widget(c); + } else { + delete static_cast<My_Simple_Counter*>(c); + } } diff --git a/body/c_fl_single_window.cpp b/body/c_fl_single_window.cpp index efafdc4..d22041e 100644 --- a/body/c_fl_single_window.cpp +++ b/body/c_fl_single_window.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Single_Window.H> #include "c_fl_single_window.h" +#include "c_fl.h" @@ -55,7 +56,11 @@ SINGLEWINDOW new_fl_single_window2(int x, int y, char* label) { } void free_fl_single_window(SINGLEWINDOW w) { - delete static_cast<My_Single_Window*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Single_Window*>(w); + } } diff --git a/body/c_fl_slider.cpp b/body/c_fl_slider.cpp index 449988c..bad03cd 100644 --- a/body/c_fl_slider.cpp +++ b/body/c_fl_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Slider.H> #include "c_fl_slider.h" +#include "c_fl.h" @@ -74,7 +75,11 @@ SLIDER new_fl_slider2(unsigned char k, int x, int y, int w, int h, char * label) } void free_fl_slider(SLIDER s) { - delete static_cast<My_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Slider*>(s); + } } diff --git a/body/c_fl_spinner.cpp b/body/c_fl_spinner.cpp index 67a5312..d8683e5 100644 --- a/body/c_fl_spinner.cpp +++ b/body/c_fl_spinner.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Spinner.H> #include "c_fl_spinner.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ SPINNER new_fl_spinner(int x, int y, int w, int h, char* label) { } void free_fl_spinner(SPINNER n) { - delete static_cast<My_Spinner*>(n); + if (fl_inside_callback) { + fl_delete_widget(n); + } else { + delete static_cast<My_Spinner*>(n); + } } diff --git a/body/c_fl_static.cpp b/body/c_fl_static.cpp index ad4cfe9..5dd90e2 100644 --- a/body/c_fl_static.cpp +++ b/body/c_fl_static.cpp @@ -12,64 +12,111 @@ -void fl_static_add_awake_handler(void * h, void * f) { - Fl::add_awake_handler_(reinterpret_cast<Fl_Awake_Handler>(h),f); +void fl_static_box_draw_marshal(void * f, int x, int y, int w, int h, unsigned int t) { + reinterpret_cast<Fl_Box_Draw_F*>(f)(x, y, w, h, static_cast<Fl_Color>(t)); } -void fl_static_get_awake_handler(void * &h, void * &f) { - Fl::get_awake_handler_(reinterpret_cast<Fl_Awake_Handler&>(h),f); + + + +const char * const fl_help_usage_string_ptr = Fl::help; + + + + +int fl_static_arg(int c, void * v, int &i) { + return Fl::arg(c, static_cast<char**>(v), i); +} + +void fl_static_args(int c, void * v) { + Fl::args(c, static_cast<char**>(v)); +} + +int fl_static_args2(int c, void * v, int &i, void * h) { + return Fl::args(c, static_cast<char**>(v), i, reinterpret_cast<Fl_Args_Handler>(h)); +} + + + + +int fl_static_add_awake_handler(void * h, void * f) { + return Fl::add_awake_handler_(reinterpret_cast<Fl_Awake_Handler>(h), f); +} + +int fl_static_get_awake_handler(void * &h, void * &f) { + return Fl::get_awake_handler_(reinterpret_cast<Fl_Awake_Handler&>(h), f); +} + +int fl_static_awake2(void * h, void * f) { + return Fl::awake(reinterpret_cast<Fl_Awake_Handler>(h), f); +} + +void fl_static_awake(void * msg) { + Fl::awake(msg); +} + +void fl_static_lock() { + Fl::lock(); +} + +void fl_static_unlock() { + Fl::unlock(); } void fl_static_add_check(void * h, void * f) { - Fl::add_check(reinterpret_cast<Fl_Timeout_Handler>(h),f); + Fl::add_check(reinterpret_cast<Fl_Timeout_Handler>(h), f); } int fl_static_has_check(void * h, void * f) { - return Fl::has_check(reinterpret_cast<Fl_Timeout_Handler>(h),f); + return Fl::has_check(reinterpret_cast<Fl_Timeout_Handler>(h), f); } void fl_static_remove_check(void * h, void * f) { - Fl::remove_check(reinterpret_cast<Fl_Timeout_Handler>(h),f); + Fl::remove_check(reinterpret_cast<Fl_Timeout_Handler>(h), f); } void fl_static_add_timeout(double s, void * h, void * f) { - Fl::add_timeout(s,reinterpret_cast<Fl_Timeout_Handler>(h),f); + Fl::add_timeout(s, reinterpret_cast<Fl_Timeout_Handler>(h), f); } int fl_static_has_timeout(void * h, void * f) { - return Fl::has_timeout(reinterpret_cast<Fl_Timeout_Handler>(h),f); + return Fl::has_timeout(reinterpret_cast<Fl_Timeout_Handler>(h), f); } void fl_static_remove_timeout(void * h, void * f) { - Fl::remove_timeout(reinterpret_cast<Fl_Timeout_Handler>(h),f); + Fl::remove_timeout(reinterpret_cast<Fl_Timeout_Handler>(h), f); } void fl_static_repeat_timeout(double s, void * h, void * f) { - Fl::repeat_timeout(s,reinterpret_cast<Fl_Timeout_Handler>(h),f); + Fl::repeat_timeout(s, reinterpret_cast<Fl_Timeout_Handler>(h), f); } void fl_static_add_clipboard_notify(void * h, void * f) { - Fl::add_clipboard_notify(reinterpret_cast<Fl_Clipboard_Notify_Handler>(h),f); + Fl::add_clipboard_notify(reinterpret_cast<Fl_Clipboard_Notify_Handler>(h), f); +} + +void fl_static_remove_clipboard_notify(void * h) { + Fl::remove_clipboard_notify(reinterpret_cast<Fl_Clipboard_Notify_Handler>(h)); } void fl_static_add_fd(int d, void * h, void * f) { - Fl::add_fd(d,reinterpret_cast<Fl_FD_Handler>(h),f); + Fl::add_fd(d,reinterpret_cast<Fl_FD_Handler>(h), f); } void fl_static_add_fd2(int d, int m, void * h, void * f) { - Fl::add_fd(d,m,reinterpret_cast<Fl_FD_Handler>(h),f); + Fl::add_fd(d,m,reinterpret_cast<Fl_FD_Handler>(h), f); } void fl_static_remove_fd(int d) { @@ -77,49 +124,73 @@ void fl_static_remove_fd(int d) { } void fl_static_remove_fd2(int d, int m) { - Fl::remove_fd(d,m); + Fl::remove_fd(d, m); } void fl_static_add_idle(void * h, void * f) { - Fl::add_idle(reinterpret_cast<Fl_Idle_Handler>(h),f); + Fl::add_idle(reinterpret_cast<Fl_Idle_Handler>(h), f); } int fl_static_has_idle(void * h, void * f) { - return Fl::has_idle(reinterpret_cast<Fl_Idle_Handler>(h),f); + return Fl::has_idle(reinterpret_cast<Fl_Idle_Handler>(h), f); } void fl_static_remove_idle(void * h, void * f) { - Fl::remove_idle(reinterpret_cast<Fl_Idle_Handler>(h),f); + Fl::remove_idle(reinterpret_cast<Fl_Idle_Handler>(h), f); } +unsigned int fl_static_get_color2(unsigned int c) { + return Fl::get_color(c); +} + void fl_static_get_color(unsigned int c, unsigned char &r, unsigned char &g, unsigned char &b) { - Fl::get_color(c,r,g,b); + Fl::get_color(c, r, g, b); +} + +void fl_static_set_color2(unsigned int t, unsigned int f) { + Fl::set_color(t, f); } void fl_static_set_color(unsigned int c, unsigned char r, unsigned char g, unsigned char b) { - Fl::set_color(c,r,g,b); + Fl::set_color(c, r, g, b); } void fl_static_free_color(unsigned int c, int b) { - Fl::free_color(c,b); + Fl::free_color(c, b); +} + +unsigned int fl_static_get_box_color(unsigned int t) { + return Fl::box_color(static_cast<Fl_Color>(t)); +} + +void fl_static_set_box_color(unsigned int t) { + Fl::set_box_color(static_cast<Fl_Color>(t)); +} + +void fl_static_own_colormap() { + Fl::own_colormap(); } void fl_static_foreground(unsigned int r, unsigned int g, unsigned int b) { - Fl::foreground(r,g,b); + Fl::foreground(r, g, b); } void fl_static_background(unsigned int r, unsigned int g, unsigned int b) { - Fl::background(r,g,b); + Fl::background(r, g, b); } void fl_static_background2(unsigned int r, unsigned int g, unsigned int b) { - Fl::background2(r,g,b); + Fl::background2(r, g, b); +} + +void fl_static_get_system_colors() { + Fl::get_system_colors(); } @@ -134,7 +205,11 @@ const char * fl_static_get_font_name(int f) { } void fl_static_set_font(int t, int f) { - Fl::set_font(t,f); + Fl::set_font(static_cast<Fl_Font>(t), static_cast<Fl_Font>(f)); +} + +void fl_static_set_font2(int t, char * s) { + Fl::set_font(static_cast<Fl_Font>(t), s); } int fl_static_get_font_sizes(int f, int * &a) { @@ -168,10 +243,20 @@ int fl_static_box_dy(int b) { return Fl::box_dy(static_cast<Fl_Boxtype>(b)); } +void * fl_static_get_boxtype(int t) { + return reinterpret_cast<void*>(Fl::get_boxtype(static_cast<Fl_Boxtype>(t))); +} + void fl_static_set_boxtype(int t, int f) { Fl::set_boxtype(static_cast<Fl_Boxtype>(t),static_cast<Fl_Boxtype>(f)); } +void fl_static_set_boxtype2(int t, void * f, + unsigned char dx, unsigned char dy, unsigned char dw, unsigned char dh) +{ + Fl::set_boxtype(static_cast<Fl_Boxtype>(t), reinterpret_cast<Fl_Box_Draw_F*>(f), dx, dy, dw, dh); +} + int fl_static_draw_box_active() { return Fl::draw_box_active(); } @@ -179,8 +264,16 @@ int fl_static_draw_box_active() { +void fl_static_set_labeltype(int k, void * d, void * m) { + Fl::set_labeltype(static_cast<Fl_Labeltype>(k), + reinterpret_cast<Fl_Label_Draw_F*>(d), reinterpret_cast<Fl_Label_Measure_F*>(m)); +} + + + + void fl_static_copy(const char * t, int l, int k) { - Fl::copy(t,l,k); + Fl::copy(t, l, k); } void fl_static_paste(void * r, int s) { @@ -193,11 +286,15 @@ void fl_static_selection(void * o, char * t, int l) { Fl::selection(ref, t, l); } +int fl_static_clipboard_contains(const char * k) { + return Fl::clipboard_contains(k); +} + -void fl_static_dnd() { - Fl::dnd(); +int fl_static_dnd() { + return Fl::dnd(); } int fl_static_get_dnd_text_ops() { @@ -219,19 +316,11 @@ void fl_static_disable_im() { Fl::disable_im(); } -int fl_static_get_visible_focus() { - return Fl::visible_focus(); -} - -void fl_static_set_visible_focus(int f) { - Fl::visible_focus(f); -} - -void fl_static_default_atclose(void * w) { - Fl::default_atclose(static_cast<Fl_Window*>(w), 0); +void fl_static_default_atclose(void * w, void * u) { + Fl::default_atclose(static_cast<Fl_Window*>(w), u); } void * fl_static_get_first_window() { @@ -257,10 +346,6 @@ void * fl_static_readqueue() { return Fl::readqueue(); } -void fl_static_do_widget_deletion() { - Fl::do_widget_deletion(); -} - @@ -277,6 +362,7 @@ int fl_static_is_scheme(const char *n) { } void fl_static_reload_scheme() { + // this always returns 1 for some reason so we can ignore the return value Fl::reload_scheme(); } @@ -284,11 +370,11 @@ void fl_static_reload_scheme() { int fl_static_get_option(int o) { - return Fl::option(static_cast<Fl::Fl_Option>(o)); + return Fl::option(static_cast<Fl::Fl_Option>(o)) ? 1 : 0; } void fl_static_set_option(int o, int t) { - Fl::option(static_cast<Fl::Fl_Option>(o),t); + Fl::option(static_cast<Fl::Fl_Option>(o), t!=0); } diff --git a/body/c_fl_static.h b/body/c_fl_static.h index 692750b..f39e557 100644 --- a/body/c_fl_static.h +++ b/body/c_fl_static.h @@ -8,8 +8,23 @@ #define FL_STATIC_GUARD -extern "C" void fl_static_add_awake_handler(void * h, void * f); -extern "C" void fl_static_get_awake_handler(void * &h, void * &f); +extern "C" void fl_static_box_draw_marshal(void * f, int x, int y, int w, int h, unsigned int t); + + +extern "C" const char * const fl_help_usage_string_ptr; + + +extern "C" int fl_static_arg(int c, void * v, int &i); +extern "C" void fl_static_args(int c, void * v); +extern "C" int fl_static_args2(int c, void * v, int &i, void * h); + + +extern "C" int fl_static_add_awake_handler(void * h, void * f); +extern "C" int fl_static_get_awake_handler(void * &h, void * &f); +extern "C" int fl_static_awake2(void * h, void * f); +extern "C" void fl_static_awake(void * msg); +extern "C" void fl_static_lock(); +extern "C" void fl_static_unlock(); extern "C" void fl_static_add_check(void * h, void * f); @@ -24,6 +39,7 @@ extern "C" void fl_static_repeat_timeout(double s, void * h, void * f); extern "C" void fl_static_add_clipboard_notify(void * h, void * f); +extern "C" void fl_static_remove_clipboard_notify(void * h); extern "C" void fl_static_add_fd(int d, void * h, void * f); @@ -37,19 +53,26 @@ extern "C" int fl_static_has_idle(void * h, void * f); extern "C" void fl_static_remove_idle(void * h, void * f); +extern "C" unsigned int fl_static_get_color2(unsigned int c); extern "C" void fl_static_get_color(unsigned int c, unsigned char &r, unsigned char &g, unsigned char &b); +extern "C" void fl_static_set_color2(unsigned int t, unsigned int f); extern "C" void fl_static_set_color(unsigned int c, unsigned char r, unsigned char g, unsigned char b); extern "C" void fl_static_free_color(unsigned int c, int b); +extern "C" unsigned int fl_static_get_box_color(unsigned int t); +extern "C" void fl_static_set_box_color(unsigned int t); +extern "C" void fl_static_own_colormap(); extern "C" void fl_static_foreground(unsigned int r, unsigned int g, unsigned int b); extern "C" void fl_static_background(unsigned int r, unsigned int g, unsigned int b); extern "C" void fl_static_background2(unsigned int r, unsigned int g, unsigned int b); +extern "C" void fl_static_get_system_colors(); extern "C" const char * fl_static_get_font(int f); extern "C" const char * fl_static_get_font_name(int f); extern "C" void fl_static_set_font(int t, int f); +extern "C" void fl_static_set_font2(int t, char * s); extern "C" int fl_static_get_font_sizes(int f, int * &a); extern "C" int fl_static_font_size_array_get(int * a, int i); extern "C" int fl_static_set_fonts(); @@ -59,27 +82,32 @@ extern "C" int fl_static_box_dh(int b); extern "C" int fl_static_box_dw(int b); extern "C" int fl_static_box_dx(int b); extern "C" int fl_static_box_dy(int b); +extern "C" void * fl_static_get_boxtype(int t); extern "C" void fl_static_set_boxtype(int t, int f); +extern "C" void fl_static_set_boxtype2(int t, void * f, + unsigned char dx, unsigned char dy, unsigned char dw, unsigned char dh); extern "C" int fl_static_draw_box_active(); +extern "C" void fl_static_set_labeltype(int k, void * d, void * m); + + extern "C" void fl_static_copy(const char * t, int l, int k); extern "C" void fl_static_paste(void * r, int s); extern "C" void fl_static_selection(void * o, char * t, int l); +extern "C" int fl_static_clipboard_contains(const char * k); -extern "C" void fl_static_dnd(); +extern "C" int fl_static_dnd(); extern "C" int fl_static_get_dnd_text_ops(); extern "C" void fl_static_set_dnd_text_ops(int t); extern "C" void fl_static_enable_im(); extern "C" void fl_static_disable_im(); -extern "C" int fl_static_get_visible_focus(); -extern "C" void fl_static_set_visible_focus(int f); -extern "C" void fl_static_default_atclose(void * w); +extern "C" void fl_static_default_atclose(void * w, void * u); extern "C" void * fl_static_get_first_window(); extern "C" void fl_static_set_first_window(void * w); extern "C" void * fl_static_next_window(void * w); @@ -87,7 +115,6 @@ extern "C" void * fl_static_modal(); extern "C" void * fl_static_readqueue(); -extern "C" void fl_static_do_widget_deletion(); extern "C" const char * fl_static_get_scheme(); diff --git a/body/c_fl_sys_menu_bar.cpp b/body/c_fl_sys_menu_bar.cpp index fbd6e34..7f28574 100644 --- a/body/c_fl_sys_menu_bar.cpp +++ b/body/c_fl_sys_menu_bar.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Sys_Menu_Bar.H> #include <FL/Fl_Menu_Item.H> #include "c_fl_sys_menu_bar.h" +#include "c_fl.h" @@ -53,7 +54,11 @@ SYSMENUBAR new_fl_sys_menu_bar(int x, int y, int w, int h, char* label) { } void free_fl_sys_menu_bar(SYSMENUBAR m) { - delete static_cast<My_Sys_Menu_Bar*>(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast<My_Sys_Menu_Bar*>(m); + } } diff --git a/body/c_fl_table.cpp b/body/c_fl_table.cpp index b264c1e..377ec37 100644 --- a/body/c_fl_table.cpp +++ b/body/c_fl_table.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Table.H> #include "c_fl_table.h" +#include "c_fl.h" @@ -105,7 +106,11 @@ TABLE new_fl_table(int x, int y, int w, int h, char * label) { } void free_fl_table(TABLE t) { - delete static_cast<My_Table*>(t); + if (fl_inside_callback) { + fl_delete_widget(t); + } else { + delete static_cast<My_Table*>(t); + } } diff --git a/body/c_fl_table_row.cpp b/body/c_fl_table_row.cpp index 8094df4..0ded792 100644 --- a/body/c_fl_table_row.cpp +++ b/body/c_fl_table_row.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Table_Row.H> #include "c_fl_table_row.h" +#include "c_fl.h" @@ -68,7 +69,11 @@ ROWTABLE new_fl_table_row(int x, int y, int w, int h, char * label) { } void free_fl_table_row(ROWTABLE t) { - delete static_cast<My_Table_Row*>(t); + if (fl_inside_callback) { + fl_delete_widget(t); + } else { + delete static_cast<My_Table_Row*>(t); + } } diff --git a/body/c_fl_tabs.cpp b/body/c_fl_tabs.cpp index df7327f..4e09135 100644 --- a/body/c_fl_tabs.cpp +++ b/body/c_fl_tabs.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Tabs.H> #include "c_fl_tabs.h" +#include "c_fl.h" @@ -60,7 +61,11 @@ TABS new_fl_tabs(int x, int y, int w, int h, char* label) { } void free_fl_tabs(TABS t) { - delete static_cast<My_Tabs*>(t); + if (fl_inside_callback) { + fl_delete_widget(t); + } else { + delete static_cast<My_Tabs*>(t); + } } diff --git a/body/c_fl_text_display.cpp b/body/c_fl_text_display.cpp index a50f25d..bf9dacf 100644 --- a/body/c_fl_text_display.cpp +++ b/body/c_fl_text_display.cpp @@ -8,6 +8,7 @@ #include <FL/Fl_Text_Buffer.H> #include "c_fl_text_display.h" #include "c_fl_text_buffer.h" +#include "c_fl.h" @@ -104,7 +105,11 @@ TEXTDISPLAY new_fl_text_display(int x, int y, int w, int h, char* label) { } void free_fl_text_display(TEXTDISPLAY td) { - delete static_cast<My_Text_Display*>(td); + if (fl_inside_callback) { + fl_delete_widget(td); + } else { + delete static_cast<My_Text_Display*>(td); + } } diff --git a/body/c_fl_text_editor.cpp b/body/c_fl_text_editor.cpp index 0da5f5e..0efea0b 100644 --- a/body/c_fl_text_editor.cpp +++ b/body/c_fl_text_editor.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Text_Editor.H> #include "c_fl_text_editor.h" +#include "c_fl.h" @@ -61,7 +62,11 @@ TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label) { } void free_fl_text_editor(TEXTEDITOR te) { - delete static_cast<My_Text_Editor*>(te); + if (fl_inside_callback) { + fl_delete_widget(te); + } else { + delete static_cast<My_Text_Editor*>(te); + } } diff --git a/body/c_fl_tile.cpp b/body/c_fl_tile.cpp index 81f820a..feea448 100644 --- a/body/c_fl_tile.cpp +++ b/body/c_fl_tile.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Tile.H> #include "c_fl_tile.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ TILE new_fl_tile(int x, int y, int w, int h, char* label) { } void free_fl_tile(TILE t) { - delete static_cast<My_Tile*>(t); + if (fl_inside_callback) { + fl_delete_widget(t); + } else { + delete static_cast<My_Tile*>(t); + } } diff --git a/body/c_fl_toggle_button.cpp b/body/c_fl_toggle_button.cpp index d396f37..f87e78a 100644 --- a/body/c_fl_toggle_button.cpp +++ b/body/c_fl_toggle_button.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Toggle_Button.H> #include "c_fl_toggle_button.h" +#include "c_fl.h" @@ -50,7 +51,11 @@ TOGGLEBUTTON new_fl_toggle_button(int x, int y, int w, int h, char* label) { } void free_fl_toggle_button(TOGGLEBUTTON b) { - delete static_cast<My_Toggle_Button*>(b); + if (fl_inside_callback) { + fl_delete_widget(b); + } else { + delete static_cast<My_Toggle_Button*>(b); + } } diff --git a/body/c_fl_valuator.cpp b/body/c_fl_valuator.cpp index 3b4ebba..44ab601 100644 --- a/body/c_fl_valuator.cpp +++ b/body/c_fl_valuator.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Valuator.H> #include "c_fl_valuator.h" +#include "c_fl.h" @@ -68,7 +69,11 @@ VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label) { } void free_fl_valuator(VALUATOR v) { - delete static_cast<My_Valuator*>(v); + if (fl_inside_callback) { + fl_delete_widget(v); + } else { + delete static_cast<My_Valuator*>(v); + } } diff --git a/body/c_fl_value_input.cpp b/body/c_fl_value_input.cpp index 3d19845..29a7772 100644 --- a/body/c_fl_value_input.cpp +++ b/body/c_fl_value_input.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Value_Input.H> #include "c_fl_value_input.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ VALUEINPUT new_fl_value_input(int x, int y, int w, int h, char* label) { } void free_fl_value_input(VALUEINPUT a) { - delete static_cast<My_Value_Input*>(a); + if (fl_inside_callback) { + fl_delete_widget(a); + } else { + delete static_cast<My_Value_Input*>(a); + } } diff --git a/body/c_fl_value_output.cpp b/body/c_fl_value_output.cpp index 5e42996..2929cc7 100644 --- a/body/c_fl_value_output.cpp +++ b/body/c_fl_value_output.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Value_Output.H> #include "c_fl_value_output.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ VALUEOUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) { } void free_fl_value_output(VALUEOUTPUT a) { - delete static_cast<My_Value_Output*>(a); + if (fl_inside_callback) { + fl_delete_widget(a); + } else { + delete static_cast<My_Value_Output*>(a); + } } diff --git a/body/c_fl_value_slider.cpp b/body/c_fl_value_slider.cpp index ac7498c..4d881c9 100644 --- a/body/c_fl_value_slider.cpp +++ b/body/c_fl_value_slider.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Value_Slider.H> #include "c_fl_value_slider.h" +#include "c_fl.h" @@ -57,7 +58,11 @@ VALUESLIDER new_fl_value_slider(int x, int y, int w, int h, char* label) { } void free_fl_value_slider(VALUESLIDER s) { - delete static_cast<My_Value_Slider*>(s); + if (fl_inside_callback) { + fl_delete_widget(s); + } else { + delete static_cast<My_Value_Slider*>(s); + } } diff --git a/body/c_fl_widget.cpp b/body/c_fl_widget.cpp index d226305..4ac39ed 100644 --- a/body/c_fl_widget.cpp +++ b/body/c_fl_widget.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Widget.H> #include <FL/Fl_Image.H> #include "c_fl_widget.h" +#include "c_fl.h" @@ -65,7 +66,11 @@ WIDGET new_fl_widget(int x, int y, int w, int h, char* label) { } void free_fl_widget(WIDGET w) { - delete static_cast<My_Widget*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Widget*>(w); + } } diff --git a/body/c_fl_window.cpp b/body/c_fl_window.cpp index e41af01..d0314be 100644 --- a/body/c_fl_window.cpp +++ b/body/c_fl_window.cpp @@ -7,6 +7,7 @@ #include <FL/Fl_Window.H> #include <FL/Fl_RGB_Image.H> #include "c_fl_window.h" +#include "c_fl.h" @@ -67,7 +68,11 @@ WINDOW new_fl_window2(int w, int h, char* label) { } void free_fl_window(WINDOW n) { - delete static_cast<My_Window*>(n); + if (fl_inside_callback) { + fl_delete_widget(n); + } else { + delete static_cast<My_Window*>(n); + } } diff --git a/body/c_fl_wizard.cpp b/body/c_fl_wizard.cpp index e29995a..b494cc3 100644 --- a/body/c_fl_wizard.cpp +++ b/body/c_fl_wizard.cpp @@ -6,6 +6,7 @@ #include <FL/Fl_Wizard.H> #include "c_fl_wizard.h" +#include "c_fl.h" @@ -67,7 +68,11 @@ WIZARD new_fl_wizard(int x, int y, int w, int h, char* label) { } void free_fl_wizard(WIZARD w) { - delete static_cast<My_Wizard*>(w); + if (fl_inside_callback) { + fl_delete_widget(w); + } else { + delete static_cast<My_Wizard*>(w); + } } diff --git a/body/fltk-show_argv.adb b/body/fltk-args_marshal.adb index 52e22e2..f08e025 100644 --- a/body/fltk-show_argv.adb +++ b/body/fltk-args_marshal.adb @@ -7,10 +7,10 @@ with Ada.Command_Line, - Interfaces.C.Strings; + Interfaces.C; -package body FLTK.Show_Argv is +package body FLTK.Args_Marshal is package ACom renames Ada.Command_Line; @@ -31,20 +31,26 @@ package body FLTK.Show_Argv is end Create_Argv; + procedure Free_Argv + (Argv : in out Interfaces.C.Strings.chars_ptr_array) is + begin + for Ptr of Argv loop + ICS.Free (Ptr); + end loop; + end Free_Argv; + + procedure Dispatch (Func : in Show_With_Args_Func; CObj : in Storage.Integer_Address) is Argv : ICS.chars_ptr_array := Create_Argv; begin - Func (CObj, IntC.int (ACom.Argument_Count + 1), - Storage.To_Integer (Argv (Argv'First)'Address)); - for Ptr of Argv loop - ICS.Free (Ptr); - end loop; + Func (CObj, Argv'Length, Storage.To_Integer (Argv (Argv'First)'Address)); + Free_Argv (Argv); end Dispatch; -end FLTK.Show_Argv; +end FLTK.Args_Marshal; diff --git a/body/fltk-show_argv.ads b/body/fltk-args_marshal.ads index faa93a4..b19c182 100644 --- a/body/fltk-show_argv.ads +++ b/body/fltk-args_marshal.ads @@ -6,10 +6,19 @@ with - Interfaces.C; + Interfaces.C.Strings; + + +private package FLTK.Args_Marshal is + + + function Create_Argv + return Interfaces.C.Strings.chars_ptr_array; + + procedure Free_Argv + (Argv : in out Interfaces.C.Strings.chars_ptr_array); -private package FLTK.Show_Argv is -- Used for implementing show(argc,argv) @@ -32,6 +41,6 @@ private pragma Convention (C, Show_With_Args_Func); -end FLTK.Show_Argv; +end FLTK.Args_Marshal; diff --git a/body/fltk-asks.adb b/body/fltk-asks.adb index 034a674..8d4f900 100644 --- a/body/fltk-asks.adb +++ b/body/fltk-asks.adb @@ -234,9 +234,9 @@ package body FLTK.Asks is - --------------- - -- Cleanup -- - --------------- + ------------------- + -- Destructors -- + ------------------- procedure Finalize (This : in out Dialog_String_Final_Controller) @@ -254,6 +254,21 @@ package body FLTK.Asks is + -------------------- + -- Constructors -- + -------------------- + + -- You can get out of a hole by digging deeper, right? + procedure fl_box_extra_init + (Ada_Obj : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + C_Str : in Interfaces.C.char_array); + pragma Import (C, fl_box_extra_init, "fl_box_extra_init"); + pragma Inline (fl_box_extra_init); + + + + ----------------------- -- API Subprograms -- ----------------------- @@ -362,13 +377,17 @@ package body FLTK.Asks is (Message, Button1 : in String) return Choice_Result is - Result : Interfaces.C.int := fl_ask_choice + Result : constant Interfaces.C.int := fl_ask_choice (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.Null_Ptr, Interfaces.C.Strings.Null_Ptr); begin return Choice_Result'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_choice returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Choice; @@ -377,13 +396,17 @@ package body FLTK.Asks is return Choice_Result is Str2 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button2); - Result : Interfaces.C.int := fl_ask_choice + Result : constant Interfaces.C.int := fl_ask_choice (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.To_Chars_Ptr (Str2'Unchecked_Access), Interfaces.C.Strings.Null_Ptr); begin return Choice_Result'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_choice returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Choice; @@ -393,13 +416,17 @@ package body FLTK.Asks is is Str2 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button2); Str3 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button3); - Result : Interfaces.C.int := fl_ask_choice + Result : constant Interfaces.C.int := fl_ask_choice (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.To_Chars_Ptr (Str2'Unchecked_Access), Interfaces.C.Strings.To_Chars_Ptr (Str3'Unchecked_Access)); begin return Choice_Result'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_choice returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Choice; @@ -407,7 +434,7 @@ package body FLTK.Asks is (Message, Button1 : in String) return Extended_Choice_Result is - Result : Interfaces.C.int := fl_ask_choice_n + Result : constant Interfaces.C.int := fl_ask_choice_n (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.Null_Ptr, @@ -427,7 +454,7 @@ package body FLTK.Asks is return Extended_Choice_Result is Str2 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button2); - Result : Interfaces.C.int := fl_ask_choice_n + Result : constant Interfaces.C.int := fl_ask_choice_n (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.To_Chars_Ptr (Str2'Unchecked_Access), @@ -448,7 +475,7 @@ package body FLTK.Asks is is Str2 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button2); Str3 : aliased Interfaces.C.char_array := Interfaces.C.To_C (Button3); - Result : Interfaces.C.int := fl_ask_choice_n + Result : constant Interfaces.C.int := fl_ask_choice_n (Interfaces.C.To_C (Message), Interfaces.C.To_C (Button1), Interfaces.C.Strings.To_Chars_Ptr (Str2'Unchecked_Access), @@ -468,7 +495,7 @@ package body FLTK.Asks is Default : in String := "") return String is - Result : Interfaces.C.Strings.chars_ptr := fl_ask_input + Result : constant Interfaces.C.Strings.chars_ptr := fl_ask_input (Interfaces.C.To_C (Message), Interfaces.C.To_C (Default)); begin @@ -493,7 +520,7 @@ package body FLTK.Asks is Default : in String := "") return String is - Result : Interfaces.C.Strings.chars_ptr := fl_ask_password + Result : constant Interfaces.C.Strings.chars_ptr := fl_ask_password (Interfaces.C.To_C (Message), Interfaces.C.To_C (Default)); begin @@ -520,8 +547,8 @@ package body FLTK.Asks is C_R : Interfaces.C.double := Interfaces.C.double (R); C_G : Interfaces.C.double := Interfaces.C.double (G); C_B : Interfaces.C.double := Interfaces.C.double (B); - M : Interfaces.C.int := FLTK.Widgets.Groups.Color_Choosers.Color_Mode'Pos (Mode); - Result : Interfaces.C.int := fl_ask_color_chooser + M : constant Interfaces.C.int := FLTK.Widgets.Groups.Color_Choosers.Color_Mode'Pos (Mode); + Result : constant Interfaces.C.int := fl_ask_color_chooser (Interfaces.C.To_C (Title), C_R, C_G, C_B, M); begin if Result = 1 then @@ -550,8 +577,8 @@ package body FLTK.Asks is C_R : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (R); C_G : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (G); C_B : Interfaces.C.unsigned_char := Interfaces.C.unsigned_char (B); - M : Interfaces.C.int := FLTK.Widgets.Groups.Color_Choosers.Color_Mode'Pos (Mode); - Result : Interfaces.C.int := fl_ask_color_chooser2 + M : constant Interfaces.C.int := FLTK.Widgets.Groups.Color_Choosers.Color_Mode'Pos (Mode); + Result : constant Interfaces.C.int := fl_ask_color_chooser2 (Interfaces.C.To_C (Title), C_R, C_G, C_B, M); begin if Result = 1 then @@ -583,7 +610,7 @@ package body FLTK.Asks is Relative : in Boolean := False) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_ask_dir_chooser + Result : constant Interfaces.C.Strings.chars_ptr := fl_ask_dir_chooser (Interfaces.C.To_C (Message), Interfaces.C.To_C (Default), Boolean'Pos (Relative)); @@ -602,7 +629,7 @@ package body FLTK.Asks is Relative : in Boolean := False) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_ask_file_chooser + Result : constant Interfaces.C.Strings.chars_ptr := fl_ask_file_chooser (Interfaces.C.To_C (Message), Interfaces.C.To_C (Filter_Pattern), Interfaces.C.To_C (Default), @@ -685,6 +712,14 @@ begin Wrapper (Icon_Box).Void_Ptr := fl_ask_message_icon; Wrapper (Icon_Box).Needs_Dealloc := False; + fl_box_extra_init + (Storage.To_Integer (Icon_Box'Address), + Interfaces.C.int (Icon_Box.Get_X), + Interfaces.C.int (Icon_Box.Get_Y), + Interfaces.C.int (Icon_Box.Get_W), + Interfaces.C.int (Icon_Box.Get_H), + Interfaces.C.To_C (Icon_Box.Get_Label)); + fl_ask_file_chooser_callback (Storage.To_Integer (File_Chooser_Callback_Hook'Address)); diff --git a/body/fltk-box_draw_marshal.adb b/body/fltk-box_draw_marshal.adb new file mode 100644 index 0000000..95a33ba --- /dev/null +++ b/body/fltk-box_draw_marshal.adb @@ -0,0 +1,693 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Assertions, + FLTK.Static, + Interfaces.C; + +use type + + FLTK.Static.Box_Draw_Function; + + +package body FLTK.Box_Draw_Marshal is + + + package Chk renames Ada.Assertions; + + + + + C_Ptr_Array : array (Box_Kind) of Storage.Integer_Address; + Ada_Access_Array : array (Box_Kind) of FLTK.Static.Box_Draw_Function; + + + + + procedure fl_static_box_draw_marshal + (F : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + T : in Interfaces.C.unsigned); + pragma Import (C, fl_static_box_draw_marshal, "fl_static_box_draw_marshal"); + pragma Inline (fl_static_box_draw_marshal); + + + + + generic + Kind : Box_Kind; + procedure Generic_Box_Draw + (X, Y, W, H : in Integer; + Tone : in Color) + with Inline; + + procedure Generic_Box_Draw + (X, Y, W, H : in Integer; + Tone : in Color) is + begin + fl_static_box_draw_marshal + (C_Ptr_Array (Kind), + Interfaces.C.int (X), + Interfaces.C.int (Y), + Interfaces.C.int (W), + Interfaces.C.int (H), + Interfaces.C.unsigned (Tone)); + end Generic_Box_Draw; + + procedure No_Box_Draw is new Generic_Box_Draw (No_Box); + procedure Flat_Box_Draw is new Generic_Box_Draw (Flat_Box); + procedure Up_Box_Draw is new Generic_Box_Draw (Up_Box); + procedure Down_Box_Draw is new Generic_Box_Draw (Down_Box); + procedure Up_Frame_Draw is new Generic_Box_Draw (Up_Frame); + procedure Down_Frame_Draw is new Generic_Box_Draw (Down_Frame); + procedure Thin_Up_Box_Draw is new Generic_Box_Draw (Thin_Up_Box); + procedure Thin_Down_Box_Draw is new Generic_Box_Draw (Thin_Down_Box); + procedure Thin_Up_Frame_Draw is new Generic_Box_Draw (Thin_Up_Frame); + procedure Thin_Down_Frame_Draw is new Generic_Box_Draw (Thin_Down_Frame); + procedure Engraved_Box_Draw is new Generic_Box_Draw (Engraved_Box); + procedure Embossed_Box_Draw is new Generic_Box_Draw (Embossed_Box); + procedure Engraved_Frame_Draw is new Generic_Box_Draw (Engraved_Frame); + procedure Embossed_Frame_Draw is new Generic_Box_Draw (Embossed_Frame); + procedure Border_Box_Draw is new Generic_Box_Draw (Border_Box); + procedure Shadow_Box_Draw is new Generic_Box_Draw (Shadow_Box); + procedure Border_Frame_Draw is new Generic_Box_Draw (Border_Frame); + procedure Shadow_Frame_Draw is new Generic_Box_Draw (Shadow_Frame); + procedure Rounded_Box_Draw is new Generic_Box_Draw (Rounded_Box); + procedure RShadow_Box_Draw is new Generic_Box_Draw (RShadow_Box); + procedure Rounded_Frame_Draw is new Generic_Box_Draw (Rounded_Frame); + procedure RFlat_Box_Draw is new Generic_Box_Draw (RFlat_Box); + procedure Round_Up_Box_Draw is new Generic_Box_Draw (Round_Up_Box); + procedure Round_Down_Box_Draw is new Generic_Box_Draw (Round_Down_Box); + procedure Diamond_Up_Box_Draw is new Generic_Box_Draw (Diamond_Up_Box); + procedure Diamond_Down_Box_Draw is new Generic_Box_Draw (Diamond_Down_Box); + procedure Oval_Box_Draw is new Generic_Box_Draw (Oval_Box); + procedure OShadow_Box_Draw is new Generic_Box_Draw (OShadow_Box); + procedure Oval_Frame_Draw is new Generic_Box_Draw (Oval_Frame); + procedure OFlat_Box_Draw is new Generic_Box_Draw (OFlat_Box); + procedure Plastic_Up_Box_Draw is new Generic_Box_Draw (Plastic_Up_Box); + procedure Plastic_Down_Box_Draw is new Generic_Box_Draw (Plastic_Down_Box); + procedure Plastic_Up_Frame_Draw is new Generic_Box_Draw (Plastic_Up_Frame); + procedure Plastic_Down_Frame_Draw is new Generic_Box_Draw (Plastic_Down_Frame); + procedure Plastic_Thin_Up_Box_Draw is new Generic_Box_Draw (Plastic_Thin_Up_Box); + procedure Plastic_Thin_Down_Box_Draw is new Generic_Box_Draw (Plastic_Thin_Down_Box); + procedure Plastic_Round_Up_Box_Draw is new Generic_Box_Draw (Plastic_Round_Up_Box); + procedure Plastic_Round_Down_Box_Draw is new Generic_Box_Draw (Plastic_Round_Down_Box); + procedure Gtk_Up_Box_Draw is new Generic_Box_Draw (Gtk_Up_Box); + procedure Gtk_Down_Box_Draw is new Generic_Box_Draw (Gtk_Down_Box); + procedure Gtk_Up_Frame_Draw is new Generic_Box_Draw (Gtk_Up_Frame); + procedure Gtk_Down_Frame_Draw is new Generic_Box_Draw (Gtk_Down_Frame); + procedure Gtk_Thin_Up_Box_Draw is new Generic_Box_Draw (Gtk_Thin_Up_Box); + procedure Gtk_Thin_Down_Box_Draw is new Generic_Box_Draw (Gtk_Thin_Down_Box); + procedure Gtk_Thin_Up_Frame_Draw is new Generic_Box_Draw (Gtk_Thin_Up_Frame); + procedure Gtk_Thin_Down_Frame_Draw is new Generic_Box_Draw (Gtk_Thin_Down_Frame); + procedure Gtk_Round_Up_Box_Draw is new Generic_Box_Draw (Gtk_Round_Up_Box); + procedure Gtk_Round_Down_Box_Draw is new Generic_Box_Draw (Gtk_Round_Down_Box); + procedure Gleam_Up_Box_Draw is new Generic_Box_Draw (Gleam_Up_Box); + procedure Gleam_Down_Box_Draw is new Generic_Box_Draw (Gleam_Down_Box); + procedure Gleam_Up_Frame_Draw is new Generic_Box_Draw (Gleam_Up_Frame); + procedure Gleam_Down_Frame_Draw is new Generic_Box_Draw (Gleam_Down_Frame); + procedure Gleam_Thin_Up_Box_Draw is new Generic_Box_Draw (Gleam_Thin_Up_Box); + procedure Gleam_Thin_Down_Box_Draw is new Generic_Box_Draw (Gleam_Thin_Down_Box); + procedure Gleam_Round_Up_Box_Draw is new Generic_Box_Draw (Gleam_Round_Up_Box); + procedure Gleam_Round_Down_Box_Draw is new Generic_Box_Draw (Gleam_Round_Down_Box); + procedure Free_Box_Draw is new Generic_Box_Draw (Free_Box); + + + + + generic + Kind : Box_Kind; + procedure Generic_Box_Draw_Hook + (X, Y, W, H : in Interfaces.C.int; + Tone : in Interfaces.C.unsigned) + with Inline, Convention => C; + + procedure Generic_Box_Draw_Hook + (X, Y, W, H : in Interfaces.C.int; + Tone : in Interfaces.C.unsigned) is + begin + pragma Assert (Ada_Access_Array (Kind) /= null); + Ada_Access_Array (Kind) + (Integer (X), Integer (Y), + Integer (W), Integer (H), + Color (Tone)); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Box_Draw_Function hook tried to get a null subprogram access"; + end Generic_Box_Draw_Hook; + + procedure No_Box_Hook is new Generic_Box_Draw_Hook (No_Box); + procedure Flat_Box_Hook is new Generic_Box_Draw_Hook (Flat_Box); + procedure Up_Box_Hook is new Generic_Box_Draw_Hook (Up_Box); + procedure Down_Box_Hook is new Generic_Box_Draw_Hook (Down_Box); + procedure Up_Frame_Hook is new Generic_Box_Draw_Hook (Up_Frame); + procedure Down_Frame_Hook is new Generic_Box_Draw_Hook (Down_Frame); + procedure Thin_Up_Box_Hook is new Generic_Box_Draw_Hook (Thin_Up_Box); + procedure Thin_Down_Box_Hook is new Generic_Box_Draw_Hook (Thin_Down_Box); + procedure Thin_Up_Frame_Hook is new Generic_Box_Draw_Hook (Thin_Up_Frame); + procedure Thin_Down_Frame_Hook is new Generic_Box_Draw_Hook (Thin_Down_Frame); + procedure Engraved_Box_Hook is new Generic_Box_Draw_Hook (Engraved_Box); + procedure Embossed_Box_Hook is new Generic_Box_Draw_Hook (Embossed_Box); + procedure Engraved_Frame_Hook is new Generic_Box_Draw_Hook (Engraved_Frame); + procedure Embossed_Frame_Hook is new Generic_Box_Draw_Hook (Embossed_Frame); + procedure Border_Box_Hook is new Generic_Box_Draw_Hook (Border_Box); + procedure Shadow_Box_Hook is new Generic_Box_Draw_Hook (Shadow_Box); + procedure Border_Frame_Hook is new Generic_Box_Draw_Hook (Border_Frame); + procedure Shadow_Frame_Hook is new Generic_Box_Draw_Hook (Shadow_Frame); + procedure Rounded_Box_Hook is new Generic_Box_Draw_Hook (Rounded_Box); + procedure RShadow_Box_Hook is new Generic_Box_Draw_Hook (RShadow_Box); + procedure Rounded_Frame_Hook is new Generic_Box_Draw_Hook (Rounded_Frame); + procedure RFlat_Box_Hook is new Generic_Box_Draw_Hook (RFlat_Box); + procedure Round_Up_Box_Hook is new Generic_Box_Draw_Hook (Round_Up_Box); + procedure Round_Down_Box_Hook is new Generic_Box_Draw_Hook (Round_Down_Box); + procedure Diamond_Up_Box_Hook is new Generic_Box_Draw_Hook (Diamond_Up_Box); + procedure Diamond_Down_Box_Hook is new Generic_Box_Draw_Hook (Diamond_Down_Box); + procedure Oval_Box_Hook is new Generic_Box_Draw_Hook (Oval_Box); + procedure OShadow_Box_Hook is new Generic_Box_Draw_Hook (OShadow_Box); + procedure Oval_Frame_Hook is new Generic_Box_Draw_Hook (Oval_Frame); + procedure OFlat_Box_Hook is new Generic_Box_Draw_Hook (OFlat_Box); + procedure Plastic_Up_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Up_Box); + procedure Plastic_Down_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Down_Box); + procedure Plastic_Up_Frame_Hook is new Generic_Box_Draw_Hook (Plastic_Up_Frame); + procedure Plastic_Down_Frame_Hook is new Generic_Box_Draw_Hook (Plastic_Down_Frame); + procedure Plastic_Thin_Up_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Thin_Up_Box); + procedure Plastic_Thin_Down_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Thin_Down_Box); + procedure Plastic_Round_Up_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Round_Up_Box); + procedure Plastic_Round_Down_Box_Hook is new Generic_Box_Draw_Hook (Plastic_Round_Down_Box); + procedure Gtk_Up_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Up_Box); + procedure Gtk_Down_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Down_Box); + procedure Gtk_Up_Frame_Hook is new Generic_Box_Draw_Hook (Gtk_Up_Frame); + procedure Gtk_Down_Frame_Hook is new Generic_Box_Draw_Hook (Gtk_Down_Frame); + procedure Gtk_Thin_Up_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Thin_Up_Box); + procedure Gtk_Thin_Down_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Thin_Down_Box); + procedure Gtk_Thin_Up_Frame_Hook is new Generic_Box_Draw_Hook (Gtk_Thin_Up_Frame); + procedure Gtk_Thin_Down_Frame_Hook is new Generic_Box_Draw_Hook (Gtk_Thin_Down_Frame); + procedure Gtk_Round_Up_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Round_Up_Box); + procedure Gtk_Round_Down_Box_Hook is new Generic_Box_Draw_Hook (Gtk_Round_Down_Box); + procedure Gleam_Up_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Up_Box); + procedure Gleam_Down_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Down_Box); + procedure Gleam_Up_Frame_Hook is new Generic_Box_Draw_Hook (Gleam_Up_Frame); + procedure Gleam_Down_Frame_Hook is new Generic_Box_Draw_Hook (Gleam_Down_Frame); + procedure Gleam_Thin_Up_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Thin_Up_Box); + procedure Gleam_Thin_Down_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Thin_Down_Box); + procedure Gleam_Round_Up_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Round_Up_Box); + procedure Gleam_Round_Down_Box_Hook is new Generic_Box_Draw_Hook (Gleam_Round_Down_Box); + procedure Free_Box_Hook is new Generic_Box_Draw_Hook (Free_Box); + + + + + function To_Ada + (Kind : in Box_Kind; + Ptr : in Storage.Integer_Address) + return FLTK.Static.Box_Draw_Function is + begin + if Ptr = Null_Pointer then + return null; + end if; + C_Ptr_Array (Kind) := Ptr; + case Kind is + when No_Box => return + (if Ptr = Storage.To_Integer (No_Box_Hook'Address) + then Ada_Access_Array (Kind) + else No_Box_Draw'Access); + when Flat_Box => return + (if Ptr = Storage.To_Integer (Flat_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Flat_Box_Draw'Access); + when Up_Box => return + (if Ptr = Storage.To_Integer (Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Up_Box_Draw'Access); + when Down_Box => return + (if Ptr = Storage.To_Integer (Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Down_Box_Draw'Access); + when Up_Frame => return + (if Ptr = Storage.To_Integer (Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Up_Frame_Draw'Access); + when Down_Frame => return + (if Ptr = Storage.To_Integer (Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Down_Frame_Draw'Access); + when Thin_Up_Box => return + (if Ptr = Storage.To_Integer (Thin_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Thin_Up_Box_Draw'Access); + when Thin_Down_Box => return + (if Ptr = Storage.To_Integer (Thin_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Thin_Down_Box_Draw'Access); + when Thin_Up_Frame => return + (if Ptr = Storage.To_Integer (Thin_Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Thin_Up_Frame_Draw'Access); + when Thin_Down_Frame => return + (if Ptr = Storage.To_Integer (Thin_Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Thin_Down_Frame_Draw'Access); + when Engraved_Box => return + (if Ptr = Storage.To_Integer (Engraved_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Engraved_Box_Draw'Access); + when Embossed_Box => return + (if Ptr = Storage.To_Integer (Embossed_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Embossed_Box_Draw'Access); + when Engraved_Frame => return + (if Ptr = Storage.To_Integer (Engraved_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Engraved_Frame_Draw'Access); + when Embossed_Frame => return + (if Ptr = Storage.To_Integer (Embossed_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Embossed_Frame_Draw'Access); + when Border_Box => return + (if Ptr = Storage.To_Integer (Border_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Border_Box_Draw'Access); + when Shadow_Box => return + (if Ptr = Storage.To_Integer (Shadow_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Shadow_Box_Draw'Access); + when Border_Frame => return + (if Ptr = Storage.To_Integer (Border_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Border_Frame_Draw'Access); + when Shadow_Frame => return + (if Ptr = Storage.To_Integer (Shadow_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Shadow_Frame_Draw'Access); + when Rounded_Box => return + (if Ptr = Storage.To_Integer (Rounded_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Rounded_Box_Draw'Access); + when RShadow_Box => return + (if Ptr = Storage.To_Integer (RShadow_Box_Hook'Address) + then Ada_Access_Array (Kind) + else RShadow_Box_Draw'Access); + when Rounded_Frame => return + (if Ptr = Storage.To_Integer (Rounded_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Rounded_Frame_Draw'Access); + when RFlat_Box => return + (if Ptr = Storage.To_Integer (RFlat_Box_Hook'Address) + then Ada_Access_Array (Kind) + else RFlat_Box_Draw'Access); + when Round_Up_Box => return + (if Ptr = Storage.To_Integer (Round_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Round_Up_Box_Draw'Access); + when Round_Down_Box => return + (if Ptr = Storage.To_Integer (Round_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Round_Down_Box_Draw'Access); + when Diamond_Up_Box => return + (if Ptr = Storage.To_Integer (Diamond_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Diamond_Up_Box_Draw'Access); + when Diamond_Down_Box => return + (if Ptr = Storage.To_Integer (Diamond_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Diamond_Down_Box_Draw'Access); + when Oval_Box => return + (if Ptr = Storage.To_Integer (Oval_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Oval_Box_Draw'Access); + when OShadow_Box => return + (if Ptr = Storage.To_Integer (OShadow_Box_Hook'Address) + then Ada_Access_Array (Kind) + else OShadow_Box_Draw'Access); + when Oval_Frame => return + (if Ptr = Storage.To_Integer (Oval_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Oval_Frame_Draw'Access); + when OFlat_Box => return + (if Ptr = Storage.To_Integer (OFlat_Box_Hook'Address) + then Ada_Access_Array (Kind) + else OFlat_Box_Draw'Access); + when Plastic_Up_Box => return + (if Ptr = Storage.To_Integer (Plastic_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Up_Box_Draw'Access); + when Plastic_Down_Box => return + (if Ptr = Storage.To_Integer (Plastic_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Down_Box_Draw'Access); + when Plastic_Up_Frame => return + (if Ptr = Storage.To_Integer (Plastic_Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Up_Frame_Draw'Access); + when Plastic_Down_Frame => return + (if Ptr = Storage.To_Integer (Plastic_Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Down_Frame_Draw'Access); + when Plastic_Thin_Up_Box => return + (if Ptr = Storage.To_Integer (Plastic_Thin_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Thin_Up_Box_Draw'Access); + when Plastic_Thin_Down_Box => return + (if Ptr = Storage.To_Integer (Plastic_Thin_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Thin_Down_Box_Draw'Access); + when Plastic_Round_Up_Box => return + (if Ptr = Storage.To_Integer (Plastic_Round_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Round_Up_Box_Draw'Access); + when Plastic_Round_Down_Box => return + (if Ptr = Storage.To_Integer (Plastic_Round_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Plastic_Round_Down_Box_Draw'Access); + when Gtk_Up_Box => return + (if Ptr = Storage.To_Integer (Gtk_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Up_Box_Draw'Access); + when Gtk_Down_Box => return + (if Ptr = Storage.To_Integer (Gtk_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Down_Box_Draw'Access); + when Gtk_Up_Frame => return + (if Ptr = Storage.To_Integer (Gtk_Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Up_Frame_Draw'Access); + when Gtk_Down_Frame => return + (if Ptr = Storage.To_Integer (Gtk_Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Down_Frame_Draw'Access); + when Gtk_Thin_Up_Box => return + (if Ptr = Storage.To_Integer (Gtk_Thin_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Thin_Up_Box_Draw'Access); + when Gtk_Thin_Down_Box => return + (if Ptr = Storage.To_Integer (Gtk_Thin_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Thin_Down_Box_Draw'Access); + when Gtk_Thin_Up_Frame => return + (if Ptr = Storage.To_Integer (Gtk_Thin_Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Thin_Up_Frame_Draw'Access); + when Gtk_Thin_Down_Frame => return + (if Ptr = Storage.To_Integer (Gtk_Thin_Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Thin_Down_Frame_Draw'Access); + when Gtk_Round_Up_Box => return + (if Ptr = Storage.To_Integer (Gtk_Round_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Round_Up_Box_Draw'Access); + when Gtk_Round_Down_Box => return + (if Ptr = Storage.To_Integer (Gtk_Round_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gtk_Round_Down_Box_Draw'Access); + when Gleam_Up_Box => return + (if Ptr = Storage.To_Integer (Gleam_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Up_Box_Draw'Access); + when Gleam_Down_Box => return + (if Ptr = Storage.To_Integer (Gleam_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Down_Box_Draw'Access); + when Gleam_Up_Frame => return + (if Ptr = Storage.To_Integer (Gleam_Up_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Up_Frame_Draw'Access); + when Gleam_Down_Frame => return + (if Ptr = Storage.To_Integer (Gleam_Down_Frame_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Down_Frame_Draw'Access); + when Gleam_Thin_Up_Box => return + (if Ptr = Storage.To_Integer (Gleam_Thin_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Thin_Up_Box_Draw'Access); + when Gleam_Thin_Down_Box => return + (if Ptr = Storage.To_Integer (Gleam_Thin_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Thin_Down_Box_Draw'Access); + when Gleam_Round_Up_Box => return + (if Ptr = Storage.To_Integer (Gleam_Round_Up_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Round_Up_Box_Draw'Access); + when Gleam_Round_Down_Box => return + (if Ptr = Storage.To_Integer (Gleam_Round_Down_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Gleam_Round_Down_Box_Draw'Access); + when Free_Box => return + (if Ptr = Storage.To_Integer (Free_Box_Hook'Address) + then Ada_Access_Array (Kind) + else Free_Box_Draw'Access); + end case; + end To_Ada; + + + + + function To_C + (Kind : in Box_Kind; + Func : in FLTK.Static.Box_Draw_Function) + return Storage.Integer_Address is + begin + if Func = null then + return Null_Pointer; + end if; + Ada_Access_Array (Kind) := Func; + case Kind is + when No_Box => return + (if Func = No_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (No_Box_Hook'Address)); + when Flat_Box => return + (if Func = Flat_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Flat_Box_Hook'Address)); + when Up_Box => return + (if Func = Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Up_Box_Hook'Address)); + when Down_Box => return + (if Func = Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Down_Box_Hook'Address)); + when Up_Frame => return + (if Func = Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Up_Frame_Hook'Address)); + when Down_Frame => return + (if Func = Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Down_Frame_Hook'Address)); + when Thin_Up_Box => return + (if Func = Thin_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Thin_Up_Box_Hook'Address)); + when Thin_Down_Box => return + (if Func = Thin_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Thin_Down_Box_Hook'Address)); + when Thin_Up_Frame => return + (if Func = Thin_Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Thin_Up_Frame_Hook'Address)); + when Thin_Down_Frame => return + (if Func = Thin_Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Thin_Down_Frame_Hook'Address)); + when Engraved_Box => return + (if Func = Engraved_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Engraved_Box_Hook'Address)); + when Embossed_Box => return + (if Func = Embossed_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Embossed_Box_Hook'Address)); + when Engraved_Frame => return + (if Func = Engraved_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Engraved_Frame_Hook'Address)); + when Embossed_Frame => return + (if Func = Embossed_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Embossed_Frame_Hook'Address)); + when Border_Box => return + (if Func = Border_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Border_Box_Hook'Address)); + when Shadow_Box => return + (if Func = Shadow_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Shadow_Box_Hook'Address)); + when Border_Frame => return + (if Func = Border_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Border_Frame_Hook'Address)); + when Shadow_Frame => return + (if Func = Shadow_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Shadow_Frame_Hook'Address)); + when Rounded_Box => return + (if Func = Rounded_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Rounded_Box_Hook'Address)); + when RShadow_Box => return + (if Func = RShadow_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (RShadow_Box_Hook'Address)); + when Rounded_Frame => return + (if Func = Rounded_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Rounded_Frame_Hook'Address)); + when RFlat_Box => return + (if Func = RFlat_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (RFlat_Box_Hook'Address)); + when Round_Up_Box => return + (if Func = Round_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Round_Up_Box_Hook'Address)); + when Round_Down_Box => return + (if Func = Round_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Round_Down_Box_Hook'Address)); + when Diamond_Up_Box => return + (if Func = Diamond_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Diamond_Up_Box_Hook'Address)); + when Diamond_Down_Box => return + (if Func = Diamond_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Diamond_Down_Box_Hook'Address)); + when Oval_Box => return + (if Func = Oval_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Oval_Box_Hook'Address)); + when OShadow_Box => return + (if Func = OShadow_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (OShadow_Box_Hook'Address)); + when Oval_Frame => return + (if Func = Oval_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Oval_Frame_Hook'Address)); + when OFlat_Box => return + (if Func = OFlat_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (OFlat_Box_Hook'Address)); + when Plastic_Up_Box => return + (if Func = Plastic_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Up_Box_Hook'Address)); + when Plastic_Down_Box => return + (if Func = Plastic_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Down_Box_Hook'Address)); + when Plastic_Up_Frame => return + (if Func = Plastic_Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Up_Frame_Hook'Address)); + when Plastic_Down_Frame => return + (if Func = Plastic_Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Down_Frame_Hook'Address)); + when Plastic_Thin_Up_Box => return + (if Func = Plastic_Thin_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Thin_Up_Box_Hook'Address)); + when Plastic_Thin_Down_Box => return + (if Func = Plastic_Thin_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Thin_Down_Box_Hook'Address)); + when Plastic_Round_Up_Box => return + (if Func = Plastic_Round_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Round_Up_Box_Hook'Address)); + when Plastic_Round_Down_Box => return + (if Func = Plastic_Round_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Plastic_Round_Down_Box_Hook'Address)); + when Gtk_Up_Box => return + (if Func = Gtk_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Up_Box_Hook'Address)); + when Gtk_Down_Box => return + (if Func = Gtk_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Down_Box_Hook'Address)); + when Gtk_Up_Frame => return + (if Func = Gtk_Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Up_Frame_Hook'Address)); + when Gtk_Down_Frame => return + (if Func = Gtk_Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Down_Frame_Hook'Address)); + when Gtk_Thin_Up_Box => return + (if Func = Gtk_Thin_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Thin_Up_Box_Hook'Address)); + when Gtk_Thin_Down_Box => return + (if Func = Gtk_Thin_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Thin_Down_Box_Hook'Address)); + when Gtk_Thin_Up_Frame => return + (if Func = Gtk_Thin_Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Thin_Up_Frame_Hook'Address)); + when Gtk_Thin_Down_Frame => return + (if Func = Gtk_Thin_Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Thin_Down_Frame_Hook'Address)); + when Gtk_Round_Up_Box => return + (if Func = Gtk_Round_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Round_Up_Box_Hook'Address)); + when Gtk_Round_Down_Box => return + (if Func = Gtk_Round_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gtk_Round_Down_Box_Hook'Address)); + when Gleam_Up_Box => return + (if Func = Gleam_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Up_Box_Hook'Address)); + when Gleam_Down_Box => return + (if Func = Gleam_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Down_Box_Hook'Address)); + when Gleam_Up_Frame => return + (if Func = Gleam_Up_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Up_Frame_Hook'Address)); + when Gleam_Down_Frame => return + (if Func = Gleam_Down_Frame_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Down_Frame_Hook'Address)); + when Gleam_Thin_Up_Box => return + (if Func = Gleam_Thin_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Thin_Up_Box_Hook'Address)); + when Gleam_Thin_Down_Box => return + (if Func = Gleam_Thin_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Thin_Down_Box_Hook'Address)); + when Gleam_Round_Up_Box => return + (if Func = Gleam_Round_Up_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Round_Up_Box_Hook'Address)); + when Gleam_Round_Down_Box => return + (if Func = Gleam_Round_Down_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Gleam_Round_Down_Box_Hook'Address)); + when Free_Box => return + (if Func = Free_Box_Draw'Access + then C_Ptr_Array (Kind) + else Storage.To_Integer (Free_Box_Hook'Address)); + end case; + end To_C; + + +end FLTK.Box_Draw_Marshal; + + diff --git a/body/fltk-box_draw_marshal.ads b/body/fltk-box_draw_marshal.ads new file mode 100644 index 0000000..373a3a8 --- /dev/null +++ b/body/fltk-box_draw_marshal.ads @@ -0,0 +1,28 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +limited with + + FLTK.Static; + + +private package FLTK.Box_Draw_Marshal is + + + function To_Ada + (Kind : in Box_Kind; + Ptr : in Storage.Integer_Address) + return FLTK.Static.Box_Draw_Function; + + function To_C + (Kind : in Box_Kind; + Func : in FLTK.Static.Box_Draw_Function) + return Storage.Integer_Address; + + +end FLTK.Box_Draw_Marshal; + + diff --git a/body/fltk-devices-surface-paged-postscript.adb b/body/fltk-devices-surface-paged-postscript.adb index 76553b1..07284bb 100644 --- a/body/fltk-devices-surface-paged-postscript.adb +++ b/body/fltk-devices-surface-paged-postscript.adb @@ -7,7 +7,7 @@ with Ada.Assertions, - Interfaces.C.Strings; + Interfaces.C; use type @@ -75,11 +75,12 @@ package body FLTK.Devices.Surface.Paged.Postscript is -- Driver -- - function fl_postscript_file_device_get_driver - (D : in Storage.Integer_Address) - return Storage.Integer_Address; - pragma Import (C, fl_postscript_file_device_get_driver, "fl_postscript_file_device_get_driver"); - pragma Inline (fl_postscript_file_device_get_driver); + -- function fl_postscript_file_device_get_driver + -- (D : in Storage.Integer_Address) + -- return Storage.Integer_Address; + -- pragma Import (C, fl_postscript_file_device_get_driver, + -- "fl_postscript_file_device_get_driver"); + -- pragma Inline (fl_postscript_file_device_get_driver); @@ -362,7 +363,7 @@ package body FLTK.Devices.Surface.Paged.Postscript is Format : in Page_Format := A4; Layout : in Page_Layout := Portrait) is - Code : Interfaces.C.int := fl_postscript_file_device_start_job3 + Code : constant Interfaces.C.int := fl_postscript_file_device_start_job3 (This.Void_Ptr, Output.C_File, Interfaces.C.int (Count), @@ -383,7 +384,7 @@ package body FLTK.Devices.Surface.Paged.Postscript is Format : in Page_Format := A4; Layout : in Page_Layout := Portrait) is - Code : Interfaces.C.int := fl_postscript_file_device_start_job4 + Code : constant Interfaces.C.int := fl_postscript_file_device_start_job4 (This.Void_Ptr, Interfaces.C.int (Count), To_Cint (Format), diff --git a/body/fltk-devices-surface-paged-printers.adb b/body/fltk-devices-surface-paged-printers.adb index e460eb1..8ee0660 100644 --- a/body/fltk-devices-surface-paged-printers.adb +++ b/body/fltk-devices-surface-paged-printers.adb @@ -6,7 +6,7 @@ with - Interfaces.C.Strings; + Interfaces.C; use type diff --git a/body/fltk-devices-surface-paged.adb b/body/fltk-devices-surface-paged.adb index 950d3ce..fbc8dc6 100644 --- a/body/fltk-devices-surface-paged.adb +++ b/body/fltk-devices-surface-paged.adb @@ -7,7 +7,6 @@ with Ada.Assertions, - Ada.Strings.Unbounded, Interfaces.C.Strings; use type diff --git a/body/fltk-draw.adb b/body/fltk-draw.adb index e7119ed..38ccb80 100644 --- a/body/fltk-draw.adb +++ b/body/fltk-draw.adb @@ -14,8 +14,7 @@ with use type - Interfaces.C.int, - Interfaces.C.size_t; + Interfaces.C.int; package body FLTK.Draw is @@ -642,7 +641,7 @@ package body FLTK.Draw is function Can_Do_Alpha_Blending return Boolean is - Result : Interfaces.C.int := fl_draw_can_do_alpha_blending; + Result : constant Interfaces.C.int := fl_draw_can_do_alpha_blending; begin if Result = 1 then return True; @@ -662,7 +661,7 @@ package body FLTK.Draw is return String is begin return Interfaces.C.Strings.Value - (fl_draw_shortcut_label (Interfaces.C.unsigned (To_C (Keys)))); + (fl_draw_shortcut_label (To_C (Keys))); end Shortcut_Label; @@ -716,7 +715,7 @@ package body FLTK.Draw is return Boolean is CX, CY, CW, CH : Interfaces.C.int; - Result : Interfaces.C.int := fl_draw_clip_box + Result : constant Interfaces.C.int := fl_draw_clip_box (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), @@ -1007,12 +1006,12 @@ package body FLTK.Draw is (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 3; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : in Boolean := False; Flip_Vertical : in Boolean := False) is Real_Depth : Integer := Depth; - Real_Line_Data : Integer := Line_Data; + Real_Line_Data : Integer := Line_Size; begin if Flip_Horizontal then Real_Depth := Real_Depth * (-1); @@ -1025,7 +1024,9 @@ package body FLTK.Draw is end if; end if; fl_draw_draw_image - (Storage.To_Integer (Data (Data'First)'Address), + ((if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), @@ -1038,18 +1039,17 @@ package body FLTK.Draw is Image_Func_Ptr : Image_Draw_Function; procedure Draw_Image_Hook - (User : in Storage.Integer_Address; + (Ignore : in Storage.Integer_Address; X, Y, W : in Interfaces.C.int; Buf_Ptr : in Storage.Integer_Address); - pragma Convention (C, Draw_Image_Hook); procedure Draw_Image_Hook - (User : in Storage.Integer_Address; + (Ignore : in Storage.Integer_Address; X, Y, W : in Interfaces.C.int; Buf_Ptr : in Storage.Integer_Address) is - Data_Buffer : Color_Component_Array (1 .. Integer (W)); + Data_Buffer : Color_Component_Array (1 .. Size_Type (W)); for Data_Buffer'Address use Storage.To_Address (Buf_Ptr); pragma Import (Ada, Data_Buffer); begin @@ -1077,12 +1077,12 @@ package body FLTK.Draw is (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 1; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : Boolean := False; Flip_Vertical : Boolean := False) is Real_Depth : Integer := Depth; - Real_Line_Data : Integer := Line_Data; + Real_Line_Data : Integer := Line_Size; begin if Flip_Horizontal then Real_Depth := Real_Depth * (-1); @@ -1095,7 +1095,9 @@ package body FLTK.Draw is end if; end if; fl_draw_draw_image_mono - (Storage.To_Integer (Data (Data'First)'Address), + ((if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), @@ -1108,18 +1110,17 @@ package body FLTK.Draw is Mono_Image_Func_Ptr : Image_Draw_Function; procedure Draw_Image_Mono_Hook - (User : in Storage.Integer_Address; + (Ignore : in Storage.Integer_Address; X, Y, W : in Interfaces.C.int; Buf_Ptr : in Storage.Integer_Address); - pragma Convention (C, Draw_Image_Mono_Hook); procedure Draw_Image_Mono_Hook - (User : in Storage.Integer_Address; + (Ignore : in Storage.Integer_Address; X, Y, W : in Interfaces.C.int; Buf_Ptr : in Storage.Integer_Address) is - Data_Buffer : Color_Component_Array (1 .. Integer (W)); + Data_Buffer : Color_Component_Array (1 .. Size_Type (W)); for Data_Buffer'Address use Storage.To_Address (Buf_Ptr); pragma Import (Ada, Data_Buffer); begin @@ -1148,15 +1149,15 @@ package body FLTK.Draw is Colors : in FLTK.Images.Pixmaps.Color_Definition_Array; Pixels : in FLTK.Images.Pixmaps.Pixmap_Data; X, Y : in Integer; - Hue : in Color := Grey0_Color) + Tone : in Color := Grey0_Color) is C_Data : Pixmap_Marshal.chars_ptr_array_access := Pixmap_Marshal.Marshal_Data (Values, Colors, Pixels); - Result : Interfaces.C.int := fl_draw_draw_pixmap + Result : constant Interfaces.C.int := fl_draw_draw_pixmap (Storage.To_Integer (C_Data (C_Data'First)'Address), Interfaces.C.int (X), Interfaces.C.int (Y), - Interfaces.C.unsigned (Hue)); + Interfaces.C.unsigned (Tone)); begin pragma Assert (Result /= 0); Pixmap_Marshal.Free_Recursive (C_Data); @@ -1172,18 +1173,26 @@ package body FLTK.Draw is Alpha : in Integer := 0) return Color_Component_Array is - My_Len : Integer := (if Alpha = 0 then W * H * 3 else W * H * 4); + My_Len : constant Size_Type := + (if Alpha = 0 + then Size_Type (W) * Size_Type (H) * 3 + else Size_Type (W) * Size_Type (H) * 4); Result : Color_Component_Array (1 .. My_Len); Buffer : Storage.Integer_Address; begin Buffer := fl_draw_read_image - (Storage.To_Integer (Result (Result'First)'Address), + ((if Result'Length > 0 + then Storage.To_Integer (Result (Result'First)'Address) + else Null_Pointer), Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.int (Alpha)); - pragma Assert (Buffer = Storage.To_Integer (Result (Result'First)'Address)); + pragma Assert + ((if Result'Length > 0 + then Buffer = Storage.To_Integer (Result (Result'First)'Address) + else Buffer = Null_Pointer)); return Result; exception when Chk.Assertion_Error => raise Internal_FLTK_Error with @@ -1201,7 +1210,7 @@ package body FLTK.Draw is Callback : in Symbol_Draw_Function; Scalable : in Boolean) is - Ret_Val : Interfaces.C.int := fl_draw_add_symbol + Ret_Val : constant Interfaces.C.int := fl_draw_add_symbol (Interfaces.C.To_C (Text), Storage.To_Integer (Callback.all'Address), Boolean'Pos (Scalable)); @@ -1374,7 +1383,7 @@ package body FLTK.Draw is Name : in String; Hue : in Color) is - Ret_Val : Interfaces.C.int := fl_draw_draw_symbol + Ret_Val : constant Interfaces.C.int := fl_draw_draw_symbol (Interfaces.C.To_C (Name), Interfaces.C.int (X), Interfaces.C.int (Y), @@ -1479,7 +1488,7 @@ package body FLTK.Draw is Buffer : Interfaces.C.Strings.chars_ptr; Length : Interfaces.C.int; Temp : Interfaces.C.char_array := Interfaces.C.To_C (Text); - Result : Char_Pointers.Pointer := fl_draw_expand_text + Result : constant Char_Pointers.Pointer := fl_draw_expand_text (Temp, Buffer, 0, Interfaces.C.double (Max_Width), Length, diff --git a/body/fltk-environment.adb b/body/fltk-environment.adb index f09795f..c510e26 100644 --- a/body/fltk-environment.adb +++ b/body/fltk-environment.adb @@ -125,9 +125,9 @@ package body FLTK.Environment is pragma Inline (fl_preferences_flush); function fl_preferences_getuserdatapath - (E : in Storage.Integer_Address; - P : in Interfaces.C.char_array; - L : in Interfaces.C.int) + (E : in Storage.Integer_Address; + P : out Interfaces.C.char_array; + L : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_preferences_getuserdatapath, "fl_preferences_getuserdatapath"); pragma Inline (fl_preferences_getuserdatapath); @@ -285,11 +285,11 @@ package body FLTK.Environment is pragma Inline (fl_preferences_get_str); function fl_preferences_get_str_limit - (E : in Storage.Integer_Address; - K : in Interfaces.C.char_array; - V : in Interfaces.C.char_array; - D : in Interfaces.C.char_array; - M : in Interfaces.C.int) + (E : in Storage.Integer_Address; + K : in Interfaces.C.char_array; + V : out Interfaces.C.char_array; + D : in Interfaces.C.char_array; + M : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_preferences_get_str_limit, "fl_preferences_get_str_limit"); pragma Inline (fl_preferences_get_str_limit); @@ -552,7 +552,7 @@ package body FLTK.Environment is function New_UUID return String is - Text : Interfaces.C.Strings.chars_ptr := fl_preferences_new_uuid; + Text : constant Interfaces.C.Strings.chars_ptr := fl_preferences_new_uuid; begin return Interfaces.C.Strings.Value (Text); end New_UUID; @@ -655,7 +655,7 @@ package body FLTK.Environment is Index : in Positive) return String is - Key : Interfaces.C.Strings.chars_ptr := + Key : constant Interfaces.C.Strings.chars_ptr := fl_preferences_entry (This.Void_Ptr, Interfaces.C.int (Index) - 1); begin -- no need for dealloc? @@ -702,7 +702,7 @@ package body FLTK.Environment is Index : in Positive) return String is - Name : Interfaces.C.Strings.chars_ptr := + Name : constant Interfaces.C.Strings.chars_ptr := fl_preferences_group (This.Void_Ptr, Interfaces.C.int (Index) - 1); begin -- no need for dealloc? @@ -731,7 +731,7 @@ package body FLTK.Environment is (This : in Pref_Group) return String is - Text : Interfaces.C.Strings.chars_ptr := fl_preferences_name (This.Void_Ptr); + Text : constant Interfaces.C.Strings.chars_ptr := fl_preferences_name (This.Void_Ptr); begin if Text = Interfaces.C.Strings.Null_Ptr then return ""; @@ -745,7 +745,7 @@ package body FLTK.Environment is (This : in Pref_Group) return String is - Text : Interfaces.C.Strings.chars_ptr := fl_preferences_path (This.Void_Ptr); + Text : constant Interfaces.C.Strings.chars_ptr := fl_preferences_path (This.Void_Ptr); begin if Text = Interfaces.C.Strings.Null_Ptr then return ""; @@ -783,9 +783,9 @@ package body FLTK.Environment is Default : in Integer) return Integer is - Value, X : Interfaces.C.int; + Value, Ignore : Interfaces.C.int; begin - X := fl_preferences_get_int + Ignore := fl_preferences_get_int (This.Void_Ptr, Interfaces.C.To_C (Key), Value, @@ -819,9 +819,9 @@ package body FLTK.Environment is return Float is Value : Interfaces.C.C_float; - X : Interfaces.C.int; + Ignore : Interfaces.C.int; begin - X := fl_preferences_get_float + Ignore := fl_preferences_get_float (This.Void_Ptr, Interfaces.C.To_C (Key), Value, @@ -855,9 +855,9 @@ package body FLTK.Environment is return Long_Float is Value : Interfaces.C.double; - X : Interfaces.C.int; + Ignore : Interfaces.C.int; begin - X := fl_preferences_get_double + Ignore := fl_preferences_get_double (This.Void_Ptr, Interfaces.C.To_C (Key), Value, @@ -872,7 +872,7 @@ package body FLTK.Environment is return String is Text : Interfaces.C.Strings.chars_ptr; - Check : Interfaces.C.int := fl_preferences_get_str + Check : constant Interfaces.C.int := fl_preferences_get_str (This.Void_Ptr, Interfaces.C.To_C (Key), Text, @@ -884,7 +884,7 @@ package body FLTK.Environment is if Text = Interfaces.C.Strings.Null_Ptr then return ""; end if; - return Str : String := Interfaces.C.Strings.Value (Text) do + return Str : constant String := Interfaces.C.Strings.Value (Text) do Interfaces.C.Strings.Free (Text); end return; end Get; @@ -897,7 +897,7 @@ package body FLTK.Environment is return String is Text : Interfaces.C.Strings.chars_ptr; - X : Interfaces.C.int := fl_preferences_get_str + Ignore : Interfaces.C.int := fl_preferences_get_str (This.Void_Ptr, Interfaces.C.To_C (Key), Text, @@ -906,7 +906,7 @@ package body FLTK.Environment is if Text = Interfaces.C.Strings.Null_Ptr then return Default; end if; - return Str : String := Interfaces.C.Strings.Value (Text) do + return Str : constant String := Interfaces.C.Strings.Value (Text) do Interfaces.C.Strings.Free (Text); end return; end Get; @@ -920,7 +920,7 @@ package body FLTK.Environment is return String is Text : Interfaces.C.char_array := (1 .. Interfaces.C.size_t (Max_Length + 1) => ' '); - Check : Interfaces.C.int := fl_preferences_get_str_limit + Check : constant Interfaces.C.int := fl_preferences_get_str_limit (This.Void_Ptr, Interfaces.C.To_C (Key), Text, @@ -942,7 +942,7 @@ package body FLTK.Environment is is Thing : Storage.Integer_Address; Dummy : Interfaces.C.int := 42; - Check : Interfaces.C.int := fl_preferences_get_void + Check : constant Interfaces.C.int := fl_preferences_get_void (This.Void_Ptr, Interfaces.C.To_C (Key), Thing, @@ -954,12 +954,12 @@ package body FLTK.Environment is raise Preference_Error; end if; declare - Length : Natural := This.Value_Size (Key) * Natural (c_pointer_size); + Length : constant Natural := This.Value_Size (Key) * Natural (c_pointer_size); Actual : Binary_Data (1 .. Length); for Actual'Address use Storage.To_Address (Thing); pragma Import (Ada, Actual); begin - return Result : Binary_Data := Actual do + return Result : constant Binary_Data := Actual do free_fl_preferences_void_data (Thing); end return; end; @@ -979,12 +979,12 @@ package body FLTK.Environment is Thing, Storage.To_Integer (Default'Address), Default'Length / Interfaces.C.int (c_pointer_size)); - Length : Natural := This.Value_Size (Key) * Natural (c_pointer_size); + Length : constant Natural := This.Value_Size (Key) * Natural (c_pointer_size); Actual : Binary_Data (1 .. Length); for Actual'Address use Storage.To_Address (Thing); pragma Import (Ada, Actual); begin - return Result : Binary_Data := Actual do + return Result : constant Binary_Data := Actual do free_fl_preferences_void_data (Thing); end return; end Get; @@ -1005,7 +1005,7 @@ package body FLTK.Environment is Storage.To_Integer (Default'Address), Default'Length / Interfaces.C.int (c_pointer_size), Interfaces.C.int (Max_Length) / Interfaces.C.int (c_pointer_size)); - Length : Natural := This.Value_Size (Key) * Natural (c_pointer_size); + Length : constant Natural := This.Value_Size (Key) * Natural (c_pointer_size); begin return Actual (1 .. Length); end Get; diff --git a/body/fltk-event.adb b/body/fltk-events.adb index 8c3db1f..7a5932f 100644 --- a/body/fltk-event.adb +++ b/body/fltk-events.adb @@ -7,6 +7,7 @@ with Ada.Assertions, + Ada.Containers.Vectors, Interfaces.C.Strings; use type @@ -15,7 +16,7 @@ use type Interfaces.C.Strings.chars_ptr; -package body FLTK.Event is +package body FLTK.Events is package Chk renames Ada.Assertions; @@ -24,6 +25,43 @@ package body FLTK.Event is ------------------------ + -- Constants From C -- + ------------------------ + + fl_enum_button1 : constant Interfaces.C.int; + pragma Import (C, fl_enum_button1, "fl_enum_button1"); + + fl_enum_button2 : constant Interfaces.C.int; + pragma Import (C, fl_enum_button2, "fl_enum_button2"); + + fl_enum_button3 : constant Interfaces.C.int; + pragma Import (C, fl_enum_button3, "fl_enum_button3"); + + fl_enum_button4 : constant Interfaces.C.int; + pragma Import (C, fl_enum_button4, "fl_enum_button4"); + + fl_enum_button5 : constant Interfaces.C.int; + pragma Import (C, fl_enum_button5, "fl_enum_button5"); + + fl_enum_left_mouse : constant Interfaces.C.int; + pragma Import (C, fl_enum_left_mouse, "fl_enum_left_mouse"); + + fl_enum_middle_mouse : constant Interfaces.C.int; + pragma Import (C, fl_enum_middle_mouse, "fl_enum_middle_mouse"); + + fl_enum_right_mouse : constant Interfaces.C.int; + pragma Import (C, fl_enum_right_mouse, "fl_enum_right_mouse"); + + fl_enum_back_mouse : constant Interfaces.C.int; + pragma Import (C, fl_enum_back_mouse, "fl_enum_back_mouse"); + + fl_enum_forward_mouse : constant Interfaces.C.int; + pragma Import (C, fl_enum_forward_mouse, "fl_enum_forward_mouse"); + + + + + ------------------------ -- Functions From C -- ------------------------ @@ -34,12 +72,38 @@ package body FLTK.Event is pragma Import (C, fl_event_add_handler, "fl_event_add_handler"); pragma Inline (fl_event_add_handler); - procedure fl_event_set_event_dispatch + procedure fl_event_remove_handler + (F : in Storage.Integer_Address); + pragma Import (C, fl_event_remove_handler, "fl_event_remove_handler"); + pragma Inline (fl_event_remove_handler); + + procedure fl_event_add_system_handler + (H, F : in Storage.Integer_Address); + pragma Import (C, fl_event_add_system_handler, "fl_event_add_system_handler"); + pragma Inline (fl_event_add_system_handler); + + procedure fl_event_remove_system_handler + (H : in Storage.Integer_Address); + pragma Import (C, fl_event_remove_system_handler, "fl_event_remove_system_handler"); + pragma Inline (fl_event_remove_system_handler); + + + + + -- Dispatch -- + + procedure fl_event_set_dispatch (F : in Storage.Integer_Address); - pragma Import (C, fl_event_set_event_dispatch, "fl_event_set_event_dispatch"); - pragma Inline (fl_event_set_event_dispatch); + pragma Import (C, fl_event_set_dispatch, "fl_event_set_dispatch"); + pragma Inline (fl_event_set_dispatch); + + function fl_event_handle_dispatch + (E : in Interfaces.C.int; + W : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_event_handle_dispatch, "fl_event_handle_dispatch"); + pragma Inline (fl_event_handle_dispatch); - -- actually handle_ but can't have an underscore on the end of an identifier function fl_event_handle (E : in Interfaces.C.int; W : in Storage.Integer_Address) @@ -92,6 +156,31 @@ package body FLTK.Event is pragma Import (C, fl_event_set_focus, "fl_event_set_focus"); pragma Inline (fl_event_set_focus); + function fl_event_get_visible_focus + return Interfaces.C.int; + pragma Import (C, fl_event_get_visible_focus, "fl_event_get_visible_focus"); + pragma Inline (fl_event_get_visible_focus); + + procedure fl_event_set_visible_focus + (T : in Interfaces.C.int); + pragma Import (C, fl_event_set_visible_focus, "fl_event_set_visible_focus"); + pragma Inline (fl_event_set_visible_focus); + + + + + -- Clipboard -- + + function fl_event_clipboard_text + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_event_clipboard_text, "fl_event_clipboard_text"); + pragma Inline (fl_event_clipboard_text); + + function fl_event_clipboard_type + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_event_clipboard_type, "fl_event_clipboard_type"); + pragma Inline (fl_event_clipboard_type); + @@ -113,6 +202,12 @@ package body FLTK.Event is pragma Import (C, fl_event_length, "fl_event_length"); pragma Inline (fl_event_length); + function fl_event_test_shortcut + (S : in Interfaces.C.unsigned) + return Interfaces.C.int; + pragma Import (C, fl_event_test_shortcut, "fl_event_test_shortcut"); + pragma Inline (fl_event_test_shortcut); + @@ -179,10 +274,15 @@ package body FLTK.Event is pragma Import (C, fl_event_is_click, "fl_event_is_click"); pragma Inline (fl_event_is_click); - function fl_event_is_clicks + procedure fl_event_set_click + (C : in Interfaces.C.int); + pragma Import (C, fl_event_set_click, "fl_event_set_click"); + pragma Inline (fl_event_set_click); + + function fl_event_get_clicks return Interfaces.C.int; - pragma Import (C, fl_event_is_clicks, "fl_event_is_clicks"); - pragma Inline (fl_event_is_clicks); + pragma Import (C, fl_event_get_clicks, "fl_event_get_clicks"); + pragma Inline (fl_event_get_clicks); procedure fl_event_set_clicks (C : in Interfaces.C.int); @@ -209,6 +309,27 @@ package body FLTK.Event is pragma Import (C, fl_event_button3, "fl_event_button3"); pragma Inline (fl_event_button3); + function fl_event_button4 + return Interfaces.C.int; + pragma Import (C, fl_event_button4, "fl_event_button4"); + pragma Inline (fl_event_button4); + + function fl_event_button5 + return Interfaces.C.int; + pragma Import (C, fl_event_button5, "fl_event_button5"); + pragma Inline (fl_event_button5); + + function fl_event_buttons + return Interfaces.C.int; + pragma Import (C, fl_event_buttons, "fl_event_buttons"); + pragma Inline (fl_event_buttons); + + function fl_event_inside2 + (C : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_event_inside2, "fl_event_inside2"); + pragma Inline (fl_event_inside2); + function fl_event_inside (X, Y, W, H : in Interfaces.C.int) return Interfaces.C.int; @@ -269,41 +390,100 @@ package body FLTK.Event is -- Hooks -- ------------- + -- This is handled on the Ada side since otherwise marshalling the + -- types from C++ to Ada would be extremely difficult. This hook is + -- passed during package init. + package Handler_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => Event_Handler); + + Handlers : Handler_Vectors.Vector; + function Event_Handler_Hook (Num : in Interfaces.C.int) - return Interfaces.C.int - is - Ret_Val : Event_Outcome; + return Interfaces.C.int; + pragma Convention (C, Event_Handler_Hook); + + function Event_Handler_Hook + (Num : in Interfaces.C.int) + return Interfaces.C.int is begin - for Func of reverse Handlers loop - Ret_Val := Func (Event_Kind'Val (Num)); - if Ret_Val /= Not_Handled then - return Event_Outcome'Pos (Ret_Val); + for Call of reverse Handlers loop + if Call (Event_Kind'Val (Num)) /= Not_Handled then + return Event_Outcome'Pos (Handled); end if; end loop; return Event_Outcome'Pos (Not_Handled); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Event_Handler hook received unexpected event int value of " & + Interfaces.C.int'Image (Num); end Event_Handler_Hook; - -- function Dispatch_Hook - -- (Num : in Interfaces.C.int; - -- Ptr : in Storage.Integer_Address) - -- return Interfaces.C.int - -- is - -- Ret_Val : Event_Outcome; - -- Actual_Window : access FLTK.Widgets.Groups.Windows.Window'Class; - -- begin - -- if Ptr /= Null_Pointer then - -- Actual_Window := Window_Convert.To_Pointer - -- (Storage.To_Address (fl_widget_get_user_data (Ptr))); - -- end if; - -- if Current_Dispatch = null then - -- Ret_Val := Default_Dispatch (Event_Kind'Val (Num), Actual_Window); - -- else - -- Ret_Val := Current_Dispatch (Event_Kind'Val (Num), Actual_Window); - -- end if; - -- return Event_Outcome'Pos (Ret_Val); - -- end Dispatch_Hook; + -- This is handled on the Ada side because otherwise there would be + -- no way to specify which callback to remove in FLTK once one was + -- added. This is because Fl::remove_system_handler does not pay + -- attention to the void * data. This hook is passed during package init. + package System_Handler_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => System_Handler); + + System_Handlers : System_Handler_Vectors.Vector; + + function System_Handler_Hook + (E, U : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Convention (C, System_Handler_Hook); + + function System_Handler_Hook + (E, U : in Storage.Integer_Address) + return Interfaces.C.int is + begin + for Call of reverse System_Handlers loop + if Call (System_Event (Storage.To_Address (E))) = Handled then + return Event_Outcome'Pos (Handled); + end if; + end loop; + return Event_Outcome'Pos (Not_Handled); + end System_Handler_Hook; + + + function Dispatch_Hook + (Num : in Interfaces.C.int; + Ptr : in Storage.Integer_Address) + return Interfaces.C.int + is + Ada_Ptr : Storage.Integer_Address; + Actual_Window : access FLTK.Widgets.Groups.Windows.Window'Class; + begin + if Ptr /= Null_Pointer then + Ada_Ptr := fl_widget_get_user_data (Ptr); + pragma Assert (Ada_Ptr /= Null_Pointer); + Actual_Window := Window_Convert.To_Pointer (Storage.To_Address (Ada_Ptr)); + end if; + return Event_Outcome'Pos (Current_Dispatch (Event_Kind'Val (Num), Actual_Window)); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Window passed to Event_Dispatch hook did not have user_data pointer back to Ada"; + when Constraint_Error => raise Internal_FLTK_Error with + "Event_Dispatch hook received unexpected event int value of " & + Interfaces.C.int'Image (Num); + end Dispatch_Hook; + + + + + ------------------- + -- Destructors -- + ------------------- + + procedure Finalize + (This : in out FLTK_Events_Final_Controller) is + begin + fl_event_remove_handler (Storage.To_Integer (Event_Handler_Hook'Address)); + fl_event_remove_system_handler (Storage.To_Integer (System_Handler_Hook'Address)); + end Finalize; @@ -315,14 +495,14 @@ package body FLTK.Event is -- Handlers -- procedure Add_Handler - (Func : in Event_Handler) is + (Func : in not null Event_Handler) is begin Handlers.Append (Func); end Add_Handler; procedure Remove_Handler - (Func : in Event_Handler) is + (Func : in not null Event_Handler) is begin for I in reverse Handlers.First_Index .. Handlers.Last_Index loop if Handlers (I) = Func then @@ -333,38 +513,78 @@ package body FLTK.Event is end Remove_Handler; - -- function Get_Dispatch - -- return Event_Dispatch is - -- begin - -- if Current_Dispatch = null then - -- return Default_Dispatch'Access; - -- else - -- return Current_Dispatch; - -- end if; - -- end Get_Dispatch; + procedure Add_System_Handler + (Func : in not null System_Handler) is + begin + System_Handlers.Append (Func); + end Add_System_Handler; + + + procedure Remove_System_Handler + (Func : in not null System_Handler) is + begin + for I in reverse System_Handlers.First_Index .. System_Handlers.Last_Index loop + if System_Handlers (I) = Func then + System_Handlers.Delete (I); + return; + end if; + end loop; + end Remove_System_Handler; + + + + + -- Dispatch -- + + function Get_Dispatch + return Event_Dispatch is + begin + return Current_Dispatch; + end Get_Dispatch; + + + procedure Set_Dispatch + (Func : in Event_Dispatch) is + begin + Current_Dispatch := Func; + if Current_Dispatch /= null then + fl_event_set_dispatch (Storage.To_Integer (Dispatch_Hook'Address)); + else + fl_event_set_dispatch (Null_Pointer); + end if; + end Set_Dispatch; - -- procedure Set_Dispatch - -- (Func : in Event_Dispatch) is - -- begin - -- Current_Dispatch := Func; - -- end Set_Dispatch; + function Handle_Dispatch + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome + is + Result : constant Interfaces.C.int := fl_event_handle_dispatch + (Event_Kind'Pos (Event), + Wrapper (Origin).Void_Ptr); + begin + return Event_Outcome'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::handle returned unexpected int value of " & Interfaces.C.int'Image (Result); + end Handle_Dispatch; - -- function Default_Dispatch - -- (Event : in Event_Kind; - -- Win : access FLTK.Widgets.Groups.Windows.Window'Class) - -- return Event_Outcome is - -- begin - -- if Win = null then - -- return Event_Outcome'Val (fl_event_handle - -- (Event_Kind'Pos (Event), Null_Pointer)); - -- else - -- return Event_Outcome'Val (fl_event_handle - -- (Event_Kind'Pos (Event), - -- Wrapper (Win.all).Void_Ptr)); - -- end if; - -- end Default_Dispatch; + function Handle + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome + is + Result : constant Interfaces.C.int := fl_event_handle + (Event_Kind'Pos (Event), + Wrapper (Origin).Void_Ptr); + begin + return Event_Outcome'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::handle_ returned unexpected int value of " & Interfaces.C.int'Image (Result); + end Handle; @@ -477,6 +697,50 @@ package body FLTK.Event is end Set_Focus; + function Has_Visible_Focus + return Boolean is + begin + return fl_event_get_visible_focus /= 0; + end Has_Visible_Focus; + + + procedure Set_Visible_Focus + (To : in Boolean) is + begin + fl_event_set_visible_focus (Boolean'Pos (To)); + end Set_Visible_Focus; + + + + + -- Clipboard -- + + function Clipboard_Text + return String + is + Text_Ptr : constant Interfaces.C.Strings.chars_ptr := fl_event_clipboard_text; + begin + if Text_Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Text_Ptr); + end if; + end Clipboard_Text; + + + function Clipboard_Kind + return String + is + Text_Ptr : constant Interfaces.C.Strings.chars_ptr := fl_event_clipboard_type; + begin + if Text_Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Text_Ptr); + end if; + end Clipboard_Kind; + + -- Multikey -- @@ -492,7 +756,7 @@ package body FLTK.Event is function Text return String is - Str : Interfaces.C.Strings.chars_ptr := fl_event_text; + Str : constant Interfaces.C.Strings.chars_ptr := fl_event_text; begin if Str = Interfaces.C.Strings.Null_Ptr then return ""; @@ -509,21 +773,34 @@ package body FLTK.Event is end Text_Length; + function Test_Shortcut + (Shortcut : in Key_Combo) + return Boolean is + begin + return fl_event_test_shortcut (To_C (Shortcut)) /= 0; + end Test_Shortcut; + + -- Modifiers -- function Last - return Event_Kind is + return Event_Kind + is + Value : constant Interfaces.C.int := fl_event_get; begin - return Event_Kind'Val (fl_event_get); + return Event_Kind'Val (Value); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::event returned unexpected int value of " & Interfaces.C.int'Image (Value); end Last; function Last_Modifier return Modifier is begin - return To_Ada (fl_event_state); + return To_Ada (Interfaces.C.unsigned (fl_event_state)); end Last_Modifier; @@ -531,7 +808,7 @@ package body FLTK.Event is (Had : in Modifier) return Boolean is begin - return fl_event_check_state (To_C (Had)) /= 0; + return fl_event_check_state (Interfaces.C.int (To_C (Had))) /= 0; end Last_Modifier; @@ -596,24 +873,73 @@ package body FLTK.Event is end Is_Click; + procedure Clear_Click is + begin + fl_event_set_click (0); + end Clear_Click; + + function Is_Multi_Click return Boolean is begin - return fl_event_is_clicks /= 0; + return fl_event_get_clicks /= 0; end Is_Multi_Click; + function Get_Clicks + return Natural + is + Raw : constant Interfaces.C.int := fl_event_get_clicks; + begin + if Is_Click then + return Positive (Raw + 1); + else + return 0; + end if; + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::event_clicks returned unexpected int value of " & + Interfaces.C.int'Image (Raw); + end Get_Clicks; + + procedure Set_Clicks (To : in Natural) is begin - fl_event_set_clicks (Interfaces.C.int (To)); + if To = 0 then + fl_event_set_clicks (0); + Clear_Click; + elsif To = 1 then + fl_event_set_clicks (0); + else + fl_event_set_clicks (Interfaces.C.int (To) - 1); + end if; end Set_Clicks; function Last_Button - return Mouse_Button is + return Mouse_Button + is + Code : constant Interfaces.C.int := fl_event_button; begin - return Mouse_Button'Val (fl_event_button); + pragma Assert (Last = Push or Last = Release); + if Code = fl_enum_left_mouse then + return Left_Button; + elsif Code = fl_enum_middle_mouse then + return Middle_Button; + elsif Code = fl_enum_right_mouse then + return Right_Button; + elsif Code = fl_enum_back_mouse then + return Back_Button; + elsif Code = fl_enum_forward_mouse then + return Forward_Button; + else + raise Internal_FLTK_Error with "Fl::event_button returned unexpected int value of " & + Interfaces.C.int'Image (Code); + end if; + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Fl::event_button was called when the most recent event was not Push or Release"; end Last_Button; @@ -638,6 +964,46 @@ package body FLTK.Event is end Mouse_Right; + function Mouse_Back + return Boolean is + begin + return fl_event_button4 /= 0; + end Mouse_Back; + + + function Mouse_Forward + return Boolean is + begin + return fl_event_button5 /= 0; + end Mouse_Forward; + + + procedure Mouse_Buttons + (Left, Middle, Right, Back, Forward : out Boolean) + is + type Cint_Mod is mod 2 ** Interfaces.C.int'Size; + Mask : constant Interfaces.C.int := fl_event_buttons; + begin + Left := (Cint_Mod (Mask) and Cint_Mod (fl_enum_button1)) /= 0; + Middle := (Cint_Mod (Mask) and Cint_Mod (fl_enum_button2)) /= 0; + Right := (Cint_Mod (Mask) and Cint_Mod (fl_enum_button3)) /= 0; + Back := (Cint_Mod (Mask) and Cint_Mod (fl_enum_button4)) /= 0; + Forward := (Cint_Mod (Mask) and Cint_Mod (fl_enum_button5)) /= 0; + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::event_buttons returned unexpected int value of " & + Interfaces.C.int'Image (Mask); + end Mouse_Buttons; + + + function Is_Inside + (Child : in FLTK.Widgets.Widget'Class) + return Boolean is + begin + return fl_event_inside2 (Wrapper (Child).Void_Ptr) /= 0; + end Is_Inside; + + function Is_Inside (X, Y, W, H : in Integer) return Boolean is @@ -657,14 +1023,14 @@ package body FLTK.Event is function Last_Key return Keypress is begin - return To_Ada (fl_event_key); + return To_Ada (Interfaces.C.unsigned (fl_event_key)); end Last_Key; function Original_Last_Key return Keypress is begin - return To_Ada (fl_event_original_key); + return To_Ada (Interfaces.C.unsigned (fl_event_original_key)); end Original_Last_Key; @@ -672,7 +1038,7 @@ package body FLTK.Event is (Key : in Keypress) return Boolean is begin - return fl_event_key_during (To_C (Key)) /= 0; + return fl_event_key_during (Interfaces.C.int (To_C (Key))) /= 0; end Pressed_During; @@ -680,7 +1046,7 @@ package body FLTK.Event is (Key : in Keypress) return Boolean is begin - return fl_event_get_key (To_C (Key)) /= 0; + return fl_event_get_key (Interfaces.C.int (To_C (Key))) /= 0; end Key_Now; @@ -716,9 +1082,9 @@ begin fl_event_add_handler (Storage.To_Integer (Event_Handler_Hook'Address)); - -- fl_event_set_event_dispatch (Storage.To_Integer (Dispatch_Hook'Address)); + fl_event_add_system_handler (Storage.To_Integer (System_Handler_Hook'Address), Null_Pointer); -end FLTK.Event; +end FLTK.Events; diff --git a/body/fltk-file_choosers.adb b/body/fltk-file_choosers.adb index a1ef4f7..ef33753 100644 --- a/body/fltk-file_choosers.adb +++ b/body/fltk-file_choosers.adb @@ -39,16 +39,16 @@ package body FLTK.File_Choosers is pragma Import (C, fl_widget_get_user_data, "fl_widget_get_user_data"); pragma Inline (fl_widget_get_user_data); - procedure fl_widget_set_user_data - (W, D : in Storage.Integer_Address); - pragma Import (C, fl_widget_set_user_data, "fl_widget_set_user_data"); - pragma Inline (fl_widget_set_user_data); + -- procedure fl_widget_set_user_data + -- (W, D : in Storage.Integer_Address); + -- pragma Import (C, fl_widget_set_user_data, "fl_widget_set_user_data"); + -- pragma Inline (fl_widget_set_user_data); - function fl_file_chooser_get_user_data - (F : in Storage.Integer_Address) - return Storage.Integer_Address; - pragma Import (C, fl_file_chooser_get_user_data, "fl_file_chooser_get_user_data"); - pragma Inline (fl_file_chooser_get_user_data); + -- function fl_file_chooser_get_user_data + -- (F : in Storage.Integer_Address) + -- return Storage.Integer_Address; + -- pragma Import (C, fl_file_chooser_get_user_data, "fl_file_chooser_get_user_data"); + -- pragma Inline (fl_file_chooser_get_user_data); procedure fl_file_chooser_set_user_data (F, U : in Storage.Integer_Address); @@ -514,14 +514,13 @@ package body FLTK.File_Choosers is procedure File_Chooser_Callback_Hook - (C_Addr, User_Data : in Storage.Integer_Address); - + (Ignore, User_Data : in Storage.Integer_Address); pragma Convention (C, File_Chooser_Callback_Hook); procedure File_Chooser_Callback_Hook - (C_Addr, User_Data : in Storage.Integer_Address) + (Ignore, User_Data : in Storage.Integer_Address) is - Ada_Obj : access File_Chooser'Class := + Ada_Obj : constant access File_Chooser'Class := File_Chooser_Convert.To_Pointer (Storage.To_Address (User_Data)); begin if Ada_Obj.My_Callback /= null then @@ -536,28 +535,11 @@ package body FLTK.File_Choosers is -- Destructors -- ------------------- - -- Releasing carrier pigeon - procedure fl_button_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_button_extra_final, "fl_button_extra_final"); - pragma Inline (fl_button_extra_final); - - - -- Entering wormhole - procedure fl_check_button_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_check_button_extra_final, "fl_check_button_extra_final"); - pragma Inline (fl_check_button_extra_final); - - procedure Extra_Final (This : in out File_Chooser) is use Interfaces.C.Strings; begin - fl_button_extra_final (Storage.To_Integer (This.New_Butt'Address)); - fl_check_button_extra_final (Storage.To_Integer (This.Preview_Butt'Address)); - fl_check_button_extra_final (Storage.To_Integer (This.Hidden_Butt'Address)); Free (This.My_Label); Free (This.My_OK_Label); end Extra_Final; @@ -960,18 +942,19 @@ package body FLTK.File_Choosers is (This : in out File_Chooser; Item : in out Widgets.Widget'Class) is - C_Addr : Storage.Integer_Address; + Ignore : Storage.Integer_Address := + fl_file_chooser_add_extra (This.Void_Ptr, Wrapper (Item).Void_Ptr); begin - C_Addr := fl_file_chooser_add_extra (This.Void_Ptr, Wrapper (Item).Void_Ptr); + null; end Add_Extra; procedure Remove_Extra (This : in out File_Chooser) is - C_Addr : Storage.Integer_Address; + Ignore : Storage.Integer_Address := fl_file_chooser_add_extra (This.Void_Ptr, Null_Pointer); begin - C_Addr := fl_file_chooser_add_extra (This.Void_Ptr, Null_Pointer); + null; end Remove_Extra; @@ -1080,7 +1063,7 @@ package body FLTK.File_Choosers is (This : in File_Chooser) return Boolean is - Ret : Interfaces.C.int := fl_file_chooser_get_preview (This.Void_Ptr); + Ret : constant Interfaces.C.int := fl_file_chooser_get_preview (This.Void_Ptr); begin pragma Assert (Ret in 0 .. 1); return Boolean'Val (Ret); @@ -1151,7 +1134,7 @@ package body FLTK.File_Choosers is (This : in File_Chooser) return Chooser_Kind is - Ret : Interfaces.C.int := fl_file_chooser_get_type (This.Void_Ptr); + Ret : constant Interfaces.C.int := fl_file_chooser_get_type (This.Void_Ptr); begin pragma Assert (Ret in 0 .. Chooser_Kind'Pos (Chooser_Kind'Last)); return Chooser_Kind'Val (Ret); @@ -1186,7 +1169,8 @@ package body FLTK.File_Choosers is (This : in File_Chooser) return String is - C_Ptr : Interfaces.C.Strings.chars_ptr := fl_file_chooser_get_directory (This.Void_Ptr); + C_Ptr : constant Interfaces.C.Strings.chars_ptr := + fl_file_chooser_get_directory (This.Void_Ptr); begin if C_Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1217,7 +1201,8 @@ package body FLTK.File_Choosers is (This : in File_Chooser) return String is - C_Ptr : Interfaces.C.Strings.chars_ptr := fl_file_chooser_get_filter (This.Void_Ptr); + C_Ptr : constant Interfaces.C.Strings.chars_ptr := + fl_file_chooser_get_filter (This.Void_Ptr); begin if C_Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1279,7 +1264,7 @@ package body FLTK.File_Choosers is Index : in Positive := 1) return String is - C_Ptr : Interfaces.C.Strings.chars_ptr := + C_Ptr : constant Interfaces.C.Strings.chars_ptr := fl_file_chooser_get_value (This.Void_Ptr, Interfaces.C.int (Index)); begin if C_Ptr = Interfaces.C.Strings.Null_Ptr then diff --git a/body/fltk-filenames.adb b/body/fltk-filenames.adb index 0612810..9e41b7d 100644 --- a/body/fltk-filenames.adb +++ b/body/fltk-filenames.adb @@ -63,17 +63,17 @@ package body FLTK.Filenames is pragma Inline (filename_decode_uri); function filename_absolute - (To : in Interfaces.C.char_array; - Len : in Interfaces.C.int; - From : in Interfaces.C.char_array) + (To : out Interfaces.C.char_array; + Len : in Interfaces.C.int; + From : in Interfaces.C.char_array) return Interfaces.C.int; pragma Import (C, filename_absolute, "filename_absolute"); pragma Inline (filename_absolute); function filename_expand - (To : in Interfaces.C.char_array; - Len : in Interfaces.C.int; - From : in Interfaces.C.char_array) + (To : out Interfaces.C.char_array; + Len : in Interfaces.C.int; + From : in Interfaces.C.char_array) return Interfaces.C.int; pragma Import (C, filename_expand, "filename_expand"); pragma Inline (filename_expand); @@ -111,9 +111,9 @@ package body FLTK.Filenames is pragma Inline (filename_name); function filename_relative - (To : in Interfaces.C.char_array; - Len : in Interfaces.C.int; - From : in Interfaces.C.char_array) + (To : out Interfaces.C.char_array; + Len : in Interfaces.C.int; + From : in Interfaces.C.char_array) return Interfaces.C.int; pragma Import (C, filename_relative, "filename_relative"); pragma Inline (filename_relative); @@ -127,8 +127,9 @@ package body FLTK.Filenames is pragma Inline (filename_setext); function filename_open_uri - (U, M : in Interfaces.C.char_array; - Len : in Interfaces.C.int) + (U : in Interfaces.C.char_array; + M : out Interfaces.C.char_array; + Len : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, filename_open_uri, "filename_open_uri"); pragma Inline (filename_open_uri); @@ -171,7 +172,7 @@ package body FLTK.Filenames is (A, B : in String) return Comparison is - Result : Interfaces.C.int := + Result : constant Interfaces.C.int := filename_alphasort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin pragma Assert @@ -188,7 +189,7 @@ package body FLTK.Filenames is (A, B : in String) return Comparison is - Result : Interfaces.C.int := + Result : constant Interfaces.C.int := filename_casealphasort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin pragma Assert @@ -205,7 +206,7 @@ package body FLTK.Filenames is (A, B : in String) return Comparison is - Result : Interfaces.C.int := + Result : constant Interfaces.C.int := filename_numericsort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin pragma Assert @@ -222,7 +223,7 @@ package body FLTK.Filenames is (A, B : in String) return Comparison is - Result : Interfaces.C.int := + Result : constant Interfaces.C.int := filename_casenumericsort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin pragma Assert @@ -279,7 +280,7 @@ package body FLTK.Filenames is (URI : in Path_String) return Path_String is - C_Ptr : Interfaces.C.char_array := Interfaces.C.To_C (URI); + C_Ptr : constant Interfaces.C.char_array := Interfaces.C.To_C (URI); begin filename_decode_uri (C_Ptr); return Interfaces.C.To_Ada (C_Ptr); @@ -291,7 +292,7 @@ package body FLTK.Filenames is is Message : Interfaces.C.char_array (1 .. Interfaces.C.size_t (error_bsize)) := (others => Interfaces.C.char'Val (0)); - Result : Interfaces.C.int := filename_open_uri + Result : constant Interfaces.C.int := filename_open_uri (Interfaces.C.To_C (URI), Message, error_bsize); @@ -317,7 +318,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_absolute + Ignore : constant Interfaces.C.int := filename_absolute (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -333,7 +334,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_absolute + Code : constant Interfaces.C.int := filename_absolute (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -349,7 +350,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_relative + Ignore : constant Interfaces.C.int := filename_relative (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -365,7 +366,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_relative + Code : constant Interfaces.C.int := filename_relative (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -381,7 +382,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_expand + Ignore : constant Interfaces.C.int := filename_expand (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -397,7 +398,7 @@ package body FLTK.Filenames is is Result : Interfaces.C.char_array (1 .. Interfaces.C.size_t (Max_Path_Length)) := (others => Interfaces.C.char'Val (0)); - Code : Interfaces.C.int := filename_expand + Code : constant Interfaces.C.int := filename_expand (Result, Interfaces.C.int (Max_Path_Length), Interfaces.C.To_C (Name)); @@ -415,7 +416,7 @@ package body FLTK.Filenames is (Name : in Path_String) return Path_String is - Data : Interfaces.C.char_array := Interfaces.C.To_C (Name); + Data : constant Interfaces.C.char_array := Interfaces.C.To_C (Name); begin return Interfaces.C.Strings.Value (filename_name (Data)); end Base_Name; @@ -425,8 +426,8 @@ package body FLTK.Filenames is (Name : in Path_String) return Path_String is - Data : Interfaces.C.char_array := Interfaces.C.To_C (Name); - Result : Interfaces.C.Strings.chars_ptr := filename_ext (Data); + Data : constant Interfaces.C.char_array := Interfaces.C.To_C (Name); + Result : constant Interfaces.C.Strings.chars_ptr := filename_ext (Data); begin if Result = Interfaces.C.Strings.Null_Ptr then return ""; @@ -478,7 +479,7 @@ package body FLTK.Filenames is (DA, DB : in Storage.Integer_Address) return Interfaces.C.int is - Result : Comparison := Current_Sort + Result : constant Comparison := Current_Sort (Interfaces.C.Strings.Value (filename_dname (DA, 0)), Interfaces.C.Strings.Value (filename_dname (DB, 0))); begin diff --git a/body/fltk-help_dialogs.adb b/body/fltk-help_dialogs.adb index 48cdf18..d316662 100644 --- a/body/fltk-help_dialogs.adb +++ b/body/fltk-help_dialogs.adb @@ -6,7 +6,7 @@ with - FLTK.Show_Argv, + FLTK.Args_Marshal, Interfaces.C.Strings; use type @@ -227,7 +227,7 @@ package body FLTK.Help_Dialogs is procedure Show_With_Args (This : in out Help_Dialog) is begin - FLTK.Show_Argv.Dispatch (fl_help_dialog_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_help_dialog_show2'Access, This.Void_Ptr); end Show_With_Args; @@ -282,7 +282,8 @@ package body FLTK.Help_Dialogs is (This : in Help_Dialog) return String is - Raw_Chars : Interfaces.C.Strings.chars_ptr := fl_help_dialog_get_value (This.Void_Ptr); + Raw_Chars : constant Interfaces.C.Strings.chars_ptr := + fl_help_dialog_get_value (This.Void_Ptr); use type Interfaces.C.Strings.chars_ptr; begin if Raw_Chars = Interfaces.C.Strings.Null_Ptr then diff --git a/body/fltk-images-bitmaps.adb b/body/fltk-images-bitmaps.adb index cfb63d7..5b59c13 100644 --- a/body/fltk-images-bitmaps.adb +++ b/body/fltk-images-bitmaps.adb @@ -118,7 +118,9 @@ package body FLTK.Images.Bitmaps is begin return This : Bitmap do This.Void_Ptr := new_fl_bitmap - (Storage.To_Integer (Data (Data'First)'Address), + ((if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Interfaces.C.int (Width), Interfaces.C.int (Height)); end return; @@ -135,13 +137,13 @@ package body FLTK.Images.Bitmaps is -- Contracts -- - function To_Next_Byte + function Bytes_Needed (Bits : in Natural) return Natural is begin - return Integer (Float'Ceiling (Float (Bits) / Float (Color_Component_Array'Component_Size))) - * Color_Component_Array'Component_Size; - end To_Next_Byte; + return Integer (Float'Ceiling + (Float (Bits) / Float (Color_Component_Array'Component_Size))); + end Bytes_Needed; @@ -189,15 +191,15 @@ package body FLTK.Images.Bitmaps is function Data_Size (This : in Bitmap) - return Natural is + return Size_Type is begin - return To_Next_Byte (This.Get_W) * This.Get_H; + return Size_Type (Bytes_Needed (This.Get_W)) * Size_Type (This.Get_H); end Data_Size; function Get_Datum (This : in Bitmap; - Place : in Positive) + Place : in Positive_Size) return Color_Component is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -210,7 +212,7 @@ package body FLTK.Images.Bitmaps is procedure Set_Datum (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -223,8 +225,8 @@ package body FLTK.Images.Bitmaps is function Slice (This : in Bitmap; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -237,7 +239,7 @@ package body FLTK.Images.Bitmaps is procedure Overwrite (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) is The_Data : Color_Component_Array (1 .. This.Data_Size); diff --git a/body/fltk-images-pixmaps.adb b/body/fltk-images-pixmaps.adb index 80d6c03..8487459 100644 --- a/body/fltk-images-pixmaps.adb +++ b/body/fltk-images-pixmaps.adb @@ -6,8 +6,7 @@ with - FLTK.Pixmap_Marshal, - Interfaces.C.Strings; + FLTK.Pixmap_Marshal; package body FLTK.Images.Pixmaps is diff --git a/body/fltk-images-rgb-jpeg.adb b/body/fltk-images-rgb-jpeg.adb index 8706778..61d06e6 100644 --- a/body/fltk-images-rgb-jpeg.adb +++ b/body/fltk-images-rgb-jpeg.adb @@ -81,7 +81,9 @@ package body FLTK.Images.RGB.JPEG is return This : JPEG_Image do This.Void_Ptr := new_fl_jpeg_image2 (Interfaces.C.To_C (Name), - Storage.To_Integer (Data (Data'First)'Address)); + (if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer)); Raise_Fail_Errors (This); end return; end Create; diff --git a/body/fltk-images-rgb-png.adb b/body/fltk-images-rgb-png.adb index aa25b7b..1f6e7b9 100644 --- a/body/fltk-images-rgb-png.adb +++ b/body/fltk-images-rgb-png.adb @@ -82,7 +82,9 @@ package body FLTK.Images.RGB.PNG is return This : PNG_Image do This.Void_Ptr := new_fl_png_image2 (Interfaces.C.To_C (Name), - Storage.To_Integer (Data (Data'First)'Address), + (if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Data'Length); Raise_Fail_Errors (This); end return; diff --git a/body/fltk-images-rgb.adb b/body/fltk-images-rgb.adb index f3dff61..71d2520 100644 --- a/body/fltk-images-rgb.adb +++ b/body/fltk-images-rgb.adb @@ -159,7 +159,9 @@ package body FLTK.Images.RGB is begin return This : RGB_Image do This.Void_Ptr := new_fl_rgb_image - (Storage.To_Integer (Data (Data'First)'Address), + ((if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Interfaces.C.int (Width), Interfaces.C.int (Height), Interfaces.C.int (Depth), @@ -192,14 +194,14 @@ package body FLTK.Images.RGB is -- Static Settings -- function Get_Max_Size - return Natural is + return Size_Type is begin - return Natural (fl_rgb_image_get_max_size); + return Size_Type (fl_rgb_image_get_max_size); end Get_Max_Size; procedure Set_Max_Size - (Value : in Natural) is + (Value : in Size_Type) is begin fl_rgb_image_set_max_size (Interfaces.C.size_t (Value)); end Set_Max_Size; @@ -273,21 +275,21 @@ package body FLTK.Images.RGB is function Data_Size (This : in RGB_Image) - return Natural + return Size_Type is - Per_Line : Natural := This.Get_Line_Size; + Per_Line : constant Natural := This.Get_Line_Size; begin if Per_Line = 0 then - return This.Get_W * This.Get_D * This.Get_H; + return Size_Type (This.Get_W) * Size_Type (This.Get_D) * Size_Type (This.Get_H); else - return Per_Line * This.Get_H; + return Size_Type (Per_Line) * Size_Type (This.Get_H); end if; end Data_Size; function Get_Datum (This : in RGB_Image; - Place : in Positive) + Place : in Positive_Size) return Color_Component is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -300,7 +302,7 @@ package body FLTK.Images.RGB is procedure Set_Datum (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -313,8 +315,8 @@ package body FLTK.Images.RGB is function Slice (This : in RGB_Image; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array is The_Data : Color_Component_Array (1 .. This.Data_Size); @@ -327,7 +329,7 @@ package body FLTK.Images.RGB is procedure Overwrite (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) is The_Data : Color_Component_Array (1 .. This.Data_Size); diff --git a/body/fltk-images-shared.adb b/body/fltk-images-shared.adb index e932a09..b8de511 100644 --- a/body/fltk-images-shared.adb +++ b/body/fltk-images-shared.adb @@ -287,7 +287,7 @@ package body FLTK.Images.Shared is (This : in Shared_Image) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_shared_image_name (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_shared_image_name (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; diff --git a/body/fltk-images.adb b/body/fltk-images.adb index 3ce3bee..3d5dce7 100644 --- a/body/fltk-images.adb +++ b/body/fltk-images.adb @@ -6,7 +6,7 @@ with - Interfaces.C.Strings; + Interfaces.C; use type @@ -181,7 +181,7 @@ package body FLTK.Images is procedure Raise_Fail_Errors (This : in Image'Class) is - Result : Interfaces.C.int := fl_image_fail (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_image_fail (This.Void_Ptr); begin if Result = fl_image_err_no_image and This.Is_Empty then raise No_Image_Error; diff --git a/body/fltk-label_draw_marshal.adb b/body/fltk-label_draw_marshal.adb new file mode 100644 index 0000000..c5a2031 --- /dev/null +++ b/body/fltk-label_draw_marshal.adb @@ -0,0 +1,113 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Assertions, + FLTK.Labels, + FLTK.Registry, + FLTK.Static, + Interfaces.C; + +use type + + FLTK.Static.Label_Draw_Function, + FLTK.Static.Label_Measure_Function; + + +package body FLTK.Label_Draw_Marshal is + + + package Chk renames Ada.Assertions; + + + + + Draw_Array : array (Label_Kind) of FLTK.Static.Label_Draw_Function; + Measure_Array : array (Label_Kind) of FLTK.Static.Label_Measure_Function; + + + + + procedure Label_Draw_Hook + (L : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + A : in Interfaces.Unsigned_16) + with Convention => C; + + procedure Label_Draw_Hook + (L : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + A : in Interfaces.Unsigned_16) + is + My_Label : access FLTK.Labels.Label'Class; + begin + pragma Assert (FLTK.Registry.Label_Store.Contains (L)); + My_Label := FLTK.Registry.Label_Store.Element (L); + Draw_Array (My_Label.Get_Kind) + (My_Label.all, + Integer (X), Integer (Y), + Integer (W), Integer (H), + Alignment (A)); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Label_Draw_Hook was handed Label with no back reference to Ada in registry"; + end Label_Draw_Hook; + + + procedure Label_Measure_Hook + (L : in Storage.Integer_Address; + W, H : out Interfaces.C.int) + with Convention => C; + + procedure Label_Measure_Hook + (L : in Storage.Integer_Address; + W, H : out Interfaces.C.int) + is + My_Label : access FLTK.Labels.Label'Class; + begin + pragma Assert (FLTK.Registry.Label_Store.Contains (L)); + My_Label := FLTK.Registry.Label_Store.Element (L); + Measure_Array (My_Label.Get_Kind) + (My_Label.all, + Integer (W), Integer (H)); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Label_Measure_Hook was handed Label with no back reference to Ada in registry"; + end Label_Measure_Hook; + + + + + function To_C + (Kind : in Label_Kind; + Func : in FLTK.Static.Label_Draw_Function) + return Storage.Integer_Address is + begin + if Func = null then + return Null_Pointer; + end if; + Draw_Array (Kind) := Func; + return Storage.To_Integer (Label_Draw_Hook'Address); + end To_C; + + + function To_C + (Kind : in Label_Kind; + Func : in FLTK.Static.Label_Measure_Function) + return Storage.Integer_Address is + begin + if Func = null then + return Null_Pointer; + end if; + Measure_Array (Kind) := Func; + return Storage.To_Integer (Label_Measure_Hook'Address); + end To_C; + + +end FLTK.Label_Draw_Marshal; + + diff --git a/body/fltk-label_draw_marshal.ads b/body/fltk-label_draw_marshal.ads new file mode 100644 index 0000000..77d3885 --- /dev/null +++ b/body/fltk-label_draw_marshal.ads @@ -0,0 +1,28 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +limited with + + FLTK.Static; + + +private package FLTK.Label_Draw_Marshal is + + + function To_C + (Kind : in Label_Kind; + Func : in FLTK.Static.Label_Draw_Function) + return Storage.Integer_Address; + + function To_C + (Kind : in Label_Kind; + Func : in FLTK.Static.Label_Measure_Function) + return Storage.Integer_Address; + + +end FLTK.Label_Draw_Marshal; + + diff --git a/body/fltk-labels.adb b/body/fltk-labels.adb index e03e5c5..1cbf6fc 100644 --- a/body/fltk-labels.adb +++ b/body/fltk-labels.adb @@ -6,8 +6,13 @@ with + FLTK.Registry, Interfaces.C.Strings; +use type + + Interfaces.C.Strings.chars_ptr; + package body FLTK.Labels is @@ -39,6 +44,12 @@ package body FLTK.Labels is -- Attributes -- + function fl_label_get_value + (L : in Storage.Integer_Address) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_label_get_value, "fl_label_get_value"); + pragma Inline (fl_label_get_value); + procedure fl_label_set_value (L : in Storage.Integer_Address; V : in Interfaces.C.Strings.chars_ptr); @@ -144,10 +155,11 @@ package body FLTK.Labels is (This : in out Label) is begin if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then + FLTK.Registry.Label_Store.Delete (This.Void_Ptr); free_fl_label (This.Void_Ptr); This.Void_Ptr := Null_Pointer; - Interfaces.C.Strings.Free (This.My_Text); end if; + Interfaces.C.Strings.Free (This.My_Text); end Finalize; @@ -181,6 +193,7 @@ package body FLTK.Labels is Interfaces.C.unsigned (Place)); This.Set_Active (Active); This.Set_Inactive (Inactive); + FLTK.Registry.Label_Store.Insert (This.Void_Ptr, This'Unchecked_Access); end return; end Create; @@ -197,9 +210,15 @@ package body FLTK.Labels is function Get_Value (This : in Label) - return String is + return String + is + Text : constant Interfaces.C.Strings.chars_ptr := fl_label_get_value (This.Void_Ptr); begin - return Interfaces.C.Strings.Value (This.My_Text); + if Text = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Text); + end if; end Get_Value; diff --git a/body/fltk-menu_items.adb b/body/fltk-menu_items.adb index 4ab9f7f..d75dd4a 100644 --- a/body/fltk-menu_items.adb +++ b/body/fltk-menu_items.adb @@ -297,8 +297,8 @@ package body FLTK.Menu_Items is This.Void_Ptr := new_fl_menu_item (Interfaces.C.To_C (Text), Callback_Convert.To_Address (Action), - To_C (Shortcut), - Interfaces.C.int (Flags)); + Interfaces.C.int (To_C (Shortcut)), + MFlag_To_Cint (Flags)); end return; end Create; @@ -419,7 +419,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_menu_item_get_label (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_menu_item_get_label (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -466,7 +466,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return Font_Kind is - Result : Interfaces.C.int := fl_menu_item_get_labelfont (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_item_get_labelfont (This.Void_Ptr); begin return Font_Kind'Val (Result); exception @@ -488,7 +488,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return Font_Size is - Result : Interfaces.C.int := fl_menu_item_get_labelsize (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_item_get_labelsize (This.Void_Ptr); begin return Font_Size (Result); exception @@ -510,7 +510,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return Label_Kind is - Result : Interfaces.C.int := fl_menu_item_get_labeltype (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_item_get_labeltype (This.Void_Ptr); begin return Label_Kind'Val (Result); exception @@ -536,7 +536,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return Key_Combo is begin - return To_Ada (fl_menu_item_get_shortcut (This.Void_Ptr)); + return To_Ada (Interfaces.C.unsigned (fl_menu_item_get_shortcut (This.Void_Ptr))); end Get_Shortcut; @@ -552,7 +552,7 @@ package body FLTK.Menu_Items is (This : in Menu_Item) return Menu_Flag is begin - return Menu_Flag (fl_menu_item_get_flags (This.Void_Ptr)); + return Cint_To_MFlag (fl_menu_item_get_flags (This.Void_Ptr)); end Get_Flags; @@ -560,7 +560,7 @@ package body FLTK.Menu_Items is (This : in out Menu_Item; To : in Menu_Flag) is begin - fl_menu_item_set_flags (This.Void_Ptr, Interfaces.C.int (To)); + fl_menu_item_set_flags (This.Void_Ptr, MFlag_To_Cint (To)); end Set_Flags; diff --git a/body/fltk-pixmap_marshal.adb b/body/fltk-pixmap_marshal.adb index 768cd08..966e29b 100644 --- a/body/fltk-pixmap_marshal.adb +++ b/body/fltk-pixmap_marshal.adb @@ -9,8 +9,7 @@ with Ada.Strings.Fixed, Ada.Strings.Unbounded, Ada.Unchecked_Deallocation, - FLTK.Images.Pixmaps, - Interfaces.C.Strings; + FLTK.Images.Pixmaps; package body FLTK.Pixmap_Marshal is @@ -45,7 +44,7 @@ package body FLTK.Pixmap_Marshal is Pixels : in Pix.Pixmap_Data) return chars_ptr_array_access is - C_Data : chars_ptr_array_access := new CS.chars_ptr_array + C_Data : constant chars_ptr_array_access := new CS.chars_ptr_array (1 .. C.size_t (1 + Colors'Length + Pixels'Length (1))); begin -- Header values line diff --git a/body/fltk-registry.ads b/body/fltk-registry.ads new file mode 100644 index 0000000..9911925 --- /dev/null +++ b/body/fltk-registry.ads @@ -0,0 +1,32 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Containers.Ordered_Maps, + FLTK.Labels; + + +private package FLTK.Registry is + + + -- It finally became untenable to keep only ad hoc back-references to Ada + -- when some crucial structs and objects don't have handy built-in space + -- for user data already available. + + + type Label_Access is access all FLTK.Labels.Label'Class; + + package Label_Backref_Maps is new Ada.Containers.Ordered_Maps + (Key_Type => Storage.Integer_Address, + Element_Type => Label_Access); + + Label_Store : Label_Backref_Maps.Map; + + +end FLTK.Registry; + + diff --git a/body/fltk-screen.adb b/body/fltk-screen.adb index c7c7957..6b8118e 100644 --- a/body/fltk-screen.adb +++ b/body/fltk-screen.adb @@ -17,9 +17,44 @@ package body FLTK.Screen is ------------------------ + -- Constants From C -- + ------------------------ + + fl_enum_mode_rgb : constant Interfaces.C.int; + pragma Import (C, fl_enum_mode_rgb, "fl_enum_mode_rgb"); + + fl_enum_mode_rgb8 : constant Interfaces.C.int; + pragma Import (C, fl_enum_mode_rgb8, "fl_enum_mode_rgb8"); + + fl_enum_mode_double : constant Interfaces.C.int; + pragma Import (C, fl_enum_mode_double, "fl_enum_mode_double"); + + fl_enum_mode_index : constant Interfaces.C.int; + pragma Import (C, fl_enum_mode_index, "fl_enum_mode_index"); + + + + + ------------------------ -- Functions From C -- ------------------------ + -- Environment -- + + procedure fl_screen_display + (V : in Interfaces.C.char_array); + pragma Import (C, fl_screen_display, "fl_screen_display"); + pragma Inline (fl_screen_display); + + function fl_screen_visual + (F : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_screen_visual, "fl_screen_visual"); + pragma Inline (fl_screen_visual); + + + + -- Basic Dimensions -- function fl_screen_x @@ -123,10 +158,59 @@ package body FLTK.Screen is + -- Drawing -- + + function fl_screen_get_damage + return Interfaces.C.int; + pragma Import (C, fl_screen_get_damage, "fl_screen_get_damage"); + pragma Inline (fl_screen_get_damage); + + procedure fl_screen_set_damage + (V : in Interfaces.C.int); + pragma Import (C, fl_screen_set_damage, "fl_screen_set_damage"); + pragma Inline (fl_screen_set_damage); + + + + ----------------------- -- API Subprograms -- ----------------------- + -- Environment -- + + procedure Set_Display_String + (Value : in String) is + begin + fl_screen_display (Interfaces.C.To_C (Value)); + end Set_Display_String; + + + procedure Set_Visual_Mode + (Value : in Visual_Mode) + is + Ignore : Boolean := Set_Visual_Mode (Value); + begin + null; + end Set_Visual_Mode; + + + function Set_Visual_Mode + (Value : in Visual_Mode) + return Boolean is + begin + return fl_screen_visual + ((case Value is + when RGB => fl_enum_mode_rgb, + when RGB_24bit => fl_enum_mode_rgb8, + when Double_Buffer => fl_enum_mode_double + fl_enum_mode_index, + when Double_RGB => fl_enum_mode_double + fl_enum_mode_rgb, + when Double_RGB_24bit => fl_enum_mode_double + fl_enum_mode_rgb8)) /= 0; + end Set_Visual_Mode; + + + + -- Basic Dimensions -- function Get_X return Integer is @@ -297,6 +381,24 @@ package body FLTK.Screen is end Bounding_Rect; + + + -- Drawing -- + + function Is_Damaged + return Boolean is + begin + return fl_screen_get_damage /= 0; + end Is_Damaged; + + + procedure Set_Damaged + (To : in Boolean) is + begin + fl_screen_set_damage (Boolean'Pos (To)); + end Set_Damaged; + + end FLTK.Screen; diff --git a/body/fltk-static.adb b/body/fltk-static.adb index 59a3aa2..663a7c7 100644 --- a/body/fltk-static.adb +++ b/body/fltk-static.adb @@ -10,6 +10,8 @@ with Ada.Containers.Vectors, Interfaces.C.Strings, System.Address_To_Access_Conversions, + FLTK.Box_Draw_Marshal, + FLTK.Label_Draw_Marshal, FLTK.Static_Callback_Conversions; use type @@ -27,22 +29,94 @@ package body FLTK.Static is + ----------------- + -- Operators -- + ----------------- + + type File_Mode_Bitmask is mod 2 ** Interfaces.C.int'Size; + + function FMode_To_Bits is new + Ada.Unchecked_Conversion (File_Mode, File_Mode_Bitmask); + + function Bits_To_FMode is new + Ada.Unchecked_Conversion (File_Mode_Bitmask, File_Mode); + + + function "+" + (Left, Right : in File_Mode) + return File_Mode is + begin + return Bits_To_FMode (FMode_To_Bits (Left) or FMode_To_Bits (Right)); + end "+"; + + + function "-" + (Left, Right : in File_Mode) + return File_Mode is + begin + return Bits_To_FMode (FMode_To_Bits (Left) and not FMode_To_Bits (Right)); + end "-"; + + + + ------------------------ -- Functions From C -- ------------------------ - -- Interthread Notify -- + -- Command Line Arguments -- - procedure fl_static_add_awake_handler - (H, F : in Storage.Integer_Address); + function fl_static_arg + (C : in Interfaces.C.int; + V : in Storage.Integer_Address; + I : in out Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_static_arg, "fl_static_arg"); + pragma Inline (fl_static_arg); + + procedure fl_static_args + (C : in Interfaces.C.int; + V : in Storage.Integer_Address); + pragma Import (C, fl_static_args, "fl_static_args"); + pragma Inline (fl_static_args); + + function fl_static_args2 + (C : in Interfaces.C.int; + V : in Storage.Integer_Address; + I : in out Interfaces.C.int; + H : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_static_args2, "fl_static_args2"); + pragma Inline (fl_static_args2); + + + + + -- Thread Notify -- + + function fl_static_add_awake_handler + (H, F : in Storage.Integer_Address) + return Interfaces.C.int; pragma Import (C, fl_static_add_awake_handler, "fl_static_add_awake_handler"); pragma Inline (fl_static_add_awake_handler); - procedure fl_static_get_awake_handler - (H, F : out Storage.Integer_Address); + function fl_static_get_awake_handler + (H, F : out Storage.Integer_Address) + return Interfaces.C.int; pragma Import (C, fl_static_get_awake_handler, "fl_static_get_awake_handler"); pragma Inline (fl_static_get_awake_handler); + function fl_static_awake2 + (H, F : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_static_awake2, "fl_static_awake2"); + pragma Inline (fl_static_awake2); + + procedure fl_static_awake + (M : in Storage.Integer_Address); + pragma Import (C, fl_static_awake, "fl_static_awake"); + pragma Inline (fl_static_awake); + @@ -102,6 +176,11 @@ package body FLTK.Static is pragma Import (C, fl_static_add_clipboard_notify, "fl_static_add_clipboard_notify"); pragma Inline (fl_static_add_clipboard_notify); + procedure fl_static_remove_clipboard_notify + (H : in Storage.Integer_Address); + pragma Import (C, fl_static_remove_clipboard_notify, "fl_static_remove_clipboard_notify"); + pragma Inline (fl_static_remove_clipboard_notify); + @@ -155,12 +234,23 @@ package body FLTK.Static is -- Custom Colors -- + function fl_static_get_color2 + (C : in Interfaces.C.unsigned) + return Interfaces.C.unsigned; + pragma Import (C, fl_static_get_color2, "fl_static_get_color2"); + pragma Inline (fl_static_get_color2); + procedure fl_static_get_color (C : in Interfaces.C.unsigned; R, G, B : out Interfaces.C.unsigned_char); pragma Import (C, fl_static_get_color, "fl_static_get_color"); pragma Inline (fl_static_get_color); + procedure fl_static_set_color2 + (T, F : in Interfaces.C.unsigned); + pragma Import (C, fl_static_set_color2, "fl_static_set_color2"); + pragma Inline (fl_static_set_color2); + procedure fl_static_set_color (C : in Interfaces.C.unsigned; R, G, B : in Interfaces.C.unsigned_char); @@ -173,6 +263,17 @@ package body FLTK.Static is pragma Import (C, fl_static_free_color, "fl_static_free_color"); pragma Inline (fl_static_free_color); + function fl_static_get_box_color + (T : in Interfaces.C.unsigned) + return Interfaces.C.unsigned; + pragma Import (C, fl_static_get_box_color, "fl_static_get_box_color"); + pragma Inline (fl_static_get_box_color); + + procedure fl_static_set_box_color + (T : in Interfaces.C.unsigned); + pragma Import (C, fl_static_set_box_color, "fl_static_set_box_color"); + pragma Inline (fl_static_set_box_color); + procedure fl_static_foreground (R, G, B : in Interfaces.C.unsigned_char); pragma Import (C, fl_static_foreground, "fl_static_foreground"); @@ -210,6 +311,12 @@ package body FLTK.Static is pragma Import (C, fl_static_set_font, "fl_static_set_font"); pragma Inline (fl_static_set_font); + procedure fl_static_set_font2 + (T : in Interfaces.C.int; + S : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_static_set_font2, "fl_static_set_font2"); + pragma Inline (fl_static_set_font2); + function fl_static_get_font_sizes (F : in Interfaces.C.int; A : out Storage.Integer_Address) @@ -258,11 +365,24 @@ package body FLTK.Static is pragma Import (C, fl_static_box_dy, "fl_static_box_dy"); pragma Inline (fl_static_box_dy); + function fl_static_get_boxtype + (T : in Interfaces.C.int) + return Storage.Integer_Address; + pragma Import (C, fl_static_get_boxtype, "fl_static_get_boxtype"); + pragma Inline (fl_static_get_boxtype); + procedure fl_static_set_boxtype (T, F : in Interfaces.C.int); pragma Import (C, fl_static_set_boxtype, "fl_static_set_boxtype"); pragma Inline (fl_static_set_boxtype); + procedure fl_static_set_boxtype2 + (T : in Interfaces.C.int; + F : in Storage.Integer_Address; + DX, DY, DW, DH : in Interfaces.C.unsigned_char); + pragma Import (C, fl_static_set_boxtype2, "fl_static_set_boxtype2"); + pragma Inline (fl_static_set_boxtype2); + function fl_static_draw_box_active return Interfaces.C.int; pragma Import (C, fl_static_draw_box_active, "fl_static_draw_box_active"); @@ -271,6 +391,17 @@ package body FLTK.Static is + -- Label_Kind Attributes -- + + procedure fl_static_set_labeltype + (K : in Interfaces.C.int; + D, M : in Storage.Integer_Address); + pragma Import (C, fl_static_set_labeltype, "fl_static_set_labeltype"); + pragma Inline (fl_static_set_labeltype); + + + + -- Clipboard / Selection -- procedure fl_static_copy @@ -292,11 +423,22 @@ package body FLTK.Static is pragma Import (C, fl_static_selection, "fl_static_selection"); pragma Inline (fl_static_selection); + function fl_static_clipboard_contains + (K : in Interfaces.C.char_array) + return Interfaces.C.int; + pragma Import (C, fl_static_clipboard_contains, "fl_static_clipboard_contains"); + pragma Inline (fl_static_clipboard_contains); + -- Dragon Drop -- + function fl_static_dnd + return Interfaces.C.int; + pragma Import (C, fl_static_dnd, "fl_static_dnd"); + pragma Inline (fl_static_dnd); + function fl_static_get_dnd_text_ops return Interfaces.C.int; pragma Import (C, fl_static_get_dnd_text_ops, "fl_static_get_dnd_text_ops"); @@ -310,25 +452,10 @@ package body FLTK.Static is - -- Input Focus -- - - function fl_static_get_visible_focus - return Interfaces.C.int; - pragma Import (C, fl_static_get_visible_focus, "fl_static_get_visible_focus"); - pragma Inline (fl_static_get_visible_focus); - - procedure fl_static_set_visible_focus - (T : in Interfaces.C.int); - pragma Import (C, fl_static_set_visible_focus, "fl_static_set_visible_focus"); - pragma Inline (fl_static_set_visible_focus); - - - - -- Windows -- procedure fl_static_default_atclose - (W : in Storage.Integer_Address); + (W, U : in Storage.Integer_Address); pragma Import (C, fl_static_default_atclose, "fl_static_default_atclose"); pragma Inline (fl_static_default_atclose); @@ -437,6 +564,37 @@ package body FLTK.Static is -- Callback Hooks -- ---------------------- + Current_Args_Handler : Args_Handler; + + function Args_Hook + (C : in Interfaces.C.int; + V : in Storage.Integer_Address; + I : in out Interfaces.C.int) + return Interfaces.C.int; + pragma Convention (C, Args_Hook); + + function Args_Hook + (C : in Interfaces.C.int; + V : in Storage.Integer_Address; + I : in out Interfaces.C.int) + return Interfaces.C.int + is + Result : Natural; + begin + pragma Assert (I < C and V /= Null_Pointer); + Result := Current_Args_Handler (Positive (I)); + I := I + Interfaces.C.int (Result); + return Interfaces.C.int (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Args_Handler callback was supplied unexpected int i value of " & + Interfaces.C.int'Image (I); + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Args_Handler callback was supplied irregular argc and argv values of " & + Interfaces.C.int'Image (C) & " and " & Storage.Integer_Address'Image (V); + end Args_Hook; + + procedure Awake_Hook (U : in Storage.Integer_Address); pragma Convention (C, Awake_Hook); @@ -444,7 +602,9 @@ package body FLTK.Static is procedure Awake_Hook (U : in Storage.Integer_Address) is begin - Conv.To_Awake_Access (U).all; + if U /= Null_Pointer then + Conv.To_Awake_Access (U).all; + end if; end Awake_Hook; @@ -461,7 +621,8 @@ package body FLTK.Static is -- This is handled on the Ada side because otherwise there would be -- no way to specify which callback to remove in FLTK once one was - -- added. The hook is passed during package init. + -- added. This is because Fl::remove_clipboard_notify does not pay + -- attention to the void * data. This hook is passed during package init. package Clipboard_Notify_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Clipboard_Notify_Handler); @@ -477,9 +638,15 @@ package body FLTK.Static is (S : in Interfaces.C.int; U : in Storage.Integer_Address) is begin + pragma Assert (S in + Buffer_Kind'Pos (Buffer_Kind'First) .. Buffer_Kind'Pos (Buffer_Kind'Last)); for Call of Current_Clip_Notes loop Call.all (Buffer_Kind'Val (S)); end loop; + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Clipboard_Notify_Hook was passed unexpected Buffer_Kind int value of " & + Interfaces.C.int'Image (S); end Clipboard_Notify_Hook; @@ -509,17 +676,99 @@ package body FLTK.Static is + ------------------- + -- Destructors -- + ------------------- + + procedure Finalize + (This : in out FLTK_Static_Final_Controller) is + begin + FLTK.Args_Marshal.Free_Argv (The_Argv); + for Override of Font_Overrides loop + Interfaces.C.Strings.Free (Override); + end loop; + fl_static_remove_clipboard_notify (Storage.To_Integer (Clipboard_Notify_Hook'Address)); + end Finalize; + + + + ----------------------- -- API Subprograms -- ----------------------- - -- Interthread Notify -- + -- Command Line Arguments -- + + function Parse_Arg + (Index : in Positive) + return Natural + is + Count : Interfaces.C.int := Interfaces.C.int (Index); + begin + return Natural (fl_static_arg + (The_Argv'Length, + Storage.To_Integer (The_Argv (The_Argv'First)'Address), + Count)); + end Parse_Arg; + + + procedure Parse_Args is + begin + fl_static_args (The_Argv'Length, Storage.To_Integer (The_Argv (The_Argv'First)'Address)); + end Parse_Args; + + + procedure Parse_Args + (Count : out Natural; + Func : in Args_Handler := null) + is + My_Count : Interfaces.C.int := 1; + Result : Interfaces.C.int; + begin + Current_Args_Handler := Func; + Result := fl_static_args2 + (The_Argv'Length, + Storage.To_Integer (The_Argv (The_Argv'First)'Address), + My_Count, + (if Func = null then Null_Pointer else Storage.To_Integer (Args_Hook'Address))); + Count := Integer (My_Count) - 1; + if Result = 0 then + raise Argument_Error with + "Fl::args could not recognise switch at argument number " & + Interfaces.C.int'Image (My_Count); + else + pragma Assert (Result > 0); + end if; + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::args produced unexpected i parameter of " & Interfaces.C.int'Image (My_Count); + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Fl::args returned unexpected int value of " & Interfaces.C.int'Image (Result); + end Parse_Args; + + + + + -- Thread Notify -- procedure Add_Awake_Handler - (Func : in Awake_Handler) is + (Func : in Awake_Handler) + is + Result : constant Interfaces.C.int := fl_static_add_awake_handler + (Storage.To_Integer (Awake_Hook'Address), + Conv.To_Address (Func)); begin - fl_static_add_awake_handler - (Storage.To_Integer (Awake_Hook'Address), Conv.To_Address (Func)); + pragma Assert (Result = 0); + exception + when Chk.Assertion_Error => + if Result = -1 then + raise Tasking_Error with + "Fl::add_awake_handler_ failed to register Awake_Handler callback"; + else + raise Internal_FLTK_Error with + "Fl::add_awake_handler_ returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end if; end Add_Awake_Handler; @@ -527,40 +776,77 @@ package body FLTK.Static is return Awake_Handler is Hook, Func : Storage.Integer_Address; + Result : constant Interfaces.C.int := fl_static_get_awake_handler (Hook, Func); begin - fl_static_get_awake_handler (Hook, Func); + pragma Assert (Result = 0); return Conv.To_Awake_Access (Func); + exception + when Chk.Assertion_Error => + if Result = -1 then + raise Tasking_Error with + "Fl::get_awake_handler_ invoked without prior awake setup"; + else + raise Internal_FLTK_Error with + "Fl::get_awake_handler_ returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end if; end Get_Awake_Handler; + procedure Awake + (Func : in Awake_Handler) + is + Result : constant Interfaces.C.int := fl_static_awake2 + (Storage.To_Integer (Awake_Hook'Address), + Conv.To_Address (Func)); + begin + pragma Assert (Result = 0); + exception + when Chk.Assertion_Error => + if Result = -1 then + raise Tasking_Error with "Fl::awake failed to register Awake_Handler callback"; + else + raise Internal_FLTK_Error with "Fl::awake returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end if; + end Awake; + + + procedure Awake is + begin + fl_static_awake (Null_Pointer); + end Awake; + + -- Pre-Eventloop Callbacks -- procedure Add_Check - (Func : in Timeout_Handler) is + (Func : in not null Timeout_Handler) is begin fl_static_add_check - (Storage.To_Integer (Timeout_Hook'Address), Conv.To_Address (Func)); + (Storage.To_Integer (Timeout_Hook'Address), + Conv.To_Address (Timeout_Handler'(Func))); end Add_Check; function Has_Check - (Func : in Timeout_Handler) + (Func : in not null Timeout_Handler) return Boolean is begin return fl_static_has_check (Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)) /= 0; + Conv.To_Address (Timeout_Handler'(Func))) /= 0; end Has_Check; procedure Remove_Check - (Func : in Timeout_Handler) is + (Func : in not null Timeout_Handler) is begin fl_static_remove_check (Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Timeout_Handler'(Func))); end Remove_Check; @@ -569,43 +855,43 @@ package body FLTK.Static is -- Timer Callbacks -- procedure Add_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler) is + (Seconds : in Long_Float; + Func : in not null Timeout_Handler) is begin fl_static_add_timeout (Interfaces.C.double (Seconds), Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Timeout_Handler'(Func))); end Add_Timeout; function Has_Timeout - (Func : in Timeout_Handler) + (Func : in not null Timeout_Handler) return Boolean is begin return fl_static_has_timeout (Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)) /= 0; + Conv.To_Address (Timeout_Handler'(Func))) /= 0; end Has_Timeout; procedure Remove_Timeout - (Func : in Timeout_Handler) is + (Func : in not null Timeout_Handler) is begin fl_static_remove_timeout (Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Timeout_Handler'(Func))); end Remove_Timeout; procedure Repeat_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler) is + (Seconds : in Long_Float; + Func : in not null Timeout_Handler) is begin fl_static_repeat_timeout (Interfaces.C.double (Seconds), Storage.To_Integer (Timeout_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Timeout_Handler'(Func))); end Repeat_Timeout; @@ -614,16 +900,16 @@ package body FLTK.Static is -- Clipboard Callbacks -- procedure Add_Clipboard_Notify - (Func : in Clipboard_Notify_Handler) is + (Func : in not null Clipboard_Notify_Handler) is begin Current_Clip_Notes.Append (Func); end Add_Clipboard_Notify; procedure Remove_Clipboard_Notify - (Func : in Clipboard_Notify_Handler) is + (Func : in not null Clipboard_Notify_Handler) is begin - for Index in Current_Clip_Notes.First_Index .. Current_Clip_Notes.Last_Index loop + for Index in reverse Current_Clip_Notes.First_Index .. Current_Clip_Notes.Last_Index loop if Current_Clip_Notes (Index) = Func then Current_Clip_Notes.Delete (Index); return; @@ -637,8 +923,8 @@ package body FLTK.Static is -- File Descriptor Waiting Callbacks -- procedure Add_File_Descriptor - (FD : in File_Descriptor; - Func : in File_Handler) is + (FD : in File_Descriptor; + Func : in not null File_Handler) is begin fl_static_add_fd (Interfaces.C.int (FD), @@ -648,13 +934,13 @@ package body FLTK.Static is procedure Add_File_Descriptor - (FD : in File_Descriptor; - Mode : in File_Mode; - Func : in File_Handler) is + (FD : in File_Descriptor; + Mode : in File_Mode; + Func : in not null File_Handler) is begin fl_static_add_fd2 (Interfaces.C.int (FD), - File_Mode_Codes (Mode), + FMode_To_Cint (Mode), Storage.To_Integer (FD_Hook'Address), Conv.To_Address (Func)); end Add_File_Descriptor; @@ -671,7 +957,7 @@ package body FLTK.Static is (FD : in File_Descriptor; Mode : in File_Mode) is begin - fl_static_remove_fd2 (Interfaces.C.int (FD), File_Mode_Codes (Mode)); + fl_static_remove_fd2 (Interfaces.C.int (FD), FMode_To_Cint (Mode)); end Remove_File_Descriptor; @@ -680,30 +966,30 @@ package body FLTK.Static is -- Idle Callbacks -- procedure Add_Idle - (Func : in Idle_Handler) is + (Func : in not null Idle_Handler) is begin fl_static_add_idle (Storage.To_Integer (Idle_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Idle_Handler'(Func))); end Add_Idle; function Has_Idle - (Func : in Idle_Handler) + (Func : in not null Idle_Handler) return Boolean is begin return fl_static_has_idle (Storage.To_Integer (Idle_Hook'Address), - Conv.To_Address (Func)) /= 0; + Conv.To_Address (Idle_Handler'(Func))) /= 0; end Has_Idle; procedure Remove_Idle - (Func : in Idle_Handler) is + (Func : in not null Idle_Handler) is begin fl_static_remove_idle (Storage.To_Integer (Idle_Hook'Address), - Conv.To_Address (Func)); + Conv.To_Address (Idle_Handler'(Func))); end Remove_Idle; @@ -711,6 +997,14 @@ package body FLTK.Static is -- Custom Colors -- + function Get_Color + (From : in Color) + return Color is + begin + return Color (fl_static_get_color2 (Interfaces.C.unsigned (From))); + end Get_Color; + + procedure Get_Color (From : in Color; R, G, B : out Color_Component) is @@ -724,11 +1018,20 @@ package body FLTK.Static is procedure Set_Color - (To : in Color; + (Target, Source : in Color) is + begin + fl_static_set_color2 + (Interfaces.C.unsigned (Target), + Interfaces.C.unsigned (Source)); + end Set_Color; + + + procedure Set_Color + (Target : in Color; R, G, B : in Color_Component) is begin fl_static_set_color - (Interfaces.C.unsigned (To), + (Interfaces.C.unsigned (Target), Interfaces.C.unsigned_char (R), Interfaces.C.unsigned_char (G), Interfaces.C.unsigned_char (B)); @@ -745,6 +1048,21 @@ package body FLTK.Static is end Free_Color; + function Get_Box_Color + (Tone : in Color) + return Color is + begin + return Color (fl_static_get_box_color (Interfaces.C.unsigned (Tone))); + end Get_Box_Color; + + + procedure Set_Box_Color + (Tone : in Color) is + begin + fl_static_set_box_color (Interfaces.C.unsigned (Tone)); + end Set_Box_Color; + + procedure Set_Foreground (R, G, B : in Color_Component) is begin @@ -798,9 +1116,19 @@ package body FLTK.Static is procedure Set_Font_Kind - (To, From : in Font_Kind) is + (Target, Source : in Font_Kind) is begin - fl_static_set_font (Font_Kind'Pos (To), Font_Kind'Pos (From)); + fl_static_set_font (Font_Kind'Pos (Target), Font_Kind'Pos (Source)); + end Set_Font_Kind; + + + procedure Set_Font_Kind + (Target : in Font_Kind; + Source : in String) is + begin + Interfaces.C.Strings.Free (Font_Overrides (Target)); + Font_Overrides (Target) := Interfaces.C.Strings.New_String (Source); + fl_static_set_font2 (Font_Kind'Pos (Target), Font_Overrides (Target)); end Set_Font_Kind; @@ -821,9 +1149,15 @@ package body FLTK.Static is procedure Setup_Fonts - (How_Many_Set_Up : out Natural) is + (How_Many_Set_Up : out Natural) + is + Result : constant Interfaces.C.int := fl_static_set_fonts; begin - How_Many_Set_Up := Natural (fl_static_set_fonts); + How_Many_Set_Up := Natural (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::set_fonts returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Setup_Fonts; @@ -877,22 +1211,53 @@ package body FLTK.Static is end Draw_Box_Active; - -- function Get_Box_Draw_Function - -- (Kind : in Box_Kind) - -- return Box_Draw_Function is - -- begin - -- return null; - -- end Get_Box_Draw_Function; + function Get_Box_Draw_Function + (Kind : in Box_Kind) + return Box_Draw_Function is + begin + return FLTK.Box_Draw_Marshal.To_Ada (Kind, fl_static_get_boxtype (Box_Kind'Pos (Kind))); + end Get_Box_Draw_Function; + + + procedure Set_Box_Draw_Function + (Kind : in Box_Kind; + Func : in Box_Draw_Function; + Offset_X, Offset_Y : in Byte_Integer := 0; + Offset_W, Offset_H : in Byte_Integer := 0) is + begin + fl_static_set_boxtype2 + (Box_Kind'Pos (Kind), + FLTK.Box_Draw_Marshal.To_C (Kind, Func), + Interfaces.C.unsigned_char (Offset_X), + Interfaces.C.unsigned_char (Offset_Y), + Interfaces.C.unsigned_char (Offset_W), + Interfaces.C.unsigned_char (Offset_H)); + end Set_Box_Draw_Function; + + - -- procedure Set_Box_Draw_Function - -- (Kind : in Box_Kind; - -- Func : in Box_Draw_Function; - -- Offset_X, Offset_Y : in Integer := 0; - -- Offset_W, Offset_H : in Integer := 0) is - -- begin - -- null; - -- end Set_Box_Draw_Function; + -- Label_Kind Attributes -- + + procedure Set_Label_Kind + (Target, Source : in Label_Kind) is + begin + -- As of FLTK 1.3.11 there is no definition given for this function + -- so this is null to avoid linker errors. + null; + end Set_Label_Kind; + + + procedure Set_Label_Draw_Function + (Kind : in Label_Kind; + Draw_Func : in Label_Draw_Function; + Measure_Func : in Label_Measure_Function) is + begin + fl_static_set_labeltype + (Label_Kind'Pos (Kind), + FLTK.Label_Draw_Marshal.To_C (Kind, Draw_Func), + FLTK.Label_Draw_Marshal.To_C (Kind, Measure_Func)); + end Set_Label_Draw_Function; @@ -931,10 +1296,25 @@ package body FLTK.Static is end Selection; + function Clipboard_Contains + (Kind : in String) + return Boolean is + begin + return fl_static_clipboard_contains (Interfaces.C.To_C (Kind)) /= 0; + end Clipboard_Contains; + + -- Dragon Drop -- + procedure Drag_Drop_Start is + Ignore : Interfaces.C.int := fl_static_dnd; + begin + null; + end Drag_Drop_Start; + + function Get_Drag_Drop_Text_Support return Boolean is begin @@ -951,30 +1331,18 @@ package body FLTK.Static is - -- Input Focus -- - - function Has_Visible_Focus - return Boolean is - begin - return fl_static_get_visible_focus /= 0; - end Has_Visible_Focus; - - - procedure Set_Visible_Focus - (To : in Boolean) is - begin - fl_static_set_visible_focus (Boolean'Pos (To)); - end Set_Visible_Focus; - - - - -- Windows -- procedure Default_Window_Close (Item : in out FLTK.Widgets.Widget'Class) is begin - fl_static_default_atclose (Wrapper (Item).Void_Ptr); + pragma Assert (Wrapper (Item).Void_Ptr /= Null_Pointer); + fl_static_default_atclose + (Wrapper (Item).Void_Ptr, + fl_widget_get_user_data (Wrapper (Item).Void_Ptr)); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error with + "Fl::default_atclose received uninitialised widget"; end Default_Window_Close; @@ -1069,7 +1437,7 @@ package body FLTK.Static is function Get_Scheme return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_static_get_scheme; + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_static_get_scheme; begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1082,15 +1450,22 @@ package body FLTK.Static is procedure Set_Scheme (To : in String) is begin + -- A copy of the Scheme string is stored in FLTK fl_static_set_scheme (Interfaces.C.To_C (To)); end Set_Scheme; function Is_Scheme (Scheme : in String) - return Boolean is + return Boolean + is + Result : constant Interfaces.C.int := fl_static_is_scheme (Interfaces.C.To_C (Scheme)); begin - return fl_static_is_scheme (Interfaces.C.To_C (Scheme)) /= 0; + return Boolean'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::is_scheme returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Is_Scheme; @@ -1119,9 +1494,15 @@ package body FLTK.Static is -- Scrollbars -- function Get_Default_Scrollbar_Size - return Natural is + return Natural + is + Result : constant Interfaces.C.int := fl_static_get_scrollbar_size; begin - return Natural (fl_static_get_scrollbar_size); + return Natural (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "Fl::scrollbar_size returned unexpected int value of " & + Interfaces.C.int'Image (Result); end Get_Default_Scrollbar_Size; diff --git a/body/fltk-text_buffers.adb b/body/fltk-text_buffers.adb index f113e22..a870ece 100644 --- a/body/fltk-text_buffers.adb +++ b/body/fltk-text_buffers.adb @@ -498,11 +498,11 @@ package body FLTK.Text_Buffers is UD : in Storage.Integer_Address) is Action : Modification; - Place : Position := Position (Pos); + Place : constant Position := Position (Pos); Length : Natural; Deleted_Text : Unbounded_String := To_Unbounded_String (""); - Ada_Text_Buffer : access Text_Buffer := + Ada_Text_Buffer : constant access Text_Buffer := Text_Buffer_Convert.To_Pointer (Storage.To_Address (UD)); begin if Ada_Text_Buffer.CB_Active then @@ -534,10 +534,10 @@ package body FLTK.Text_Buffers is (Pos, Deleted : in Interfaces.C.int; UD : in Storage.Integer_Address) is - Place : Position := Position (Pos); - Length : Natural := Natural (Deleted); + Place : constant Position := Position (Pos); + Length : constant Natural := Natural (Deleted); - Ada_Text_Buffer : access Text_Buffer := + Ada_Text_Buffer : constant access Text_Buffer := Text_Buffer_Convert.To_Pointer (Storage.To_Address (UD)); begin if Ada_Text_Buffer.CB_Active then @@ -682,10 +682,10 @@ package body FLTK.Text_Buffers is Name : in String; Buffer : in Natural := 128 * 1024) is - Err_No : Interfaces.C.int := fl_text_buffer_loadfile - (This.Void_Ptr, - Interfaces.C.To_C (Name), - Interfaces.C.int (Buffer)); + Err_No : constant Interfaces.C.int := fl_text_buffer_loadfile + (This.Void_Ptr, + Interfaces.C.To_C (Name), + Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error with Interfaces.C.Strings.Value (strerror (Err_No)); @@ -698,7 +698,7 @@ package body FLTK.Text_Buffers is Name : in String; Buffer : in Natural := 128 * 1024) is - Err_No : Interfaces.C.int := fl_text_buffer_appendfile + Err_No : constant Interfaces.C.int := fl_text_buffer_appendfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Buffer)); @@ -715,7 +715,7 @@ package body FLTK.Text_Buffers is Place : in Position; Buffer : in Natural := 128 * 1024) is - Err_No : Interfaces.C.int := fl_text_buffer_insertfile + Err_No : constant Interfaces.C.int := fl_text_buffer_insertfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Place), @@ -733,7 +733,7 @@ package body FLTK.Text_Buffers is Start, Finish : in Position; Buffer : in Natural := 128 * 1024) is - Err_No : Interfaces.C.int := fl_text_buffer_outputfile + Err_No : constant Interfaces.C.int := fl_text_buffer_outputfile (This.Void_Ptr, Interfaces.C.To_C (Name), Interfaces.C.int (Start), @@ -751,10 +751,10 @@ package body FLTK.Text_Buffers is Name : in String; Buffer : in Natural := 128 * 1024) is - Err_No : Interfaces.C.int := fl_text_buffer_savefile - (This.Void_Ptr, - Interfaces.C.To_C (Name), - Interfaces.C.int (Buffer)); + Err_No : constant Interfaces.C.int := fl_text_buffer_savefile + (This.Void_Ptr, + Interfaces.C.To_C (Name), + Interfaces.C.int (Buffer)); begin if Err_No /= 0 then raise Storage_Error with Interfaces.C.Strings.Value (strerror (Err_No)); @@ -772,9 +772,9 @@ package body FLTK.Text_Buffers is Text : in String) is begin fl_text_buffer_insert - (This.Void_Ptr, - Interfaces.C.int (Place), - Interfaces.C.To_C (Text)); + (This.Void_Ptr, + Interfaces.C.int (Place), + Interfaces.C.To_C (Text)); end Insert_Text; @@ -806,9 +806,9 @@ package body FLTK.Text_Buffers is Start, Finish : in Position) is begin fl_text_buffer_remove - (This.Void_Ptr, - Interfaces.C.int (Start), - Interfaces.C.int (Finish)); + (This.Void_Ptr, + Interfaces.C.int (Start), + Interfaces.C.int (Finish)); end Remove_Text; @@ -823,7 +823,7 @@ package body FLTK.Text_Buffers is return ""; else declare - Ada_String : String := Interfaces.C.Strings.Value (Raw); + Ada_String : constant String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; @@ -856,8 +856,8 @@ package body FLTK.Text_Buffers is return Character is begin return Character'Val (fl_text_buffer_char_at - (This.Void_Ptr, - Interfaces.C.int (Place))); + (This.Void_Ptr, + Interfaces.C.int (Place))); end Character_At; @@ -867,15 +867,15 @@ package body FLTK.Text_Buffers is return String is C_Str : Interfaces.C.Strings.chars_ptr := fl_text_buffer_text_range - (This.Void_Ptr, - Interfaces.C.int (Start), - Interfaces.C.int (Finish)); + (This.Void_Ptr, + Interfaces.C.int (Start), + Interfaces.C.int (Finish)); begin if C_Str = Interfaces.C.Strings.Null_Ptr then return ""; else declare - The_Text : String := Interfaces.C.Strings.Value (C_Str); + The_Text : constant String := Interfaces.C.Strings.Value (C_Str); begin Interfaces.C.Strings.Free (C_Str); return The_Text; @@ -1001,9 +1001,9 @@ package body FLTK.Text_Buffers is Start, Finish : in Position) is begin fl_text_buffer_select - (This.Void_Ptr, - Interfaces.C.int (Start), - Interfaces.C.int (Finish)); + (This.Void_Ptr, + Interfaces.C.int (Start), + Interfaces.C.int (Finish)); end Set_Selection; @@ -1045,7 +1045,7 @@ package body FLTK.Text_Buffers is return ""; else declare - Ada_String : String := Interfaces.C.Strings.Value (Raw); + Ada_String : constant String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; @@ -1065,7 +1065,7 @@ package body FLTK.Text_Buffers is return ""; else declare - Ada_String : String := Interfaces.C.Strings.Value (Raw); + Ada_String : constant String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; @@ -1155,7 +1155,7 @@ package body FLTK.Text_Buffers is return ""; else declare - Ada_String : String := Interfaces.C.Strings.Value (Raw); + Ada_String : constant String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; @@ -1324,7 +1324,7 @@ package body FLTK.Text_Buffers is return ""; else declare - Ada_String : String := Interfaces.C.Strings.Value (Raw); + Ada_String : constant String := Interfaces.C.Strings.Value (Raw); begin Interfaces.C.Strings.Free (Raw); return Ada_String; diff --git a/body/fltk-widgets-boxes.adb b/body/fltk-widgets-boxes.adb index 6bd11f4..efe6e54 100644 --- a/body/fltk-widgets-boxes.adb +++ b/body/fltk-widgets-boxes.adb @@ -86,6 +86,30 @@ package body FLTK.Widgets.Boxes is -- Constructors -- -------------------- + -- Hole successfully dug out of + procedure box_extra_init_hook + (Ada_Obj : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + C_Str : in Interfaces.C.Strings.chars_ptr); + pragma Export (C, box_extra_init_hook, "box_extra_init_hook"); + + procedure box_extra_init_hook + (Ada_Obj : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int; + C_Str : in Interfaces.C.Strings.chars_ptr) + is + My_Box : Box; + for My_Box'Address use Storage.To_Address (Ada_Obj); + pragma Import (Ada, My_Box); + begin + Extra_Init + (My_Box, + Integer (X), Integer (Y), + Integer (W), Integer (H), + Interfaces.C.Strings.Value (C_Str)); + end box_extra_init_hook; + + procedure Extra_Init (This : in out Box; X, Y, W, H : in Integer; diff --git a/body/fltk-widgets-buttons-light-check.adb b/body/fltk-widgets-buttons-light-check.adb index b75ef64..c3f1971 100644 --- a/body/fltk-widgets-buttons-light-check.adb +++ b/body/fltk-widgets-buttons-light-check.adb @@ -55,22 +55,6 @@ package body FLTK.Widgets.Buttons.Light.Check is -- Destructors -- ------------------- - -- Round the world and home again, that's the sailor's way! - procedure check_button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, check_button_extra_final_hook, "check_button_extra_final_hook"); - - procedure check_button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Check_Button : Check_Button; - for My_Check_Button'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Check_Button); - begin - Extra_Final (My_Check_Button); - end check_button_extra_final_hook; - - procedure Extra_Final (This : in out Check_Button) is begin diff --git a/body/fltk-widgets-buttons.adb b/body/fltk-widgets-buttons.adb index d6e587e..2d1e169 100644 --- a/body/fltk-widgets-buttons.adb +++ b/body/fltk-widgets-buttons.adb @@ -116,22 +116,6 @@ package body FLTK.Widgets.Buttons is -- Destructors -- ------------------- - -- Clipper route successfully navigated - procedure button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, button_extra_final_hook, "button_extra_final_hook"); - - procedure button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Button : Button; - for My_Button'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Button); - begin - Extra_Final (My_Button); - end button_extra_final_hook; - - procedure Extra_Final (This : in out Button) is begin @@ -293,7 +277,7 @@ package body FLTK.Widgets.Buttons is (This : in Button) return Key_Combo is begin - return To_Ada (fl_button_get_shortcut (This.Void_Ptr)); + return To_Ada (Interfaces.C.unsigned (fl_button_get_shortcut (This.Void_Ptr))); end Get_Shortcut; diff --git a/body/fltk-widgets-clocks-updated-round.adb b/body/fltk-widgets-clocks-updated-round.adb index 0b7590b..a91584e 100644 --- a/body/fltk-widgets-clocks-updated-round.adb +++ b/body/fltk-widgets-clocks-updated-round.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Clocks.Updated.Round is diff --git a/body/fltk-widgets-clocks-updated.adb b/body/fltk-widgets-clocks-updated.adb index 035ffda..63337f1 100644 --- a/body/fltk-widgets-clocks-updated.adb +++ b/body/fltk-widgets-clocks-updated.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Clocks.Updated is diff --git a/body/fltk-widgets-clocks.adb b/body/fltk-widgets-clocks.adb index 0d78df0..dc2ee6d 100644 --- a/body/fltk-widgets-clocks.adb +++ b/body/fltk-widgets-clocks.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Clocks is diff --git a/body/fltk-widgets-groups-browsers-check.adb b/body/fltk-widgets-groups-browsers-check.adb index 9890cdf..c519f31 100644 --- a/body/fltk-widgets-groups-browsers-check.adb +++ b/body/fltk-widgets-groups-browsers-check.adb @@ -321,7 +321,7 @@ package body FLTK.Widgets.Groups.Browsers.Check is Text : in String; Checked : in Boolean := False) is - Code : Interfaces.C.int := fl_check_browser_add + Ignore : Interfaces.C.int := fl_check_browser_add (This.Void_Ptr, Interfaces.C.To_C (Text), Boolean'Pos (Checked)); @@ -334,7 +334,7 @@ package body FLTK.Widgets.Groups.Browsers.Check is (This : in out Check_Browser; Index : in Positive) is - Code : Interfaces.C.int := fl_check_browser_remove + Ignore : Interfaces.C.int := fl_check_browser_remove (This.Void_Ptr, Interfaces.C.int (Index)); begin diff --git a/body/fltk-widgets-groups-browsers-textline-file.adb b/body/fltk-widgets-groups-browsers-textline-file.adb index b437bae..d22cfc1 100644 --- a/body/fltk-widgets-groups-browsers-textline-file.adb +++ b/body/fltk-widgets-groups-browsers-textline-file.adb @@ -266,7 +266,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline.File is (DA, DB : in Storage.Integer_Address) return Interfaces.C.int is - Result : FLTK.Filenames.Comparison := Current_Sort + Result : constant FLTK.Filenames.Comparison := Current_Sort (Interfaces.C.Strings.Value (filename_dname (DA, 0)), Interfaces.C.Strings.Value (filename_dname (DB, 0))); begin @@ -411,7 +411,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline.File is Sort : in not null FLTK.Filenames.Compare_Function := FLTK.Filenames.Numeric_Sort'Access) is - Result : Natural := This.Load (Dir, Sort); + Ignore : constant Natural := This.Load (Dir, Sort); begin null; end Load; @@ -425,7 +425,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline.File is (This : in File_Browser) return File_Kind is - Code : Interfaces.C.int := fl_file_browser_get_filetype (This.Void_Ptr); + Code : constant Interfaces.C.int := fl_file_browser_get_filetype (This.Void_Ptr); begin pragma Assert (Code in File_Kind'Pos (File_Kind'First) .. File_Kind'Pos (File_Kind'Last)); return File_Kind'Val (Code); @@ -448,7 +448,8 @@ package body FLTK.Widgets.Groups.Browsers.Textline.File is (This : in File_Browser) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_file_browser_get_filter (This.Void_Ptr); + Result : constant Interfaces.C.Strings.chars_ptr := + fl_file_browser_get_filter (This.Void_Ptr); begin if Result = Interfaces.C.Strings.Null_Ptr then return ""; diff --git a/body/fltk-widgets-groups-browsers-textline.adb b/body/fltk-widgets-groups-browsers-textline.adb index c772a10..e75ea6f 100644 --- a/body/fltk-widgets-groups-browsers-textline.adb +++ b/body/fltk-widgets-groups-browsers-textline.adb @@ -8,7 +8,6 @@ with Ada.Assertions, Ada.Unchecked_Deallocation, - FLTK.Images, Interfaces.C.Strings; use type @@ -644,7 +643,8 @@ package body FLTK.Widgets.Groups.Browsers.Textline is File : in String) is Msg : Interfaces.C.Strings.chars_ptr; - Code : Interfaces.C.int := fl_browser_load (This.Void_Ptr, Interfaces.C.To_C (File)); + Code : constant Interfaces.C.int := + fl_browser_load (This.Void_Ptr, Interfaces.C.To_C (File)); begin if Code = 0 then Msg := get_error_message; @@ -667,7 +667,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline is Line : in Positive) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_browser_get_text + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_browser_get_text (This.Void_Ptr, Interfaces.C.int (Line)); begin @@ -828,7 +828,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline is State : in Boolean := True) return Boolean is - Code : Interfaces.C.int := fl_browser_select + Code : constant Interfaces.C.int := fl_browser_select (This.Void_Ptr, Interfaces.C.int (Line), Boolean'Pos (State)); @@ -846,7 +846,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline is Line : in Positive; State : in Boolean := True) is - Code : Interfaces.C.int := fl_browser_select + Code : constant Interfaces.C.int := fl_browser_select (This.Void_Ptr, Interfaces.C.int (Line), Boolean'Pos (State)); @@ -863,7 +863,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline is Line : in Positive) return Boolean is - Code : Interfaces.C.int := fl_browser_selected + Code : constant Interfaces.C.int := fl_browser_selected (This.Void_Ptr, Interfaces.C.int (Line)); begin @@ -909,7 +909,7 @@ package body FLTK.Widgets.Groups.Browsers.Textline is Line : in Positive) return Boolean is - Code : Interfaces.C.int := fl_browser_displayed + Code : constant Interfaces.C.int := fl_browser_displayed (This.Void_Ptr, Interfaces.C.int (Line)); begin @@ -1174,7 +1174,8 @@ package body FLTK.Widgets.Groups.Browsers.Textline is return Interfaces.C.int; for my_item_selected'Address use This.Item_Override_Ptrs (Item_Selected_Ptr); pragma Import (Ada, my_item_selected); - Code : Interfaces.C.int := my_item_selected (This.Void_Ptr, Cursor_To_Address (Item)); + Code : constant Interfaces.C.int := + my_item_selected (This.Void_Ptr, Cursor_To_Address (Item)); begin pragma Assert (Code in 0 .. 1); return Boolean'Val (Code); diff --git a/body/fltk-widgets-groups-browsers.adb b/body/fltk-widgets-groups-browsers.adb index d60ecca..13cdba7 100644 --- a/body/fltk-widgets-groups-browsers.adb +++ b/body/fltk-widgets-groups-browsers.adb @@ -7,7 +7,7 @@ with Ada.Assertions, - Interfaces.C.Strings, + Interfaces.C, System.Address_To_Access_Conversions; @@ -366,7 +366,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Full_List_Width); @@ -382,7 +382,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Full_List_Height); @@ -398,7 +398,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Average_Item_Height); @@ -414,7 +414,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Item_Quick_Height (Address_To_Cursor (Item_Ptr))); @@ -430,7 +430,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Item_Width (Address_To_Cursor (Item_Ptr))); @@ -446,7 +446,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Interfaces.C.int (Ada_Object.Item_Height (Address_To_Cursor (Item_Ptr))); @@ -462,7 +462,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr : in Storage.Integer_Address) return Storage.Integer_Address is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Cursor_To_Address (Ada_Object.Item_First); @@ -478,7 +478,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr : in Storage.Integer_Address) return Storage.Integer_Address is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Cursor_To_Address (Ada_Object.Item_Last); @@ -494,7 +494,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Storage.Integer_Address is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Cursor_To_Address (Ada_Object.Item_Next (Address_To_Cursor (Item_Ptr))); @@ -510,7 +510,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Storage.Integer_Address is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Cursor_To_Address (Ada_Object.Item_Previous (Address_To_Cursor (Item_Ptr))); @@ -528,7 +528,7 @@ package body FLTK.Widgets.Groups.Browsers is Index : in Interfaces.C.int) return Storage.Integer_Address is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); use type Interfaces.C.int; begin @@ -545,7 +545,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address; Int_State : in Interfaces.C.int) is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); use type Interfaces.C.int; begin @@ -564,7 +564,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Interfaces.C.int is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin return Boolean'Pos (Ada_Object.Item_Selected (Address_To_Cursor (Item_Ptr))); @@ -578,7 +578,7 @@ package body FLTK.Widgets.Groups.Browsers is procedure Item_Swap_Hook (Ada_Addr, A_Ptr, B_Ptr : in Storage.Integer_Address) is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin Ada_Object.Item_Swap (Address_To_Cursor (A_Ptr), Address_To_Cursor (B_Ptr)); @@ -606,13 +606,13 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address) return Interfaces.C.Strings.chars_ptr is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin Interfaces.C.Strings.Free (Ada_Object.Text_Store (Ada_Object.Current)); Ada_Object.Text_Store (Ada_Object.Current) := Interfaces.C.Strings.New_String (Ada_Object.Item_Text (Address_To_Cursor (Item_Ptr))); - return C_Char_Is_Not_A_String : Interfaces.C.Strings.chars_ptr := + return C_Char_Is_Not_A_String : constant Interfaces.C.Strings.chars_ptr := Ada_Object.Text_Store (Ada_Object.Current) do Ada_Object.Current := Ada_Object.Current + 1; @@ -632,7 +632,7 @@ package body FLTK.Widgets.Groups.Browsers is (Ada_Addr, Item_Ptr : in Storage.Integer_Address; X, Y, W, H : in Interfaces.C.int) is - Ada_Object : access Browser'Class := + Ada_Object : constant access Browser'Class := Browser_Convert.To_Pointer (Storage.To_Address (Ada_Addr)); begin Ada_Object.Item_Draw @@ -650,18 +650,9 @@ package body FLTK.Widgets.Groups.Browsers is -- Destructors -- ------------------- - -- Preparing to use morse code - procedure fl_scrollbar_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_scrollbar_extra_final, "fl_scrollbar_extra_final"); - pragma Inline (fl_scrollbar_extra_final); - - procedure Extra_Final (This : in out Browser) is begin - fl_scrollbar_extra_final (Storage.To_Integer (This.Horizon'Address)); - fl_scrollbar_extra_final (Storage.To_Integer (This.Vertigo'Address)); Extra_Final (Group (This)); for Index in This.Text_Store'Range loop Interfaces.C.Strings.Free (This.Text_Store (Index)); @@ -803,7 +794,7 @@ package body FLTK.Widgets.Groups.Browsers is Do_Callbacks : in Boolean := False) return Boolean is - Code : Interfaces.C.int := fl_abstract_browser_select + Code : constant Interfaces.C.int := fl_abstract_browser_select (This.Void_Ptr, Cursor_To_Address (Item), Boolean'Pos (State), @@ -823,7 +814,7 @@ package body FLTK.Widgets.Groups.Browsers is State : in Boolean := True; Do_Callbacks : in Boolean := False) is - Code : Interfaces.C.int := fl_abstract_browser_select + Code : constant Interfaces.C.int := fl_abstract_browser_select (This.Void_Ptr, Cursor_To_Address (Item), Boolean'Pos (State), @@ -842,7 +833,7 @@ package body FLTK.Widgets.Groups.Browsers is Do_Callbacks : in Boolean := False) return Boolean is - Code : Interfaces.C.int := fl_abstract_browser_select_only + Code : constant Interfaces.C.int := fl_abstract_browser_select_only (This.Void_Ptr, Cursor_To_Address (Item), Boolean'Pos (Do_Callbacks)); @@ -861,7 +852,7 @@ package body FLTK.Widgets.Groups.Browsers is Item : in Item_Cursor; Do_Callbacks : in Boolean := False) is - Code : Interfaces.C.int := fl_abstract_browser_select_only + Code : constant Interfaces.C.int := fl_abstract_browser_select_only (This.Void_Ptr, Cursor_To_Address (Item), Boolean'Pos (Do_Callbacks)); @@ -887,7 +878,7 @@ package body FLTK.Widgets.Groups.Browsers is Do_Callbacks : in Boolean := False) return Boolean is - Code : Interfaces.C.int := fl_abstract_browser_deselect + Code : constant Interfaces.C.int := fl_abstract_browser_deselect (This.Void_Ptr, Boolean'Pos (Do_Callbacks)); begin @@ -904,7 +895,7 @@ package body FLTK.Widgets.Groups.Browsers is (This : in out Browser; Do_Callbacks : in Boolean := False) is - Code : Interfaces.C.int := fl_abstract_browser_deselect + Code : constant Interfaces.C.int := fl_abstract_browser_deselect (This.Void_Ptr, Boolean'Pos (Do_Callbacks)); begin @@ -929,7 +920,7 @@ package body FLTK.Widgets.Groups.Browsers is Item : in Item_Cursor) return Boolean is - Code : Interfaces.C.int := fl_abstract_browser_displayed + Code : constant Interfaces.C.int := fl_abstract_browser_displayed (This.Void_Ptr, Cursor_To_Address (Item)); begin pragma Assert (Code in 0 .. 1); @@ -964,7 +955,7 @@ package body FLTK.Widgets.Groups.Browsers is (This : in out Browser; Order : in Sort_Order) is - Code : Interfaces.C.int := + Code : constant Interfaces.C.int := (case Order is when Ascending => fl_sort_ascending, when Descending => fl_sort_descending); diff --git a/body/fltk-widgets-groups-color_choosers.adb b/body/fltk-widgets-groups-color_choosers.adb index 15c7000..cce0f08 100644 --- a/body/fltk-widgets-groups-color_choosers.adb +++ b/body/fltk-widgets-groups-color_choosers.adb @@ -268,7 +268,7 @@ package body FLTK.Widgets.Groups.Color_Choosers is (This : in out Color_Chooser; R, G, B : in Long_Float) is - Result : Interfaces.C.int := fl_color_chooser_rgb + Result : constant Interfaces.C.int := fl_color_chooser_rgb (This.Void_Ptr, Interfaces.C.double (R), Interfaces.C.double (G), @@ -287,7 +287,7 @@ package body FLTK.Widgets.Groups.Color_Choosers is R, G, B : in Long_Float) return Boolean is - Result : Interfaces.C.int := fl_color_chooser_rgb + Result : constant Interfaces.C.int := fl_color_chooser_rgb (This.Void_Ptr, Interfaces.C.double (R), Interfaces.C.double (G), @@ -333,7 +333,7 @@ package body FLTK.Widgets.Groups.Color_Choosers is (This : in out Color_Chooser; H, S, V : in Long_Float) is - Result : Interfaces.C.int := fl_color_chooser_hsv + Result : constant Interfaces.C.int := fl_color_chooser_hsv (This.Void_Ptr, Interfaces.C.double (H), Interfaces.C.double (S), @@ -352,7 +352,7 @@ package body FLTK.Widgets.Groups.Color_Choosers is H, S, V : in Long_Float) return Boolean is - Result : Interfaces.C.int := fl_color_chooser_hsv + Result : constant Interfaces.C.int := fl_color_chooser_hsv (This.Void_Ptr, Interfaces.C.double (H), Interfaces.C.double (S), diff --git a/body/fltk-widgets-groups-help_views.adb b/body/fltk-widgets-groups-help_views.adb index cdc0046..d31e532 100644 --- a/body/fltk-widgets-groups-help_views.adb +++ b/body/fltk-widgets-groups-help_views.adb @@ -7,7 +7,7 @@ with Ada.Assertions, - Interfaces.C.Strings, + Interfaces.C, System.Address_To_Access_Conversions; use type @@ -255,7 +255,7 @@ package body FLTK.Widgets.Groups.Help_Views is S : in Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr is - User_Data : Storage.Integer_Address := fl_widget_get_user_data (V); + User_Data : constant Storage.Integer_Address := fl_widget_get_user_data (V); Ada_Help_View : access Help_View'Class; begin pragma Assert (User_Data /= Null_Pointer); @@ -463,7 +463,8 @@ package body FLTK.Widgets.Groups.Help_Views is (This : in out Help_View; Name : in String) is - Code : Interfaces.C.int := fl_help_view_load (This.Void_Ptr, Interfaces.C.To_C (Name)); + Code : constant Interfaces.C.int := + fl_help_view_load (This.Void_Ptr, Interfaces.C.To_C (Name)); begin if Code = -1 then raise Load_Help_Error; @@ -481,7 +482,7 @@ package body FLTK.Widgets.Groups.Help_Views is (This : in Help_View) return String is - Raw_Chars : Interfaces.C.Strings.chars_ptr := fl_help_view_title (This.Void_Ptr); + Raw_Chars : constant Interfaces.C.Strings.chars_ptr := fl_help_view_title (This.Void_Ptr); use type Interfaces.C.Strings.chars_ptr; begin if Raw_Chars = Interfaces.C.Strings.Null_Ptr then @@ -496,7 +497,8 @@ package body FLTK.Widgets.Groups.Help_Views is (This : in Help_View) return String is - Raw_Chars : Interfaces.C.Strings.chars_ptr := fl_help_view_get_value (This.Void_Ptr); + Raw_Chars : constant Interfaces.C.Strings.chars_ptr := + fl_help_view_get_value (This.Void_Ptr); use type Interfaces.C.Strings.chars_ptr; begin if Raw_Chars = Interfaces.C.Strings.Null_Ptr then diff --git a/body/fltk-widgets-groups-input_choices.adb b/body/fltk-widgets-groups-input_choices.adb index 0479920..9119768 100644 --- a/body/fltk-widgets-groups-input_choices.adb +++ b/body/fltk-widgets-groups-input_choices.adb @@ -184,25 +184,9 @@ package body FLTK.Widgets.Groups.Input_Choices is -- Destructors -- ------------------- - -- Resorting to smoke signals - procedure fl_text_input_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_text_input_extra_final, "fl_text_input_extra_final"); - pragma Inline (fl_text_input_extra_final); - - - -- Message in a bottle - procedure fl_menu_button_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_menu_button_extra_final, "fl_menu_button_extra_final"); - pragma Inline (fl_menu_button_extra_final); - - procedure Extra_Final (This : in out Input_Choice) is begin - fl_text_input_extra_final (Storage.To_Integer (This.My_Input'Address)); - fl_menu_button_extra_final (Storage.To_Integer (This.My_Menu_Button'Address)); Extra_Final (Group (This)); end Extra_Final; @@ -468,7 +452,7 @@ package body FLTK.Widgets.Groups.Input_Choices is (This : in Input_Choice) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_input_choice_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_input_choice_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; diff --git a/body/fltk-widgets-groups-packed.adb b/body/fltk-widgets-groups-packed.adb index c5edda9..d832a35 100644 --- a/body/fltk-widgets-groups-packed.adb +++ b/body/fltk-widgets-groups-packed.adb @@ -173,7 +173,7 @@ package body FLTK.Widgets.Groups.Packed is (This : in Packed_Group) return Pack_Kind is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Pack_Kind'Val (Result); exception diff --git a/body/fltk-widgets-groups-scrolls.adb b/body/fltk-widgets-groups-scrolls.adb index a75d677..65498a6 100644 --- a/body/fltk-widgets-groups-scrolls.adb +++ b/body/fltk-widgets-groups-scrolls.adb @@ -153,34 +153,9 @@ package body FLTK.Widgets.Groups.Scrolls is -- Destructors -- ------------------- - -- I used the FFI to bypass namespace rules and all I got was this lousy tshirt - procedure scroll_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, scroll_extra_final_hook, "scroll_extra_final_hook"); - - procedure scroll_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Scroll : Scroll; - for My_Scroll'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Scroll); - begin - Extra_Final (My_Scroll); - end scroll_extra_final_hook; - - - -- It's the only way to be sure - procedure fl_scrollbar_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_scrollbar_extra_final, "fl_scrollbar_extra_final"); - pragma Inline (fl_scrollbar_extra_final); - - procedure Extra_Final (This : in out Scroll) is begin - fl_scrollbar_extra_final (Storage.To_Integer (This.Horizon'Address)); - fl_scrollbar_extra_final (Storage.To_Integer (This.Vertigo'Address)); Extra_Final (Group (This)); end Extra_Final; @@ -397,7 +372,7 @@ package body FLTK.Widgets.Groups.Scrolls is (This : in Scroll) return Scroll_Kind is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Scroll_Kind'Val (Result - 1); exception diff --git a/body/fltk-widgets-groups-spinners.adb b/body/fltk-widgets-groups-spinners.adb index 255daec..d9501ee 100644 --- a/body/fltk-widgets-groups-spinners.adb +++ b/body/fltk-widgets-groups-spinners.adb @@ -481,7 +481,7 @@ package body FLTK.Widgets.Groups.Spinners is (This : in Spinner) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_spinner_get_format (This.Void_Ptr); + Result : constant Interfaces.C.Strings.chars_ptr := fl_spinner_get_format (This.Void_Ptr); begin if Result = Interfaces.C.Strings.Null_Ptr then return ""; @@ -505,7 +505,7 @@ package body FLTK.Widgets.Groups.Spinners is (This : in Spinner) return Spinner_Kind is - Result : Interfaces.C.unsigned_char := fl_spinner_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_spinner_get_type (This.Void_Ptr); begin return Spinner_Kind'Val (Result - 1); exception diff --git a/body/fltk-widgets-groups-tables-row.adb b/body/fltk-widgets-groups-tables-row.adb index 5848cb9..0a7250a 100644 --- a/body/fltk-widgets-groups-tables-row.adb +++ b/body/fltk-widgets-groups-tables-row.adb @@ -232,7 +232,7 @@ package body FLTK.Widgets.Groups.Tables.Row is (This : in Row_Table) return Natural is - Result : Interfaces.C.int := fl_table_row_get_rows (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_row_get_rows (This.Void_Ptr); begin return Natural (Result); exception @@ -259,7 +259,7 @@ package body FLTK.Widgets.Groups.Tables.Row is Row : in Positive) return Boolean is - Result : Interfaces.C.int := fl_table_row_row_selected + Result : constant Interfaces.C.int := fl_table_row_row_selected (This.Void_Ptr, Interfaces.C.int (Row) - 1); begin return Boolean'Val (Result); @@ -275,7 +275,7 @@ package body FLTK.Widgets.Groups.Tables.Row is Row : in Positive; Value : in Selection_State := Selected) is - Result : Interfaces.C.int := fl_table_row_select_row + Result : constant Interfaces.C.int := fl_table_row_select_row (This.Void_Ptr, Interfaces.C.int (Row) - 1, Selection_State'Pos (Value)); @@ -298,7 +298,7 @@ package body FLTK.Widgets.Groups.Tables.Row is Value : in Selection_State := Selected) return Boolean is - Result : Interfaces.C.int := fl_table_row_select_row + Result : constant Interfaces.C.int := fl_table_row_select_row (This.Void_Ptr, Interfaces.C.int (Row) - 1, Selection_State'Pos (Value)); @@ -327,7 +327,7 @@ package body FLTK.Widgets.Groups.Tables.Row is (This : in Row_Table) return Row_Select_Mode is - Result : Interfaces.C.int := fl_table_row_get_type (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_row_get_type (This.Void_Ptr); begin return Row_Select_Mode'Val (Result); exception @@ -355,7 +355,7 @@ package body FLTK.Widgets.Groups.Tables.Row is Row, Column : in Positive; X, Y, W, H : out Integer) is - Result : Interfaces.C.int := fl_table_row_find_cell + Result : constant Interfaces.C.int := fl_table_row_find_cell (This.Void_Ptr, To_Cint (Context), Interfaces.C.int (Row) - 1, diff --git a/body/fltk-widgets-groups-tables.adb b/body/fltk-widgets-groups-tables.adb index 74ed22d..8417cd6 100644 --- a/body/fltk-widgets-groups-tables.adb +++ b/body/fltk-widgets-groups-tables.adb @@ -743,26 +743,9 @@ package body FLTK.Widgets.Groups.Tables is -- Destructors -- ------------------- - -- Attempting to divide by zero - procedure fl_scrollbar_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_scrollbar_extra_final, "fl_scrollbar_extra_final"); - pragma Inline (fl_scrollbar_extra_final); - - - -- Close the door; Open the nExt - procedure fl_scroll_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_scroll_extra_final, "fl_scroll_extra_final"); - pragma Inline (fl_scroll_extra_final); - - procedure Extra_Final (This : in out Table) is begin - fl_scrollbar_extra_final (Storage.To_Integer (This.Horizon'Address)); - fl_scrollbar_extra_final (Storage.To_Integer (This.Vertigo'Address)); - fl_scroll_extra_final (Storage.To_Integer (This.Playing_Area'Address)); Extra_Final (Group (This)); end Extra_Final; @@ -1024,7 +1007,7 @@ package body FLTK.Widgets.Groups.Tables is Item : in Widget'Class) return Extended_Index is - Result : Interfaces.C.int := fl_table_find (This.Void_Ptr, Item.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_find (This.Void_Ptr, Item.Void_Ptr); begin if Result = fl_table_children (This.Void_Ptr) then return No_Index; @@ -1086,7 +1069,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_callback_col (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_callback_col (This.Void_Ptr); begin return Positive (Result + 1); exception @@ -1100,7 +1083,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_callback_row (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_callback_row (This.Void_Ptr); begin return Positive (Result + 1); exception @@ -1114,7 +1097,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Table_Context is - Result : Interfaces.C.int := fl_table_callback_context (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_callback_context (This.Void_Ptr); begin return To_Context (Result); exception @@ -1192,7 +1175,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_col_header_height (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_col_header_height (This.Void_Ptr); begin return Positive (Result); exception @@ -1215,7 +1198,7 @@ package body FLTK.Widgets.Groups.Tables is Column : in Positive) return Positive is - Result : Interfaces.C.int := fl_table_get_col_width + Result : constant Interfaces.C.int := fl_table_get_col_width (This.Void_Ptr, Interfaces.C.int (Column) - 1); begin return Positive (Result); @@ -1250,7 +1233,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Natural is - Result : Interfaces.C.int := fl_table_get_cols (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_cols (This.Void_Ptr); begin return Natural (Result); exception @@ -1272,7 +1255,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_col_position (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_col_position (This.Void_Ptr); begin return Positive (Result + 1); exception @@ -1321,7 +1304,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_col_resize_min (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_col_resize_min (This.Void_Ptr); begin return Positive (Result); exception @@ -1379,7 +1362,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_row_header_width (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_row_header_width (This.Void_Ptr); begin return Positive (Result); exception @@ -1402,7 +1385,7 @@ package body FLTK.Widgets.Groups.Tables is Row : in Positive) return Positive is - Result : Interfaces.C.int := fl_table_get_row_height + Result : constant Interfaces.C.int := fl_table_get_row_height (This.Void_Ptr, Interfaces.C.int (Row) - 1); begin return Positive (Result); @@ -1437,7 +1420,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Natural is - Result : Interfaces.C.int := fl_table_get_rows (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_rows (This.Void_Ptr); begin return Natural (Result); exception @@ -1459,7 +1442,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_row_position (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_row_position (This.Void_Ptr); begin return Positive (Result + 1); exception @@ -1508,7 +1491,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_row_resize_min (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_row_resize_min (This.Void_Ptr); begin return Positive (Result); exception @@ -1530,7 +1513,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Positive is - Result : Interfaces.C.int := fl_table_get_top_row (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_top_row (This.Void_Ptr); begin return Positive (Result + 1); exception @@ -1567,7 +1550,7 @@ package body FLTK.Widgets.Groups.Tables is Resize : out Resize_Flag) is C_Row, C_Column, C_Flag : Interfaces.C.int; - Result : Interfaces.C.int := fl_table_cursor2rowcol + Result : constant Interfaces.C.int := fl_table_cursor2rowcol (This.Void_Ptr, C_Row, C_Column, C_Flag); begin Row := Positive (C_Row + 1); @@ -1659,7 +1642,7 @@ package body FLTK.Widgets.Groups.Tables is Row, Column : in Positive) return Boolean is - Result : Interfaces.C.int := fl_table_is_selected + Result : constant Interfaces.C.int := fl_table_is_selected (This.Void_Ptr, Interfaces.C.int (Row) - 1, Interfaces.C.int (Column) - 1); @@ -1677,7 +1660,7 @@ package body FLTK.Widgets.Groups.Tables is Row, Column : in Positive; Shift_Select : in Boolean := True) is - Result : Interfaces.C.int := fl_table_move_cursor + Result : constant Interfaces.C.int := fl_table_move_cursor (This.Void_Ptr, Interfaces.C.int (Row) - 1, Interfaces.C.int (Column) - 1, @@ -1697,7 +1680,7 @@ package body FLTK.Widgets.Groups.Tables is Shift_Select : in Boolean := True) return Boolean is - Result : Interfaces.C.int := fl_table_move_cursor + Result : constant Interfaces.C.int := fl_table_move_cursor (This.Void_Ptr, Interfaces.C.int (Row) - 1, Interfaces.C.int (Column) - 1, @@ -1715,7 +1698,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Tab_Navigation is - Result : Interfaces.C.int := fl_table_get_tab_cell_nav (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_tab_cell_nav (This.Void_Ptr); begin return Tab_Navigation'Val (Result); exception @@ -1737,7 +1720,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Box_Kind is - Result : Interfaces.C.int := fl_table_get_table_box (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_get_table_box (This.Void_Ptr); begin return Box_Kind'Val (Result); exception @@ -1792,7 +1775,7 @@ package body FLTK.Widgets.Groups.Tables is (This : in Table) return Boolean is - Result : Interfaces.C.int := fl_table_is_interactive_resize (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_table_is_interactive_resize (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -1922,7 +1905,7 @@ package body FLTK.Widgets.Groups.Tables is Row, Column : in Positive; X, Y, W, H : out Integer) is - Result : Interfaces.C.int := fl_table_find_cell + Result : constant Interfaces.C.int := fl_table_find_cell (This.Void_Ptr, To_Cint (Context), Interfaces.C.int (Row) - 1, @@ -1967,7 +1950,7 @@ package body FLTK.Widgets.Groups.Tables is is C_Row : Interfaces.C.int := Interfaces.C.int (Row) - 1; C_Column : Interfaces.C.int := Interfaces.C.int (Column) - 1; - Result : Interfaces.C.int := fl_table_row_col_clamp + Result : constant Interfaces.C.int := fl_table_row_col_clamp (This.Void_Ptr, To_Cint (Context), C_Row, C_Column); @@ -1990,7 +1973,7 @@ package body FLTK.Widgets.Groups.Tables is is C_Row : Interfaces.C.int := Interfaces.C.int (Row) - 1; C_Column : Interfaces.C.int := Interfaces.C.int (Column) - 1; - Result : Interfaces.C.int := fl_table_row_col_clamp + Result : constant Interfaces.C.int := fl_table_row_col_clamp (This.Void_Ptr, To_Cint (Context), C_Row, C_Column); diff --git a/body/fltk-widgets-groups-text_displays-text_editors.adb b/body/fltk-widgets-groups-text_displays-text_editors.adb index 906edef..c2722b6 100644 --- a/body/fltk-widgets-groups-text_displays-text_editors.adb +++ b/body/fltk-widgets-groups-text_displays-text_editors.adb @@ -8,8 +8,7 @@ with Ada.Assertions, Ada.Characters.Latin_1, - FLTK.Event, - Interfaces.C; + FLTK.Events; package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is @@ -385,12 +384,12 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is -- Key Binding Modification -- - procedure fl_text_editor_add_key_binding - (TE : in Storage.Integer_Address; - K, S : in Interfaces.C.int; - F : in Storage.Integer_Address); - pragma Import (C, fl_text_editor_add_key_binding, "fl_text_editor_add_key_binding"); - pragma Inline (fl_text_editor_add_key_binding); + -- procedure fl_text_editor_add_key_binding + -- (TE : in Storage.Integer_Address; + -- K, S : in Interfaces.C.int; + -- F : in Storage.Integer_Address); + -- pragma Import (C, fl_text_editor_add_key_binding, "fl_text_editor_add_key_binding"); + -- pragma Inline (fl_text_editor_add_key_binding); procedure fl_text_editor_remove_all_key_bindings (TE : in Storage.Integer_Address); @@ -473,12 +472,13 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is E : in Storage.Integer_Address) return Interfaces.C.int is - Editor_Ptr : Storage.Integer_Address := fl_widget_get_user_data (E); + Editor_Ptr : constant Storage.Integer_Address := fl_widget_get_user_data (E); Ada_Editor : access Text_Editor'Class; - Extra_Keys : Modifier := FLTK.Event.Last_Modifier; - Actual_Key : Keypress := FLTK.Event.Last_Key; -- fuck you FLTK, give me the real code - Ada_Key : Key_Combo := Extra_Keys + Actual_Key; + Extra_Keys : constant Modifier := FLTK.Events.Last_Modifier; + Actual_Key : constant Keypress := FLTK.Events.Last_Key; + -- fuck you FLTK, give me the real code + Ada_Key : constant Key_Combo := Extra_Keys + Actual_Key; -- For whatever reason, if a regular key function is used then FLTK will -- give you the key code, but if a default key function is used instead it @@ -577,9 +577,7 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is function Create (X, Y, W, H : in Integer; Text : in String := "") - return Text_Editor - is - use type Interfaces.C.int; + return Text_Editor is begin return This : Text_Editor do This.Void_Ptr := new_fl_text_editor @@ -1198,7 +1196,7 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is (This : in Text_Editor) return Insert_Mode is - Result : Interfaces.C.int := fl_text_editor_get_insert_mode (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_editor_get_insert_mode (This.Void_Ptr); begin return Insert_Mode'Val (Result); exception @@ -1220,7 +1218,7 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is (This : in Text_Editor) return Tab_Navigation is - Result : Interfaces.C.int := fl_text_editor_get_tab_nav (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_editor_get_tab_nav (This.Void_Ptr); begin return Tab_Navigation'Val (Result); exception @@ -1255,7 +1253,7 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is (This : in out Text_Editor) return Event_Outcome is - Result : Interfaces.C.int := fl_text_editor_handle_key (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_editor_handle_key (This.Void_Ptr); begin return Event_Outcome'Val (Result); exception diff --git a/body/fltk-widgets-groups-text_displays.adb b/body/fltk-widgets-groups-text_displays.adb index 7fda2fd..ac1f6e9 100644 --- a/body/fltk-widgets-groups-text_displays.adb +++ b/body/fltk-widgets-groups-text_displays.adb @@ -9,8 +9,7 @@ with Ada.Assertions, Ada.Characters.Latin_1, Ada.Unchecked_Conversion, - Interfaces.C.Strings, - FLTK.Text_Buffers; + Interfaces.C.Strings; use type @@ -50,11 +49,11 @@ package body FLTK.Widgets.Groups.Text_Displays is -- Buffers -- - function fl_text_display_get_buffer - (TD : in Storage.Integer_Address) - return Storage.Integer_Address; - pragma Import (C, fl_text_display_get_buffer, "fl_text_display_get_buffer"); - pragma Inline (fl_text_display_get_buffer); + -- function fl_text_display_get_buffer + -- (TD : in Storage.Integer_Address) + -- return Storage.Integer_Address; + -- pragma Import (C, fl_text_display_get_buffer, "fl_text_display_get_buffer"); + -- pragma Inline (fl_text_display_get_buffer); procedure fl_text_display_set_buffer (TD, TB : in Storage.Integer_Address); @@ -834,7 +833,7 @@ package body FLTK.Widgets.Groups.Text_Displays is is use Styles; -- for maximum stylin' - Ada_Widget : access Text_Display'Class := + Ada_Widget : constant access Text_Display'Class := Text_Display_Convert.To_Pointer (Storage.To_Address (D)); begin if Ada_Widget.Style_Callback /= null then @@ -1010,7 +1009,9 @@ package body FLTK.Widgets.Groups.Text_Displays is fl_text_display_highlight_data (This.Void_Ptr, Wrapper (Buff).Void_Ptr, - Storage.To_Integer (Table (Table'First)'Address), + (if Table'Length > 0 + then Storage.To_Integer (Table (Table'First)'Address) + else Null_Pointer), Table'Length); end Highlight_Data; @@ -1026,7 +1027,9 @@ package body FLTK.Widgets.Groups.Text_Displays is fl_text_display_highlight_data2 (This.Void_Ptr, Wrapper (Buff).Void_Ptr, - Storage.To_Integer (Table (Table'First)'Address), + (if Table'Length > 0 + then Storage.To_Integer (Table (Table'First)'Address) + else Null_Pointer), Table'Length, Interfaces.C.To_C (Unfinished), Storage.To_Integer (Style_Hook'Address), @@ -1041,7 +1044,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Line_Index : in Natural) return Styles.Style_Info is - Result : Interfaces.C.int := fl_text_display_position_style + Result : constant Interfaces.C.int := fl_text_display_position_style (This.Void_Ptr, Interfaces.C.int (Line_Start), Interfaces.C.int (Line_Length), @@ -1134,7 +1137,7 @@ package body FLTK.Widgets.Groups.Text_Displays is X : in Integer) return Natural is - Result : Interfaces.C.int := fl_text_display_find_x + Result : constant Interfaces.C.int := fl_text_display_find_x (This.Void_Ptr, Interfaces.C.To_C (Text), Text'Length, @@ -1155,7 +1158,7 @@ package body FLTK.Widgets.Groups.Text_Displays is return Natural is C_Line_Num : Interfaces.C.int; - Result : Interfaces.C.int := fl_text_display_position_to_line + Result : constant Interfaces.C.int := fl_text_display_position_to_line (This.Void_Ptr, Interfaces.C.int (Position), C_Line_Num); @@ -1179,7 +1182,7 @@ package body FLTK.Widgets.Groups.Text_Displays is return Natural is C_Line_Num : Interfaces.C.int; - Result : Interfaces.C.int := fl_text_display_position_to_line + Result : constant Interfaces.C.int := fl_text_display_position_to_line (This.Void_Ptr, Interfaces.C.int (Position), C_Line_Num); @@ -1204,7 +1207,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Column : out Natural) is C_Line_Num, C_Column : Interfaces.C.int; - Result : Interfaces.C.int := fl_text_display_position_to_linecol + Result : constant Interfaces.C.int := fl_text_display_position_to_linecol (This.Void_Ptr, Interfaces.C.int (Position), C_Line_Num, C_Column); @@ -1231,7 +1234,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Displayed : out Boolean) is C_Line_Num, C_Column : Interfaces.C.int; - Result : Interfaces.C.int := fl_text_display_position_to_linecol + Result : constant Interfaces.C.int := fl_text_display_position_to_linecol (This.Void_Ptr, Interfaces.C.int (Position), C_Line_Num, C_Column); @@ -1257,7 +1260,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Kind : in Position_Kind := Character_Position) return Natural is - Result : Interfaces.C.int := fl_text_display_xy_to_position + Result : constant Interfaces.C.int := fl_text_display_xy_to_position (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), @@ -1493,7 +1496,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Row : in Natural) return Natural is - Result : Interfaces.C.int := fl_text_display_wrapped_row + Result : constant Interfaces.C.int := fl_text_display_wrapped_row (This.Void_Ptr, Interfaces.C.int (Row)); begin @@ -1510,7 +1513,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Row, Column : in Natural) return Natural is - Result : Interfaces.C.int := fl_text_display_wrapped_column + Result : constant Interfaces.C.int := fl_text_display_wrapped_column (This.Void_Ptr, Interfaces.C.int (Row), Interfaces.C.int (Column)); @@ -1528,7 +1531,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Line_End : in Natural) return Boolean is - Result : Interfaces.C.int := fl_text_display_wrap_uses_character + Result : constant Interfaces.C.int := fl_text_display_wrap_uses_character (This.Void_Ptr, Interfaces.C.int (Line_End)); begin @@ -1693,7 +1696,8 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return Natural is - Result : Interfaces.C.int := fl_text_display_get_absolute_top_line_number (This.Void_Ptr); + Result : constant Interfaces.C.int := + fl_text_display_get_absolute_top_line_number (This.Void_Ptr); begin return Natural (Result); exception @@ -1715,7 +1719,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_maintaining_absolute_top_line_number + Result : constant Interfaces.C.int := fl_text_display_maintaining_absolute_top_line_number (This.Void_Ptr); begin return Boolean'Val (Result); @@ -1741,7 +1745,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_empty_vlines (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_empty_vlines (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -1755,7 +1759,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return Natural is - Result : Interfaces.C.int := fl_text_display_longest_vline (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_longest_vline (This.Void_Ptr); begin return Natural (Result); exception @@ -1770,7 +1774,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Line : in Natural) return Natural is - Result : Interfaces.C.int := fl_text_display_vline_length + Result : constant Interfaces.C.int := fl_text_display_vline_length (This.Void_Ptr, Interfaces.C.int (Line)); begin @@ -1898,7 +1902,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return String is - Result : Interfaces.C.Strings.chars_ptr := + Result : constant Interfaces.C.Strings.chars_ptr := fl_text_display_get_linenumber_format (This.Void_Ptr); begin if Result = Interfaces.C.Strings.Null_Ptr then @@ -1941,7 +1945,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Line : in Natural) return Natural is - Result : Interfaces.C.int := fl_text_display_measure_vline + Result : constant Interfaces.C.int := fl_text_display_measure_vline (This.Void_Ptr, Interfaces.C.int (Line)); begin @@ -1974,7 +1978,7 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Move_Down (This : in out Text_Display) is - Result : Interfaces.C.int := fl_text_display_move_down (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_down (This.Void_Ptr); begin pragma Assert (Result in 0 .. 1); exception @@ -1988,7 +1992,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in out Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_move_down (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_down (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -2001,7 +2005,7 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Move_Left (This : in out Text_Display) is - Result : Interfaces.C.int := fl_text_display_move_left (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_left (This.Void_Ptr); begin pragma Assert (Result in 0 .. 1); exception @@ -2015,7 +2019,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in out Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_move_left (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_left (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -2028,7 +2032,7 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Move_Right (This : in out Text_Display) is - Result : Interfaces.C.int := fl_text_display_move_right (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_right (This.Void_Ptr); begin pragma Assert (Result in 0 .. 1); exception @@ -2042,7 +2046,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in out Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_move_right (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_right (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -2055,7 +2059,7 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Move_Up (This : in out Text_Display) is - Result : Interfaces.C.int := fl_text_display_move_up (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_up (This.Void_Ptr); begin pragma Assert (Result in 0 .. 1); exception @@ -2069,7 +2073,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in out Text_Display) return Boolean is - Result : Interfaces.C.int := fl_text_display_move_up (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_text_display_move_up (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -2101,7 +2105,7 @@ package body FLTK.Widgets.Groups.Text_Displays is Pixel : in Natural := 0) return Boolean is - Result : Interfaces.C.int := fl_text_display_scroll2 + Result : constant Interfaces.C.int := fl_text_display_scroll2 (This.Void_Ptr, Interfaces.C.int (Line), Interfaces.C.int (Pixel)); @@ -2172,7 +2176,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in Text_Display) return Key_Combo is begin - return To_Ada (fl_text_display_get_shortcut (This.Void_Ptr)); + return To_Ada (Interfaces.C.unsigned (fl_text_display_get_shortcut (This.Void_Ptr))); end Get_Shortcut; @@ -2180,7 +2184,7 @@ package body FLTK.Widgets.Groups.Text_Displays is (This : in out Text_Display; Value : in Key_Combo) is begin - fl_text_display_set_shortcut (This.Void_Ptr, To_C (Value)); + fl_text_display_set_shortcut (This.Void_Ptr, Interfaces.C.int (To_C (Value))); end Set_Shortcut; diff --git a/body/fltk-widgets-groups-windows-double-cairo.adb b/body/fltk-widgets-groups-windows-double-cairo.adb index 270a30e..1560c20 100644 --- a/body/fltk-widgets-groups-windows-double-cairo.adb +++ b/body/fltk-widgets-groups-windows-double-cairo.adb @@ -81,9 +81,9 @@ package body FLTK.Widgets.Groups.Windows.Double.Cairo is procedure Cairo_Draw_Hook (C_Addr, Cairo_Addr : in Storage.Integer_Address) is - Ada_Addr : System.Address := + Ada_Addr : constant System.Address := Storage.To_Address (fl_widget_get_user_data (C_Addr)); - Ada_Object : access Cairo_Window'Class := + Ada_Object : constant access Cairo_Window'Class := Cairo_Convert.To_Pointer (Ada_Addr); begin pragma Assert (Ada_Object /= null); diff --git a/body/fltk-widgets-groups-windows-double-overlay.adb b/body/fltk-widgets-groups-windows-double-overlay.adb index e6d00cf..94542af 100644 --- a/body/fltk-widgets-groups-windows-double-overlay.adb +++ b/body/fltk-widgets-groups-windows-double-overlay.adb @@ -6,7 +6,7 @@ with - FLTK.Show_Argv, + FLTK.Args_Marshal, Interfaces.C, System.Address_To_Access_Conversions; @@ -125,7 +125,7 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is procedure Overlay_Window_Draw_Overlay_Hook (U : in Storage.Integer_Address) is - Overlay_Widget : access Overlay_Window'Class := + Overlay_Widget : constant access Overlay_Window'Class := Over_Convert.To_Pointer (Storage.To_Address (U)); begin Overlay_Widget.Draw_Overlay; @@ -257,7 +257,7 @@ package body FLTK.Widgets.Groups.Windows.Double.Overlay is procedure Show_With_Args (This : in out Overlay_Window) is begin - FLTK.Show_Argv.Dispatch (fl_overlay_window_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_overlay_window_show2'Access, This.Void_Ptr); end Show_With_Args; diff --git a/body/fltk-widgets-groups-windows-double.adb b/body/fltk-widgets-groups-windows-double.adb index d4ec67c..9c388e0 100644 --- a/body/fltk-widgets-groups-windows-double.adb +++ b/body/fltk-widgets-groups-windows-double.adb @@ -6,7 +6,7 @@ with - FLTK.Show_Argv, + FLTK.Args_Marshal, Interfaces.C; @@ -225,7 +225,7 @@ package body FLTK.Widgets.Groups.Windows.Double is procedure Show_With_Args (This : in out Double_Window) is begin - FLTK.Show_Argv.Dispatch (fl_double_window_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_double_window_show2'Access, This.Void_Ptr); end Show_With_Args; diff --git a/body/fltk-widgets-groups-windows-opengl.adb b/body/fltk-widgets-groups-windows-opengl.adb index 55e80b6..df61bd9 100644 --- a/body/fltk-widgets-groups-windows-opengl.adb +++ b/body/fltk-widgets-groups-windows-opengl.adb @@ -6,9 +6,8 @@ with - FLTK.Show_Argv, - Interfaces.C, - System; + FLTK.Args_Marshal, + Interfaces.C; use type @@ -355,7 +354,7 @@ package body FLTK.Widgets.Groups.Windows.OpenGL is procedure Show_With_Args (This : in out GL_Window) is begin - FLTK.Show_Argv.Dispatch (fl_gl_window_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_gl_window_show2'Access, This.Void_Ptr); end Show_With_Args; diff --git a/body/fltk-widgets-groups-windows-single.adb b/body/fltk-widgets-groups-windows-single.adb index 7eed730..6788d1a 100644 --- a/body/fltk-widgets-groups-windows-single.adb +++ b/body/fltk-widgets-groups-windows-single.adb @@ -6,7 +6,7 @@ with - FLTK.Show_Argv, + FLTK.Args_Marshal, Interfaces.C; @@ -213,7 +213,7 @@ package body FLTK.Widgets.Groups.Windows.Single is procedure Show_With_Args (This : in out Single_Window) is begin - FLTK.Show_Argv.Dispatch (fl_single_window_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_single_window_show2'Access, This.Void_Ptr); end Show_With_Args; diff --git a/body/fltk-widgets-groups-windows.adb b/body/fltk-widgets-groups-windows.adb index 3ff2f32..55f3506 100644 --- a/body/fltk-widgets-groups-windows.adb +++ b/body/fltk-widgets-groups-windows.adb @@ -6,10 +6,8 @@ with - Ada.Command_Line, Interfaces.C.Strings, - FLTK.Images.RGB, - FLTK.Show_Argv; + FLTK.Args_Marshal; use type @@ -513,7 +511,7 @@ package body FLTK.Widgets.Groups.Windows is procedure Show_With_Args (This : in out Window) is begin - FLTK.Show_Argv.Dispatch (fl_window_show2'Access, This.Void_Ptr); + FLTK.Args_Marshal.Dispatch (fl_window_show2'Access, This.Void_Ptr); end Show_With_Args; @@ -638,7 +636,9 @@ package body FLTK.Widgets.Groups.Windows is end loop; fl_window_icons (This.Void_Ptr, - Storage.To_Integer (Pointers (Pointers'First)'Address), + (if Pointers'Length > 0 + then Storage.To_Integer (Pointers (Pointers'First)'Address) + else Null_Pointer), Pointers'Length); end Set_Icons; @@ -666,7 +666,9 @@ package body FLTK.Widgets.Groups.Windows is Pointers (Index) := Wrapper (Pics (Index)).Void_Ptr; end loop; fl_window_default_icons - (Storage.To_Integer (Pointers (Pointers'First)'Address), + ((if Pointers'Length > 0 + then Storage.To_Integer (Pointers (Pointers'First)'Address) + else Null_Pointer), Pointers'Length); end Set_Default_Icons; @@ -681,7 +683,7 @@ package body FLTK.Widgets.Groups.Windows is (This : in Window) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_window_get_iconlabel (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_window_get_iconlabel (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -842,7 +844,7 @@ package body FLTK.Widgets.Groups.Windows is (This : in Window) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_window_get_label (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_window_get_label (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -942,7 +944,7 @@ package body FLTK.Widgets.Groups.Windows is (This : in Window) return Boolean is - Result : Interfaces.C.int := fl_window_get_force_position (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_window_get_force_position (This.Void_Ptr); begin return Boolean'Val (Result); exception @@ -1000,7 +1002,7 @@ package body FLTK.Widgets.Groups.Windows is (This : in Window) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_window_get_xclass (This.Void_Ptr); + Result : constant Interfaces.C.Strings.chars_ptr := fl_window_get_xclass (This.Void_Ptr); begin if Result = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1021,7 +1023,7 @@ package body FLTK.Widgets.Groups.Windows is function Get_Default_X_Class return String is - Result : Interfaces.C.Strings.chars_ptr := fl_window_get_default_xclass; + Result : constant Interfaces.C.Strings.chars_ptr := fl_window_get_default_xclass; begin if Result = Interfaces.C.Strings.Null_Ptr then return ""; diff --git a/body/fltk-widgets-groups.adb b/body/fltk-widgets-groups.adb index 6c94c4a..d6b51d4 100644 --- a/body/fltk-widgets-groups.adb +++ b/body/fltk-widgets-groups.adb @@ -217,7 +217,9 @@ package body FLTK.Widgets.Groups is procedure Extra_Final (This : in out Group) is begin - This.Clear; + if This.Needs_Dealloc then + This.Clear; + end if; Extra_Final (Widget (This)); end Extra_Final; @@ -411,7 +413,7 @@ package body FLTK.Widgets.Groups is Item : in Widget'Class) return Extended_Index is - Result : Interfaces.C.int := fl_group_find (This.Void_Ptr, Item.Void_Ptr); + Result : constant Interfaces.C.int := fl_group_find (This.Void_Ptr, Item.Void_Ptr); begin if Result = fl_group_children (This.Void_Ptr) then return No_Index; @@ -436,7 +438,7 @@ package body FLTK.Widgets.Groups is (This : in Group) return Group_Iterators.Reversible_Iterator'Class is begin - return It : Iterator := (My_Container => This'Unrestricted_Access); + return It : constant Iterator := (My_Container => This'Unrestricted_Access); end Iterate; @@ -444,7 +446,7 @@ package body FLTK.Widgets.Groups is (Object : in Iterator) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Object.My_Container, My_Index => 1); end First; @@ -458,7 +460,7 @@ package body FLTK.Widgets.Groups is if Object.My_Container /= Place.My_Container then raise Program_Error; end if; - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Place.My_Container, My_Index => Place.My_Index + 1); end Next; @@ -468,7 +470,7 @@ package body FLTK.Widgets.Groups is (Object : in Iterator) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Object.My_Container, My_Index => Object.My_Container.Number_Of_Children); end Last; @@ -482,7 +484,7 @@ package body FLTK.Widgets.Groups is if Object.My_Container /= Place.My_Container then raise Program_Error; end if; - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Place.My_Container, My_Index => Place.My_Index - 1); end Previous; @@ -496,7 +498,7 @@ package body FLTK.Widgets.Groups is (This : in Group) return Clip_Mode is - Result : Interfaces.C.unsigned := fl_group_get_clip_children (This.Void_Ptr); + Result : constant Interfaces.C.unsigned := fl_group_get_clip_children (This.Void_Ptr); begin return Clip_Mode'Val (Result); exception diff --git a/body/fltk-widgets-inputs-text-file.adb b/body/fltk-widgets-inputs-text-file.adb index ac3cec7..42c4961 100644 --- a/body/fltk-widgets-inputs-text-file.adb +++ b/body/fltk-widgets-inputs-text-file.adb @@ -236,7 +236,7 @@ package body FLTK.Widgets.Inputs.Text.File is (This : in File_Input) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_file_input_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_file_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -251,7 +251,7 @@ package body FLTK.Widgets.Inputs.Text.File is (This : in out File_Input; To : in String) is - Result : Interfaces.C.int := fl_file_input_set_value + Result : constant Interfaces.C.int := fl_file_input_set_value (This.Void_Ptr, Interfaces.C.To_C (To), To'Length); begin diff --git a/body/fltk-widgets-inputs-text-floating_point.adb b/body/fltk-widgets-inputs-text-floating_point.adb index 4bdcc0f..6a7925c 100644 --- a/body/fltk-widgets-inputs-text-floating_point.adb +++ b/body/fltk-widgets-inputs-text-floating_point.adb @@ -145,7 +145,7 @@ package body FLTK.Widgets.Inputs.Text.Floating_Point is (This : in Float_Input) return Long_Float is - Ptr : Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr or else Interfaces.C.Strings.Value (Ptr) = "" diff --git a/body/fltk-widgets-inputs-text-multiline.adb b/body/fltk-widgets-inputs-text-multiline.adb index 4969082..b348ce5 100644 --- a/body/fltk-widgets-inputs-text-multiline.adb +++ b/body/fltk-widgets-inputs-text-multiline.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Inputs.Text.Multiline is diff --git a/body/fltk-widgets-inputs-text-outputs-multiline.adb b/body/fltk-widgets-inputs-text-outputs-multiline.adb index 3f01dc3..e18d9b3 100644 --- a/body/fltk-widgets-inputs-text-outputs-multiline.adb +++ b/body/fltk-widgets-inputs-text-outputs-multiline.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Inputs.Text.Outputs.Multiline is diff --git a/body/fltk-widgets-inputs-text-outputs.adb b/body/fltk-widgets-inputs-text-outputs.adb index eeb83fb..6be0738 100644 --- a/body/fltk-widgets-inputs-text-outputs.adb +++ b/body/fltk-widgets-inputs-text-outputs.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Inputs.Text.Outputs is diff --git a/body/fltk-widgets-inputs-text-secret.adb b/body/fltk-widgets-inputs-text-secret.adb index 72d9f77..146133f 100644 --- a/body/fltk-widgets-inputs-text-secret.adb +++ b/body/fltk-widgets-inputs-text-secret.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Inputs.Text.Secret is diff --git a/body/fltk-widgets-inputs-text-whole_number.adb b/body/fltk-widgets-inputs-text-whole_number.adb index b0a5aa5..070dc0f 100644 --- a/body/fltk-widgets-inputs-text-whole_number.adb +++ b/body/fltk-widgets-inputs-text-whole_number.adb @@ -145,7 +145,7 @@ package body FLTK.Widgets.Inputs.Text.Whole_Number is (This : in Integer_Input) return Long_Integer is - Ptr : Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr or else Interfaces.C.Strings.Value (Ptr) = "" diff --git a/body/fltk-widgets-inputs-text.adb b/body/fltk-widgets-inputs-text.adb index 472f279..ddac5d9 100644 --- a/body/fltk-widgets-inputs-text.adb +++ b/body/fltk-widgets-inputs-text.adb @@ -55,22 +55,6 @@ package body FLTK.Widgets.Inputs.Text is -- Destructors -- ------------------- - -- Message received, every zig will take off - procedure text_input_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, text_input_extra_final_hook, "text_input_extra_final_hook"); - - procedure text_input_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Text_Input : Text_Input; - for My_Text_Input'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Text_Input); - begin - Extra_Final (My_Text_Input); - end text_input_extra_final_hook; - - procedure Extra_Final (This : in out Text_Input) is begin diff --git a/body/fltk-widgets-inputs.adb b/body/fltk-widgets-inputs.adb index 888ef68..2057f96 100644 --- a/body/fltk-widgets-inputs.adb +++ b/body/fltk-widgets-inputs.adb @@ -429,7 +429,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Destination : in Clipboard_Kind := Cut_Paste_Board) is - Result : Interfaces.C.int := fl_input_copy + Result : constant Interfaces.C.int := fl_input_copy (This.Void_Ptr, Clipboard_Kind'Pos (Destination)); begin pragma Assert (Result in 0 .. 1); @@ -445,7 +445,7 @@ package body FLTK.Widgets.Inputs is Destination : in Clipboard_Kind := Cut_Paste_Board) return Boolean is - Result : Interfaces.C.int := fl_input_copy + Result : constant Interfaces.C.int := fl_input_copy (This.Void_Ptr, Clipboard_Kind'Pos (Destination)); begin pragma Assert (Result in 0 .. 1); @@ -460,7 +460,7 @@ package body FLTK.Widgets.Inputs is procedure Cut (This : in out Input) is - Result : Interfaces.C.int := fl_input_cut (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_cut (This.Void_Ptr); begin null; end Cut; @@ -478,7 +478,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Num_Bytes : in Integer) is - Result : Interfaces.C.int := fl_input_cut2 + Ignore : constant Interfaces.C.int := fl_input_cut2 (This.Void_Ptr, Interfaces.C.int (Num_Bytes)); begin @@ -501,7 +501,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Start, Finish : in Integer) is - Result : Interfaces.C.int := fl_input_cut3 + Ignore : constant Interfaces.C.int := fl_input_cut3 (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)); @@ -525,7 +525,7 @@ package body FLTK.Widgets.Inputs is procedure Copy_Cuts (This : in out Input) is - Result : Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); begin null; end Copy_Cuts; @@ -535,7 +535,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input) return Boolean is - Result : Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_input_copy_cuts (This.Void_Ptr); begin return Result /= 0; end Copy_Cuts; @@ -544,7 +544,7 @@ package body FLTK.Widgets.Inputs is procedure Undo (This : in out Input) is - Result : Interfaces.C.int := fl_input_undo (This.Void_Ptr); + Ignore : constant Interfaces.C.int := fl_input_undo (This.Void_Ptr); begin null; end Undo; @@ -618,7 +618,7 @@ package body FLTK.Widgets.Inputs is (This : in Input) return Input_Kind is - C_Val : Interfaces.C.int := fl_input_get_input_type (This.Void_Ptr); + C_Val : constant Interfaces.C.int := fl_input_get_input_type (This.Void_Ptr); begin for V in Input_Kind loop if Input_Kind_Values (V) = C_Val then @@ -633,7 +633,7 @@ package body FLTK.Widgets.Inputs is (This : in Input) return Key_Combo is begin - return To_Ada (fl_input_get_shortcut (This.Void_Ptr)); + return To_Ada (Interfaces.C.unsigned (fl_input_get_shortcut (This.Void_Ptr))); end Get_Shortcut; @@ -641,7 +641,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in Key_Combo) is begin - fl_input_set_shortcut (This.Void_Ptr, To_C (To)); + fl_input_set_shortcut (This.Void_Ptr, Interfaces.C.int (To_C (To))); end Set_Shortcut; @@ -657,7 +657,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in Natural) is - Result : Interfaces.C.int := fl_input_set_mark + Ignore : constant Interfaces.C.int := fl_input_set_mark (This.Void_Ptr, Interfaces.C.int (To)); begin @@ -688,7 +688,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in Natural) is - Result : Interfaces.C.int := fl_input_set_position + Ignore : constant Interfaces.C.int := fl_input_set_position (This.Void_Ptr, Interfaces.C.int (To)); begin @@ -712,7 +712,7 @@ package body FLTK.Widgets.Inputs is Place : in Natural; Mark : in Natural) is - Result : Interfaces.C.int := fl_input_set_position2 + Ignore : constant Interfaces.C.int := fl_input_set_position2 (This.Void_Ptr, Interfaces.C.int (Place), Interfaces.C.int (Mark)); @@ -751,7 +751,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; Str : in String) is - Result : Interfaces.C.int := fl_input_insert + Ignore : constant Interfaces.C.int := fl_input_insert (This.Void_Ptr, Interfaces.C.To_C (Str, False), Str'Length); @@ -777,7 +777,7 @@ package body FLTK.Widgets.Inputs is From, To : in Natural; New_Text : in String) is - Result : Interfaces.C.int := fl_input_replace + Ignore : constant Interfaces.C.int := fl_input_replace (This.Void_Ptr, Interfaces.C.int (From), Interfaces.C.int (To), @@ -807,7 +807,7 @@ package body FLTK.Widgets.Inputs is (This : in Input) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -822,7 +822,7 @@ package body FLTK.Widgets.Inputs is (This : in out Input; To : in String) is - Result : Interfaces.C.int := fl_input_set_value + Ignore : constant Interfaces.C.int := fl_input_set_value (This.Void_Ptr, Interfaces.C.To_C (To), To'Length); begin null; diff --git a/body/fltk-widgets-menus-choices.adb b/body/fltk-widgets-menus-choices.adb index 80168f9..ac4564c 100644 --- a/body/fltk-widgets-menus-choices.adb +++ b/body/fltk-widgets-menus-choices.adb @@ -7,8 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C, - System; + Interfaces.C; use type diff --git a/body/fltk-widgets-menus-menu_bars-systemwide.adb b/body/fltk-widgets-menus-menu_bars-systemwide.adb index e96772e..88792bb 100644 --- a/body/fltk-widgets-menus-menu_bars-systemwide.adb +++ b/body/fltk-widgets-menus-menu_bars-systemwide.adb @@ -308,7 +308,7 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is (This : in out System_Menu_Bar; Text : in String) is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add + Ignore : constant Interfaces.C.int := fl_sys_menu_bar_add (This.Void_Ptr, Interfaces.C.To_C (Text)); begin This.Adjust_Item_Store; @@ -320,7 +320,7 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Text : in String) return Index is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add + Added_Spot : constant Interfaces.C.int := fl_sys_menu_bar_add (This.Void_Ptr, Interfaces.C.To_C (Text)); begin This.Adjust_Item_Store; @@ -335,12 +335,12 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Shortcut : in Key_Combo := No_Key; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add2 + Ignore : constant Interfaces.C.int := fl_sys_menu_bar_add2 (This.Void_Ptr, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Add; @@ -354,12 +354,12 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add2 + Added_Spot : constant Interfaces.C.int := fl_sys_menu_bar_add2 (This.Void_Ptr, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -373,12 +373,12 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Shortcut : in String; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add3 + Ignore : constant Interfaces.C.int := fl_sys_menu_bar_add3 (This.Void_Ptr, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Add; @@ -392,12 +392,12 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_add3 + Added_Spot : constant Interfaces.C.int := fl_sys_menu_bar_add3 (This.Void_Ptr, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -412,13 +412,13 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Shortcut : in Key_Combo := No_Key; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_insert + Ignore : constant Interfaces.C.int := fl_sys_menu_bar_insert (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Insert; @@ -433,13 +433,13 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_insert + Added_Spot : constant Interfaces.C.int := fl_sys_menu_bar_insert (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -454,13 +454,13 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Shortcut : in String; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_insert2 + Ignore : constant Interfaces.C.int := fl_sys_menu_bar_insert2 (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Insert; @@ -475,13 +475,13 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_sys_menu_bar_insert2 + Added_Spot : constant Interfaces.C.int := fl_sys_menu_bar_insert2 (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -522,7 +522,7 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is (This : in out System_Menu_Bar; Place : in Index) is - Result : Interfaces.C.int := fl_sys_menu_bar_clear_submenu + Result : constant Interfaces.C.int := fl_sys_menu_bar_clear_submenu (This.Void_Ptr, Interfaces.C.int (Place) - 1); begin @@ -584,7 +584,7 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is fl_sys_menu_bar_shortcut (This.Void_Ptr, Interfaces.C.int (Place) - 1, - To_C (Press)); + Interfaces.C.int (To_C (Press))); end Set_Shortcut; @@ -593,7 +593,8 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is Place : in Index) return Menu_Flag is begin - return Menu_Flag (fl_sys_menu_bar_get_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1)); + return Cint_To_MFlag + (fl_sys_menu_bar_get_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1)); end Get_Flags; @@ -605,7 +606,7 @@ package body FLTK.Widgets.Menus.Menu_Bars.Systemwide is fl_sys_menu_bar_set_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1, - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); end Set_Flags; diff --git a/body/fltk-widgets-menus-menu_buttons.adb b/body/fltk-widgets-menus-menu_buttons.adb index 3c4614c..c305320 100644 --- a/body/fltk-widgets-menus-menu_buttons.adb +++ b/body/fltk-widgets-menus-menu_buttons.adb @@ -90,22 +90,6 @@ package body FLTK.Widgets.Menus.Menu_Buttons is -- Destructors -- ------------------- - -- More magic - procedure menu_button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, menu_button_extra_final_hook, "menu_button_extra_final_hook"); - - procedure menu_button_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Menu_Button : Menu_Button; - for My_Menu_Button'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Menu_Button); - begin - Extra_Final (My_Menu_Button); - end menu_button_extra_final_hook; - - procedure Extra_Final (This : in out Menu_Button) is begin @@ -218,7 +202,7 @@ package body FLTK.Widgets.Menus.Menu_Buttons is (This : in Menu_Button) return Popup_Buttons is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Popup_Buttons'Val (Result); exception @@ -241,7 +225,7 @@ package body FLTK.Widgets.Menus.Menu_Buttons is return Extended_Index is use type Interfaces.C.int; - Ptr : Storage.Integer_Address := fl_menu_button_popup (This.Void_Ptr); + Ptr : constant Storage.Integer_Address := fl_menu_button_popup (This.Void_Ptr); begin return Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1); end Popup; diff --git a/body/fltk-widgets-menus.adb b/body/fltk-widgets-menus.adb index 3344efd..1295d76 100644 --- a/body/fltk-widgets-menus.adb +++ b/body/fltk-widgets-menus.adb @@ -415,7 +415,7 @@ package body FLTK.Widgets.Menus is procedure Adjust_Item_Store (This : in out Menu) is - Target : Natural := This.Number_Of_Items; + Target : constant Natural := This.Number_Of_Items; begin while Natural (This.My_Items.Length) > Target loop Free_Item (This.My_Items.Reference (This.My_Items.Last_Index)); @@ -446,9 +446,9 @@ package body FLTK.Widgets.Menus is procedure Item_Hook (C_Obj, User_Data : in Storage.Integer_Address) is - Ada_Ptr : Storage.Integer_Address := fl_widget_get_user_data (C_Obj); + Ada_Ptr : constant Storage.Integer_Address := fl_widget_get_user_data (C_Obj); Ada_Widget : access Widget'Class; - Action : Widget_Callback := Callback_Convert.To_Access (User_Data); + Action : constant Widget_Callback := Callback_Convert.To_Access (User_Data); begin pragma Assert (Ada_Ptr /= Null_Pointer); Ada_Widget := Widget_Convert.To_Pointer (Storage.To_Address (Ada_Ptr)); @@ -568,7 +568,7 @@ package body FLTK.Widgets.Menus is (This : in out Menu; Text : in String) is - Added_Spot : Interfaces.C.int := fl_menu_add (This.Void_Ptr, Interfaces.C.To_C (Text)); + Ignore : constant Interfaces.C.int := fl_menu_add (This.Void_Ptr, Interfaces.C.To_C (Text)); begin This.Adjust_Item_Store; end Add; @@ -579,7 +579,8 @@ package body FLTK.Widgets.Menus is Text : in String) return Index is - Added_Spot : Interfaces.C.int := fl_menu_add (This.Void_Ptr, Interfaces.C.To_C (Text)); + Added_Spot : constant Interfaces.C.int := + fl_menu_add (This.Void_Ptr, Interfaces.C.To_C (Text)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -593,12 +594,12 @@ package body FLTK.Widgets.Menus is Shortcut : in Key_Combo := No_Key; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_menu_add2 + Ignore : constant Interfaces.C.int := fl_menu_add2 (This.Void_Ptr, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Add; @@ -612,12 +613,12 @@ package body FLTK.Widgets.Menus is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_menu_add2 + Added_Spot : constant Interfaces.C.int := fl_menu_add2 (This.Void_Ptr, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -631,12 +632,12 @@ package body FLTK.Widgets.Menus is Shortcut : in String; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_menu_add3 + Ignore : constant Interfaces.C.int := fl_menu_add3 (This.Void_Ptr, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Add; @@ -650,12 +651,12 @@ package body FLTK.Widgets.Menus is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_menu_add3 + Added_Spot : constant Interfaces.C.int := fl_menu_add3 (This.Void_Ptr, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -670,13 +671,13 @@ package body FLTK.Widgets.Menus is Shortcut : in Key_Combo := No_Key; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_menu_insert + Ignore : constant Interfaces.C.int := fl_menu_insert (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Insert; @@ -691,13 +692,13 @@ package body FLTK.Widgets.Menus is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_menu_insert + Added_Spot : constant Interfaces.C.int := fl_menu_insert (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), - To_C (Shortcut), + Interfaces.C.int (To_C (Shortcut)), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -712,13 +713,13 @@ package body FLTK.Widgets.Menus is Shortcut : in String; Flags : in Menu_Flag := Flag_Normal) is - Added_Spot : Interfaces.C.int := fl_menu_insert2 + Ignore : constant Interfaces.C.int := fl_menu_insert2 (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; end Insert; @@ -733,13 +734,13 @@ package body FLTK.Widgets.Menus is Flags : in Menu_Flag := Flag_Normal) return Index is - Added_Spot : Interfaces.C.int := fl_menu_insert2 + Added_Spot : constant Interfaces.C.int := fl_menu_insert2 (This.Void_Ptr, Interfaces.C.int (Place) - 1, Interfaces.C.To_C (Text), Interfaces.C.To_C (Shortcut), Callback_Convert.To_Address (Action), - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); begin This.Adjust_Item_Store; return Index (Added_Spot + 1); @@ -750,7 +751,8 @@ package body FLTK.Widgets.Menus is (This : in out Menu; Items : in FLTK.Menu_Items.Menu_Item_Array) is - Pointers : aliased array (Items'First .. Items'Last + 1) of Storage.Integer_Address; + Pointers : aliased array + (Items'First .. Integer'Max (Items'First, Items'Last + 1)) of Storage.Integer_Address; pragma Convention (C, Pointers); begin for Place in Pointers'First .. Pointers'Last - 1 loop @@ -796,7 +798,7 @@ package body FLTK.Widgets.Menus is (This : in out Menu; Place : in Index) is - Result : Interfaces.C.int := fl_menu_clear_submenu + Result : constant Interfaces.C.int := fl_menu_clear_submenu (This.Void_Ptr, Interfaces.C.int (Place) - 1); begin @@ -866,7 +868,7 @@ package body FLTK.Widgets.Menus is Name : in String) return FLTK.Menu_Items.Menu_Item_Reference is - Place : Extended_Index := This.Find_Index (Name); + Place : constant Extended_Index := This.Find_Index (Name); begin if Place = No_Index then raise No_Reference_Error; @@ -880,7 +882,7 @@ package body FLTK.Widgets.Menus is Action : in Widget_Callback) return FLTK.Menu_Items.Menu_Item_Reference is - Place : Extended_Index := This.Find_Index (Action); + Place : constant Extended_Index := This.Find_Index (Action); begin if Place = No_Index then raise No_Reference_Error; @@ -894,7 +896,8 @@ package body FLTK.Widgets.Menus is Name : in String) return Extended_Index is - Result : Interfaces.C.int := fl_menu_find_index (This.Void_Ptr, Interfaces.C.To_C (Name)); + Result : constant Interfaces.C.int := + fl_menu_find_index (This.Void_Ptr, Interfaces.C.To_C (Name)); begin return Extended_Index (Result + 1); end Find_Index; @@ -905,7 +908,8 @@ package body FLTK.Widgets.Menus is Item : in FLTK.Menu_Items.Menu_Item) return Extended_Index is - Result : Interfaces.C.int := fl_menu_find_index2 (This.Void_Ptr, Wrapper (Item).Void_Ptr); + Result : constant Interfaces.C.int := + fl_menu_find_index2 (This.Void_Ptr, Wrapper (Item).Void_Ptr); begin return Extended_Index (Result + 1); end Find_Index; @@ -931,7 +935,7 @@ package body FLTK.Widgets.Menus is is Buffer : Interfaces.C.char_array := (0 .. Interfaces.C.size_t (Item_Path_Max) => Interfaces.C.nul); - Result : Interfaces.C.int := fl_menu_item_pathname + Result : constant Interfaces.C.int := fl_menu_item_pathname (This.Void_Ptr, Buffer, Interfaces.C.int (Item_Path_Max), @@ -959,7 +963,7 @@ package body FLTK.Widgets.Menus is is Buffer : Interfaces.C.char_array := (0 .. Interfaces.C.size_t (Item_Path_Max) => Interfaces.C.nul); - Result : Interfaces.C.int := fl_menu_item_pathname + Result : constant Interfaces.C.int := fl_menu_item_pathname (This.Void_Ptr, Buffer, Interfaces.C.int (Item_Path_Max), @@ -999,7 +1003,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return Menu_Iterators.Reversible_Iterator'Class is begin - return It : Iterator := (My_Container => This'Unrestricted_Access); + return It : constant Iterator := (My_Container => This'Unrestricted_Access); end Iterate; @@ -1007,7 +1011,7 @@ package body FLTK.Widgets.Menus is (Object : in Iterator) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Object.My_Container, My_Index => 1); end First; @@ -1018,7 +1022,7 @@ package body FLTK.Widgets.Menus is Place : in Cursor) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Place.My_Container, My_Index => Place.My_Index + 1); end Next; @@ -1028,7 +1032,7 @@ package body FLTK.Widgets.Menus is (Object : in Iterator) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Object.My_Container, My_Index => Object.My_Container.Number_Of_Items); end Last; @@ -1039,7 +1043,7 @@ package body FLTK.Widgets.Menus is Place : in Cursor) return Cursor is begin - return Cu : Cursor := + return Cu : constant Cursor := (My_Container => Place.My_Container, My_Index => Place.My_Index - 1); end Previous; @@ -1053,7 +1057,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return FLTK.Menu_Items.Menu_Item_Reference is - Place : Extended_Index := This.Chosen_Index; + Place : constant Extended_Index := This.Chosen_Index; begin if Place = No_Index then raise No_Reference_Error; @@ -1066,7 +1070,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_menu_text (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_menu_text (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1145,7 +1149,7 @@ package body FLTK.Widgets.Menus is Place : in Index) return String is - Result : Interfaces.C.Strings.chars_ptr := fl_menu_text2 + Result : constant Interfaces.C.Strings.chars_ptr := fl_menu_text2 (This.Void_Ptr, Interfaces.C.int (Place) - 1); begin @@ -1177,7 +1181,7 @@ package body FLTK.Widgets.Menus is fl_menu_shortcut (This.Void_Ptr, Interfaces.C.int (Place) - 1, - To_C (Press)); + Interfaces.C.int (To_C (Press))); end Set_Shortcut; @@ -1186,7 +1190,7 @@ package body FLTK.Widgets.Menus is Place : in Index) return Menu_Flag is begin - return Menu_Flag (fl_menu_get_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1)); + return Cint_To_MFlag (fl_menu_get_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1)); end Get_Flags; @@ -1198,7 +1202,7 @@ package body FLTK.Widgets.Menus is fl_menu_set_mode (This.Void_Ptr, Interfaces.C.int (Place) - 1, - Interfaces.C.int (Flags)); + MFlag_To_Cint (Flags)); end Set_Flags; @@ -1226,7 +1230,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return Font_Kind is - Result : Interfaces.C.int := fl_menu_get_textfont (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_get_textfont (This.Void_Ptr); begin return Font_Kind'Val (Result); exception @@ -1248,7 +1252,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return Font_Size is - Result : Interfaces.C.int := fl_menu_get_textsize (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_get_textsize (This.Void_Ptr); begin return Font_Size (Result); exception @@ -1274,7 +1278,7 @@ package body FLTK.Widgets.Menus is (This : in Menu) return Box_Kind is - Result : Interfaces.C.int := fl_menu_get_down_box (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_menu_get_down_box (This.Void_Ptr); begin return Box_Kind'Val (Result); exception @@ -1323,7 +1327,7 @@ package body FLTK.Widgets.Menus is return Extended_Index is C_Title : aliased Interfaces.C.char_array := Interfaces.C.To_C (Title); - Ptr : Storage.Integer_Address := fl_menu_popup + Ptr : constant Storage.Integer_Address := fl_menu_popup (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), @@ -1342,7 +1346,7 @@ package body FLTK.Widgets.Menus is Initial : in Extended_Index := No_Index) return Extended_Index is - Ptr : Storage.Integer_Address := fl_menu_pulldown + Ptr : constant Storage.Integer_Address := fl_menu_pulldown (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), @@ -1371,7 +1375,7 @@ package body FLTK.Widgets.Menus is Require_Alt : in Boolean := False) return access FLTK.Menu_Items.Menu_Item'Class is - Tentative_Result : Storage.Integer_Address := fl_menu_find_shortcut + Tentative_Result : constant Storage.Integer_Address := fl_menu_find_shortcut (This.Void_Ptr, Null_Pointer, Boolean'Pos (Require_Alt)); @@ -1392,7 +1396,7 @@ package body FLTK.Widgets.Menus is return access FLTK.Menu_Items.Menu_Item'Class is C_Place : Interfaces.C.int; - Tentative_Result : Storage.Integer_Address := fl_menu_find_shortcut + Tentative_Result : constant Storage.Integer_Address := fl_menu_find_shortcut (This.Void_Ptr, Storage.To_Integer (C_Place'Address), Boolean'Pos (Require_Alt)); @@ -1412,7 +1416,7 @@ package body FLTK.Widgets.Menus is (This : in out Menu) return access FLTK.Menu_Items.Menu_Item'Class is - Tentative_Pick : Storage.Integer_Address := fl_menu_test_shortcut (This.Void_Ptr); + Tentative_Pick : constant Storage.Integer_Address := fl_menu_test_shortcut (This.Void_Ptr); begin if Tentative_Pick = Null_Pointer then return null; diff --git a/body/fltk-widgets-positioners.adb b/body/fltk-widgets-positioners.adb index 91e948e..29246cd 100644 --- a/body/fltk-widgets-positioners.adb +++ b/body/fltk-widgets-positioners.adb @@ -289,7 +289,7 @@ package body FLTK.Widgets.Positioners is (This : in out Positioner; X, Y : in Long_Float) is - Result : Interfaces.C.int := fl_positioner_set_value + Result : constant Interfaces.C.int := fl_positioner_set_value (This.Void_Ptr, Interfaces.C.double (X), Interfaces.C.double (Y)); @@ -307,7 +307,7 @@ package body FLTK.Widgets.Positioners is X, Y : in Long_Float) return Boolean is - Result : Interfaces.C.int := fl_positioner_set_value + Result : constant Interfaces.C.int := fl_positioner_set_value (This.Void_Ptr, Interfaces.C.double (X), Interfaces.C.double (Y)); @@ -387,7 +387,7 @@ package body FLTK.Widgets.Positioners is (This : in out Positioner; Value : in Long_Float) is - Result : Interfaces.C.int := fl_positioner_set_xvalue + Result : constant Interfaces.C.int := fl_positioner_set_xvalue (This.Void_Ptr, Interfaces.C.double (Value)); begin @@ -404,7 +404,7 @@ package body FLTK.Widgets.Positioners is Value : in Long_Float) return Boolean is - Result : Interfaces.C.int := fl_positioner_set_xvalue + Result : constant Interfaces.C.int := fl_positioner_set_xvalue (This.Void_Ptr, Interfaces.C.double (Value)); begin @@ -483,7 +483,7 @@ package body FLTK.Widgets.Positioners is (This : in out Positioner; Value : in Long_Float) is - Result : Interfaces.C.int := fl_positioner_set_yvalue + Result : constant Interfaces.C.int := fl_positioner_set_yvalue (This.Void_Ptr, Interfaces.C.double (Value)); begin @@ -500,7 +500,7 @@ package body FLTK.Widgets.Positioners is Value : in Long_Float) return Boolean is - Result : Interfaces.C.int := fl_positioner_set_yvalue + Result : constant Interfaces.C.int := fl_positioner_set_yvalue (This.Void_Ptr, Interfaces.C.double (Value)); begin @@ -551,7 +551,7 @@ package body FLTK.Widgets.Positioners is X, Y, W, H : in Integer) return Event_Outcome is - Result : Interfaces.C.int := fl_positioner_handle2 + Result : constant Interfaces.C.int := fl_positioner_handle2 (This.Void_Ptr, Event_Kind'Pos (Event), Interfaces.C.int (X), diff --git a/body/fltk-widgets-progress_bars.adb b/body/fltk-widgets-progress_bars.adb index 8dc24ee..d04c275 100644 --- a/body/fltk-widgets-progress_bars.adb +++ b/body/fltk-widgets-progress_bars.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Progress_Bars is diff --git a/body/fltk-widgets-valuators-adjusters.adb b/body/fltk-widgets-valuators-adjusters.adb index 2ffad15..d740da5 100644 --- a/body/fltk-widgets-valuators-adjusters.adb +++ b/body/fltk-widgets-valuators-adjusters.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; use type diff --git a/body/fltk-widgets-valuators-counters-simple.adb b/body/fltk-widgets-valuators-counters-simple.adb index 9f41321..cd9a8f4 100644 --- a/body/fltk-widgets-valuators-counters-simple.adb +++ b/body/fltk-widgets-valuators-counters-simple.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Counters.Simple is diff --git a/body/fltk-widgets-valuators-counters.adb b/body/fltk-widgets-valuators-counters.adb index 1c5426f..f05df69 100644 --- a/body/fltk-widgets-valuators-counters.adb +++ b/body/fltk-widgets-valuators-counters.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Counters is @@ -331,7 +330,7 @@ package body FLTK.Widgets.Valuators.Counters is (This : in out Counter) return Counter_Kind is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Counter_Kind'Val (Result); exception diff --git a/body/fltk-widgets-valuators-dials-fill.adb b/body/fltk-widgets-valuators-dials-fill.adb index 44f87fe..a1d1066 100644 --- a/body/fltk-widgets-valuators-dials-fill.adb +++ b/body/fltk-widgets-valuators-dials-fill.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Dials.Fill is diff --git a/body/fltk-widgets-valuators-dials-line.adb b/body/fltk-widgets-valuators-dials-line.adb index 707b85d..8f6914c 100644 --- a/body/fltk-widgets-valuators-dials-line.adb +++ b/body/fltk-widgets-valuators-dials-line.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Dials.Line is diff --git a/body/fltk-widgets-valuators-dials.adb b/body/fltk-widgets-valuators-dials.adb index 9e2d885..43d943f 100644 --- a/body/fltk-widgets-valuators-dials.adb +++ b/body/fltk-widgets-valuators-dials.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Dials is @@ -284,7 +283,7 @@ package body FLTK.Widgets.Valuators.Dials is X, Y, W, H : in Integer) return Event_Outcome is - Result : Interfaces.C.int := fl_dial_handle2 + Result : constant Interfaces.C.int := fl_dial_handle2 (This.Void_Ptr, Event_Kind'Pos (Event), Interfaces.C.int (X), @@ -308,7 +307,7 @@ package body FLTK.Widgets.Valuators.Dials is (This : in Dial) return Dial_Kind is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Dial_Kind'Val (Result); exception diff --git a/body/fltk-widgets-valuators-rollers.adb b/body/fltk-widgets-valuators-rollers.adb index c04e274..45939fb 100644 --- a/body/fltk-widgets-valuators-rollers.adb +++ b/body/fltk-widgets-valuators-rollers.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Rollers is diff --git a/body/fltk-widgets-valuators-sliders-fill.adb b/body/fltk-widgets-valuators-sliders-fill.adb index 2cb4c18..c9b0d82 100644 --- a/body/fltk-widgets-valuators-sliders-fill.adb +++ b/body/fltk-widgets-valuators-sliders-fill.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Sliders.Fill is diff --git a/body/fltk-widgets-valuators-sliders-horizontal.adb b/body/fltk-widgets-valuators-sliders-horizontal.adb index c774a3b..1fb5114 100644 --- a/body/fltk-widgets-valuators-sliders-horizontal.adb +++ b/body/fltk-widgets-valuators-sliders-horizontal.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Sliders.Horizontal is diff --git a/body/fltk-widgets-valuators-sliders-horizontal_fill.adb b/body/fltk-widgets-valuators-sliders-horizontal_fill.adb index 6a91d4b..2ecf088 100644 --- a/body/fltk-widgets-valuators-sliders-horizontal_fill.adb +++ b/body/fltk-widgets-valuators-sliders-horizontal_fill.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Sliders.Horizontal_Fill is diff --git a/body/fltk-widgets-valuators-sliders-horizontal_nice.adb b/body/fltk-widgets-valuators-sliders-horizontal_nice.adb index e12113a..5efb3ca 100644 --- a/body/fltk-widgets-valuators-sliders-horizontal_nice.adb +++ b/body/fltk-widgets-valuators-sliders-horizontal_nice.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Sliders.Horizontal_Nice is diff --git a/body/fltk-widgets-valuators-sliders-nice.adb b/body/fltk-widgets-valuators-sliders-nice.adb index 995a585..4b24754 100644 --- a/body/fltk-widgets-valuators-sliders-nice.adb +++ b/body/fltk-widgets-valuators-sliders-nice.adb @@ -6,8 +6,7 @@ with - FLTK.Widgets.Groups, - Interfaces.C.Strings; + FLTK.Widgets.Groups; package body FLTK.Widgets.Valuators.Sliders.Nice is diff --git a/body/fltk-widgets-valuators-sliders-scrollbars.adb b/body/fltk-widgets-valuators-sliders-scrollbars.adb index f08ccaf..660970a 100644 --- a/body/fltk-widgets-valuators-sliders-scrollbars.adb +++ b/body/fltk-widgets-valuators-sliders-scrollbars.adb @@ -90,22 +90,6 @@ package body FLTK.Widgets.Valuators.Sliders.Scrollbars is -- Destructors -- ------------------- - -- End of the line - procedure scrollbar_extra_final_hook - (Ada_Obj : in Storage.Integer_Address); - pragma Export (C, scrollbar_extra_final_hook, "scrollbar_extra_final_hook"); - - procedure scrollbar_extra_final_hook - (Ada_Obj : in Storage.Integer_Address) - is - My_Scrollbar : Scrollbar; - for My_Scrollbar'Address use Storage.To_Address (Ada_Obj); - pragma Import (Ada, My_Scrollbar); - begin - Extra_Final (My_Scrollbar); - end scrollbar_extra_final_hook; - - procedure Extra_Final (This : in out Scrollbar) is begin diff --git a/body/fltk-widgets-valuators-sliders-value-horizontal.adb b/body/fltk-widgets-valuators-sliders-value-horizontal.adb index a126b4c..9e3d946 100644 --- a/body/fltk-widgets-valuators-sliders-value-horizontal.adb +++ b/body/fltk-widgets-valuators-sliders-value-horizontal.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Sliders.Value.Horizontal is diff --git a/body/fltk-widgets-valuators-sliders-value.adb b/body/fltk-widgets-valuators-sliders-value.adb index 17e9591..28a932e 100644 --- a/body/fltk-widgets-valuators-sliders-value.adb +++ b/body/fltk-widgets-valuators-sliders-value.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Sliders.Value is diff --git a/body/fltk-widgets-valuators-sliders.adb b/body/fltk-widgets-valuators-sliders.adb index 00153dc..b670ba2 100644 --- a/body/fltk-widgets-valuators-sliders.adb +++ b/body/fltk-widgets-valuators-sliders.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; package body FLTK.Widgets.Valuators.Sliders is @@ -367,7 +367,7 @@ package body FLTK.Widgets.Valuators.Sliders is (This : in Slider) return Slider_Kind is - Result : Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); + Result : constant Interfaces.C.unsigned_char := fl_widget_get_type (This.Void_Ptr); begin return Slider_Kind'Val (Result); exception diff --git a/body/fltk-widgets-valuators-value_inputs.adb b/body/fltk-widgets-valuators-value_inputs.adb index 929d117..1909c1c 100644 --- a/body/fltk-widgets-valuators-value_inputs.adb +++ b/body/fltk-widgets-valuators-value_inputs.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; use type @@ -173,17 +173,9 @@ package body FLTK.Widgets.Valuators.Value_Inputs is -- Destructors -- ------------------- - -- Making a long distance telephone call - procedure fl_text_input_extra_final - (Ada_Obj : in Storage.Integer_Address); - pragma Import (C, fl_text_input_extra_final, "fl_text_input_extra_final"); - pragma Inline (fl_text_input_extra_final); - - procedure Extra_Final (This : in out Value_Input) is begin - fl_text_input_extra_final (Storage.To_Integer (This.My_Input'Address)); Extra_Final (Valuator (This)); end Extra_Final; @@ -317,7 +309,7 @@ package body FLTK.Widgets.Valuators.Value_Inputs is (This : in Value_Input) return Key_Combo is begin - return To_Ada (fl_value_input_get_shortcut (This.Void_Ptr)); + return To_Ada (Interfaces.C.unsigned (fl_value_input_get_shortcut (This.Void_Ptr))); end Get_Shortcut; diff --git a/body/fltk-widgets-valuators-value_outputs.adb b/body/fltk-widgets-valuators-value_outputs.adb index 471e58d..82259a6 100644 --- a/body/fltk-widgets-valuators-value_outputs.adb +++ b/body/fltk-widgets-valuators-value_outputs.adb @@ -7,7 +7,7 @@ with FLTK.Widgets.Groups, - Interfaces.C.Strings; + Interfaces.C; use type diff --git a/body/fltk-widgets-valuators.adb b/body/fltk-widgets-valuators.adb index 69aa150..c762fe4 100644 --- a/body/fltk-widgets-valuators.adb +++ b/body/fltk-widgets-valuators.adb @@ -210,7 +210,7 @@ package body FLTK.Widgets.Valuators is declare -- God this whole Format method is sketchy as hell. -- ...what? This is the area to declare things and that needed declaring. - String_Result : String := Ada_Obj.Format; + String_Result : constant String := Ada_Obj.Format; begin if String_Result'Length <= FLTK.Buffer_Size then Interfaces.C.Strings.Update (Buffer, 0, Interfaces.C.To_C (String_Result), False); @@ -321,7 +321,7 @@ package body FLTK.Widgets.Valuators is is Buffer : Interfaces.C.char_array := (1 .. Interfaces.C.size_t (FLTK.Buffer_Size) => Interfaces.C.To_C (Character'Val (0))); - Result : Interfaces.C.int := fl_valuator_format (This.Void_Ptr, Buffer); + Result : constant Interfaces.C.int := fl_valuator_format (This.Void_Ptr, Buffer); begin return Interfaces.C.To_Ada (Buffer (1 .. Interfaces.C.size_t (Result)), False); end Format; diff --git a/body/fltk-widgets.adb b/body/fltk-widgets.adb index 8bc5c86..f4409e4 100644 --- a/body/fltk-widgets.adb +++ b/body/fltk-widgets.adb @@ -8,9 +8,7 @@ with Ada.Assertions, Interfaces.C.Strings, - System.Address_To_Access_Conversions, - FLTK.Widgets.Groups.Windows, - FLTK.Images; + FLTK.Widgets.Groups.Windows; use type @@ -26,33 +24,6 @@ package body FLTK.Widgets is package Chk renames Ada.Assertions; - function "+" - (Left, Right : in Callback_Flag) - return Callback_Flag is - begin - return - (Changed => Left.Changed or Right.Changed, - Interact => Left.Interact or Right.Interact, - Release => Left.Release or Right.Release, - Enter_Key => Left.Enter_Key or Right.Enter_Key); - end "+"; - - - function "+" - (Left, Right : in Damage_Mask) - return Damage_Mask is - begin - return - (Child => Left.Child or Right.Child, - Expose => Left.Expose or Right.Expose, - Scroll => Left.Scroll or Right.Scroll, - Overlay => Left.Overlay or Right.Overlay, - User_1 => Left.User_1 or Right.User_1, - User_2 => Left.User_2 or Right.User_2, - Full => Left.Full or Right.Full); - end "+"; - - package Group_Convert is new System.Address_To_Access_Conversions (FLTK.Widgets.Groups.Group'Class); @@ -628,7 +599,7 @@ package body FLTK.Widgets is procedure Callback_Hook (W, U : in Storage.Integer_Address) is - Ada_Widget : access Widget'Class := + Ada_Widget : constant access Widget'Class := Widget_Convert.To_Pointer (Storage.To_Address (U)); begin Ada_Widget.Callback.all (Ada_Widget.all); @@ -638,7 +609,7 @@ package body FLTK.Widgets is procedure Draw_Hook (U : in Storage.Integer_Address) is - Ada_Widget : access Widget'Class := + Ada_Widget : constant access Widget'Class := Widget_Convert.To_Pointer (Storage.To_Address (U)); begin Ada_Widget.Draw; @@ -650,7 +621,7 @@ package body FLTK.Widgets is E : in Interfaces.C.int) return Interfaces.C.int is - Ada_Widget : access Widget'Class := + Ada_Widget : constant access Widget'Class := Widget_Convert.To_Pointer (Storage.To_Address (U)); begin return Event_Outcome'Pos (Ada_Widget.Handle (Event_Kind'Val (E))); @@ -666,10 +637,13 @@ package body FLTK.Widgets is procedure Extra_Final (This : in out Widget) is - Maybe_Parent : access FLTK.Widgets.Groups.Group'Class := This.Parent; + Maybe_Parent : access FLTK.Widgets.Groups.Group'Class; begin - if Maybe_Parent /= null then - Maybe_Parent.Remove (This); + if This.Needs_Dealloc then + Maybe_Parent := This.Parent; + if Maybe_Parent /= null then + Maybe_Parent.Remove (This); + end if; end if; end Extra_Final; @@ -1050,13 +1024,13 @@ package body FLTK.Widgets is begin if Parent_Ptr /= Null_Pointer then Parent_Ptr := fl_widget_get_user_data (Parent_Ptr); - pragma Assert (Parent_Ptr /= Null_Pointer); + -- Can't assert user data being not null here because fl_ask is a bitch, + -- so have to fall back on saying that if it's null then you get nothing. + -- Any widget created by users of this binding will have appropriate back + -- reference to the corresponding Ada object in the user data anyway. Actual_Parent := Group_Convert.To_Pointer (Storage.To_Address (Parent_Ptr)); end if; return Actual_Parent; - exception - when Chk.Assertion_Error => raise Internal_FLTK_Error with - "Widget returned by Fl_Widget::parent has no user_data reference back to Ada"; end Parent; @@ -1163,7 +1137,7 @@ package body FLTK.Widgets is (This : in Widget) return Box_Kind is - Result : Interfaces.C.int := fl_widget_get_box (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_widget_get_box (This.Void_Ptr); begin return Box_Kind'Val (Result); exception @@ -1185,7 +1159,7 @@ package body FLTK.Widgets is (This : in Widget) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_tooltip (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_widget_tooltip (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1212,7 +1186,7 @@ package body FLTK.Widgets is (This : in Widget) return String is - Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_get_label (This.Void_Ptr); + Ptr : constant Interfaces.C.Strings.chars_ptr := fl_widget_get_label (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; @@ -1292,7 +1266,7 @@ package body FLTK.Widgets is (This : in Widget) return Label_Kind is - Result : Interfaces.C.int := fl_widget_get_labeltype (This.Void_Ptr); + Result : constant Interfaces.C.int := fl_widget_get_labeltype (This.Void_Ptr); begin return Label_Kind'Val (Result); exception @@ -1690,7 +1664,7 @@ package body FLTK.Widgets is for my_handle'Address use This.Handle_Ptr; pragma Import (Ada, my_handle); - Result : Interfaces.C.int := my_handle (This.Void_Ptr, Event_Kind'Pos (Event)); + Result : constant Interfaces.C.int := my_handle (This.Void_Ptr, Event_Kind'Pos (Event)); begin return Event_Outcome'Val (Result); exception diff --git a/body/fltk.adb b/body/fltk.adb index 4dfdf8f..49d9048 100644 --- a/body/fltk.adb +++ b/body/fltk.adb @@ -11,33 +11,148 @@ with use type Interfaces.C.int, - Interfaces.C.unsigned_long; + Interfaces.C.unsigned, + Interfaces.C.unsigned_char; package body FLTK is ------------------------ + -- Constants From C -- + ------------------------ + + -- Color -- + + fl_enum_num_red : constant Interfaces.C.int; + pragma Import (C, fl_enum_num_red, "fl_enum_num_red"); + + fl_enum_num_green : constant Interfaces.C.int; + pragma Import (C, fl_enum_num_green, "fl_enum_num_green"); + + fl_enum_num_blue : constant Interfaces.C.int; + pragma Import (C, fl_enum_num_blue, "fl_enum_num_blue"); + + fl_enum_num_gray : constant Interfaces.C.int; + pragma Import (C, fl_enum_num_gray, "fl_enum_num_gray"); + + + + + -- Keyboard and Mouse Input -- + + fl_enum_button1 : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_button1, "fl_enum_button1"); + + fl_enum_button2 : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_button2, "fl_enum_button2"); + + fl_enum_button3 : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_button3, "fl_enum_button3"); + + fl_enum_button4 : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_button4, "fl_enum_button4"); + + fl_enum_button5 : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_button5, "fl_enum_button5"); + + fl_enum_buttons : constant Interfaces.C.unsigned; + pragma Import (C, fl_enum_buttons, "fl_enum_buttons"); + + + + + ------------------------ -- Functions From C -- ------------------------ -- Enumerations.H -- + -- Color -- + + function fl_enum_rgb_color2 + (L : in Interfaces.C.unsigned_char) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_rgb_color2, "fl_enum_rgb_color2"); + pragma Inline (fl_enum_rgb_color2); + function fl_enum_rgb_color (R, G, B : in Interfaces.C.unsigned_char) return Interfaces.C.unsigned; pragma Import (C, fl_enum_rgb_color, "fl_enum_rgb_color"); pragma Inline (fl_enum_rgb_color); + function fl_enum_color_cube + (R, G, B : in Interfaces.C.int) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_color_cube, "fl_enum_color_cube"); + pragma Inline (fl_enum_color_cube); + + function fl_enum_gray_ramp + (L : in Interfaces.C.int) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_gray_ramp, "fl_enum_gray_ramp"); + pragma Inline (fl_enum_gray_ramp); + + function fl_enum_darker + (T : in Interfaces.C.unsigned) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_darker, "fl_enum_darker"); + pragma Inline (fl_enum_darker); + + function fl_enum_lighter + (T : in Interfaces.C.unsigned) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_lighter, "fl_enum_lighter"); + pragma Inline (fl_enum_lighter); + function fl_enum_contrast (F, B : in Interfaces.C.unsigned) return Interfaces.C.unsigned; pragma Import (C, fl_enum_contrast, "fl_enum_contrast"); pragma Inline (fl_enum_contrast); + function fl_enum_inactive + (T : in Interfaces.C.unsigned) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_inactive, "fl_enum_inactive"); + pragma Inline (fl_enum_inactive); + + function fl_enum_color_average + (T1, T2 : in Interfaces.C.unsigned; + W : in Interfaces.C.C_float) + return Interfaces.C.unsigned; + pragma Import (C, fl_enum_color_average, "fl_enum_color_average"); + pragma Inline (fl_enum_color_average); + + + + + -- Box Types -- + + function fl_enum_box + (B : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_enum_box, "fl_enum_box"); + pragma Inline (fl_enum_box); + + function fl_enum_frame + (B : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_enum_frame, "fl_enum_frame"); + pragma Inline (fl_enum_frame); + + function fl_enum_down + (B : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_enum_down, "fl_enum_down"); + pragma Inline (fl_enum_down); + + -- Fl.H -- + -- Versioning -- function fl_abi_check @@ -64,21 +179,6 @@ package body FLTK is - -- Drawing -- - - function fl_get_damage - return Interfaces.C.int; - pragma Import (C, fl_get_damage, "fl_get_damage"); - pragma Inline (fl_get_damage); - - procedure fl_set_damage - (V : in Interfaces.C.int); - pragma Import (C, fl_set_damage, "fl_set_damage"); - pragma Inline (fl_set_damage); - - - - -- Event Loop -- function fl_check @@ -98,7 +198,7 @@ package body FLTK is function fl_wait2 (S : in Interfaces.C.double) - return Interfaces.C.int; + return Interfaces.C.double; pragma Import (C, fl_wait2, "fl_wait2"); pragma Inline (fl_wait2); @@ -129,6 +229,26 @@ package body FLTK is -- Color -- function RGB_Color + (Light : in Greyscale) + return Color is + begin + case Light is + when 'A' .. 'W' => return Color (fl_enum_rgb_color2 + ((Greyscale'Pos (Light) - Greyscale'Pos (Greyscale'First)) * 11)); + when 'X' => return Color (fl_enum_rgb_color2 (255)); + end case; + end RGB_Color; + + + function RGB_Color + (Light : in Color_Component) + return Color is + begin + return Color (fl_enum_rgb_color2 (Interfaces.C.unsigned_char (Light))); + end RGB_Color; + + + function RGB_Color (R, G, B : in Color_Component) return Color is begin @@ -139,6 +259,50 @@ package body FLTK is end RGB_Color; + function Color_Cube + (R, G, B : in Color_Component) + return Color is + begin + return Color (fl_enum_color_cube + (Interfaces.C.int (Float'Rounding (Float (R) * Float (fl_enum_num_red - 1) / 255.0)), + Interfaces.C.int (Float'Rounding (Float (G) * Float (fl_enum_num_green - 1) / 255.0)), + Interfaces.C.int (Float'Rounding (Float (B) * Float (fl_enum_num_blue - 1) / 255.0)))); + end Color_Cube; + + + function Grey_Ramp + (Light : in Greyscale) + return Color is + begin + return Color (fl_enum_gray_ramp (Greyscale'Pos (Light) - Greyscale'Pos (Greyscale'First))); + end Grey_Ramp; + + + function Grey_Ramp + (Light : in Color_Component) + return Color is + begin + return Color (fl_enum_gray_ramp (Interfaces.C.int + (Float'Rounding (Float (Light) * Float (fl_enum_num_gray - 1) / 255.0)))); + end Grey_Ramp; + + + function Darker + (Tone : in Color) + return Color is + begin + return Color (fl_enum_darker (Interfaces.C.unsigned (Tone))); + end Darker; + + + function Lighter + (Tone : in Color) + return Color is + begin + return Color (fl_enum_lighter (Interfaces.C.unsigned (Tone))); + end Lighter; + + function Contrast (Fore, Back : in Color) return Color is @@ -149,6 +313,26 @@ package body FLTK is end Contrast; + function Inactive + (Tone : in Color) + return Color is + begin + return Color (fl_enum_inactive (Interfaces.C.unsigned (Tone))); + end Inactive; + + + function Color_Average + (Tone1, Tone2 : in Color; + Weight : in Blend := 0.5) + return Color is + begin + return Color (fl_enum_color_average + (Interfaces.C.unsigned (Tone1), + Interfaces.C.unsigned (Tone2), + Interfaces.C.C_float (Weight))); + end Color_Average; + + -- Alignment -- @@ -165,7 +349,7 @@ package body FLTK is (Left, Right : in Alignment) return Alignment is begin - return Left and (not Right); + return Left and not Right; end "-"; @@ -283,14 +467,14 @@ package body FLTK is function To_C (Key : in Key_Combo) - return Interfaces.C.int is + return Interfaces.C.unsigned is begin return To_C (Key.Modcode) + To_C (Key.Keycode) + To_C (Key.Mousecode); end To_C; function To_Ada - (Key : in Interfaces.C.int) + (Key : in Interfaces.C.unsigned) return Key_Combo is begin return Result : Key_Combo do @@ -303,14 +487,14 @@ package body FLTK is function To_C (Key : in Keypress) - return Interfaces.C.int is + return Interfaces.C.unsigned is begin - return Interfaces.C.int (Key); + return Interfaces.C.unsigned (Key); end To_C; function To_Ada - (Key : in Interfaces.C.int) + (Key : in Interfaces.C.unsigned) return Keypress is begin return Keypress (Key mod 65536); @@ -319,14 +503,14 @@ package body FLTK is function To_C (Modi : in Modifier) - return Interfaces.C.int is + return Interfaces.C.unsigned is begin - return Interfaces.C.int (Modi) * 65536; + return Interfaces.C.unsigned (Modi) * 65536; end To_C; function To_Ada - (Modi : in Interfaces.C.int) + (Modi : in Interfaces.C.unsigned) return Modifier is begin return Modifier ((Modi / 65536) mod 256); @@ -335,42 +519,177 @@ package body FLTK is function To_C (Button : in Mouse_Button) - return Interfaces.C.int is + return Interfaces.C.unsigned is begin case Button is - when Left_Button => return 1 * (256 ** 3); - when Middle_Button => return 2 * (256 ** 3); - when Right_Button => return 4 * (256 ** 3); - when others => return 0; + when No_Button => return 0; + when Left_Button => return fl_enum_button1; + when Middle_Button => return fl_enum_button2; + when Right_Button => return fl_enum_button3; + when Back_Button => return fl_enum_button4; + when Forward_Button => return fl_enum_button5; + when Any_Button => return fl_enum_buttons; end case; end To_C; function To_Ada - (Button : in Interfaces.C.int) + (Button : in Interfaces.C.unsigned) return Mouse_Button is begin - case (Button / (256 ** 3)) is - when 1 => return Left_Button; - when 2 => return Middle_Button; - when 4 => return Right_Button; - when others => return No_Button; - end case; + if Button = 0 then + return No_Button; + elsif Button = fl_enum_button1 then + return Left_Button; + elsif Button = fl_enum_button2 then + return Middle_Button; + elsif Button = fl_enum_button3 then + return Right_Button; + elsif Button = fl_enum_button4 then + return Back_Button; + elsif Button = fl_enum_button5 then + return Forward_Button; + elsif Button = fl_enum_buttons then + return Any_Button; + else + raise Constraint_Error; + end if; end To_Ada; + -- Box Types -- + + function Filled + (Box : in Box_Kind) + return Box_Kind + is + Result : constant Interfaces.C.int := fl_enum_box (Box_Kind'Pos (Box)); + begin + return Box_Kind'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_box in Enumerations.H returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end Filled; + + + function Frame + (Box : in Box_Kind) + return Box_Kind + is + Result : constant Interfaces.C.int := fl_enum_frame (Box_Kind'Pos (Box)); + begin + return Box_Kind'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_frame in Enumerations.H returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end Frame; + + + function Down + (Box : in Box_Kind) + return Box_Kind + is + Result : constant Interfaces.C.int := fl_enum_down (Box_Kind'Pos (Box)); + begin + return Box_Kind'Val (Result); + exception + when Constraint_Error => raise Internal_FLTK_Error with + "fl_down in Enumerations.H returned unexpected int value of " & + Interfaces.C.int'Image (Result); + end Down; + + + + + -- Callback Flags -- + + type Callback_Bitmask is mod 2 ** Interfaces.C.unsigned_char'Size; + + function CFlag_To_Bits is new + Ada.Unchecked_Conversion (Callback_Flag, Callback_Bitmask); + + function Bits_To_CFlag is new + Ada.Unchecked_Conversion (Callback_Bitmask, Callback_Flag); + + + function "+" + (Left, Right : in Callback_Flag) + return Callback_Flag is + begin + return Bits_To_CFlag (CFlag_To_Bits (Left) or CFlag_To_Bits (Right)); + end "+"; + + + function "-" + (Left, Right : in Callback_Flag) + return Callback_Flag is + begin + return Bits_To_CFlag (CFlag_To_Bits (Left) and not CFlag_To_Bits (Right)); + end "-"; + + + + -- Menu Flags -- + type Menu_Bitmask is mod 2 ** Interfaces.C.int'Size; + + function MFlag_To_Bits is new + Ada.Unchecked_Conversion (Menu_Flag, Menu_Bitmask); + + function Bits_To_MFlag is new + Ada.Unchecked_Conversion (Menu_Bitmask, Menu_Flag); + + function "+" (Left, Right : in Menu_Flag) return Menu_Flag is begin - return Left or Right; + return Bits_To_MFlag (MFlag_To_Bits (Left) or MFlag_To_Bits (Right)); + end "+"; + + + function "-" + (Left, Right : in Menu_Flag) + return Menu_Flag is + begin + return Bits_To_MFlag (MFlag_To_Bits (Left) and not MFlag_To_Bits (Right)); + end "-"; + + + + + -- Damage Bits -- + + type Damage_Bitmask is mod 2 ** Interfaces.C.unsigned_char'Size; + + function Damage_To_Bits is new + Ada.Unchecked_Conversion (Damage_Mask, Damage_Bitmask); + + function Bits_To_Damage is new + Ada.Unchecked_Conversion (Damage_Bitmask, Damage_Mask); + + + function "+" + (Left, Right : in Damage_Mask) + return Damage_Mask is + begin + return Bits_To_Damage (Damage_To_Bits (Left) or Damage_To_Bits (Right)); end "+"; + function "-" + (Left, Right : in Damage_Mask) + return Damage_Mask is + begin + return Bits_To_Damage (Damage_To_Bits (Left) and not Damage_To_Bits (Right)); + end "-"; + + -- Versioning -- @@ -406,26 +725,16 @@ package body FLTK is - -- Drawing -- - - function Is_Damaged - return Boolean is - begin - return fl_get_damage /= 0; - end Is_Damaged; - + -- Event Loop -- - procedure Set_Damaged - (To : in Boolean) is + procedure Check + is + Ignore : Interfaces.C.int := fl_check; begin - fl_set_damage (Boolean'Pos (To)); - end Set_Damaged; - - + null; + end Check; - -- Event Loop -- - function Check return Boolean is begin @@ -449,9 +758,9 @@ package body FLTK is function Wait (Seconds : in Long_Float) - return Integer is + return Long_Float is begin - return Integer (fl_wait2 (Interfaces.C.double (Seconds))); + return Long_Float (fl_wait2 (Interfaces.C.double (Seconds))); end Wait; diff --git a/doc/enumerations.html b/doc/enumerations.html new file mode 100644 index 0000000..6e4f521 --- /dev/null +++ b/doc/enumerations.html @@ -0,0 +1,302 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Enumerations Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Enumerations Binding Map</h2> + + +<a href="index.html">Back to Index</a> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Enumerations</td> + <td>FLTK</td> + </tr> + + <tr> + <td>fl_types</td> + <td> </td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Color</td> + <td>Greyscale</td> + </tr> + + <tr> + <td>Fl_Color</td> + <td>Color</td> + </tr> + + <tr> + <td>unsigned char</td> + <td>Color_Component</td> + </tr> + + <tr> + <td>unsigned char *</td> + <td>Color_Component_Array</td> + </tr> + + <tr> + <td>float</td> + <td>Blend</td> + </tr> + + <tr> + <td>Fl_Align</td> + <td>Alignment</td> + </tr> + + <tr> + <td>Fl_Cursor</td> + <td>Mouse_Cursor_Kind</td> + </tr> + + <tr> + <td>short</td> + <td>Keypress</td> + </tr> + + <tr> + <td> + #define FL_BUTTON1 0x01000000<br /> + #define FL_BUTTON2 0x02000000<br /> + #define FL_BUTTON3 0x04000000<br /> + #define FL_BUTTONS 0x7f000000 + </td> + <td>Mouse_Button</td> + </tr> + + <tr> + <td>short</td> + <td>Modifier</td> + </tr> + + <tr> + <td>Fl_Shortcut</td> + <td>Key_Combo</td> + </tr> + + <tr> + <td>Fl_Boxtype</td> + <td>Box_Kind</td> + </tr> + + <tr> + <td>Fl_Font</td> + <td>Font_Kind</td> + </tr> + + <tr> + <td>Fl_Fontsize</td> + <td>Font_Size</td> + </tr> + + <tr> + <td>Fl_Fontsize *</td> + <td>Font_Size_Array</td> + </tr> + + <tr> + <td>Fl_Labeltype</td> + <td>Label_Kind</td> + </tr> + + <tr> + <td>Fl_Event</td> + <td>Event_Kind</td> + </tr> + + <tr> + <td>int</td> + <td>Event_Outcome</td> + </tr> + + <tr> + <td>Fl_When</td> + <td>Callback_Flag</td> + </tr> + + <tr> + <td>Fl_Damage</td> + <td>Damage_Mask</td> + </tr> + + <tr> + <td>int</td> + <td>Version_Number</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td><pre> +inline Fl_Boxtype fl_box(Fl_Boxtype b); +</pre></td> +<td><pre> +function Filled + (Box : in Box_Kind) + return Box_Kind; +</pre></td> + </tr> + + <tr> +<td><pre> +Fl_Color fl_color_average(Fl_Color c1, Fl_Color c2, float weight); +</pre></td> +<td><pre> +function Color_Average + (Tone1, Tone2 : in Color; + Weight : in Blend := 0.5) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_color_cube(int r, int g, int b); +</pre></td> +<td><pre> +function Color_Cube + (R, G, B : in Color_Component) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg); +</pre></td> +<td><pre> +function Contrast + (Fore, Back : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_darker(Fl_Color c); +</pre></td> +<td><pre> +function Darker + (Tone : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Boxtype fl_down(Fl_Boxtype b); +</pre></td> +<td><pre> +function Down + (Box : in Box_Kind) + return Box_Kind; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Boxtype fl_frame(Fl_Boxtype b); +</pre></td> +<td><pre> +function Frame + (Box : in Box_Kind) + return Box_Kind; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_gray_ramp(int i); +</pre></td> +<td><pre> +function Grey_Ramp + (Light : in Greyscale) + return Color; + +function Grey_Ramp + (Light : in Color_Component) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +Fl_Color fl_inactive(Fl_Color c); +</pre></td> +<td><pre> +function Inactive + (Tone : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_lighter(Fl_Color c); +</pre></td> +<td><pre> +function Lighter + (Tone : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_rgb_color(uchar g); +</pre></td> +<td><pre> +function RGB_Color + (Light : in Greyscale) + return Color; + +function RGB_Color + (Light : in Color_Component) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +inline Fl_Color fl_rgb_color(uchar r, uchar g, uchar b); +</pre></td> +<td><pre> +function RGB_Color + (R, G, B : in Color_Component) + return Color; +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/fl.html b/doc/fl.html index db60f5b..96bb11d 100644 --- a/doc/fl.html +++ b/doc/fl.html @@ -24,31 +24,6 @@ <td>FLTK</td> </tr> - <tr> - <td> </td> - <td>FLTK.Errors</td> - </tr> - - <tr> - <td> </td> - <td>FLTK.Event</td> - </tr> - - <tr> - <td> </td> - <td>FLTK.Screen</td> - </tr> - - <tr> - <td> </td> - <td>FLTK.Static</td> - </tr> - - <tr> - <td>Enumerations</td> - <td> </td> - </tr> - </table> @@ -57,183 +32,33 @@ <tr><th colspan="2">Types</th></tr> <tr> - <td>Fl_Option</td> - <td>Option</td> - </tr> - - <tr> - <td>Fl_Color</td> - <td>Color</td> - </tr> - - <tr> - <td>Fl_Align</td> - <td>Alignment</td> - </tr> - - <tr> - <td> </td> - <td>Keypress</td> - </tr> - - <tr> - <td> </td> - <td>Mouse_Button</td> - </tr> - - <tr> - <td> </td> - <td>Modifier</td> - </tr> - - <tr> - <td>Fl_Shortcut</td> - <td>Key_Combo</td> + <td>void *</td> + <td>Wrapper</td> </tr> <tr> - <td>Fl_Boxtype</td> - <td>Box_Kind</td> - </tr> - - <tr> - <td>Fl_Font</td> - <td>Font_Kind</td> - </tr> - - <tr> - <td>Fl_Fontsize</td> - <td>Font_Size</td> - </tr> - - <tr> - <td> </td> - <td>Font_Size_Array</td> - </tr> - - <tr> - <td>Fl_Labeltype</td> - <td>Label_Kind</td> - </tr> - - <tr> - <td> </td> - <td>Event_Kind</td> - </tr> - - <tr> - <td> </td> - <td>Event_Outcome</td> - </tr> - - <tr> - <td> </td> + <td>enum {<br /> + FL_MENU_INACTIVE = 1,<br /> + FL_MENU_TOGGLE = 2,<br /> + FL_MENU_VALUE = 4,<br /> + FL_MENU_RADIO = 8,<br /> + FL_MENU_INVISIBLE = 0x10,<br /> + FL_SUBMENU_POINTER = 0x20,<br /> + FL_SUBMENU = 0x40,<br /> + FL_MENU_DIVIDER = 0x80,<br /> + FL_MENU_HORIZONTAL = 0x100 }<br /> + </td> <td>Menu_Flag</td> </tr> <tr> - <td> </td> - <td>Version_Number</td> - </tr> - - <tr> - <td>Fl_Event_Handler</td> - <td>Event_Handler</td> - </tr> - - <tr> - <td>Fl_Event_Dispatch</td> - <td>TBA</td> - </tr> - - <tr> - <td>Fl_Awake_Handler</td> - <td>Awake_Handler</td> + <td>size_t</td> + <td>Size_Type</td> </tr> <tr> - <td>Fl_Timeout_Handler</td> - <td>Timeout_Handler</td> - </tr> - - <tr> - <td>Fl_Idle_Handler</td> - <td>Idle_Handler</td> - </tr> - - <tr> - <td> </td> - <td>Buffer_Kind</td> - </tr> - - <tr> - <td>Fl_Clipboard_Notify_Handler</td> - <td>Clipboard_Notify_Handler</td> - </tr> - - <tr> - <td>FL_SOCKET</td> - <td>File_Descriptor</td> - </tr> - - <tr> - <td> </td> - <td>File_Mode</td> - </tr> - - <tr> - <td>Fl_FD_Handler</td> - <td>File_Handler</td> - </tr> - - <tr> - <td>Fl_Box_Draw_F</td> - <td>Box_Draw_Function</td> - </tr> - - <tr> - <td>Fl_Abort_Handler</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Args_Handler</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Atclose_Handler</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Label_Draw_F</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Label_Measure_F</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Old_Idle_Handler</td> - <td> </td> - </tr> - - <tr> - <td>Fl_System_Handler</td> - <td> </td> - </tr> - - <tr> - <td>Fl_Cursor</td> - <td>Mouse_Cursor</td> - </tr> - - <tr> - <td> </td> - <td>Error_Function</td> + <td>size_t</td> + <td>Positive_Size</td> </tr> </table> @@ -253,77 +78,24 @@ <table class="function"> - <tr><th colspan="2">Attributes</th></tr> - - <tr> -<td><pre> -static void (*atclose)(Fl_Window *, void *); -</pre></td> -<td>Deprecated, set the callback for the Window instead</td> - </tr> + <tr><th colspan="2">Static Attributes</th></tr> <tr> <td><pre> static char const * const clipboard_image = "image"; </pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static char const * const clipboard_plain_text = "text/plain"; -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void (*error)(const char *, ...) = ::error; -</pre></td> -<td><pre> -procedure Default_Error - (Message : in String); - -Current_Error : Error_Function := Default_Error'Access; -</pre>(In FLTK.Errors)</td> - </tr> - - <tr> -<td><pre> -static void (*fatal)(const char *, ...) = ::fatal; -</pre></td> -<td><pre> -procedure Default_Fatal - (Message : in String); - -Current_Fatal : Error_Function := Default_Fatal'Access; -</pre>(In FLTK.Errors)</td> - </tr> - - <tr> <td><pre> -static const char * const help = helpmsg + 13; +Clipboard_Image : constant String; </pre></td> -<td> </td> </tr> <tr> <td><pre> -static void (*idle)(); +static char const * const clipboard_plain_text = "text/plain"; </pre></td> -<td>Should not be used directly</td> - </tr> - - <tr> <td><pre> -static void (*warning)(const char *, ...) = ::warning; +Clipboard_Plain_Text : constant String; </pre></td> -<td><pre> -procedure Default_Warning - (Message : in String); - -Current_Warning : Error_Function := Default_Warning'Access; -</pre>(In FLTK.Errors)</td> </tr> </table> @@ -331,7 +103,7 @@ Current_Warning : Error_Function := Default_Warning'Access; <table class="function"> - <tr><th colspan="2">Functions and Procedures</th></tr> + <tr><th colspan="2">Static Functions and Procedures</th></tr> <tr> <td><pre> @@ -356,97 +128,6 @@ function ABI_Version <tr> <td><pre> -static int add_awake_handler_(Fl_Awake_Handler, void *); -</pre></td> -<td><pre> -procedure Add_Awake_Handler - (Func : in Awake_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_check(Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -procedure Add_Check - (Func : in Timeout_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data=0); -</pre></td> -<td><pre> -procedure Add_Clipboard_Notify - (Func : in Clipboard_Notify_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_fd(int fd, int when, Fl_FD_Handler cb, void *=0); -</pre></td> -<td><pre> -procedure Add_File_Descriptor - (FD : in File_Descriptor; - Mode : in File_Mode; - Func : in File_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_fd(int fd, Fl_FD_Handler cb, void *=0); -</pre></td> -<td><pre> -procedure Add_File_Descriptor - (FD : in File_Descriptor; - Func : in File_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_handler(Fl_Event_Handler h); -</pre></td> -<td><pre> -procedure Add_Handler - (Func : in Event_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_idle(Fl_Idle_Handler cb, void *data=0); -</pre></td> -<td><pre> -procedure Add_Idle - (Func : in Idle_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void add_system_handler(Fl_System_Handler h, void *data); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void add_timeout(double t, Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -procedure Add_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> static int api_version(); </pre></td> <td><pre> @@ -457,134 +138,6 @@ function API_Version <tr> <td><pre> -static int arg(int argc, char **argv, int &i); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int args(int argc, char **argv, int &i, Fl_Args_Handler cb=0); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void args(int argc, char **argv); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void awake(void *message=0); -</pre></td> -<td><pre> -procedure Awake; -</pre></td> - </tr> - - <tr> -<td><pre> -static int awake(Fl_Awake_Handler cb, void *message=0); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void background(uchar, uchar, uchar); -</pre></td> -<td><pre> -procedure Set_Background - (R, G, B : in Color_Component); -</pre></td> - </tr> - - <tr> -<td><pre> -static void background2(uchar, uchar, uchar); -</pre></td> -<td><pre> -procedure Set_Alt_Background - (R, G, B : in Color_Component); -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Widget * belowmouse(); -</pre></td> -<td><pre> -function Get_Below_Mouse - return access FLTK.Widgets.Widget'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static void belowmouse(Fl_Widget *); -</pre></td> -<td><pre> -procedure Set_Below_Mouse - (To : in FLTK.Widgets.Widget'Class); -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Color box_color(Fl_Color); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int box_dh(Fl_Boxtype); -</pre></td> -<td><pre> -function Get_Box_Height_Offset - (Kind : in Box_Kind) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int box_dw(Fl_Boxtype); -</pre></td> -<td><pre> -function Get_Box_Width_Offset - (Kind : in Box_Kind) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int box_dx(Fl_Boxtype); -</pre></td> -<td><pre> -function Get_Box_X_Offset - (Kind : in Box_Kind) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int box_dy(Fl_Boxtype); -</pre></td> -<td><pre> -function Get_Box_Y_Offset - (Kind : in Box_Kind) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> static void cairo_autolink_context(bool alink); </pre></td> <td> </td> @@ -623,6 +176,8 @@ static cairo_t * cairo_make_current(Fl_Window *w); static int check(); </pre></td> <td><pre> +procedure Check; + function Check return Boolean; </pre></td> @@ -632,637 +187,21 @@ function Check <td><pre> static void clear_widget_pointer(Fl_Widget const *w); </pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int clipboard_contains(const char *type); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int compose(int &del); -</pre></td> -<td><pre> -function Compose - (Del : out Natural) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void compose_reset(); -</pre></td> -<td><pre> -procedure Compose_Reset; -</pre></td> - </tr> - - <tr> -<td><pre> -static void copy - (const char *stuff, int len, int destination=0, - const char *type=Fl::clipboard_plain_text); -</pre></td> -<td><pre> -procedure Copy - (Text : in String; - Dest : in Buffer_Kind); -</pre></td> - </tr> - - <tr> -<td><pre> -static void damage(int d); -</pre></td> -<td><pre> -procedure Set_Damaged - (To : in Boolean); -</pre></td> - </tr> - - <tr> -<td><pre> -static int damage(); -</pre></td> -<td><pre> -function Is_Damaged - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void default_atclose(Fl_Window *, void *); -</pre></td> -<td><pre> -procedure Default_Window_Close - (Item : in out FLTK.Widgets.Widget'Class); -</pre></td> +<td>Marked as internal use only.</td> </tr> <tr> <td><pre> static void delete_widget(Fl_Widget *w); </pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void disable_im(); -</pre></td> -<td><pre> -procedure Disable_System_Input; -</pre></td> - </tr> - - <tr> -<td><pre> -static void display(const char *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int dnd(); -</pre></td> -<td><pre> -procedure Drag_Drop_Start; -</pre></td> - </tr> - - <tr> -<td><pre> -static void dnd_text_ops(int v); -</pre></td> -<td><pre> -procedure Set_Drag_Drop_Text_Support - (To : in Boolean); -</pre></td> - </tr> - - <tr> -<td><pre> -static int dnd_text_ops(); -</pre></td> -<td><pre> -function Get_Drag_Drop_Text_Support - return Boolean; -</pre></td> +<td>Used automatically as appropriate by the binding.</td> </tr> <tr> <td><pre> static void do_widget_deletion(); </pre></td> -<td><pre> -procedure Do_Widget_Deletion; -</pre></td> - </tr> - - <tr> -<td><pre> -static int draw_box_active(); -</pre></td> -<td><pre> -function Draw_Box_Active - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void enable_im(); -</pre></td> -<td><pre> -procedure Enable_System_Input; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event(); -</pre></td> -<td><pre> -function Last - return Event_Kind; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_alt(); -</pre></td> -<td><pre> -function Key_Alt - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_button(); -</pre></td> -<td><pre> -function Last_Button - return Mouse_Button; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_button1(); -</pre></td> -<td><pre> -function Mouse_Left - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_button2(); -</pre></td> -<td><pre> -function Mouse_Middle - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_button3(); -</pre></td> -<td><pre> -function Mouse_Right - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_buttons(); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int event_clicks(); -</pre></td> -<td><pre> -function Is_Multi_Click - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void event_clicks(int i); -</pre></td> -<td><pre> -procedure Set_Clicks - (To : in Natural); -</pre></td> - </tr> - - <tr> -<td><pre> -static void * event_clipboard(); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static const char * event_clipboard_type(); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int event_command(); -</pre></td> -<td><pre> -function Key_Command - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_ctrl(); -</pre></td> -<td><pre> -function Key_Ctrl - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void event_dispatch(Fl_Event_Dispatch d); -</pre></td> -<td>TBA</td> - </tr> - - <tr> -<td><pre> -static Fl_Event_Dispatch event_dispatch(); -</pre></td> -<td>TBA</td> - </tr> - - <tr> -<td><pre> -static int event_dx(); -</pre></td> -<td><pre> -function Mouse_DX - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_dy(); -</pre></td> -<td><pre> -function Mouse_DY - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_inside(int, int, int, int); -</pre></td> -<td><pre> -function Is_Inside - (X, Y, W, H : in Integer) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_inside(const Fl_Widget *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int event_is_click(); -</pre></td> -<td><pre> -function Is_Click - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void event_is_click(int i); -</pre></td> -<td>See static void event_clicks(int i);</td> - </tr> - - <tr> -<td><pre> -static int event_key(); -</pre></td> -<td><pre> -function Last_Key - return Keypress; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_key(int key); -</pre></td> -<td><pre> -function Pressed_During - (Key : in Keypress) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_length(); -</pre></td> -<td><pre> -function Text_Length - return Natural; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_original_key(); -</pre></td> -<td><pre> -function Original_Last_Key - return Keypress; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_shift(); -</pre></td> -<td><pre> -function Key_Shift - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_state(); -</pre></td> -<td><pre> -function Last_Modifier - return Modifier; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_state(int mask); -</pre></td> -<td><pre> -function Last_Modifier - (Had : in Modifier) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static const char * event_text(); -</pre></td> -<td><pre> -function Text - return String; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_x(); -</pre></td> -<td><pre> -function Mouse_X - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_x_root(); -</pre></td> -<td><pre> -function Mouse_X_Root - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_y(); -</pre></td> -<td><pre> -function Mouse_Y - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int event_y_root(); -</pre></td> -<td><pre> -function Mouse_Y_Root - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Window * first_window(); -</pre></td> -<td><pre> -function Get_First_Window - return access FLTK.Widgets.Groups.Windows.Window'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static void first_window(Fl_Window *); -</pre></td> -<td><pre> -procedure Set_First_Window - (To : in FLTK.Widgets.Groups.Windows.Window'Class); -</pre></td> - </tr> - - <tr> -<td><pre> -static void flush(); -</pre></td> -<td><pre> -procedure Flush; -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Widget * focus(); -</pre></td> -<td><pre> -function Get_Focus - return access FLTK.Widgets.Widget'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static void focus(Fl_Widget *); -</pre></td> -<td><pre> -procedure Set_Focus - (To : in FLTK.Widgets.Widget'Class); -</pre></td> - </tr> - - <tr> -<td><pre> -static void foreground(uchar, uchar, uchar); -</pre></td> -<td><pre> -procedure Set_Foreground - (R, G, B : in Color_Component); -</pre></td> - </tr> - - <tr> -<td><pre> -static void free_color(Fl_Color i, int overlay=0); -</pre></td> -<td><pre> -procedure Free_Color - (Value : in Color; - Overlay : in Boolean := False); -</pre></td> - </tr> - - <tr> -<td><pre> -static int get_awake_handler_(Fl_Awake_Handler &, void *&); -</pre></td> -<td><pre> -function Get_Awake_Handler - return Awake_Handler; -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Box_Draw_F * get_boxtype(Fl_Boxtype); -</pre></td> -<td>TBA</td> - </tr> - - <tr> -<td><pre> -static unsigned get_color(Fl_Color i); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue); -</pre></td> -<td><pre> -procedure Get_Color - (From : in Color; - R, G, B : out Color_Component); -</pre></td> - </tr> - - <tr> -<td><pre> -static const char * get_font(Fl_Font); -</pre></td> -<td><pre> -function Font_Image - (Kind : in Font_Kind) - return String; -</pre></td> - </tr> - - <tr> -<td><pre> -static const char * get_font_name(Fl_Font, int *attributes=0); -</pre></td> -<td><pre> -function Font_Family_Image - (Kind : in Font_Kind) - return String; -</pre></td> - </tr> - - <tr> -<td><pre> -static int get_font_sizes(Fl_Font, int *&sizep); -</pre></td> -<td><pre> -function Font_Sizes - (Kind : in Font_Kind) - return Font_Size_Array; -</pre></td> - </tr> - - <tr> -<td><pre> -static int get_key(int key); -</pre></td> -<td><pre> -function Key_Now - (Key : in Keypress) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void get_mouse(int &, int &); -</pre></td> -<td><pre> -procedure Get_Mouse - (X, Y : out Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void get_system_colors(); -</pre></td> -<td><pre> -procedure System_Colors; -</pre></td> +<td>Marked as internal use only.</td> </tr> <tr> @@ -1274,200 +213,6 @@ static int gl_visual(int, int *alist=0); <tr> <td><pre> -static Fl_Window * grab(); -</pre></td> -<td><pre> -function Get_Grab - return access FLTK.Widgets.Groups.Windows.Window'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static void grab(Fl_Window *); -static void grab(Fl_Window &win); -</pre></td> -<td><pre> -procedure Set_Grab - (To : in FLTK.Widgets.Groups.Windows.Window'Class); -</pre></td> - </tr> - - <tr> -<td><pre> -static int h(); -</pre></td> -<td><pre> -function Get_H - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int handle(int, Fl_Window *); -static int handle_(int, Fl_Window *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int has_check(Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -function Has_Check - (Func : in Timeout_Handler) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int has_idle(Fl_Idle_Handler cb, void *data=0); -</pre></td> -<td><pre> -function Has_Idle - (Func : in Idle_Handler) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int has_timeout(Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -function Has_Timeout - (Func : in Timeout_Handler) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int is_scheme(const char *name); -</pre></td> -<td><pre> -function Is_Scheme - (Scheme : in String) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int lock(); -</pre></td> -<td><pre> -procedure Lock; -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Window * modal(); -</pre></td> -<td><pre> -function Get_Top_Modal - return access FLTK.Widgets.Groups.Windows.Window'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Window * next_window(const Fl_Window *); -</pre></td> -<td><pre> -function Get_Next_Window - (From : in FLTK.Widgets.Groups.Windows.Window'Class) - return access FLTK.Widgets.Groups.Windows.Window'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static bool option(Fl_Option opt); -</pre></td> -<td><pre> -function Get_Option - (Opt : in Option) - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static void option(Fl_Option opt, bool val); -</pre></td> -<td><pre> -procedure Set_Option - (Opt : in Option; - To : in Boolean); -</pre></td> - </tr> - - <tr> -<td><pre> -static void own_colormap(); -</pre></td> -<td><pre> -procedure Own_Colormap; -</pre></td> - </tr> - - <tr> -<td><pre> -static void paste - (Fl_Widget &receiver, int source, - const char *type=Fl::clipboard_plain_text); -</pre></td> -<td><pre> -procedure Paste - (Receiver : in FLTK.Widgets.Widget'Class; - Source : in Buffer_Kind); -</pre></td> - </tr> - - <tr> -<td><pre> -static void paste(Fl_Widget &receiver); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static Fl_Widget * pushed(); -</pre></td> -<td><pre> -function Get_Pushed - return access FLTK.Widgets.Widget'Class; -</pre></td> - </tr> - - <tr> -<td><pre> -static void pushed(Fl_Widget *); -</pre></td> -<td><pre> -procedure Set_Pushed - (To : in FLTK.Widgets.Widget'Class); -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Widget * readqueue(); -</pre></td> -<td><pre> -function Read_Queue - return access FLTK.Widgets.Widget'Class; -</pre></td> - </tr> - - <tr> -<td><pre> static int ready(); </pre></td> <td><pre> @@ -1478,125 +223,9 @@ function Ready <tr> <td><pre> -static void redraw(); -</pre></td> -<td><pre> -procedure Redraw; -</pre></td> - </tr> - - <tr> -<td><pre> -static void release(); -</pre></td> -<td><pre> -procedure Release_Grab; -</pre></td> - </tr> - - <tr> -<td><pre> static void release_widget_pointer(Fl_Widget *&w); </pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int reload_scheme(); -</pre></td> -<td><pre> -procedure Reload_Scheme; -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_check(Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -procedure Remove_Check - (Func : in Timeout_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h); -</pre></td> -<td><pre> -procedure Remove_Clipboard_Notify - (Func : in Clipboard_Notify_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_fd(int, int when); -</pre></td> -<td><pre> -procedure Remove_File_Descriptor - (FD : in File_Descriptor; - Mode : in File_Mode); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_fd(int); -</pre></td> -<td><pre> -procedure Remove_File_Descriptor - (FD : in File_Descriptor); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_handler(Fl_Event_Handler h); -</pre></td> -<td><pre> -procedure Remove_Handler - (Func : in Event_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_idle(Fl_Idle_Handler cb, void *data=0); -</pre></td> -<td><pre> -procedure Remove_Idle - (Func : in Idle_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static void remove_system_handler(Fl_System_Handler h); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void remove_timeout(Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -procedure Remove_Timeout - (Func : in Timeout_Handler); -</pre></td> - </tr> - - <tr> -<td><pre> -static repeat_timeout(double t, Fl_Timeout_Handler, void *=0); -</pre></td> -<td><pre> -procedure Repeat_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler); -</pre></td> +<td>Marked as internal use only.</td> </tr> <tr> @@ -1611,326 +240,25 @@ function Run <tr> <td><pre> -static int scheme(const char *name); -</pre></td> -<td><pre> -procedure Set_Scheme - (To : in String); -</pre></td> - </tr> - - <tr> -<td><pre> -static const char * scheme(); -</pre></td> -<td><pre> -function Get_Scheme - return String; -</pre></td> - </tr> - - <tr> -<td><pre> -static int screen_count(); -</pre></td> -<td><pre> -function Count - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_dpi(float &h, float &v, int n=0); -</pre></td> -<td><pre> -procedure DPI - (Horizontal, Vertical : out Float; - Screen_Number : in Integer := 1); -</pre></td> - </tr> - - <tr> -<td><pre> -static int screen_num(int x, int y); -</pre></td> -<td><pre> -function Containing - (X, Y : in Integer) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int screen_num(int x, int y, int w, int h); -</pre></td> -<td><pre> -function Containing - (X, Y, W, H : in Integer) - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my); -</pre></td> -<td><pre> -procedure Work_Area - (X, Y, W, H : out Integer; - Pos_X, Pos_Y : in Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_work_area(int &X, int &Y, int &W, int &H, int n); -</pre></td> -<td><pre> -procedure Work_Area - (X, Y, W, H : out Integer; - Screen_Num : in Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_work_area(int &X, int &Y, int &W, int &H); -</pre></td> -<td><pre> -procedure Work_Area - (X, Y, W, H : out Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_xywh(int &X, int &Y, int &W, int &H); -</pre></td> -<td><pre> -procedure Bounding_Rect - (X, Y, W, H : out Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my); -</pre></td> -<td><pre> -procedure Bounding_Rect - (X, Y, W, H : out Integer; - Pos_X, Pos_Y : in Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_xywh(int &X, int &Y, int &W, int &H, int n); -</pre></td> -<td><pre> -procedure Bounding_Rect - (X, Y, W, H : out Integer; - Screen_Num : in Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh); -</pre></td> -<td><pre> -procedure Bounding_Rect - (X, Y, W, H : out Integer; - PX, PY, PW, PH : in Integer); -</pre></td> - </tr> - - <tr> -<td><pre> -static int scrollbar_size(); -</pre></td> -<td><pre> -function Get_Default_Scrollbar_Size - return Natural; -</pre></td> - </tr> - - <tr> -<td><pre> -static void scrollbar_size(int W); -</pre></td> -<td><pre> -procedure Set_Default_Scrollbar_Size - (To : in Natural); -</pre></td> - </tr> - - <tr> -<td><pre> -static void selection(Fl_Widget &owner, const char *, int len); -</pre></td> -<td><pre> -procedure Selection - (Owner : in FLTK.Widgets.Widget'Class; - Text : in String); -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Widget * selection_owner(); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void selection_owner(Fl_Widget *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_abort(Fl_Abort_Handler f); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_atclose(Fl_Atclose_Handler f); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_box_color(Fl_Color); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F *, uchar, uchar, uchar, uchar); -</pre></td> -<td>TBA</td> - </tr> - - <tr> -<td><pre> -static void set_boxtype(Fl_Boxtype, Fl_Boxtype from); -</pre></td> -<td><pre> -procedure Set_Box_Kind - (To, From : in Box_Kind); -</pre></td> - </tr> - - <tr> -<td><pre> -static void set_color(Fl_Color, uchar, uchar, uchar, uchar); -</pre></td> -<td><pre> -procedure Set_Color - (To : in Color; - R, G, B : in Color_Component); -</pre></td> - </tr> - - <tr> -<td><pre> -static void set_color(Fl_Color i, unsigned c); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_font(Fl_Font, const char *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_font(Fl_Font, Fl_Font); -</pre></td> -<td><pre> -procedure Set_Font_Kind - (To, From : in Font_Kind); -</pre></td> - </tr> - - <tr> -<td><pre> -static Fl_Font set_fonts(const char *=0); -</pre></td> -<td><pre> -procedure Setup_Fonts - (How_Many_Set_Up : out Natural); -</pre></td> - </tr> - - <tr> -<td><pre> -static void set_idle(Fl_Old_Idle_Handler cb); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_labeltype(Fl_Labeltype, Fl_Label_Draw_F *, FL_Label_Measure_F *); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int test_shortcut(Fl_Shortcut); +static void use_high_res_GL(int val); </pre></td> <td> </td> </tr> <tr> <td><pre> -static void * thread_message(); +static int use_high_res_GL(); </pre></td> <td> </td> </tr> <tr> -<td><pre> -static void unlock(); -</pre></td> -<td><pre> -procedure Unlock; -</pre></td> - </tr> - - <tr> -<td><pre> -static void use_high_res_GL(int val); -</pre></td> <td> </td> - </tr> - - <tr> <td><pre> -static int use_high_res_GL(); +function Is_Valid + (Object : in Wrapper) + return Boolean; </pre></td> -<td> </td> </tr> <tr> @@ -1945,43 +273,6 @@ function Version <tr> <td><pre> -static void visible_focus(int v); -</pre></td> -<td><pre> -procedure Set_Visible_Focus - (To : in Boolean); -</pre></td> - </tr> - - <tr> -<td><pre> -static int visible_focus(); -</pre></td> -<td><pre> -function Has_Visible_Focus - return Boolean; -</pre></td> - </tr> - - <tr> -<td><pre> -static int visual(int); -</pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int w(); -</pre></td> -<td><pre> -function Get_W - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> static int wait(); </pre></td> <td><pre> @@ -1997,7 +288,7 @@ static double wait(double time); <td><pre> function Wait (Seconds : in Long_Float) - return Integer; + return Long_Float; </pre></td> </tr> @@ -2005,27 +296,7 @@ function Wait <td><pre> static void watch_widget_pointer(Fl_Widget *&w); </pre></td> -<td> </td> - </tr> - - <tr> -<td><pre> -static int x(); -</pre></td> -<td><pre> -function Get_X - return Integer; -</pre></td> - </tr> - - <tr> -<td><pre> -static int y(); -</pre></td> -<td><pre> -function Get_Y - return Integer; -</pre></td> +<td>Marked as internal use only.</td> </tr> </table> diff --git a/doc/fl_(fltk-errors).html b/doc/fl_(fltk-errors).html new file mode 100644 index 0000000..7ccbe38 --- /dev/null +++ b/doc/fl_(fltk-errors).html @@ -0,0 +1,115 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl (FLTK.Errors) Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl (FLTK.Errors) Binding Map</h2> + + +<a href="index.html">Back to Index</a> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Fl</td> + <td>FLTK.Errors</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>void (*)(const char *, ...)</td> + <td>Error_Function</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Attributes</th></tr> + + <tr> +<td><pre> +static void (*error)(const char *, ...) = ::error; +</pre></td> +<td><pre> +Current_Error : Error_Function := Default_Error'Access; +</pre></td> + </tr> + + <tr> +<td><pre> +static void (*fatal)(const char *, ...) = ::fatal; +</pre></td> +<td><pre> +Current_Fatal : Error_Function := Default_Fatal'Access; +</pre></td> + </tr> + + <tr> +<td><pre> +static void (*warning)(const char *, ...) = ::warning; +</pre></td> +<td><pre> +Current_Warning : Error_Function := Default_Warning'Access; +</pre></td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td><pre> +static void error(const char *format, ...); +</pre></td> +<td><pre> +procedure Default_Error + (Message : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static void fatal(const char *format, ...); +</pre></td> +<td><pre> +procedure Default_Fatal + (Message : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static void warning(const char *, ...); +</pre></td> +<td><pre> +procedure Default_Warning + (Message : in String); +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/fl_(fltk-events).html b/doc/fl_(fltk-events).html new file mode 100644 index 0000000..6d17e85 --- /dev/null +++ b/doc/fl_(fltk-events).html @@ -0,0 +1,650 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl (FLTK.Events) Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl (FLTK.Events) Binding Map</h2> + + +<a href="index.html">Back to Index</a> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Fl</td> + <td>FLTK.Events</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Event_Handler</td> + <td>Event_Handler</td> + </tr> + + <tr> + <td>Fl_Event_Dispatch</td> + <td>Event_Dispatch</td> + </tr> + + <tr> + <td>void *</td> + <td>System_Event</td> + </tr> + + <tr> + <td>Fl_System_Handler</td> + <td>System_Handler</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td><pre> +static void add_handler(Fl_Event_Handler h); +</pre></td> +<td><pre> +procedure Add_Handler + (Func : in not null Event_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_system_handler(Fl_System_Handler h, + void *data); +</pre></td> +<td><pre> +procedure Add_System_Handler + (Func : in not null System_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Widget * belowmouse(); +</pre></td> +<td><pre> +function Get_Below_Mouse + return access FLTK.Widgets.Widget'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static void belowmouse(Fl_Widget *); +</pre></td> +<td><pre> +procedure Set_Below_Mouse + (To : in FLTK.Widgets.Widget'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static int compose(int &del); +</pre></td> +<td><pre> +function Compose + (Del : out Natural) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void compose_reset(); +</pre></td> +<td><pre> +procedure Compose_Reset; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event(); +</pre></td> +<td><pre> +function Last + return Event_Kind; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_alt(); +</pre></td> +<td><pre> +function Key_Alt + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button(); +</pre></td> +<td><pre> +function Last_Button + return Mouse_Button; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button1(); +</pre></td> +<td><pre> +function Mouse_Left + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button2(); +</pre></td> +<td><pre> +function Mouse_Middle + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button3(); +</pre></td> +<td><pre> +function Mouse_Right + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button4(); +</pre></td> +<td><pre> +function Mouse_Back + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_button5(); +</pre></td> +<td><pre> +function Mouse_Forward + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_buttons(); +</pre></td> +<td><pre> +procedure Mouse_Buttons + (Left, Middle, Right, Back, Forward : out Boolean); +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_clicks(); +</pre></td> +<td><pre> +function Is_Multi_Click + return Boolean; + +function Get_Clicks + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +static void event_clicks(int i); +</pre></td> +<td><pre> +procedure Set_Clicks + (To : in Natural); +</pre></td> + </tr> + + <tr> +<td><pre> +static void * event_clipboard(); +</pre></td> +<td><pre> +function Clipboard_Text + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static const char * event_clipboard_type(); +</pre></td> +<td><pre> +function Clipboard_Kind + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_command(); +</pre></td> +<td><pre> +function Key_Command + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_ctrl(); +</pre></td> +<td><pre> +function Key_Ctrl + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Event_Dispatch event_dispatch(); +</pre></td> +<td><pre> +function Get_Dispatch + return Event_Dispatch; +</pre></td> + </tr> + + <tr> +<td><pre> +static void event_dispatch(Fl_Event_Dispatch d); +</pre></td> +<td><pre> +procedure Set_Dispatch + (Func : in Event_Dispatch); +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_dx(); +</pre></td> +<td><pre> +function Mouse_DX + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_dy(); +</pre></td> +<td><pre> +function Mouse_DY + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_inside(const Fl_Widget *); +</pre></td> +<td><pre> +function Is_Inside + (Child : in FLTK.Widgets.Widget'Class) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_inside(int, int, int, int); +</pre></td> +<td><pre> +function Is_Inside + (X, Y, W, H : in Integer) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_is_click(); +</pre></td> +<td><pre> +function Is_Click + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void event_is_click(int i); +</pre></td> +<td><pre> +procedure Clear_Click; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_key(); +</pre></td> +<td><pre> +function Last_Key + return Keypress; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_key(int key); +</pre></td> +<td><pre> +function Pressed_During + (Key : in Keypress) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_length(); +</pre></td> +<td><pre> +function Text_Length + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_original_key(); +</pre></td> +<td><pre> +function Original_Last_Key + return Keypress; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_shift(); +</pre></td> +<td><pre> +function Key_Shift + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_state(); +</pre></td> +<td><pre> +function Last_Modifier + return Modifier; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_state(int mask); +</pre></td> +<td><pre> +function Last_Modifier + (Had : in Modifier) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static const char * event_text(); +</pre></td> +<td><pre> +function Text + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_x(); +</pre></td> +<td><pre> +function Mouse_X + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_x_root(); +</pre></td> +<td><pre> +function Mouse_X_Root + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_y(); +</pre></td> +<td><pre> +function Mouse_Y + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int event_y_root(); +</pre></td> +<td><pre> +function Mouse_Y_Root + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Widget * focus(); +</pre></td> +<td><pre> +function Get_Focus + return access FLTK.Widgets.Widget'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static void focus(Fl_Widget *); +</pre></td> +<td><pre> +procedure Set_Focus + (To : in FLTK.Widgets.Widget'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static int get_key(int key); +</pre></td> +<td><pre> +function Key_Now + (Key : in Keypress) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void get_mouse(int &, int &); +</pre></td> +<td><pre> +procedure Get_Mouse + (X, Y : out Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Window * grab(); +</pre></td> +<td><pre> +function Get_Grab + return access FLTK.Widgets.Groups.Windows.Window'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static void grab(Fl_Window *); + +static void grab(Fl_Window &win); +</pre></td> +<td><pre> +procedure Set_Grab + (To : in FLTK.Widgets.Groups.Windows.Window'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static int handle(int, Fl_Window *); +</pre></td> +<td><pre> +function Handle_Dispatch + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome; +</pre></td> + </tr> + + <tr> +<td><pre> +static int handle_(int, Fl_Window *); +</pre></td> +<td><pre> +function Handle + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Widget * pushed(); +</pre></td> +<td><pre> +function Get_Pushed + return access FLTK.Widgets.Widget'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static void pushed(Fl_Widget *); +</pre></td> +<td><pre> +procedure Set_Pushed + (To : in FLTK.Widgets.Widget'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static void release(); +</pre></td> +<td><pre> +procedure Release_Grab; +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_handler(Fl_Event_Handler h); +</pre></td> +<td><pre> +procedure Remove_Handler + (Func : in not null Event_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_system_handler(Fl_System_Handler h); +</pre></td> +<td><pre> +procedure Remove_System_Handler + (Func : in not null System_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static int test_shortcut(Fl_Shortcut); +</pre></td> +<td><pre> +function Test_Shortcut + (Shortcut : in Key_Combo) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int visible_focus(); +</pre></td> +<td><pre> +function Has_Visible_Focus + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void visible_focus(int v); +</pre></td> +<td><pre> +procedure Set_Visible_Focus + (To : in Boolean); +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/fl_(fltk-screen).html b/doc/fl_(fltk-screen).html new file mode 100644 index 0000000..7d44273 --- /dev/null +++ b/doc/fl_(fltk-screen).html @@ -0,0 +1,278 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl (FLTK.Screen) Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl (FLTK.Screen) Binding Map</h2> + + +<a href="index.html">Back to Index</a> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Fl</td> + <td>FLTK.Screen</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Mode</td> + <td>Visual_Mode</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td><pre> +static int damage(); +</pre></td> +<td><pre> +function Is_Damaged + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void damage(int d); +</pre></td> +<td><pre> +procedure Set_Damaged + (To : in Boolean); +</pre></td> + </tr> + + <tr> +<td><pre> +static void display(const char *); +</pre></td> +<td><pre> +procedure Set_Display_String + (Value : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static void flush(); +</pre></td> +<td><pre> +procedure Flush; +</pre></td> + </tr> + + <tr> +<td><pre> +static int h(); +</pre></td> +<td><pre> +function Get_H + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static void redraw(); +</pre></td> +<td><pre> +procedure Redraw; +</pre></td> + </tr> + + <tr> +<td><pre> +static int screen_count(); +</pre></td> +<td><pre> +function Count + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_dpi(float &h, float &v, int n=0); +</pre></td> +<td><pre> +procedure DPI + (Horizontal, Vertical : out Float; + Screen_Number : in Integer := 1); +</pre></td> + </tr> + + <tr> +<td><pre> +static int screen_num(int x, int y); +</pre></td> +<td><pre> +function Containing + (X, Y : in Integer) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int screen_num(int x, int y, int w, int h); +</pre></td> +<td><pre> +function Containing + (X, Y, W, H : in Integer) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_work_area(int &X, int &Y, + int &W, int &H, int mx, int my); +</pre></td> +<td><pre> +procedure Work_Area + (X, Y, W, H : out Integer; + Pos_X, Pos_Y : in Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_work_area(int &X, int &Y, + int &W, int &H, int n); +</pre></td> +<td><pre> +procedure Work_Area + (X, Y, W, H : out Integer; + Screen_Num : in Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_xywh(int &X, int &Y, + int &W, int &H); +</pre></td> +<td><pre> +procedure Bounding_Rect + (X, Y, W, H : out Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_xywh(int &X, int &Y, + int &W, int &H, int mx, int my); +</pre></td> +<td><pre> +procedure Bounding_Rect + (X, Y, W, H : out Integer; + Pos_X, Pos_Y : in Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_xywh(int &X, int &Y, + int &W, int &H, int n); +</pre></td> +<td><pre> +procedure Bounding_Rect + (X, Y, W, H : out Integer; + Screen_Num : in Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_xywh(int &X, int &Y, + int &W, int &H, int mx, int my, int mw, int mh); +</pre></td> +<td><pre> +procedure Bounding_Rect + (X, Y, W, H : out Integer; + PX, PY, PW, PH : in Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static void screen_work_area(int &X, int &Y, + int &W, int &H); +</pre></td> +<td><pre> +procedure Work_Area + (X, Y, W, H : out Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +static int visual(int); +</pre></td> +<td><pre> +procedure Set_Visual_Mode + (Value : in Visual_Mode); + +function Set_Visual_Mode + (Value : in Visual_Mode) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int w(); +</pre></td> +<td><pre> +function Get_W + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int x(); +</pre></td> +<td><pre> +function Get_X + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int y(); +</pre></td> +<td><pre> +function Get_Y + return Integer; +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/fl_(fltk-static).html b/doc/fl_(fltk-static).html new file mode 100644 index 0000000..90e74cd --- /dev/null +++ b/doc/fl_(fltk-static).html @@ -0,0 +1,1028 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl (FLTK.Static) Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl (FLTK.Static) Binding Map</h2> + + +<a href="index.html">Back to Index</a> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Fl</td> + <td>FLTK.Static</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Abort_Handler</td> + <td> </td> + </tr> + + <tr> + <td>Fl_Args_Handler</td> + <td>Args_Handler</td> + </tr> + + <tr> + <td>Fl_Atclose_Handler</td> + <td> </td> + </tr> + + <tr> + <td>Fl_Awake_Handler</td> + <td>Awake_Handler</td> + </tr> + + <tr> + <td>Fl_Idle_Handler</td> + <td>Idle_Handler</td> + </tr> + + <tr> + <td>Fl_Old_Idle_Handler</td> + <td> </td> + </tr> + + <tr> + <td>Fl_Timeout_Handler</td> + <td>Timeout_Handler</td> + </tr> + + <tr> + <td>int</td> + <td>Buffer_Kind</td> + </tr> + + <tr> + <td>Fl_Clipboard_Notify_Handler</td> + <td>Clipboard_Notify_Handler</td> + </tr> + + <tr> + <td>FL_SOCKET</td> + <td>File_Descriptor</td> + </tr> + + <tr> + <td>int</td> + <td>File_Mode</td> + </tr> + + <tr> + <td>Fl_FD_Handler</td> + <td>File_Handler</td> + </tr> + + <tr> + <td>uchar</td> + <td>Byte_Integer</td> + </tr> + + <tr> + <td>Fl_Box_Draw_F</td> + <td>Box_Draw_Function</td> + </tr> + + <tr> + <td>Fl_Label_Draw_F</td> + <td>Label_Draw_Function</td> + </tr> + + <tr> + <td>Fl_Label_Measure_F</td> + <td>Label_Measure_Function</td> + </tr> + + <tr> + <td>Fl_Option</td> + <td>Option</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Errors</th></tr> + + <tr> + <td>int</td> + <td>Argument_Error</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Attributes</th></tr> + + <tr> +<td><pre> +static void (*atclose)(Fl_Window *, void *); +</pre></td> +<td>Deprecated, set the callback for the Window instead.</td> + </tr> + + <tr> +<td><pre> +static const char * const help = helpmsg + 13; +</pre></td> +<td><pre> +Help_Message : constant String; +</pre></td> + </tr> + + <tr> +<td><pre> +static void (*idle)(); +</pre></td> +<td>Should not be used directly.</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td><pre> +static int add_awake_handler_(Fl_Awake_Handler, void *); +</pre></td> +<td><pre> +procedure Add_Awake_Handler + (Func : in Awake_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_check(Fl_Timeout_Handler, void *=0); +</pre></td> +<td><pre> +procedure Add_Check + (Func : in not null Timeout_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, + void *data=0); +</pre></td> +<td><pre> +procedure Add_Clipboard_Notify + (Func : in not null Clipboard_Notify_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_fd(int fd, Fl_FD_Handler cb, void *=0); +</pre></td> +<td><pre> +procedure Add_File_Descriptor + (FD : in File_Descriptor; + Func : in not null File_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_fd(int fd, int when, Fl_FD_Handler cb, + void *=0); +</pre></td> +<td><pre> +procedure Add_File_Descriptor + (FD : in File_Descriptor; + Mode : in File_Mode; + Func : in not null File_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_idle(Fl_Idle_Handler cb, void *data=0); +</pre></td> +<td><pre> +procedure Add_Idle + (Func : in not null Idle_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void add_timeout(double t, Fl_Timeout_Handler, + void *=0); +</pre></td> +<td><pre> +procedure Add_Timeout + (Seconds : in Long_Float; + Func : in not null Timeout_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static int arg(int argc, char **argv, int &i); +</pre></td> +<td><pre> +function Parse_Arg + (Index : in Positive) + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +static int args(int argc, char **argv, int &i, + Fl_Args_Handler cb=0); +</pre></td> +<td><pre> +procedure Parse_Args + (Count : out Natural; + Func : in Args_Handler := null); +</pre></td> + </tr> + + <tr> +<td><pre> +static void args(int argc, char **argv); +</pre></td> +<td><pre> +procedure Parse_Args; +</pre></td> + </tr> + + <tr> +<td><pre> +static int awake(Fl_Awake_Handler cb, void *message=0); +</pre></td> +<td><pre> +procedure Awake + (Func : in Awake_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void awake(void *message=0); +</pre></td> +<td><pre> +procedure Awake; +</pre></td> + </tr> + + <tr> +<td><pre> +static void background(uchar, uchar, uchar); +</pre></td> +<td><pre> +procedure Set_Background + (R, G, B : in Color_Component); +</pre></td> + </tr> + + <tr> +<td><pre> +static void background2(uchar, uchar, uchar); +</pre></td> +<td><pre> +procedure Set_Alt_Background + (R, G, B : in Color_Component); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Color box_color(Fl_Color); +</pre></td> +<td><pre> +function Get_Box_Color + (Tone : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +static int box_dh(Fl_Boxtype); +</pre></td> +<td><pre> +function Get_Box_Height_Offset + (Kind : in Box_Kind) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int box_dw(Fl_Boxtype); +</pre></td> +<td><pre> +function Get_Box_Width_Offset + (Kind : in Box_Kind) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int box_dx(Fl_Boxtype); +</pre></td> +<td><pre> +function Get_Box_X_Offset + (Kind : in Box_Kind) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int box_dy(Fl_Boxtype); +</pre></td> +<td><pre> +function Get_Box_Y_Offset + (Kind : in Box_Kind) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +static int clipboard_contains(const char *type); +</pre></td> +<td><pre> +function Clipboard_Contains + (Kind : in String) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void copy + (const char *stuff, int len, int destination=0, + const char *type=Fl::clipboard_plain_text); +</pre></td> +<td><pre> +procedure Copy + (Text : in String; + Dest : in Buffer_Kind); +</pre></td> + </tr> + + <tr> +<td><pre> +static void default_atclose(Fl_Window *, void *); +</pre></td> +<td><pre> +procedure Default_Window_Close + (Item : in out FLTK.Widgets.Widget'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static void disable_im(); +</pre></td> +<td><pre> +procedure Disable_System_Input; +</pre></td> + </tr> + + <tr> +<td><pre> +static int dnd(); +</pre></td> +<td><pre> +procedure Drag_Drop_Start; +</pre></td> + </tr> + + <tr> +<td><pre> +static int dnd_text_ops(); +</pre></td> +<td><pre> +function Get_Drag_Drop_Text_Support + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void dnd_text_ops(int v); +</pre></td> +<td><pre> +procedure Set_Drag_Drop_Text_Support + (To : in Boolean); +</pre></td> + </tr> + + <tr> +<td><pre> +static int draw_box_active(); +</pre></td> +<td><pre> +function Draw_Box_Active + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void enable_im(); +</pre></td> +<td><pre> +procedure Enable_System_Input; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Window * first_window(); +</pre></td> +<td><pre> +function Get_First_Window + return access FLTK.Widgets.Groups.Windows.Window'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static void first_window(Fl_Window *); +</pre></td> +<td><pre> +procedure Set_First_Window + (To : in FLTK.Widgets.Groups.Windows.Window'Class); +</pre></td> + </tr> + + <tr> +<td><pre> +static void foreground(uchar, uchar, uchar); +</pre></td> +<td><pre> +procedure Set_Foreground + (R, G, B : in Color_Component); +</pre></td> + </tr> + + <tr> +<td><pre> +static void free_color(Fl_Color i, int overlay=0); +</pre></td> +<td><pre> +procedure Free_Color + (Value : in Color; + Overlay : in Boolean := False); +</pre></td> + </tr> + + <tr> +<td><pre> +static int get_awake_handler_(Fl_Awake_Handler &, void *&); +</pre></td> +<td><pre> +function Get_Awake_Handler + return Awake_Handler; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Box_Draw_F * get_boxtype(Fl_Boxtype); +</pre></td> +<td><pre> +function Get_Box_Draw_Function + (Kind : in Box_Kind) + return Box_Draw_Function; +</pre></td> + </tr> + + <tr> +<td><pre> +static unsigned get_color(Fl_Color i); +</pre></td> +<td><pre> +function Get_Color + (From : in Color) + return Color; +</pre></td> + </tr> + + <tr> +<td><pre> +static void get_color(Fl_Color i, + uchar &red, uchar &green, uchar &blue); +</pre></td> +<td><pre> +procedure Get_Color + (From : in Color; + R, G, B : out Color_Component); +</pre></td> + </tr> + + <tr> +<td><pre> +static const char * get_font(Fl_Font); +</pre></td> +<td><pre> +function Font_Image + (Kind : in Font_Kind) + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static const char * get_font_name(Fl_Font, + int *attributes=0); +</pre></td> +<td><pre> +function Font_Family_Image + (Kind : in Font_Kind) + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static int get_font_sizes(Fl_Font, int *&sizep); +</pre></td> +<td><pre> +function Font_Sizes + (Kind : in Font_Kind) + return Font_Size_Array; +</pre></td> + </tr> + + <tr> +<td><pre> +static void get_system_colors(); +</pre></td> +<td><pre> +procedure System_Colors; +</pre></td> + </tr> + + <tr> +<td><pre> +static int has_check(Fl_Timeout_Handler, void *=0); +</pre></td> +<td><pre> +function Has_Check + (Func : in not null Timeout_Handler) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int has_idle(Fl_Idle_Handler cb, void *data=0); +</pre></td> +<td><pre> +function Has_Idle + (Func : in not null Idle_Handler) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int has_timeout(Fl_Timeout_Handler, void *=0); +</pre></td> +<td><pre> +function Has_Timeout + (Func : in not null Timeout_Handler) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int is_scheme(const char *name); +</pre></td> +<td><pre> +function Is_Scheme + (Scheme : in String) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static int lock(); +</pre></td> +<td><pre> +procedure Lock; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Window * modal(); +</pre></td> +<td><pre> +function Get_Top_Modal + return access FLTK.Widgets.Groups.Windows.Window'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Window * next_window(const Fl_Window *); +</pre></td> +<td><pre> +function Get_Next_Window + (From : in FLTK.Widgets.Groups.Windows.Window'Class) + return access FLTK.Widgets.Groups.Windows.Window'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static bool option(Fl_Option opt); +</pre></td> +<td><pre> +function Get_Option + (Opt : in Option) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +static void option(Fl_Option opt, bool val); +</pre></td> +<td><pre> +procedure Set_Option + (Opt : in Option; + To : in Boolean); +</pre></td> + </tr> + + <tr> +<td><pre> +static void own_colormap(); +</pre></td> +<td><pre> +procedure Own_Colormap; +</pre></td> + </tr> + + <tr> +<td><pre> +static void paste(Fl_Widget &receiver); +</pre></td> +<td>Marked as backwards compatibility only.</td> + </tr> + + <tr> +<td><pre> +static void paste + (Fl_Widget &receiver, int source, + const char *type=Fl::clipboard_plain_text); +</pre></td> +<td><pre> +procedure Paste + (Receiver : in FLTK.Widgets.Widget'Class; + Source : in Buffer_Kind); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Widget * readqueue(); +</pre></td> +<td><pre> +function Read_Queue + return access FLTK.Widgets.Widget'Class; +</pre></td> + </tr> + + <tr> +<td><pre> +static int reload_scheme(); +</pre></td> +<td><pre> +procedure Reload_Scheme; +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_check(Fl_Timeout_Handler, void *=0); +</pre></td> +<td><pre> +procedure Remove_Check + (Func : in not null Timeout_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_clipboard_notify + (Fl_Clipboard_Notify_Handler h); +</pre></td> +<td><pre> +procedure Remove_Clipboard_Notify + (Func : in not null Clipboard_Notify_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_fd(int); +</pre></td> +<td><pre> +procedure Remove_File_Descriptor + (FD : in File_Descriptor); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_fd(int, int when); +</pre></td> +<td><pre> +procedure Remove_File_Descriptor + (FD : in File_Descriptor; + Mode : in File_Mode); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_idle(Fl_Idle_Handler cb, + void *data=0); +</pre></td> +<td><pre> +procedure Remove_Idle + (Func : in not null Idle_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static void remove_timeout(Fl_Timeout_Handler, + void *=0); +</pre></td> +<td><pre> +procedure Remove_Timeout + (Func : in not null Timeout_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static repeat_timeout(double t, Fl_Timeout_Handler, + void *=0); +</pre></td> +<td><pre> +procedure Repeat_Timeout + (Seconds : in Long_Float; + Func : in not null Timeout_Handler); +</pre></td> + </tr> + + <tr> +<td><pre> +static const char * scheme(); +</pre></td> +<td><pre> +function Get_Scheme + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +static int scheme(const char *name); +</pre></td> +<td><pre> +procedure Set_Scheme + (To : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static int scrollbar_size(); +</pre></td> +<td><pre> +function Get_Default_Scrollbar_Size + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +static void scrollbar_size(int W); +</pre></td> +<td><pre> +procedure Set_Default_Scrollbar_Size + (To : in Natural); +</pre></td> + </tr> + + <tr> +<td><pre> +static void selection(Fl_Widget &owner, const char *, + int len); +</pre></td> +<td><pre> +procedure Selection + (Owner : in FLTK.Widgets.Widget'Class; + Text : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Widget * selection_owner(); +</pre></td> +<td>Marked as backwards compatibility only.</td> + </tr> + + <tr> +<td><pre> +static void selection_owner(Fl_Widget *); +</pre></td> +<td>Marked as backwards compatibility only.</td> + </tr> + + <tr> +<td><pre> +static void set_abort(Fl_Abort_Handler f); +</pre></td> +<td>Marked as backwards compatibility only.</td> + </tr> + + <tr> +<td><pre> +static void set_atclose(Fl_Atclose_Handler f); +</pre></td> +<td>Marked as backwards compatibility only.</td> + </tr> + + <tr> +<td><pre> +static void set_box_color(Fl_Color); +</pre></td> +<td><pre> +procedure Set_Box_Color + (Tone : in Color); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F *, + uchar, uchar, uchar, uchar); +</pre></td> +<td><pre> +procedure Set_Box_Draw_Function + (Kind : in Box_Kind; + Func : in Box_Draw_Function; + Offset_X, Offset_Y : in Byte_Integer := 0; + Offset_W, Offset_H : in Byte_Integer := 0); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_boxtype(Fl_Boxtype, Fl_Boxtype from); +</pre></td> +<td><pre> +procedure Set_Box_Kind + (To, From : in Box_Kind); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_color(Fl_Color i, unsigned c); +</pre></td> +<td><pre> +procedure Set_Color + (Target, Source : in Color); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_color(Fl_Color, + uchar, uchar, uchar, uchar); +</pre></td> +<td><pre> +procedure Set_Color + (Target : in Color; + R, G, B : in Color_Component); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_font(Fl_Font, const char *); +</pre></td> +<td><pre> +procedure Set_Font_Kind + (Target : in Font_Kind; + Source : in String); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_font(Fl_Font, Fl_Font); +</pre></td> +<td><pre> +procedure Set_Font_Kind + (Target, Source : in Font_Kind); +</pre></td> + </tr> + + <tr> +<td><pre> +static Fl_Font set_fonts(const char *=0); +</pre></td> +<td><pre> +procedure Setup_Fonts + (How_Many_Set_Up : out Natural); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_idle(Fl_Old_Idle_Handler cb); +</pre></td> +<td>Deprecated, use add_idle / Add_Idle instead.</td> + </tr> + + <tr> +<td><pre> +static void set_labeltype(Fl_Labeltype, Fl_Label_Draw_F *, + FL_Label_Measure_F *); +</pre></td> +<td><pre> +procedure Set_Label_Draw_Function + (Kind : in Label_Kind; + Draw_Func : in Label_Draw_Function; + Measure_Func : in Label_Measure_Function); +</pre></td> + </tr> + + <tr> +<td><pre> +static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); +</pre></td> +<td><pre> +procedure Set_Label_Kind + (Target, Source : in Label_Kind); +</pre></td> + </tr> + + <tr> +<td><pre> +static void * thread_message(); +</pre></td> +<td>Intentionally left unbound.</td> + </tr> + + <tr> +<td><pre> +static void unlock(); +</pre></td> +<td><pre> +procedure Unlock; +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/fl_bitmap.html b/doc/fl_bitmap.html index 922b1b5..edaf6a4 100644 --- a/doc/fl_bitmap.html +++ b/doc/fl_bitmap.html @@ -62,31 +62,31 @@ const uchar * array; <td><pre> function Data_Size (This : in Bitmap) - return Natural; + return Size_Type; function Get_Datum (This : in Bitmap; - Place : in Positive) + Place : in Positive_Size) return Color_Component with Pre => Place <= This.Data_Size; procedure Set_Datum (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) with Pre => Place <= This.Data_Size; function Slice (This : in Bitmap; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array with Pre => High <= This.Data_Size, - Post => Slice'Result'Length = Integer'Max (0, High - Low + 1); + Post => Slice'Result'Length = Size_Type'Max (0, High - Low + 1); procedure Overwrite (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) with Pre => Place + Values'Length - 1 <= This.Data_Size; @@ -115,7 +115,24 @@ function Create (Data : in Color_Component_Array; Width, Height : in Natural) return Bitmap -with Pre => Data'Length = To_Next_Byte (Width) * Height; +with Pre => + Data'Length >= Size_Type (Bytes_Needed (Width)) * Size_Type (Height); +</pre></td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Static Functions and Procedures</th></tr> + + <tr> +<td> </td> +<td><pre> +function Bytes_Needed + (Bits : in Natural) + return Natural; </pre></td> </tr> diff --git a/doc/fl_browser_.html b/doc/fl_browser_.html index 1ee2a6a..a09e2e4 100644 --- a/doc/fl_browser_.html +++ b/doc/fl_browser_.html @@ -47,7 +47,14 @@ already extended from it.</p> </tr> <tr> - <td>enum mode</td> + <td>enum {<br /> + HORIZONTAL = 1,<br /> + VERTICAL = 2,<br /> + BOTH = 3,<br /> + ALWAYS_ON = 4,<br /> + HORIZONTAL_ALWAYS = 5,<br /> + VERTICAL_ALWAYS = 6,<br /> + BOTH_ALWAYS = 7 }</td> <td>Scrollbar_Mode</td> </tr> diff --git a/doc/fl_draw.html b/doc/fl_draw.html index d987920..aca154a 100644 --- a/doc/fl_draw.html +++ b/doc/fl_draw.html @@ -415,9 +415,12 @@ procedure Draw_Image (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 3; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : in Boolean := False; - Flip_Vertical : in Boolean := False); + Flip_Vertical : in Boolean := False) +with Pre => (if Line_Size = 0 + then Data'Length >= Size_Type (W) * Size_Type (H) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (H)); </pre></td> </tr> @@ -444,9 +447,12 @@ procedure Draw_Image_Mono (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 1; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : Boolean := False; - Flip_Vertical : Boolean := False); + Flip_Vertical : Boolean := False) +with Pre => (if Line_Size = 0 + then Data'Length >= Size_Type (W) * Size_Type (H) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (H)); </pre></td> </tr> @@ -477,7 +483,7 @@ procedure Draw_Pixmap Colors : in FLTK.Images.Pixmaps.Color_Definition_Array; Pixels : in FLTK.Images.Pixmaps.Pixmap_Data; X, Y : in Integer; - Hue : in Color := Grey0_Color) + Tone : in Color := Grey0_Color) with Pre => Colors'Length = Values.Colors and Pixels'Length (1) = Values.Height and @@ -909,9 +915,9 @@ function Read_Image Alpha : in Integer := 0) return Color_Component_Array with Post => - (if Alpha = 0 - then Read_Image'Result'Length = W * H * 3 - else Read_Image'Result'Length = W * H * 4); + (if Alpha = 0 + then Read_Image'Result'Length = Size_Type (W) * Size_Type (H) * 3 + else Read_Image'Result'Length = Size_Type (W) * Size_Type (H) * 4); </pre></td> </tr> diff --git a/doc/fl_file_chooser.html b/doc/fl_file_chooser.html index 24bd6d8..f186ca4 100644 --- a/doc/fl_file_chooser.html +++ b/doc/fl_file_chooser.html @@ -45,7 +45,11 @@ See Fl_Ask for related symbols that are not members of the Fl_File_Chooser class </tr> <tr> - <td>enum {SINGLE=0, MULTI=1, CREATE=2, DIRECTORY=4}</td> + <td>enum {<br /> + SINGLE = 0,<br /> + MULTI = 1,<br /> + CREATE = 2,<br /> + DIRECTORY = 4 }</td> <td>Chooser_Kind</td> </tr> diff --git a/doc/fl_image.html b/doc/fl_image.html index 10c9ed8..201a2fa 100644 --- a/doc/fl_image.html +++ b/doc/fl_image.html @@ -46,11 +46,6 @@ <td>Scaling_Kind</td> </tr> - <tr> - <td>float</td> - <td>Blend</td> - </tr> - </table> diff --git a/doc/fl_pack.html b/doc/fl_pack.html index 1a7a887..f850557 100644 --- a/doc/fl_pack.html +++ b/doc/fl_pack.html @@ -42,7 +42,9 @@ </tr> <tr> - <td>enum { VERTICAL = 0, HORIZONTAL = 1 }</td> + <td>enum {<br /> + VERTICAL = 0,<br /> + HORIZONTAL = 1 }</td> <td>Pack_Kind</td> </tr> diff --git a/doc/fl_rgb_image.html b/doc/fl_rgb_image.html index 061b07a..6d5427d 100644 --- a/doc/fl_rgb_image.html +++ b/doc/fl_rgb_image.html @@ -62,31 +62,31 @@ const uchar * array; <td><pre> function Data_Size (This : in RGB_Image) - return Natural; + return Size_Type; function Get_Datum (This : in RGB_Image; - Place : in Positive) + Place : in Positive_Size) return Color_Component with Pre => Place <= This.Data_Size; procedure Set_Datum (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) with Pre => Place <= This.Data_Size; function Slice (This : in RGB_Image; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array with Pre => High <= This.Data_Size, - Post => Slice'Result'Length = Integer'Max (0, High - Low + 1); + Post => Slice'Result'Length = Size_Type'Max (0, High - Low + 1); procedure Overwrite (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) with Pre => Place + Values'Length - 1 <= This.Data_Size; @@ -106,7 +106,8 @@ with Post => All_Data'Result'Length = This.Data_Size; <tr> <td><pre> -Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0); +Fl_RGB_Image(const uchar *bits, int W, int H, + int D=3, int LD=0); </pre></td> <td><pre> function Create @@ -116,8 +117,8 @@ function Create Line_Size : in Natural := 0) return RGB_Image with Pre => (if Line_Size = 0 - then Data'Length = Width * Height * Depth - else Data'Length = Line_Size * Height) + then Data'Length >= Size_Type (Width) * Size_Type (Height) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (Height)) and Data'Length <= Get_Max_Size; </pre></td> </tr> @@ -147,7 +148,7 @@ static void max_size(size_t size); </pre></td> <td><pre> procedure Set_Max_Size - (Value : in Natural); + (Value : in Size_Type); </pre></td> </tr> @@ -157,7 +158,7 @@ static size_t max_size(); </pre></td> <td><pre> function Get_Max_Size - return Natural; + return Size_Type; </pre></td> </tr> diff --git a/doc/fl_scroll.html b/doc/fl_scroll.html index c55dba5..4c8977b 100644 --- a/doc/fl_scroll.html +++ b/doc/fl_scroll.html @@ -42,7 +42,14 @@ </tr> <tr> - <td>enum { HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS_ON = 4, HORIZONTAL_ALWAYS = 5, VERTICAL_ALWAYS = 6, BOTH_ALWAYS = 7 } + <td>enum {<br /> + HORIZONTAL = 1,<br /> + VERTICAL = 2,<br /> + BOTH = 3,<br /> + ALWAYS_ON = 4,<br /> + HORIZONTAL_ALWAYS = 5,<br /> + VERTICAL_ALWAYS = 6,<br /> + BOTH_ALWAYS = 7 } <td>Scroll_Kind</td> </tr> diff --git a/doc/fl_text_display.html b/doc/fl_text_display.html index 8d0d20a..54b2f54 100644 --- a/doc/fl_text_display.html +++ b/doc/fl_text_display.html @@ -42,22 +42,39 @@ </tr> <tr> - <td>enum { NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR, BLOCK_CURSOR, HEAVY_CURSOR, SIMPLE_CURSOR }</td> + <td>enum {<br /> + NORMAL_CURSOR,<br /> + CARET_CURSOR,<br /> + DIM_CURSOR,<br /> + BLOCK_CURSOR,<br /> + HEAVY_CURSOR,<br /> + SIMPLE_CURSOR }</td> <td>Cursor_Style</td> </tr> <tr> - <td>enum { CURSOR_POS, CHARACTER_POS }</td> + <td>enum {<br /> + CURSOR_POS,<br /> + CHARACTER_POS }</td> <td>Position_Kind</td> </tr> <tr> - <td>enum { DRAG_NONE = -2, DRAG_START_DND = -1, DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2 }</td> + <td>enum {<br /> + DRAG_NONE = -2,<br /> + DRAG_START_DND = -1,<br /> + DRAG_CHAR = 0,<br /> + DRAG_WORD = 1,<br /> + DRAG_LINE = 2 }</td> <td> </td> </tr> <tr> - <td>enum { WRAP_NONE, WRAP_AT_COLUMN, WRAP_AT_PIXEL, WRAP_AT_BOUNDS }</td> + <td>enum {<br /> + WRAP_NONE,<br /> + WRAP_AT_COLUMN,<br /> + WRAP_AT_PIXEL,<br /> + WRAP_AT_BOUNDS }</td> <td>Wrap_Mode</td> </tr> diff --git a/doc/fl_widget.html b/doc/fl_widget.html index 419ab3b..0552325 100644 --- a/doc/fl_widget.html +++ b/doc/fl_widget.html @@ -46,16 +46,6 @@ <td>Widget_Callback</td> </tr> - <tr> - <td>Fl_When</td> - <td>Callback_Flag</td> - </tr> - - <tr> - <td>uchar</td> - <td>Damage_Mask</td> - </tr> - </table> diff --git a/doc/index.html b/doc/index.html index e8f0a45..af2faf1 100644 --- a/doc/index.html +++ b/doc/index.html @@ -16,9 +16,13 @@ <h4>List of C++ headers</h4> <ul> - <li><a href="fl.html">Enumerations</a></li> + <li><a href="enumerations.html">Enumerations</a></li> <li><a href="filename.html">Filename</a></li> <li><a href="fl.html">Fl</a></li> + <li><a href="fl_(fltk-errors).html">Fl (FLTK.Errors)</a></li> + <li><a href="fl_(fltk-events).html">Fl (FLTK.Events)</a></li> + <li><a href="fl_(fltk-screen).html">Fl (FLTK.Screen)</a></li> + <li><a href="fl_(fltk-static).html">Fl (FLTK.Static)</a></li> <li><a href="fl_adjuster.html">Fl_Adjuster</a></li> <li><a href="fl_ask.html">Fl_Ask</a></li> <li><a href="fl_bitmap.html">Fl_Bitmap</a></li> @@ -143,6 +147,7 @@ <ul> <li><a href="fl.html">FLTK</a></li> + <li><a href="enumerations.html">FLTK (Enumerations)</a></li> <li><a href="fl_ask.html">FLTK.Asks</a></li> <li><a href="fl_device.html">FLTK.Devices</a></li> <li><a href="fl_graphics_driver.html">FLTK.Devices.Graphics</a></li> @@ -155,8 +160,8 @@ <li><a href="fl_printer.html">FLTK.Devices.Surface.Paged.Printers</a></li> <li><a href="fl_draw.html">FLTK.Draw</a></li> <li><a href="fl_preferences.html">FLTK.Environment</a></li> - <li><a href="fl.html">FLTK.Errors</a></li> - <li><a href="fl.html">FLTK.Event</a></li> + <li><a href="fl_(fltk-errors).html">FLTK.Errors</a></li> + <li><a href="fl_(fltk-events).html">FLTK.Events</a></li> <li><a href="fl_file_chooser.html">FLTK.File_Choosers</a></li> <li><a href="filename.html">FLTK.Filenames</a></li> <li><a href="fl_help_dialog.html">FLTK.Help_Dialogs</a></li> @@ -175,8 +180,8 @@ <li><a href="fl_tiled_image.html">FLTK.Images.Tiled</a></li> <li><a href="fl_label.html">FLTK.Labels</a></li> <li><a href="fl_menu_item.html">FLTK.Menu_Items</a></li> - <li><a href="fl.html">FLTK.Screen</a></li> - <li><a href="fl.html">FLTK.Static</a></li> + <li><a href="fl_(fltk-screen).html">FLTK.Screen</a></li> + <li><a href="fl_(fltk-static).html">FLTK.Static</a></li> <li><a href="fl_text_buffer.html">FLTK.Text_Buffers</a></li> <li><a href="fl_tooltip.html">FLTK.Tooltips</a></li> <li><a href="fl_widget.html">FLTK.Widgets</a></li> diff --git a/fltkada.gpr b/fltkada.gpr index d09f775..3c493bb 100644 --- a/fltkada.gpr +++ b/fltkada.gpr @@ -10,13 +10,15 @@ library project FLTKAda is for Languages use ("Ada", "C++"); - for Source_Dirs use ("body", "spec"); - for Object_Dir use "obj"; - for Library_Dir use "lib"; + for Source_Dirs use ("body", "spec"); + for Object_Dir use "obj"; + for Library_Dir use "lib"; for Library_Name use "fltkada"; for Library_Kind use "dynamic"; + package Builder renames Common.Builder; package Compiler renames Common.Compiler; + package Binder renames Common.Binder; end FLTKAda; diff --git a/progress.txt b/progress.txt index 9130e3c..ec58583 100644 --- a/progress.txt +++ b/progress.txt @@ -1,15 +1,12 @@ - Approximate Progress List - Overall estimate: 85+% - Done: FLTK @@ -130,14 +127,12 @@ FLTK.Widgets.Valuators.Value_Outputs - Partially Done: Fl_Graphics_Driver / FLTK.Devices.Graphics - To-Do: Fl_GDI_Graphics_Driver @@ -168,7 +163,6 @@ Fl_PostScript_File_Device (internal Fl_PostScript_Graphics_Driver) - Never: (C++ binary plugins) (I have no idea how to bind these) @@ -189,7 +183,6 @@ Fl_System_Printer - Bugs to fix: Fl_Wizard draw() method private/protected @@ -209,7 +202,6 @@ possibly this hasn't been noticed because it's only visible to doxygen - Incomplete APIs: FLTK diff --git a/proj/common.gpr b/proj/common.gpr index 64c4dc1..0da596c 100644 --- a/proj/common.gpr +++ b/proj/common.gpr @@ -3,12 +3,101 @@ abstract project Common is + type Build_Kind is ("release", "debug"); + + Ver : Build_Kind := external ("build", "release"); + + + package Builder is + for Default_Switches ("Ada") use ("-j4", "-m"); + for Global_Compilation_Switches ("Ada") use ("-shared"); + + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use Builder'Default_Switches ("Ada") & "-g"; + + end case; + end Builder; + + + Ada_Common := + ("-gnaty" + & "4" -- indentation + & "a" -- attribute casing + & "A" -- array attribute indices + & "b" -- blanks at end of lines + & "c" -- two space comments + & "e" -- end/exit labels + & "f" -- no form feeds or vertical tabs + & "h" -- no horizontal tabs + & "i" -- if/then layout + & "k" -- keyword casing + & "l" -- reference manual layout + & "M100" -- max line length + & "n" -- package Standard casing + & "p" -- pragma casing + & "r" -- identifier casing + & "t", -- token separation + "-gnatw" + & "a" -- various warning modes + & "F" -- don't check for unreferenced formal parameters + & "J" -- don't check for obsolescent feature use + & "U"); -- don't check for unused entities + + CPP_Common := + ("-Wall", + "-Werror", + "-Wextra", + "-Wpedantic", + "-std=c++11"); + package Compiler is - for Default_Switches ("Ada") use ("-gnaty4aAbcefhiklM100nprt"); - for Default_Switches("C++") use ("-Wall","-Wextra","-std=c++11"); + case Ver is + + when "release" => + for Default_Switches ("Ada") use Ada_Common & "-O3" & "-gnatn"; + for Default_Switches ("C++") use CPP_Common & "-O3"; + + when "debug" => + for Default_Switches ("Ada") use Ada_Common & "-O0" & "-gnata" & "-gnato" & "-g"; + for Default_Switches ("C++") use CPP_Common & "-O0"; + + end case; end Compiler; + package Binder is + for Default_Switches ("Ada") use ("-shared"); + + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use Binder'Default_Switches ("Ada") & "-Es"; + + end case; + end Binder; + + + package Linker is + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use ("-g"); + + end case; + end Linker; + + end Common; diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..ce1da36 --- /dev/null +++ b/readme.md @@ -0,0 +1,87 @@ + +## FLTKAda + +This is a thick, high level binding for the [FLTK](https://www.fltk.org/) +graphical widget library to the Ada programming language using only the +standard C FFI. + +Types have been marshalled. Class hierarchies have been mapped to equivalent +packages and tagged records. Controlled types have been used to make allocation +and deallocation automatic for objects. Overrideable methods called from the +FLTK event loop have been thunked. Iterators have been implemented. And a few +convenience subprograms have been provided. + +Some of the FLTK test and example programs have also been ported. + +For documentation on what C++ function, method, or class corresponds to what +Ada function, procedure, or package, see `index.html` in the `doc` +subdirectory. + + + +#### Dependencies + +Build time: +<ul> + <li>FLTK</li> + <li>g++</li> + <li>GNAT</li> + <li>GPRbuild</li> +</ul> + +Run time: +<ul> + <li>FLTK</li> +</ul> + +It may be possible to use alternate compilation tooling but this has not been +tested. If attempted, some manual modification of project files may be +necessary. + +Note that at this time only FLTK 1.3 is supported. + + + +#### Building and Installation + +This repository is written to use the GNAT Project Manager build tools. To +build, use the following command + +`gprbuild fltkada.gpr` + +There is a single build switch of `-Xbuild` which can have a value of `release` +(the default) or `debug`. The other project files in the main directory can be +used with similar build commands to build tests, examples, and tools. + +To install the binding, use + +`gprinstall -p -m fltkada.gpr` + +For further information on the build tools, consult the +[GPRbuild docs](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html). + + + +#### Technical Notes + +As part of its normal operation, FLTK calls a Widget's Draw and Handle methods +from its main loop to deal with draw and input events. Since it's another part +of the program that is invoking them, even if it's a part the programmer has no +direct control over, this binding is set up so that if you override Draw or +Handle the behaviour will change. + +On the other hand, something like the Push method in tabbed groups is usually +invoked from within that same tabbed group widget's Handle method. Therefore, +keeping consistency with Ada semantics, overriding the Push method will NOT +change the behaviour of the corresponding Handle method. You must also override +Handle. + + + +#### Credits and Licensing + +Written by Jedidiah Barber. + +Released into the public domain. For details see `unlicense.txt`. + + diff --git a/readme.txt b/readme.txt deleted file mode 100644 index 67d4b40..0000000 --- a/readme.txt +++ /dev/null @@ -1,61 +0,0 @@ - - -FLTK Binding for the Ada Programming Language -============================================= - - - - -This is a thick binding. In particular, dynamic allocation of FLTK objects is -not necessary as in Ada they can be placed on the stack and automatically cleaned -up. Ada 2012 iterators have also been made available for the Fl_Group and Fl_Menu -bindings. - -For documentation on what C++ method or class corresponds to what Ada function, -procedure, or package, see the /doc/index.html file. - - - - -Dependencies: - - GNAT - FLTK - - - - -How to build/install: - -This repository is written to use the GNAT Project Manager build tools. To build -this FLTK-Ada binding for testing purposes, use the following command - - gprbuild fltkada.gpr - -And to install the binding, use - - gprinstall -p -m fltkada.gpr - - - - -For further information on the build tools, consult - - https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html - - - - -A technical note on callbacks and overriding: - -As part of its normal operation, FLTK calls a Widget's Draw and Handle methods from its -main loop to deal with draw and input events. Since it's another part of the program -that is invoking them, even if it's a part the programmer has no direct control over, -this binding is set up so that if you override Draw or Handle, the behaviour will change. - -On the other hand, something like the Push method in tabbed groups is usually invoked -from within that same tabbed group widget's Handle method. Therefore, keeping consistency -with Ada semantics, overriding the Push method will NOT change the behaviour of the -corresponding Handle method. You must also override Handle. - - diff --git a/spec/fltk-asks.ads b/spec/fltk-asks.ads index 75296d3..23e2076 100644 --- a/spec/fltk-asks.ads +++ b/spec/fltk-asks.ads @@ -172,6 +172,10 @@ package FLTK.Asks is (Font : in Font_Kind; Size : in Font_Size); + -- Technically the returned Box should have a parent, but you can't access + -- it for annoying technical reasons relating to how the Choice functions + -- work in C++. You shouldn't be trying to poke at those internals anyway. + -- Just stick to calling subprograms to change stuff about this Box. function Get_Message_Icon return FLTK.Widgets.Boxes.Box_Reference; diff --git a/spec/fltk-draw.ads b/spec/fltk-draw.ads index 950a247..a2c66f3 100644 --- a/spec/fltk-draw.ads +++ b/spec/fltk-draw.ads @@ -252,9 +252,12 @@ package FLTK.Draw is (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 3; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : in Boolean := False; - Flip_Vertical : in Boolean := False); + Flip_Vertical : in Boolean := False) + with Pre => (if Line_Size = 0 + then Data'Length >= Size_Type (W) * Size_Type (H) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (H)); procedure Draw_Image (X, Y, W, H : in Integer; @@ -265,9 +268,12 @@ package FLTK.Draw is (X, Y, W, H : in Integer; Data : in Color_Component_Array; Depth : in Positive := 1; - Line_Data : in Natural := 0; + Line_Size : in Natural := 0; Flip_Horizontal : Boolean := False; - Flip_Vertical : Boolean := False); + Flip_Vertical : Boolean := False) + with Pre => (if Line_Size = 0 + then Data'Length >= Size_Type (W) * Size_Type (H) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (H)); procedure Draw_Image_Mono (X, Y, W, H : in Integer; @@ -279,7 +285,7 @@ package FLTK.Draw is Colors : in FLTK.Images.Pixmaps.Color_Definition_Array; Pixels : in FLTK.Images.Pixmaps.Pixmap_Data; X, Y : in Integer; - Hue : in Color := Grey0_Color) + Tone : in Color := Grey0_Color) with Pre => Colors'Length = Values.Colors and Pixels'Length (1) = Values.Height and @@ -292,9 +298,9 @@ package FLTK.Draw is Alpha : in Integer := 0) return Color_Component_Array with Post => - (if Alpha = 0 - then Read_Image'Result'Length = W * H * 3 - else Read_Image'Result'Length = W * H * 4); + (if Alpha = 0 + then Read_Image'Result'Length = Size_Type (W) * Size_Type (H) * 3 + else Read_Image'Result'Length = Size_Type (W) * Size_Type (H) * 4); diff --git a/spec/fltk-environment.ads b/spec/fltk-environment.ads index d4a1322..9ab7f7c 100644 --- a/spec/fltk-environment.ads +++ b/spec/fltk-environment.ads @@ -317,7 +317,6 @@ private pragma Convention (C, Binary_Data); - pragma Pack (Binary_Data); for Binary_Data'Component_Size use Interfaces.C.CHAR_BIT; diff --git a/spec/fltk-event.ads b/spec/fltk-events.ads index e512432..5dbc573 100644 --- a/spec/fltk-event.ads +++ b/spec/fltk-events.ads @@ -6,25 +6,33 @@ with - FLTK.Widgets.Groups.Windows; + FLTK.Widgets.Groups.Windows, + System; private with - Ada.Containers.Vectors, + Ada.Finalization, System.Address_To_Access_Conversions; -package FLTK.Event is +package FLTK.Events is type Event_Handler is access function (Event : in Event_Kind) return Event_Outcome; - -- type Event_Dispatch is access function - -- (Event : in Event_Kind; - -- Win : access FLTK.Widgets.Groups.Windows.Window'Class) - -- return Event_Outcome; + type Event_Dispatch is access function + (Event : in Event_Kind; + Win : access FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome; + + + type System_Event is new System.Address; + + type System_Handler is access function + (Event : in System_Event) + return Event_Outcome; @@ -32,21 +40,39 @@ package FLTK.Event is -- Handlers -- procedure Add_Handler - (Func : in Event_Handler); + (Func : in not null Event_Handler); procedure Remove_Handler - (Func : in Event_Handler); + (Func : in not null Event_Handler); + + procedure Add_System_Handler + (Func : in not null System_Handler); - -- function Get_Dispatch - -- return Event_Dispatch; + procedure Remove_System_Handler + (Func : in not null System_Handler); - -- procedure Set_Dispatch - -- (Func : in Event_Dispatch); - -- function Default_Dispatch - -- (Event : in Event_Kind; - -- Win : access FLTK.Widgets.Groups.Windows.Window'Class) - -- return Event_Outcome; + + + -- Dispatch -- + + function Get_Dispatch + return Event_Dispatch; + + -- Any Event_Dispatch function set must call Handle + -- if you want the Event to actually be acknowledged. + procedure Set_Dispatch + (Func : in Event_Dispatch); + + function Handle_Dispatch + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome; + + function Handle + (Event : in Event_Kind; + Origin : in out FLTK.Widgets.Groups.Windows.Window'Class) + return Event_Outcome; @@ -79,6 +105,23 @@ package FLTK.Event is procedure Set_Focus (To : in FLTK.Widgets.Widget'Class); + function Has_Visible_Focus + return Boolean; + + procedure Set_Visible_Focus + (To : in Boolean); + + + + + -- Clipboard -- + + function Clipboard_Text + return String; + + function Clipboard_Kind + return String; + @@ -96,6 +139,10 @@ package FLTK.Event is function Text_Length return Natural; + function Test_Shortcut + (Shortcut : in Key_Combo) + return Boolean; + @@ -104,9 +151,11 @@ package FLTK.Event is function Last return Event_Kind; + -- Focuses on keyboard modifiers only, not mouse buttons function Last_Modifier return Modifier; + -- Focuses on keyboard modifiers only, not mouse buttons function Last_Modifier (Had : in Modifier) return Boolean; @@ -140,9 +189,18 @@ package FLTK.Event is function Is_Click return Boolean; + procedure Clear_Click; + function Is_Multi_Click return Boolean; + -- Returns the actual number of clicks. + -- So no clicks is 0, a single click is 1, a double click is 2, etc. + function Get_Clicks + return Natural; + + -- Will set the actual number of clicks. + -- This means setting it to 0 will make Is_Click return False. procedure Set_Clicks (To : in Natural); @@ -158,6 +216,19 @@ package FLTK.Event is function Mouse_Right return Boolean; + function Mouse_Back + return Boolean; + + function Mouse_Forward + return Boolean; + + procedure Mouse_Buttons + (Left, Middle, Right, Back, Forward : out Boolean); + + function Is_Inside + (Child : in FLTK.Widgets.Widget'Class) + return Boolean; + function Is_Inside (X, Y, W, H : in Integer) return Boolean; @@ -203,12 +274,7 @@ private (FLTK.Widgets.Groups.Windows.Window'Class); - package Handler_Vectors is new Ada.Containers.Vectors - (Index_Type => Positive, Element_Type => Event_Handler); - - - Handlers : Handler_Vectors.Vector := Handler_Vectors.Empty_Vector; - -- Current_Dispatch : Event_Dispatch := null; + Current_Dispatch : Event_Dispatch := null; function fl_widget_get_user_data @@ -223,9 +289,13 @@ private pragma Inline (Add_Handler); pragma Inline (Remove_Handler); - -- pragma Inline (Get_Dispatch); - -- pragma Inline (Set_Dispatch); - -- pragma Inline (Default_Dispatch); + pragma Inline (Add_System_Handler); + pragma Inline (Remove_System_Handler); + + pragma Inline (Get_Dispatch); + pragma Inline (Set_Dispatch); + pragma Inline (Handle_Dispatch); + pragma Inline (Handle); pragma Inline (Get_Grab); pragma Inline (Set_Grab); @@ -236,11 +306,17 @@ private pragma Inline (Set_Below_Mouse); pragma Inline (Get_Focus); pragma Inline (Set_Focus); + pragma Inline (Has_Visible_Focus); + pragma Inline (Set_Visible_Focus); + + pragma Inline (Clipboard_Text); + pragma Inline (Clipboard_Kind); pragma Inline (Compose); pragma Inline (Compose_Reset); pragma Inline (Text); pragma Inline (Text_Length); + pragma Inline (Test_Shortcut); pragma Inline (Last); pragma Inline (Last_Modifier); @@ -253,12 +329,15 @@ private pragma Inline (Mouse_DY); pragma Inline (Get_Mouse); pragma Inline (Is_Click); + pragma Inline (Clear_Click); pragma Inline (Is_Multi_Click); + pragma Inline (Get_Clicks); pragma Inline (Set_Clicks); - pragma Inline (Last_Button); pragma Inline (Mouse_Left); pragma Inline (Mouse_Middle); pragma Inline (Mouse_Right); + pragma Inline (Mouse_Back); + pragma Inline (Mouse_Forward); pragma Inline (Is_Inside); pragma Inline (Last_Key); @@ -271,6 +350,15 @@ private pragma Inline (Key_Shift); -end FLTK.Event; + -- Needed to deregister the handlers + type FLTK_Events_Final_Controller is new Ada.Finalization.Limited_Controlled with null record; + + overriding procedure Finalize + (This : in out FLTK_Events_Final_Controller); + + Cleanup : FLTK_Events_Final_Controller; + + +end FLTK.Events; diff --git a/spec/fltk-images-bitmaps.ads b/spec/fltk-images-bitmaps.ads index b31885c..9577273 100644 --- a/spec/fltk-images-bitmaps.ads +++ b/spec/fltk-images-bitmaps.ads @@ -15,9 +15,9 @@ package FLTK.Images.Bitmaps is - -- Rounds a number of bits up to the next byte boundary. + -- Calculates the bytes needed to hold a given number of bits. - function To_Next_Byte + function Bytes_Needed (Bits : in Natural) return Natural; @@ -33,7 +33,8 @@ package FLTK.Images.Bitmaps is (Data : in Color_Component_Array; Width, Height : in Natural) return Bitmap - with Pre => Data'Length = To_Next_Byte (Width) * Height; + with Pre => + Data'Length >= Size_Type (Bytes_Needed (Width)) * Size_Type (Height); end Forge; @@ -66,31 +67,31 @@ package FLTK.Images.Bitmaps is function Data_Size (This : in Bitmap) - return Natural; + return Size_Type; function Get_Datum (This : in Bitmap; - Place : in Positive) + Place : in Positive_Size) return Color_Component with Pre => Place <= This.Data_Size; procedure Set_Datum (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) with Pre => Place <= This.Data_Size; function Slice (This : in Bitmap; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array with Pre => High <= This.Data_Size, - Post => Slice'Result'Length = Integer'Max (0, High - Low + 1); + Post => Slice'Result'Length = Size_Type'Max (0, High - Low + 1); procedure Overwrite (This : in out Bitmap; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) with Pre => Place + Values'Length - 1 <= This.Data_Size; @@ -123,7 +124,7 @@ private (This : in out Bitmap); - pragma Inline (To_Next_Byte); + pragma Inline (Bytes_Needed); pragma Inline (Copy); diff --git a/spec/fltk-images-rgb.ads b/spec/fltk-images-rgb.ads index daa31c6..d893cec 100644 --- a/spec/fltk-images-rgb.ads +++ b/spec/fltk-images-rgb.ads @@ -25,10 +25,10 @@ package FLTK.Images.RGB is -- Static Settings -- function Get_Max_Size - return Natural; + return Size_Type; procedure Set_Max_Size - (Value : in Natural); + (Value : in Size_Type); @@ -45,8 +45,8 @@ package FLTK.Images.RGB is Line_Size : in Natural := 0) return RGB_Image with Pre => (if Line_Size = 0 - then Data'Length = Width * Height * Depth - else Data'Length = Line_Size * Height) + then Data'Length >= Size_Type (Width) * Size_Type (Height) * Size_Type (Depth) + else Data'Length >= Size_Type (Line_Size) * Size_Type (Height)) and Data'Length <= Get_Max_Size; function Create @@ -98,31 +98,31 @@ package FLTK.Images.RGB is function Data_Size (This : in RGB_Image) - return Natural; + return Size_Type; function Get_Datum (This : in RGB_Image; - Place : in Positive) + Place : in Positive_Size) return Color_Component with Pre => Place <= This.Data_Size; procedure Set_Datum (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Value : in Color_Component) with Pre => Place <= This.Data_Size; function Slice (This : in RGB_Image; - Low : in Positive; - High : in Natural) + Low : in Positive_Size; + High : in Size_Type) return Color_Component_Array with Pre => High <= This.Data_Size, - Post => Slice'Result'Length = Integer'Max (0, High - Low + 1); + Post => Slice'Result'Length = Size_Type'Max (0, High - Low + 1); procedure Overwrite (This : in out RGB_Image; - Place : in Positive; + Place : in Positive_Size; Values : in Color_Component_Array) with Pre => Place + Values'Length - 1 <= This.Data_Size; diff --git a/spec/fltk-images.ads b/spec/fltk-images.ads index 165c203..6afb788 100644 --- a/spec/fltk-images.ads +++ b/spec/fltk-images.ads @@ -14,8 +14,6 @@ package FLTK.Images is type Scaling_Kind is (Nearest, Bilinear); - type Blend is new Float range 0.0 .. 1.0; - No_Image_Error, File_Access_Error, Format_Error : exception; diff --git a/spec/fltk-screen.ads b/spec/fltk-screen.ads index b7d5521..38db9aa 100644 --- a/spec/fltk-screen.ads +++ b/spec/fltk-screen.ads @@ -7,6 +7,26 @@ package FLTK.Screen is + type Visual_Mode is (RGB, RGB_24bit, Double_Buffer, Double_RGB, Double_RGB_24bit); + + + + + -- Environment -- + + procedure Set_Display_String + (Value : in String); + + procedure Set_Visual_Mode + (Value : in Visual_Mode); + + function Set_Visual_Mode + (Value : in Visual_Mode) + return Boolean; + + + + -- Basic Dimensions -- function Get_X @@ -79,9 +99,31 @@ package FLTK.Screen is PX, PY, PW, PH : in Integer); + + + -- Drawing -- + + function Is_Damaged + return Boolean; + + procedure Set_Damaged + (To : in Boolean); + + procedure Flush; + + procedure Redraw; + + private + pragma Import (C, Flush, "fl_screen_flush"); + pragma Import (C, Redraw, "fl_screen_redraw"); + + + pragma Inline (Set_Display_String); + pragma Inline (Set_Visual_Mode); + pragma Inline (Get_X); pragma Inline (Get_Y); pragma Inline (Get_W); @@ -94,6 +136,11 @@ private pragma Inline (Work_Area); pragma Inline (Bounding_Rect); + pragma Inline (Is_Damaged); + pragma Inline (Set_Damaged); + pragma Inline (Flush); + pragma Inline (Redraw); + end FLTK.Screen; diff --git a/spec/fltk-static.ads b/spec/fltk-static.ads index 71d5b3f..4f71244 100644 --- a/spec/fltk-static.ads +++ b/spec/fltk-static.ads @@ -6,22 +6,32 @@ with + FLTK.Labels, FLTK.Widgets.Groups.Windows; private with - Interfaces.C; + Ada.Finalization, + Ada.Unchecked_Conversion, + FLTK.Args_Marshal, + Interfaces.C.Strings; package FLTK.Static is - type Awake_Handler is access procedure; + -- Input is the argument index usable with Ada.Command_Line. + -- Output is how many arguments parsed starting from that index. + type Args_Handler is access function + (Index : in Positive) + return Natural; - type Timeout_Handler is access procedure; + type Awake_Handler is access procedure; type Idle_Handler is access procedure; + type Timeout_Handler is access procedure; + type Buffer_Kind is (Selection, Clipboard); @@ -31,15 +41,38 @@ package FLTK.Static is type File_Descriptor is new Integer; - type File_Mode is (Read, Write, Except); + type File_Mode is record + Read : Boolean := False; + Write : Boolean := False; + Except : Boolean := False; + end record; + + function "+" (Left, Right : in File_Mode) return File_Mode; + function "-" (Left, Right : in File_Mode) return File_Mode; + + Read_Mode : constant File_Mode; + Write_Mode : constant File_Mode; + Except_Mode : constant File_Mode; type File_Handler is access procedure (FD : in File_Descriptor); + subtype Byte_Integer is Integer range 0 .. 255; + type Box_Draw_Function is access procedure (X, Y, W, H : in Integer; - My_Color : in Color); + Tone : in Color); + + + type Label_Draw_Function is access procedure + (Item : in FLTK.Labels.Label'Class; + X, Y, W, H : in Integer; + Position : in Alignment); + + type Label_Measure_Function is access procedure + (Item : in FLTK.Labels.Label'Class; + W, H : out Integer); type Option is @@ -47,13 +80,41 @@ package FLTK.Static is Visible_Focus, DND_Text, Show_Tooltips, - FNFC_Uses_GTK, - Last); + FNFC_Uses_GTK); + + + -- According to docs this should be customisable, + -- but in C++ it is a constant pointer to constant. + Help_Message : constant String; + + + Argument_Error : exception; + + + -- Command Line Arguments -- + + function Parse_Arg + (Index : in Positive) + return Natural; + + procedure Parse_Args; + + -- Not task safe, but you won't need to call this more than once anyway. + procedure Parse_Args + (Count : out Natural; + Func : in Args_Handler := null); + - -- Interthread Notify -- + + -- Thread Notify -- + + -- Unsure if it is worth actually using this or if mixing tasks, pthreads, + -- and whatever other platforms use causes errors in some unexpected way. + -- Might be better to rely on FLTK.Check, Ada tasking, and Ada protected types. + -- You'll need appropriately declared protected objects to pass messages anyway. procedure Add_Awake_Handler (Func : in Awake_Handler); @@ -61,20 +122,29 @@ package FLTK.Static is function Get_Awake_Handler return Awake_Handler; + procedure Awake + (Func : in Awake_Handler); + + procedure Awake; + + procedure Lock; + + procedure Unlock; + -- Pre-Eventloop Callbacks -- procedure Add_Check - (Func : in Timeout_Handler); + (Func : in not null Timeout_Handler); function Has_Check - (Func : in Timeout_Handler) + (Func : in not null Timeout_Handler) return Boolean; procedure Remove_Check - (Func : in Timeout_Handler); + (Func : in not null Timeout_Handler); @@ -82,19 +152,19 @@ package FLTK.Static is -- Timer Callbacks -- procedure Add_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler); + (Seconds : in Long_Float; + Func : in not null Timeout_Handler); function Has_Timeout - (Func : in Timeout_Handler) + (Func : in not null Timeout_Handler) return Boolean; procedure Remove_Timeout - (Func : in Timeout_Handler); + (Func : in not null Timeout_Handler); procedure Repeat_Timeout - (Seconds : in Long_Float; - Func : in Timeout_Handler); + (Seconds : in Long_Float; + Func : in not null Timeout_Handler); @@ -102,10 +172,10 @@ package FLTK.Static is -- Clipboard Callbacks -- procedure Add_Clipboard_Notify - (Func : in Clipboard_Notify_Handler); + (Func : in not null Clipboard_Notify_Handler); procedure Remove_Clipboard_Notify - (Func : in Clipboard_Notify_Handler); + (Func : in not null Clipboard_Notify_Handler); @@ -113,13 +183,13 @@ package FLTK.Static is -- File Descriptor Waiting Callbacks -- procedure Add_File_Descriptor - (FD : in File_Descriptor; - Func : in File_Handler); + (FD : in File_Descriptor; + Func : in not null File_Handler); procedure Add_File_Descriptor - (FD : in File_Descriptor; - Mode : in File_Mode; - Func : in File_Handler); + (FD : in File_Descriptor; + Mode : in File_Mode; + Func : in not null File_Handler); procedure Remove_File_Descriptor (FD : in File_Descriptor); @@ -134,32 +204,46 @@ package FLTK.Static is -- Idle Callbacks -- procedure Add_Idle - (Func : in Idle_Handler); + (Func : in not null Idle_Handler); function Has_Idle - (Func : in Idle_Handler) + (Func : in not null Idle_Handler) return Boolean; procedure Remove_Idle - (Func : in Idle_Handler); + (Func : in not null Idle_Handler); -- Custom Colors -- + function Get_Color + (From : in Color) + return Color; + procedure Get_Color (From : in Color; R, G, B : out Color_Component); procedure Set_Color - (To : in Color; + (Target, Source : in Color); + + procedure Set_Color + (Target : in Color; R, G, B : in Color_Component); procedure Free_Color (Value : in Color; Overlay : in Boolean := False); + function Get_Box_Color + (Tone : in Color) + return Color; + + procedure Set_Box_Color + (Tone : in Color); + procedure Own_Colormap; procedure Set_Foreground @@ -187,7 +271,11 @@ package FLTK.Static is return String; procedure Set_Font_Kind - (To, From : in Font_Kind); + (Target, Source : in Font_Kind); + + procedure Set_Font_Kind + (Target : in Font_Kind; + Source : in String); function Font_Sizes (Kind : in Font_Kind) @@ -223,15 +311,28 @@ package FLTK.Static is function Draw_Box_Active return Boolean; - -- function Get_Box_Draw_Function - -- (Kind : in Box_Kind) - -- return Box_Draw_Function; + function Get_Box_Draw_Function + (Kind : in Box_Kind) + return Box_Draw_Function; + + procedure Set_Box_Draw_Function + (Kind : in Box_Kind; + Func : in Box_Draw_Function; + Offset_X, Offset_Y : in Byte_Integer := 0; + Offset_W, Offset_H : in Byte_Integer := 0); + + + + + -- Label_Kind Attributes -- - -- procedure Set_Box_Draw_Function - -- (Kind : in Box_Kind; - -- Func : in Box_Draw_Function; - -- Offset_X, Offset_Y : in Integer := 0; - -- Offset_W, Offset_H : in Integer := 0); + procedure Set_Label_Kind + (Target, Source : in Label_Kind); + + procedure Set_Label_Draw_Function + (Kind : in Label_Kind; + Draw_Func : in Label_Draw_Function; + Measure_Func : in Label_Measure_Function); @@ -250,6 +351,10 @@ package FLTK.Static is (Owner : in FLTK.Widgets.Widget'Class; Text : in String); + function Clipboard_Contains + (Kind : in String) + return Boolean; + @@ -266,18 +371,12 @@ package FLTK.Static is - -- Input Focus -- + -- Input Methods -- procedure Enable_System_Input; procedure Disable_System_Input; - function Has_Visible_Focus - return Boolean; - - procedure Set_Visible_Focus - (To : in Boolean); - @@ -307,8 +406,6 @@ package FLTK.Static is function Read_Queue return access FLTK.Widgets.Widget'Class; - procedure Do_Widget_Deletion; - @@ -354,25 +451,54 @@ package FLTK.Static is private - File_Mode_Codes : array (File_Mode) of Interfaces.C.int := - (Read => 1, Write => 4, Except => 8); + The_Argv : Interfaces.C.Strings.chars_ptr_array := FLTK.Args_Marshal.Create_Argv; + + for File_Mode use record + Read at 0 range 0 .. 0; + -- bit position 1 is unused + Write at 0 range 2 .. 2; + Except at 0 range 3 .. 3; + end record; + + for File_Mode'Size use Interfaces.C.int'Size; + + Read_Mode : constant File_Mode := (Read => True, others => False); + Write_Mode : constant File_Mode := (Write => True, others => False); + Except_Mode : constant File_Mode := (Except => True, others => False); + + function FMode_To_Cint is new + Ada.Unchecked_Conversion (File_Mode, Interfaces.C.int); + + + help_usage_string_ptr : Interfaces.C.Strings.chars_ptr; + pragma Import (C, help_usage_string_ptr, "fl_help_usage_string_ptr"); + + Help_Message : constant String := Interfaces.C.Strings.Value (help_usage_string_ptr); + + + Font_Overrides : array (Font_Kind) of Interfaces.C.Strings.chars_ptr; + + + pragma Import (C, Lock, "fl_static_lock"); + pragma Import (C, Unlock, "fl_static_unlock"); pragma Import (C, Own_Colormap, "fl_static_own_colormap"); pragma Import (C, System_Colors, "fl_static_get_system_colors"); - pragma Import (C, Drag_Drop_Start, "fl_static_dnd"); - pragma Import (C, Enable_System_Input, "fl_static_enable_im"); pragma Import (C, Disable_System_Input, "fl_static_disable_im"); - pragma Import (C, Do_Widget_Deletion, "fl_static_do_widget_deletion"); - pragma Import (C, Reload_Scheme, "fl_static_reload_scheme"); + pragma Inline (Parse_Arg); + pragma Inline (Add_Awake_Handler); pragma Inline (Get_Awake_Handler); + pragma Inline (Awake); + pragma Inline (Lock); + pragma Inline (Unlock); pragma Inline (Add_Check); pragma Inline (Has_Check); @@ -396,6 +522,8 @@ private pragma Inline (Get_Color); pragma Inline (Set_Color); pragma Inline (Free_Color); + pragma Inline (Get_Box_Color); + pragma Inline (Set_Box_Color); pragma Inline (Own_Colormap); pragma Inline (Set_Foreground); pragma Inline (Set_Background); @@ -414,12 +542,16 @@ private pragma Inline (Get_Box_Y_Offset); pragma Inline (Set_Box_Kind); pragma Inline (Draw_Box_Active); - -- pragma Inline (Get_Box_Draw_Function); - -- pragma Inline (Set_Box_Draw_Function); + pragma Inline (Get_Box_Draw_Function); + pragma Inline (Set_Box_Draw_Function); + + pragma Inline (Set_Label_Kind); + pragma Inline (Set_Label_Draw_Function); pragma Inline (Copy); pragma Inline (Paste); pragma Inline (Selection); + pragma Inline (Clipboard_Contains); pragma Inline (Drag_Drop_Start); pragma Inline (Get_Drag_Drop_Text_Support); @@ -427,8 +559,6 @@ private pragma Inline (Enable_System_Input); pragma Inline (Disable_System_Input); - pragma Inline (Has_Visible_Focus); - pragma Inline (Set_Visible_Focus); pragma Inline (Default_Window_Close); pragma Inline (Get_First_Window); @@ -437,7 +567,6 @@ private pragma Inline (Get_Top_Modal); pragma Inline (Read_Queue); - pragma Inline (Do_Widget_Deletion); pragma Inline (Get_Scheme); pragma Inline (Set_Scheme); @@ -451,6 +580,15 @@ private pragma Inline (Set_Default_Scrollbar_Size); + -- Needed to dealloc the argv array and deregister the clipboard notify handler + type FLTK_Static_Final_Controller is new Ada.Finalization.Limited_Controlled with null record; + + overriding procedure Finalize + (This : in out FLTK_Static_Final_Controller); + + Cleanup : FLTK_Static_Final_Controller; + + end FLTK.Static; diff --git a/spec/fltk-widgets-groups-windows.ads b/spec/fltk-widgets-groups-windows.ads index dfa51d6..e2f9b3e 100644 --- a/spec/fltk-widgets-groups-windows.ads +++ b/spec/fltk-widgets-groups-windows.ads @@ -8,10 +8,6 @@ with FLTK.Images.RGB; -private with - - Interfaces.C.Strings; - package FLTK.Widgets.Groups.Windows is diff --git a/spec/fltk-widgets-inputs.ads b/spec/fltk-widgets-inputs.ads index 12fcb77..6de80da 100644 --- a/spec/fltk-widgets-inputs.ads +++ b/spec/fltk-widgets-inputs.ads @@ -10,8 +10,7 @@ limited with private with - Interfaces.C.Strings, - System; + Interfaces.C.Strings; package FLTK.Widgets.Inputs is diff --git a/spec/fltk-widgets-menus-menu_buttons.ads b/spec/fltk-widgets-menus-menu_buttons.ads index 033e3e5..7a93a6d 100644 --- a/spec/fltk-widgets-menus-menu_buttons.ads +++ b/spec/fltk-widgets-menus-menu_buttons.ads @@ -4,10 +4,6 @@ -- Released into the public domain -with - - FLTK.Menu_Items; - limited with FLTK.Widgets.Groups; diff --git a/spec/fltk-widgets.ads b/spec/fltk-widgets.ads index 144e1f7..67c1625 100644 --- a/spec/fltk-widgets.ads +++ b/spec/fltk-widgets.ads @@ -14,7 +14,6 @@ limited with private with - Ada.Unchecked_Conversion, System.Address_To_Access_Conversions, Interfaces.C, FLTK.Widget_Callback_Conversions; @@ -32,46 +31,6 @@ package FLTK.Widgets is (Item : in out Widget'Class); - type Callback_Flag is record - Changed : Boolean := False; - Interact : Boolean := False; - Release : Boolean := False; - Enter_Key : Boolean := False; - end record; - - function "+" (Left, Right : in Callback_Flag) return Callback_Flag; - - Call_Never : constant Callback_Flag; - When_Changed : constant Callback_Flag; - When_Interact : constant Callback_Flag; - When_Release : constant Callback_Flag; - When_Release_Always : constant Callback_Flag; - When_Enter_Key : constant Callback_Flag; - When_Enter_Key_Always : constant Callback_Flag; - - - type Damage_Mask is record - Child : Boolean := False; - Expose : Boolean := False; - Scroll : Boolean := False; - Overlay : Boolean := False; - User_1 : Boolean := False; - User_2 : Boolean := False; - Full : Boolean := False; - end record; - - function "+" (Left, Right : in Damage_Mask) return Damage_Mask; - - Damage_None : constant Damage_Mask; - Damage_Child : constant Damage_Mask; - Damage_Expose : constant Damage_Mask; - Damage_Scroll : constant Damage_Mask; - Damage_Overlay : constant Damage_Mask; - Damage_User_1 : constant Damage_Mask; - Damage_User_2 : constant Damage_Mask; - Damage_Full : constant Damage_Mask; - - package Forge is @@ -557,64 +516,6 @@ private (This : in out Widget); - for Callback_Flag use record - Changed at 0 range 0 .. 0; - Interact at 0 range 1 .. 1; - Release at 0 range 2 .. 2; - Enter_Key at 0 range 3 .. 3; - end record; - - for Callback_Flag'Size use Interfaces.C.unsigned_char'Size; - - Call_Never : constant Callback_Flag := (others => False); - When_Changed : constant Callback_Flag := (Changed => True, others => False); - When_Interact : constant Callback_Flag := (Interact => True, others => False); - When_Release : constant Callback_Flag := (Release => True, others => False); - When_Enter_Key : constant Callback_Flag := (Enter_Key => True, others => False); - - When_Release_Always : constant Callback_Flag := - (Release => True, Interact => True, others => False); - When_Enter_Key_Always : constant Callback_Flag := - (Enter_Key => True, Interact => True, others => False); - - - for Damage_Mask use record - Child at 0 range 0 .. 0; - Expose at 0 range 1 .. 1; - Scroll at 0 range 2 .. 2; - Overlay at 0 range 3 .. 3; - User_1 at 0 range 4 .. 4; - User_2 at 0 range 5 .. 5; - -- bit 6 missing - Full at 0 range 7 .. 7; - end record; - - for Damage_Mask'Size use Interfaces.C.unsigned_char'Size; - - Damage_None : constant Damage_Mask := (others => False); - Damage_Child : constant Damage_Mask := (Child => True, others => False); - Damage_Expose : constant Damage_Mask := (Expose => True, others => False); - Damage_Scroll : constant Damage_Mask := (Scroll => True, others => False); - Damage_Overlay : constant Damage_Mask := (Overlay => True, others => False); - Damage_User_1 : constant Damage_Mask := (User_1 => True, others => False); - Damage_User_2 : constant Damage_Mask := (User_2 => True, others => False); - Damage_Full : constant Damage_Mask := (Full => True, others => False); - - - function Flag_To_UChar is new - Ada.Unchecked_Conversion (Callback_Flag, Interfaces.C.unsigned_char); - - function UChar_To_Flag is new - Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Callback_Flag); - - - function Mask_To_UChar is new - Ada.Unchecked_Conversion (Damage_Mask, Interfaces.C.unsigned_char); - - function UChar_To_Mask is new - Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Damage_Mask); - - -- the user data portion should always be a reference back to the Ada binding procedure Callback_Hook (W, U : in Storage.Integer_Address); diff --git a/spec/fltk.ads b/spec/fltk.ads index 8129281..964af79 100644 --- a/spec/fltk.ads +++ b/spec/fltk.ads @@ -6,11 +6,13 @@ with - Ada.Finalization; + Ada.Finalization, + System; private with - Interfaces.C, + Ada.Unchecked_Conversion, + Interfaces.C.Strings, System.Storage_Elements; @@ -33,27 +35,70 @@ package FLTK is -- Text buffers for marshalling purposes will be this size. Buffer_Size : constant Natural := 1024; + -- For image data arrays. + type Size_Type is mod 2 ** System.Word_Size; + subtype Positive_Size is Size_Type range 1 .. Size_Type'Last; + -- Color -- - -- Values scale from A/Black to X/White + -- Values scale from A/Black to X/White. type Greyscale is new Character range 'A' .. 'X'; type Color is mod 2**32; type Color_Component is mod 256; - type Color_Component_Array is array (Positive range <>) of aliased Color_Component; + type Color_Component_Array is array (Positive_Size range <>) of aliased Color_Component; + + subtype Blend is Float range 0.0 .. 1.0; + + function RGB_Color + (Light : in Greyscale) + return Color; + + function RGB_Color + (Light : in Color_Component) + return Color; function RGB_Color (R, G, B : in Color_Component) return Color; + function Color_Cube + (R, G, B : in Color_Component) + return Color; + + function Grey_Ramp + (Light : in Greyscale) + return Color; + + function Grey_Ramp + (Light : in Color_Component) + return Color; + + function Darker + (Tone : in Color) + return Color; + + function Lighter + (Tone : in Color) + return Color; + function Contrast (Fore, Back : in Color) return Color; + function Inactive + (Tone : in Color) + return Color; + + function Color_Average + (Tone1, Tone2 : in Color; + Weight : in Blend := 0.5) + return Color; + -- Examples of RGB colors without the above function -- The lowest byte has to be 00 for the color to be RGB RGB_Red_Color : constant Color := 16#ff000000#; @@ -188,7 +233,14 @@ package FLTK is Tab_Key : constant Keypress; - type Mouse_Button is (No_Button, Left_Button, Middle_Button, Right_Button); + type Mouse_Button is + (No_Button, + Left_Button, + Middle_Button, + Right_Button, + Back_Button, + Forward_Button, + Any_Button); type Key_Combo is private; @@ -282,6 +334,18 @@ package FLTK is Gleam_Round_Down_Box, Free_Box); + function Filled + (Box : in Box_Kind) + return Box_Kind; + + function Frame + (Box : in Box_Kind) + return Box_Kind; + + function Down + (Box : in Box_Kind) + return Box_Kind; + @@ -365,11 +429,45 @@ package FLTK is + -- Callback Flags -- + + type Callback_Flag is record + Changed : Boolean := False; + Interact : Boolean := False; + Release : Boolean := False; + Enter_Key : Boolean := False; + end record; + + function "+" (Left, Right : in Callback_Flag) return Callback_Flag; + function "-" (Left, Right : in Callback_Flag) return Callback_Flag; + + Call_Never : constant Callback_Flag; + When_Changed : constant Callback_Flag; + When_Interact : constant Callback_Flag; + When_Release : constant Callback_Flag; + When_Release_Always : constant Callback_Flag; + When_Enter_Key : constant Callback_Flag; + When_Enter_Key_Always : constant Callback_Flag; + + + + -- Menu Flags -- - type Menu_Flag is private; + -- It's easier to have this here rather than in Menu_Items for visibility reasons. + + type Menu_Flag is record + Inactive : Boolean := False; + Toggle : Boolean := False; + Value : Boolean := False; + Radio : Boolean := False; + Invisible : Boolean := False; + Submenu : Boolean := False; + Divider : Boolean := False; + end record; function "+" (Left, Right : in Menu_Flag) return Menu_Flag; + function "-" (Left, Right : in Menu_Flag) return Menu_Flag; Flag_Normal : constant Menu_Flag; Flag_Inactive : constant Menu_Flag; @@ -383,55 +481,65 @@ package FLTK is - -- Versioning -- - - type Version_Number is new Natural; - - function ABI_Check - (ABI_Ver : in Version_Number) - return Boolean; - - function ABI_Version - return Version_Number; + -- Damage Bits -- - function API_Version - return Version_Number; + type Damage_Mask is record + Child : Boolean := False; + Expose : Boolean := False; + Scroll : Boolean := False; + Overlay : Boolean := False; + User_1 : Boolean := False; + User_2 : Boolean := False; + Full : Boolean := False; + end record; - function Version - return Version_Number; + function "+" (Left, Right : in Damage_Mask) return Damage_Mask; + function "-" (Left, Right : in Damage_Mask) return Damage_Mask; + Damage_None : constant Damage_Mask; + Damage_Child : constant Damage_Mask; + Damage_Expose : constant Damage_Mask; + Damage_Scroll : constant Damage_Mask; + Damage_Overlay : constant Damage_Mask; + Damage_User_1 : constant Damage_Mask; + Damage_User_2 : constant Damage_Mask; + Damage_Full : constant Damage_Mask; - -- Threads -- - procedure Awake; + -- Clipboard Attributes -- - procedure Lock; + Clipboard_Image : constant String; + Clipboard_Plain_Text : constant String; - procedure Unlock; + -- Versioning -- - -- Drawing -- + type Version_Number is new Natural; - -- Need to check/revise these damage bits... - function Is_Damaged + function ABI_Check + (ABI_Ver : in Version_Number) return Boolean; - procedure Set_Damaged - (To : in Boolean); + function ABI_Version + return Version_Number; - procedure Flush; + function API_Version + return Version_Number; - procedure Redraw; + function Version + return Version_Number; -- Event Loop -- + procedure Check; + function Check return Boolean; @@ -443,7 +551,7 @@ package FLTK is function Wait (Seconds : in Long_Float) - return Integer; + return Long_Float; function Run return Integer; @@ -480,18 +588,16 @@ private -- Note: This has to be Limited because otherwise the various init subprograms -- wouldn't work, the widget callbacks wouldn't work, deallocation would be -- a mess, really just all sorts of problems. - type Wrapper is new Ada.Finalization.Limited_Controlled with - record - Void_Ptr : Storage.Integer_Address := Null_Pointer; - Needs_Dealloc : Boolean := True; - end record; + type Wrapper is new Ada.Finalization.Limited_Controlled with record + Void_Ptr : Storage.Integer_Address := Null_Pointer; + Needs_Dealloc : Boolean := True; + end record; for Color_Component_Array'Component_Size use Interfaces.C.CHAR_BIT; pragma Convention (C, Color_Component_Array); - pragma Pack (Color_Component_Array); @@ -569,34 +675,34 @@ private function To_C (Key : in Key_Combo) - return Interfaces.C.int; + return Interfaces.C.unsigned; function To_Ada - (Key : in Interfaces.C.int) + (Key : in Interfaces.C.unsigned) return Key_Combo; function To_C (Key : in Keypress) - return Interfaces.C.int; + return Interfaces.C.unsigned; function To_Ada - (Key : in Interfaces.C.int) + (Key : in Interfaces.C.unsigned) return Keypress; function To_C (Modi : in Modifier) - return Interfaces.C.int; + return Interfaces.C.unsigned; function To_Ada - (Modi : in Interfaces.C.int) + (Modi : in Interfaces.C.unsigned) return Modifier; function To_C (Button : in Mouse_Button) - return Interfaces.C.int; + return Interfaces.C.unsigned; function To_Ada - (Button : in Interfaces.C.int) + (Button : in Interfaces.C.unsigned) return Mouse_Button; -- these values designed to align with FLTK enumeration types @@ -635,48 +741,128 @@ private - type Menu_Flag is new Interfaces.Unsigned_8; + for Callback_Flag use record + Changed at 0 range 0 .. 0; + Interact at 0 range 1 .. 1; + Release at 0 range 2 .. 2; + Enter_Key at 0 range 3 .. 3; + end record; + + for Callback_Flag'Size use Interfaces.C.unsigned_char'Size; + + Call_Never : constant Callback_Flag := (others => False); + When_Changed : constant Callback_Flag := (Changed => True, others => False); + When_Interact : constant Callback_Flag := (Interact => True, others => False); + When_Release : constant Callback_Flag := (Release => True, others => False); + When_Enter_Key : constant Callback_Flag := (Enter_Key => True, others => False); - Flag_Normal : constant Menu_Flag := 2#00000000#; - Flag_Inactive : constant Menu_Flag := 2#00000001#; - Flag_Toggle : constant Menu_Flag := 2#00000010#; - Flag_Value : constant Menu_Flag := 2#00000100#; - Flag_Radio : constant Menu_Flag := 2#00001000#; - Flag_Invisible : constant Menu_Flag := 2#00010000#; - -- Flag_Submenu_Pointer unlikely to be used - Flag_Submenu : constant Menu_Flag := 2#01000000#; - Flag_Divider : constant Menu_Flag := 2#10000000#; + When_Release_Always : constant Callback_Flag := + (Release => True, Interact => True, others => False); + When_Enter_Key_Always : constant Callback_Flag := + (Enter_Key => True, Interact => True, others => False); + function Flag_To_UChar is new + Ada.Unchecked_Conversion (Callback_Flag, Interfaces.C.unsigned_char); + function UChar_To_Flag is new + Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Callback_Flag); - pragma Import (C, Awake, "fl_awake"); - pragma Import (C, Lock, "fl_lock"); - pragma Import (C, Unlock, "fl_unlock"); - pragma Import (C, Flush, "fl_flush"); - pragma Import (C, Redraw, "fl_redraw"); + + for Menu_Flag use record + Inactive at 0 range 0 .. 0; + Toggle at 0 range 1 .. 1; + Value at 0 range 2 .. 2; + Radio at 0 range 3 .. 3; + Invisible at 0 range 4 .. 4; + -- Submenu_Pointer unused + Submenu at 0 range 6 .. 6; + Divider at 0 range 7 .. 7; + end record; + + for Menu_Flag'Size use Interfaces.C.int'Size; + + Flag_Normal : constant Menu_Flag := (others => False); + Flag_Inactive : constant Menu_Flag := (Inactive => True, others => False); + Flag_Toggle : constant Menu_Flag := (Toggle => True, others => False); + Flag_Value : constant Menu_Flag := (Value => True, others => False); + Flag_Radio : constant Menu_Flag := (Radio => True, others => False); + Flag_Invisible : constant Menu_Flag := (Invisible => True, others => False); + -- Flag_Submenu_Pointer unused + Flag_Submenu : constant Menu_Flag := (Submenu => True, others => False); + Flag_Divider : constant Menu_Flag := (Divider => True, others => False); + + function MFlag_To_Cint is new + Ada.Unchecked_Conversion (Menu_Flag, Interfaces.C.int); + + function Cint_To_MFlag is new + Ada.Unchecked_Conversion (Interfaces.C.int, Menu_Flag); + + + + + for Damage_Mask use record + Child at 0 range 0 .. 0; + Expose at 0 range 1 .. 1; + Scroll at 0 range 2 .. 2; + Overlay at 0 range 3 .. 3; + User_1 at 0 range 4 .. 4; + User_2 at 0 range 5 .. 5; + -- bit 6 missing + Full at 0 range 7 .. 7; + end record; + + for Damage_Mask'Size use Interfaces.C.unsigned_char'Size; + + Damage_None : constant Damage_Mask := (others => False); + Damage_Child : constant Damage_Mask := (Child => True, others => False); + Damage_Expose : constant Damage_Mask := (Expose => True, others => False); + Damage_Scroll : constant Damage_Mask := (Scroll => True, others => False); + Damage_Overlay : constant Damage_Mask := (Overlay => True, others => False); + Damage_User_1 : constant Damage_Mask := (User_1 => True, others => False); + Damage_User_2 : constant Damage_Mask := (User_2 => True, others => False); + Damage_Full : constant Damage_Mask := (Full => True, others => False); + + function Mask_To_UChar is new + Ada.Unchecked_Conversion (Damage_Mask, Interfaces.C.unsigned_char); + + function UChar_To_Mask is new + Ada.Unchecked_Conversion (Interfaces.C.unsigned_char, Damage_Mask); + + + + + clip_image_char_ptr : Interfaces.C.Strings.chars_ptr; + pragma Import (C, clip_image_char_ptr, "fl_clip_image_char_ptr"); + + clip_plain_text_char_ptr : Interfaces.C.Strings.chars_ptr; + pragma Import (C, clip_plain_text_char_ptr, "fl_clip_plain_text_char_ptr"); + + Clipboard_Image : constant String := Interfaces.C.Strings.Value (clip_image_char_ptr); + Clipboard_Plain_Text : constant String := Interfaces.C.Strings.Value (clip_plain_text_char_ptr); pragma Inline (RGB_Color); + pragma Inline (Color_Cube); + pragma Inline (Grey_Ramp); + pragma Inline (Darker); + pragma Inline (Lighter); pragma Inline (Contrast); + pragma Inline (Inactive); + pragma Inline (Color_Average); + + pragma Inline (Filled); + pragma Inline (Frame); + pragma Inline (Down); pragma Inline (ABI_Check); pragma Inline (ABI_Version); pragma Inline (API_Version); pragma Inline (Version); - pragma Inline (Awake); - pragma Inline (Lock); - pragma Inline (Unlock); - - pragma Inline (Is_Damaged); - pragma Inline (Set_Damaged); - pragma Inline (Flush); - pragma Inline (Redraw); - pragma Inline (Check); pragma Inline (Ready); pragma Inline (Wait); diff --git a/test/animated.adb b/test/animated.adb index 42d2a49..4f6f590 100644 --- a/test/animated.adb +++ b/test/animated.adb @@ -34,7 +34,8 @@ is Dimension : constant Integer := 256; - subtype Image_Data is FLTK.Color_Component_Array (1 .. Dimension ** 2 * Channels); + subtype Image_Data is FLTK.Color_Component_Array + (1 .. FLTK.Size_Type (Dimension ** 2 * Channels)); type Image_Data_Array is array (Positive range <>) of Image_Data; @@ -43,7 +44,7 @@ is begin for X in Integer range 0 .. 9 loop for Y in Integer range 0 .. 9 loop - Store (Y * Dimension * Channels + X * Channels + 4) := 255; + Store (FLTK.Size_Type (Channels * (Y * Dimension + X) + 4)) := 255; end loop; end loop; end Black_Box_Corner; @@ -82,10 +83,10 @@ is My_Alpha := FLTK.Color_Component (Float (My_Alpha) * (1.0 - Fill) * 10.0); end if; - Store (Y * Dimension * Channels + X * Channels + 1) := Grey; - Store (Y * Dimension * Channels + X * Channels + 2) := Grey; - Store (Y * Dimension * Channels + X * Channels + 3) := Grey; - Store (Y * Dimension * Channels + X * Channels + 4) := My_Alpha; + Store (FLTK.Size_Type (Channels * (Y * Dimension + X) + 1)) := Grey; + Store (FLTK.Size_Type (Channels * (Y * Dimension + X) + 2)) := Grey; + Store (FLTK.Size_Type (Channels * (Y * Dimension + X) + 3)) := Grey; + Store (FLTK.Size_Type (Channels * (Y * Dimension + X) + 4)) := My_Alpha; end if; end loop; end loop; @@ -106,8 +107,10 @@ is if (X + X_Offset >= 0) and (X + X_Offset < Dimension) then for Y in Integer range Y_Offset - W .. Y_Offset + W - 1 loop Grey := FLTK.Color_Component (abs (Y - Y_Offset)); - Store (Y * Dimension * Channels + (X + X_Offset) * Channels + 3) := Grey; - Store (Y * Dimension * Channels + (X + X_Offset) * Channels + 4) := 127; + Store (FLTK.Size_Type + (Channels * (Y * Dimension + (X + X_Offset)) + 3)) := Grey; + Store (FLTK.Size_Type + (Channels * (Y * Dimension + (X + X_Offset)) + 4)) := 127; end loop; end if; end loop; @@ -130,7 +133,7 @@ is Frame_Image_Data : constant Image_Data_Array := Make_Image_Data; -- This syntax requires Ada 2022, but it allows all overt heap usage to be avoided - Frame_Images : array (Positive range <>) of RGB.RGB_Image := + Frame_Images : constant array (Positive range <>) of RGB.RGB_Image := (for Index in Frame_Image_Data'Range => RGB.Forge.Create (Frame_Image_Data (Index), Dimension, Dimension, Channels)); diff --git a/test/ask.adb b/test/ask.adb index cb12fff..81ab104 100644 --- a/test/ask.adb +++ b/test/ask.adb @@ -16,7 +16,6 @@ with FLTK.Widgets.Boxes, FLTK.Widgets.Buttons, FLTK.Widgets.Buttons.Enter, - FLTK.Widgets.Inputs.Text, FLTK.Widgets.Groups.Windows.Double; use type @@ -38,7 +37,6 @@ is package BX renames FLTK.Widgets.Boxes; package BTN renames FLTK.Widgets.Buttons; package ENT renames FLTK.Widgets.Buttons.Enter; - package INP renames FLTK.Widgets.Inputs.Text; package WD renames FLTK.Widgets.Groups.Windows.Double; @@ -54,7 +52,7 @@ is procedure Rename_Me (Item : in out FLTK.Widgets.Widget'Class) is - Input : String := AK.Text_Input ("Input:", Item.Get_Label); + Input : constant String := AK.Text_Input ("Input:", Item.Get_Label); begin Update_Input_Text (Item, Input); end Rename_Me; @@ -63,7 +61,7 @@ is procedure Rename_Me_Pwd (Item : in out FLTK.Widgets.Widget'Class) is - Input : String := AK.Password ("Input PWD:", Item.Get_Label); + Input : constant String := AK.Password ("Input PWD:", Item.Get_Label); begin Update_Input_Text (Item, Input); end Rename_Me_Pwd; @@ -72,7 +70,7 @@ is procedure Window_Callback (Item : in out FLTK.Widgets.Widget'Class) is - Hotspot : Boolean := AK.Get_Message_Hotspot; + Hotspot : constant Boolean := AK.Get_Message_Hotspot; Reply : AK.Choice_Result; begin AK.Set_Message_Hotspot (False); @@ -91,7 +89,7 @@ is Stop : Boolean := False; procedure Timer_Callback is - Message_Icon : BX.Box_Reference := AK.Get_Message_Icon; + Message_Icon : constant BX.Box_Reference := AK.Get_Message_Icon; My_Color : FLTK.Color; begin if Stop then diff --git a/test/bitmap.adb b/test/bitmap.adb index 86c1406..04f4793 100644 --- a/test/bitmap.adb +++ b/test/bitmap.adb @@ -117,7 +117,7 @@ is procedure Button_Callback - (Item : in out FLTK.Widgets.Widget'Class) + (Ignore : in out FLTK.Widgets.Widget'Class) is New_Align : FLTK.Alignment; begin diff --git a/test/button.adb b/test/button.adb index 9ca6102..1cd6557 100644 --- a/test/button.adb +++ b/test/button.adb @@ -29,7 +29,7 @@ is procedure Beep_Callback - (This : in out Wdg.Widget'Class) is + (Ignore : in out Wdg.Widget'Class) is begin Ask.Beep; end Beep_Callback; @@ -39,7 +39,7 @@ is procedure Exit_Callback - (This : in out Wdg.Widget'Class) is + (Ignore : in out Wdg.Widget'Class) is begin ACom.Set_Exit_Status (ACom.Success); The_Window.Hide; diff --git a/test/buttons.adb b/test/buttons.adb index e93da8e..a502f44 100644 --- a/test/buttons.adb +++ b/test/buttons.adb @@ -9,7 +9,6 @@ with - FLTK.Tooltips, FLTK.Widgets.Buttons.Enter, FLTK.Widgets.Buttons.Light.Check, FLTK.Widgets.Buttons.Light.Round, diff --git a/test/clock.adb b/test/clock.adb index b4d8f40..e550941 100644 --- a/test/clock.adb +++ b/test/clock.adb @@ -23,11 +23,11 @@ is package WD renames FLTK.Widgets.Groups.Windows.Double; - Window_One : WD.Double_Window := WD.Forge.Create (220, 220, "Fl_Clock"); - Clock_One : CL.Updated_Clock := CL.Forge.Create (Window_One, 0, 0, 220, 220); + Window_One : WD.Double_Window := WD.Forge.Create (220, 220, "Fl_Clock"); + Clock_One : constant CL.Updated_Clock := CL.Forge.Create (Window_One, 0, 0, 220, 220); - Window_Two : WD.Double_Window := WD.Forge.Create (220, 220, "Fl_Round_Clock"); - Clock_Two : CR.Round_Clock := CR.Forge.Create (Window_Two, 0, 0, 220, 220); + Window_Two : WD.Double_Window := WD.Forge.Create (220, 220, "Fl_Round_Clock"); + Clock_Two : constant CR.Round_Clock := CR.Forge.Create (Window_Two, 0, 0, 220, 220); begin diff --git a/test/color_chooser.adb b/test/color_chooser.adb index 09003b9..1c7537c 100644 --- a/test/color_chooser.adb +++ b/test/color_chooser.adb @@ -21,6 +21,7 @@ with use type FLTK.Color, + FLTK.Size_Type, FLTK.Asks.Confirm_Result; @@ -44,14 +45,14 @@ is return FLTK.Color_Component_Array is X_Frac, Y_Frac : Long_Float; - Offset : Integer; + Offset : FLTK.Size_Type; begin - return Data : FLTK.Color_Component_Array (1 .. W * H * 3) do + return Data : FLTK.Color_Component_Array (1 .. FLTK.Size_Type (W * H * 3)) do for Y in 0 .. H - 1 loop Y_Frac := Long_Float (Y) / Long_Float (H - 1); for X in 0 .. W - 1 loop X_Frac := Long_Float (X) / Long_Float (W - 1); - Offset := 3 * (Y * W + X); + Offset := 3 * FLTK.Size_Type (Y * W + X); Data (Offset + 1) := FLTK.Color_Component (255.0 * (1.0 - X_Frac) * (1.0 - Y_Frac)); Data (Offset + 2) := @@ -66,7 +67,8 @@ is Image_Width, Image_Height : constant Natural := 100; - The_Image_Data : FLTK.Color_Component_Array := Make_Image_Data (Image_Width, Image_Height); + The_Image_Data : constant FLTK.Color_Component_Array := + Make_Image_Data (Image_Width, Image_Height); type Pens is new Bx.Box with null record; @@ -108,7 +110,7 @@ is procedure Callback_One - (This : in out FLTK.Widgets.Widget'Class) is + (Ignore : in out FLTK.Widgets.Widget'Class) is begin My_Color := Ask.Show_Colormap (My_Color); The_Box.Set_Background_Color (My_Color); @@ -118,7 +120,7 @@ is procedure Callback_Two - (This : in out FLTK.Widgets.Widget'Class) + (Ignore : in out FLTK.Widgets.Widget'Class) is R, G, B : FLTK.Color_Component; begin diff --git a/test/compare.adb b/test/compare.adb index 2273414..a631416 100644 --- a/test/compare.adb +++ b/test/compare.adb @@ -15,11 +15,11 @@ procedure Compare is package TIO renames Ada.Text_IO; package FFN renames FLTK.Filenames; - Aardvark : String := "aardvark"; - Zebra : String := "Zebra"; - Two : String := "item_2"; - Ten : String := "item_10"; - Cap_Ten : String := "Item_10"; + Aardvark : constant String := "aardvark"; + Zebra : constant String := "Zebra"; + Two : constant String := "item_2"; + Ten : constant String := "item_10"; + Cap_Ten : constant String := "Item_10"; begin diff --git a/test/cursor.adb b/test/cursor.adb index e968b6f..93d3f2b 100644 --- a/test/cursor.adb +++ b/test/cursor.adb @@ -16,7 +16,7 @@ with use type - FLTK.Widgets.Callback_Flag; + FLTK.Callback_Flag; function Cursor @@ -95,7 +95,7 @@ begin The_Choices.Add ("FL_CURSOR_NONE", Choice_Callback'Unrestricted_Access); The_Choices.Set_Callback (Choice_Callback'Unrestricted_Access); - The_Choices.Set_When (FLTK.Widgets.When_Release + FLTK.Widgets.When_Interact); + The_Choices.Set_When (FLTK.When_Release + FLTK.When_Interact); The_Choices.Set_Chosen (1); The_Slider.Set_Alignment (FLTK.Align_Left); diff --git a/test/dirlist.adb b/test/dirlist.adb index 1a07515..a7c159a 100644 --- a/test/dirlist.adb +++ b/test/dirlist.adb @@ -39,7 +39,7 @@ begin end if; declare - Name : Fil.Path_String := Fil.Expand (ACom.Argument (1)); + Name : constant Fil.Path_String := Fil.Expand (ACom.Argument (1)); begin if not Fil.Is_Directory (Name) then TIO.Put_Line ("Error: " & Name & " is not a valid directory."); @@ -48,7 +48,7 @@ begin end if; declare - The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Alpha_Sort'Access); + The_List : constant Fil.File_List := Fil.Get_Listing (Name, Fil.Alpha_Sort'Access); begin TIO.Put_Line ("Alphabetical Sort:"); for Index in 1 .. The_List.Length loop @@ -58,7 +58,7 @@ begin end; declare - The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Alpha_Sort'Access); + The_List : constant Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Alpha_Sort'Access); begin TIO.Put_Line ("Case Insensitive Alphabetical Sort:"); for Index in 1 .. The_List.Length loop @@ -68,7 +68,7 @@ begin end; declare - The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Numeric_Sort'Access); + The_List : constant Fil.File_List := Fil.Get_Listing (Name, Fil.Numeric_Sort'Access); begin TIO.Put_Line ("Numeric Sort:"); for Index in 1 .. The_List.Length loop @@ -78,7 +78,8 @@ begin end; declare - The_List : Fil.File_List := Fil.Get_Listing (Name, Fil.Case_Numeric_Sort'Access); + The_List : constant Fil.File_List := + Fil.Get_Listing (Name, Fil.Case_Numeric_Sort'Access); begin TIO.Put_Line ("Case Insensitive Numeric Sort:"); for Index in 1 .. The_List.Length loop diff --git a/test/filename.adb b/test/filename.adb new file mode 100644 index 0000000..937fba4 --- /dev/null +++ b/test/filename.adb @@ -0,0 +1,40 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Ada.Command_Line, + Ada.Text_IO, + FLTK.Filenames; + + +procedure Filename is + + package ACom renames Ada.Command_Line; + package TIO renames Ada.Text_IO; + package Fil renames FLTK.Filenames; + +begin + + TIO.Put_Line ("Test program for FLTK filename absolute and expand functions."); + TIO.New_Line; + TIO.Put ("Input: "); + + if ACom.Argument_Count /= 1 then + TIO.Put_Line ("Error: Need exactly one filename argument."); + ACom.Set_Exit_Status (ACom.Failure); + return; + end if; + + TIO.Put_Line (ACom.Argument (1)); + TIO.New_Line; + + TIO.Put_Line ("Absolute: " & Fil.Absolute (ACom.Argument (1))); + TIO.Put_Line ("Expanded: " & Fil.Expand (ACom.Argument (1))); + +end Filename; + + diff --git a/test/pixmap.adb b/test/pixmap.adb index 0ca3982..a9cf6b7 100644 --- a/test/pixmap.adb +++ b/test/pixmap.adb @@ -34,15 +34,15 @@ is package WD renames FLTK.Widgets.Groups.Windows.Double; - Porsche_Header : Pix.Header := (64, 64, 4, 1); + Porsche_Header : constant Pix.Header := (64, 64, 4, 1); - Porsche_Colors : Pix.Color_Definition_Array := + Porsche_Colors : constant Pix.Color_Definition_Array := ((Name => +" ", Kind => Pix.Colorful, Value => +"#background"), (Name => +".", Kind => Pix.Colorful, Value => +"#000000000000"), (Name => +"X", Kind => Pix.Colorful, Value => +"#ffd100"), (Name => +"o", Kind => Pix.Colorful, Value => +"#FFFF00000000")); - Porsche_Data : Pix.Pixmap_Data := + Porsche_Data : constant Pix.Pixmap_Data := (" ", " .......................... ", " ..................................... ", @@ -126,7 +126,7 @@ is procedure Button_Callback - (Item : in out FLTK.Widgets.Widget'Class) + (Ignore : in out FLTK.Widgets.Widget'Class) is New_Align : FLTK.Alignment; begin @@ -12,8 +12,8 @@ project Tests is for Languages use ("Ada"); for Source_Dirs use ("test"); - for Object_Dir use "obj"; - for Exec_Dir use "bin"; + for Object_Dir use "obj"; + for Exec_Dir use "bin"; for Main use ("adjuster.adb", @@ -26,6 +26,7 @@ project Tests is "color_chooser.adb", "cursor.adb", "dirlist.adb", + "filename.adb", "hello.adb", "page_formats.adb", "pixmap.adb"); @@ -41,12 +42,20 @@ project Tests is for Executable ("color_chooser.adb") use "color_chooser"; for Executable ("cursor.adb") use "cursor"; for Executable ("dirlist.adb") use "dirlist"; + for Executable ("filename.adb") use "filename"; for Executable ("hello.adb") use "hello"; for Executable ("page_formats.adb") use "page_formats"; for Executable ("pixmap.adb") use "pixmap"; + + for Default_Switches ("Ada") use + Common.Builder'Default_Switches ("Ada"); + for Global_Compilation_Switches ("Ada") use + Common.Builder'Global_Compilation_Switches ("Ada"); end Builder; package Compiler renames Common.Compiler; + package Binder renames Common.Binder; + package Linker renames Common.Linker; end Tests; diff --git a/tests_2022.gpr b/tests_2022.gpr index 84ed425..3c3fd92 100644 --- a/tests_2022.gpr +++ b/tests_2022.gpr @@ -12,8 +12,8 @@ project Tests_2022 is for Languages use ("Ada"); for Source_Dirs use ("test"); - for Object_Dir use "obj"; - for Exec_Dir use "bin"; + for Object_Dir use "obj"; + for Exec_Dir use "bin"; for Main use ("animated.adb", @@ -24,9 +24,16 @@ project Tests_2022 is for Executable ("animated.adb") use "animated"; for Executable ("arc.adb") use "arc"; for Executable ("curve.adb") use "curve"; + + for Default_Switches ("Ada") use + Common.Builder'Default_Switches ("Ada"); + for Global_Compilation_Switches ("Ada") use + Common.Builder'Global_Compilation_Switches ("Ada"); end Builder; package Compiler renames Common.Compiler; + package Binder renames Common.Binder; + package Linker renames Common.Linker; end Tests_2022; diff --git a/tool/template.adb b/tool/template.adb index a28fff8..4da7da6 100644 --- a/tool/template.adb +++ b/tool/template.adb @@ -19,7 +19,6 @@ with - Ada.Characters.Latin_1, Ada.Command_Line, Ada.Containers.Indefinite_Ordered_Maps, Ada.Direct_IO, @@ -32,7 +31,6 @@ with procedure Template is - package Latin renames Ada.Characters.Latin_1; package ACom renames Ada.Command_Line; package ADir renames Ada.Directories; package SMap renames Ada.Strings.Maps; @@ -11,16 +11,23 @@ project Tools is for Languages use ("Ada"); for Source_Dirs use ("tool"); - for Object_Dir use "obj"; - for Exec_Dir use "bin"; + for Object_Dir use "obj"; + for Exec_Dir use "bin"; for Main use ("template.adb"); package Builder is for Executable ("template.adb") use "template"; + + for Default_Switches ("Ada") use + Common.Builder'Default_Switches ("Ada"); + for Global_Compilation_Switches ("Ada") use + Common.Builder'Global_Compilation_Switches ("Ada"); end Builder; package Compiler renames Common.Compiler; + package Binder renames Common.Binder; + package Linker renames Common.Linker; end Tools; |