diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2024-12-13 14:37:42 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2024-12-13 14:37:42 +1300 |
commit | 43913b53865a86986c1944b13f9ab9fd32fa71e2 (patch) | |
tree | cd36ca161589bee1b2d2034f73fc47c42e30b3ce | |
parent | 86a0894a1c54e69ae56e147cc943893194664304 (diff) |
Fl_Check_Browser added
-rw-r--r-- | doc/fl_check_browser.html | 427 | ||||
-rw-r--r-- | doc/index.html | 3 | ||||
-rw-r--r-- | progress.txt | 2 | ||||
-rw-r--r-- | src/c_fl_check_browser.cpp | 404 | ||||
-rw-r--r-- | src/c_fl_check_browser.h | 82 | ||||
-rw-r--r-- | src/fltk-widgets-groups-browsers-check.adb | 756 | ||||
-rw-r--r-- | src/fltk-widgets-groups-browsers-check.ads | 328 |
7 files changed, 2000 insertions, 2 deletions
diff --git a/doc/fl_check_browser.html b/doc/fl_check_browser.html new file mode 100644 index 0000000..016d86b --- /dev/null +++ b/doc/fl_check_browser.html @@ -0,0 +1,427 @@ +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl_Check_Browser Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl_Check_Browser 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_Check_Browser</td> + <td>FLTK.Widgets.Groups.Browsers.Check</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Check_Browser</td> + <td>Check_Browser</td> + </tr> + + <tr> + <td> </td> + <td>Check_Browser_Reference</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Constructors</th></tr> + + <tr> +<td><pre> +Fl_Check_Browser(int x, int y, int w, int h, const char *l=0); +</pre></td> +<td><pre> +function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Check_Browser; +</pre></td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Functions and Procedures</th></tr> + + <tr> +<td><pre> +int add(char *s); + +int add(char *s, int b); + +int add(const char *s); + +int add(const char *s, int b); +</pre></td> +<td><pre> +procedure Add + (This : in out Check_Browser; + Text : in String; + Checked : in Boolean := False); +</pre></td> + </tr> + + <tr> +<td><pre> +void check_all(); +</pre></td> +<td><pre> +procedure Check_All + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +void check_none(); +</pre></td> +<td><pre> +procedure Check_None + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +int checked(int item) const; +</pre></td> +<td><pre> +function Is_Checked + (This : in Check_Browser; + Index : in Positive) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +void checked(int item, int b); +</pre></td> +<td><pre> +procedure Set_Checked + (This : in out Check_Browser; + Index : in Positive; + State : in Boolean); +</pre></td> + </tr> + + <tr> +<td><pre> +void clear(); +</pre></td> +<td><pre> +procedure Clear + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +int nchecked() const; +</pre></td> +<td><pre> +function Number_Checked + (This : in Check_Browser) + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +int nitems() const; +</pre></td> +<td><pre> +function Number_Of_Items + (This : in Check_Browser) + return Natural; +</pre></td> + </tr> + + <tr> +<td><pre> +int remove(int item); +</pre></td> +<td><pre> +procedure Remove + (This : in out Check_Browser; + Index : in Positive); +</pre></td> + </tr> + + <tr> +<td><pre> +void set_checked(int item); +</pre></td> +<td>See checked(int item, int b);</td> + </tr> + + <tr> +<td><pre> +char * text(int item) const; +</pre></td> +<td><pre> +function Item_Text + (This : in Check_Browser; + Index : in Positive) + return String; +</pre></td> + </tr> + + <tr> +<td><pre> +int value() const; +</pre></td> +<td><pre> +function Selected_Index + (This : in Check_Browser) + return Positive; +</pre></td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Protected Functions and Procedures</th></tr> + + <tr> +<td><pre> +void bbox(int &X, int &Y, int &W, int &H) const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Bounding_Box + (This : in Check_Browser; + X, Y, W, H : out Integer); +</pre></td> + </tr> + + <tr> +<td><pre> +void deleting(void *item); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Deleting + (This : in out Check_Browser; + Item : in Item_Cursor); +</pre></td> + </tr> + + <tr> +<td><pre> +int displayed(void *item) const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Is_Displayed + (This : in Check_Browser; + Item : in Item_Cursor) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +void draw(); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Draw + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +void * find_item(int ypos); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Find_Item + (This : in Check_Browser; + Y_Pos : in Integer) + return Item_Cursor; +</pre></td> + </tr> + + <tr> +<td><pre> +virtual int full_height() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Full_List_Height + (This : in Check_Browser) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +virtual int full_width() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Full_List_Width + (This : in Check_Browser) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +int handle(int); +</pre></td> +<td><pre> +function Handle + (This : in out Check_Browser; + Event : in Event_Kind) + return Event_Outcome; +</pre></td> + </tr> + + <tr> +<td><pre> +virtual int incr_height() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Average_Item_Height + (This : in Check_Browser) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +void inserting(void *a, void *b); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Inserting + (This : in out Check_Browser; + A, B : in Item_Cursor); +</pre></td> + </tr> + + <tr> +<td><pre> +virtual int item_quick_height(void *item) const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Item_Quick_Height + (This : in Check_Browser; + Item : in Item_Cursor) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +int leftedge() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Left_Edge + (This : in Check_Browser) + return Integer; +</pre></td> + </tr> + + <tr> +<td><pre> +void new_list(); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure New_List + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +void redraw_line(void *item); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Redraw_Line + (This : in out Check_Browser; + Item : in Item_Cursor); +</pre></td> + </tr> + + <tr> +<td><pre> +void redraw_lines(); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Redraw_List + (This : in out Check_Browser); +</pre></td> + </tr> + + <tr> +<td><pre> +void replacing(void *a, void *b); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Replacing + (This : in out Check_Browser; + A, B : in Item_Cursor); +</pre></td> + </tr> + + <tr> +<td><pre> +void * selection() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Current_Selection + (This : in Check_Browser) + return Item_Cursor; +</pre></td> + </tr> + + <tr> +<td><pre> +void swapping(void *a, void *b); +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +procedure Swapping + (This : in out Check_Browser; + A, B : in Item_Cursor); +</pre></td> + </tr> + + <tr> +<td><pre> +void * top() const; +</pre>(Inherited from Fl_Browser_)</td> +<td><pre> +function Top_Item + (This : in Check_Browser) + return Item_Cursor; +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/index.html b/doc/index.html index d58e2da..d5a7183 100644 --- a/doc/index.html +++ b/doc/index.html @@ -29,7 +29,7 @@ <li><a href="fl_button.html">Fl_Button</a></li> <li><a href="fl_cairo_window.html">Fl_Cairo_Window</a></li> <li><a href="fl_chart.html">Fl_Chart</a></li> - <li>Fl_Check_Browser</li> + <li><a href="fl_check_browser.html">Fl_Check_Browser</a></li> <li><a href="fl_check_button.html">Fl_Check_Button</a></li> <li><a href="fl_choice.html">Fl_Choice</a></li> <li><a href="fl_clock.html">Fl_Clock</a></li> @@ -188,6 +188,7 @@ <li><a href="fl_round_clock.html">FLTK.Widgets.Clocks.Updated.Round</a></li> <li><a href="fl_group.html">FLTK.Widgets.Groups</a></li> <li><a href="fl_browser_.html">FLTK.Widgets.Groups.Browsers</a></li> + <li><a href="fl_check_browser.html">FLTK.Widgets.Groups.Browsers.Check</a></li> <li><a href="fl_color_chooser.html">FLTK.Widgets.Groups.Color_Choosers</a></li> <li><a href="fl_help_view.html">FLTK.Widgets.Groups.Help_Views</a></li> <li><a href="fl_input_choice.html">FLTK.Widgets.Groups.Input_Choices</a></li> diff --git a/progress.txt b/progress.txt index 274c603..00daa1a 100644 --- a/progress.txt +++ b/progress.txt @@ -71,6 +71,7 @@ FLTK.Widgets.Clocks.Updated FLTK.Widgets.Clocks.Updated.Round FLTK.Widgets.Groups FLTK.Widgets.Groups.Browsers +FLTK.Widgets.Groups.Browsers.Check FLTK.Widgets.Groups.Color_Choosers FLTK.Widgets.Groups.Help_Views FLTK.Widgets.Groups.Input_Choices @@ -141,7 +142,6 @@ FLTK.Devices.Surfaces (incomplete API, otherwise polished) To-Do: Fl_Browser -Fl_Check_Browser Fl_Display_Device Fl_File_Browser Fl_Glut_Window diff --git a/src/c_fl_check_browser.cpp b/src/c_fl_check_browser.cpp new file mode 100644 index 0000000..4788f07 --- /dev/null +++ b/src/c_fl_check_browser.cpp @@ -0,0 +1,404 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#include <FL/Fl_Check_Browser.H> +#include "c_fl_check_browser.h" + + + + +// Exports from Ada + +extern "C" int browser_full_width_hook(void * b); +extern "C" int browser_full_height_hook(void * b); +extern "C" int browser_incr_height_hook(void * b); +extern "C" int browser_item_quick_height_hook(void * b, void * i); + +// These browser_item_* hooks are disabled since if they are used to hook +// into Ada using virtual dispatch then there will be no way to access the +// real Fl_Check_Browser versions once coming back into C++ via C since the +// versions we want to actually use here are private in FLTK because reasons. + +// Should be possible to re-enable in 1.4. + +// extern "C" int browser_item_width_hook(void * b, void * i); +// extern "C" int browser_item_height_hook(void * b, void * i); +// extern "C" void * browser_item_first_hook(void * b); +// extern "C" void * browser_item_last_hook(void * b); +// extern "C" void * browser_item_next_hook(void * b, void * i); +// extern "C" void * browser_item_prev_hook(void * b, void * i); +// extern "C" void * browser_item_at_hook(void * b, int n); +// extern "C" void browser_item_select_hook(void * b, void * i, int s); +// extern "C" int browser_item_selected_hook(void * b, void * i); +// extern "C" void browser_item_swap_hook(void * b, void * one, void * two); +// extern "C" const char * browser_item_text_hook(void * b, void * i); +// extern "C" void browser_item_draw_hook(void * b, void * i, int x, int y, int w, int h); + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + + + + +// Attaching all relevant hooks and friends + +class My_Check_Browser : public Fl_Check_Browser { +public: + using Fl_Check_Browser::Fl_Check_Browser; + + friend void * fl_check_browser_selection(CHECKBROWSER c); + friend int fl_check_browser_displayed(CHECKBROWSER c, void * i); + friend void * fl_check_browser_find_item(CHECKBROWSER c, int y); + friend void * fl_check_browser_top(CHECKBROWSER c); + + friend void fl_check_browser_bbox(CHECKBROWSER c, int &x, int &y, int &w, int &h); + friend int fl_check_browser_leftedge(CHECKBROWSER c); + friend void fl_check_browser_redraw_line(CHECKBROWSER c, void * i); + friend void fl_check_browser_redraw_lines(CHECKBROWSER c); + + friend int fl_check_browser_full_width(CHECKBROWSER c); + friend int fl_check_browser_full_height(CHECKBROWSER c); + friend int fl_check_browser_incr_height(CHECKBROWSER c); + friend int fl_check_browser_item_quick_height(CHECKBROWSER c, void * i); + + friend int fl_check_browser_item_width(CHECKBROWSER c, void * i); + friend int fl_check_browser_item_height(CHECKBROWSER c, void * i); + friend void * fl_check_browser_item_first(CHECKBROWSER c); + // item_last goes here + friend void * fl_check_browser_item_next(CHECKBROWSER c, void * i); + friend void * fl_check_browser_item_prev(CHECKBROWSER c, void * i); + // item_at goes here + friend void fl_check_browser_item_select(CHECKBROWSER c, void * i, int v); + friend int fl_check_browser_item_selected(CHECKBROWSER c, void * i); + // item_swap goes here + // item_text goes here + friend void fl_check_browser_item_draw(CHECKBROWSER c, void * item, int x, int y, int w, int h); + + friend void fl_check_browser_new_list(CHECKBROWSER c); + friend void fl_check_browser_inserting(CHECKBROWSER c, void * a1, void * a2); + friend void fl_check_browser_deleting(CHECKBROWSER c, void * item); + friend void fl_check_browser_replacing(CHECKBROWSER c, void * a1, void * a2); + friend void fl_check_browser_swapping(CHECKBROWSER c, void * a1, void * a2); + + friend void fl_check_browser_draw(CHECKBROWSER c); + friend int fl_check_browser_handle(CHECKBROWSER c, int e); + +protected: + int full_width() const; + int full_height() const; + int incr_height() const; + int item_quick_height(void * item) const; + + // int item_width(void * item) const; + // int item_height(void * item) const; + // void * item_first() const; + // void * item_last() const; + // void * item_next(void * item) const; + // void * item_prev(void * item) const; + // void * item_at(int index) const; + // void item_select(void * item, int val=1); + // int item_selected(void * item) const; + // void item_swap(void * a, void * b); + // const char * item_text(void * item) const; + // void item_draw(void * item, int x, int y, int w, int h) const; + + void draw(); + int handle(int e); +}; + + +int My_Check_Browser::full_width() const { + return browser_full_width_hook(this->user_data()); +} + +int My_Check_Browser::full_height() const { + return browser_full_height_hook(this->user_data()); +} + +int My_Check_Browser::incr_height() const { + return browser_incr_height_hook(this->user_data()); +} + +int My_Check_Browser::item_quick_height(void * item) const { + return browser_item_quick_height_hook(this->user_data(), item); +} + + +// int My_Check_Browser::item_width(void * item) const { +// return browser_item_width_hook(this->user_data(), item); +// } + +// int My_Check_Browser::item_height(void * item) const { +// return browser_item_height_hook(this->user_data(), item); +// } + +// void * My_Check_Browser::item_first() const { +// return browser_item_first_hook(this->user_data()); +// } + +// void * My_Check_Browser::item_last() const { +// return browser_item_last_hook(this->user_data()); +// } + +// void * My_Check_Browser::item_next(void * item) const { +// return browser_item_next_hook(this->user_data(), item); +// } + +// void * My_Check_Browser::item_prev(void * item) const { +// return browser_item_prev_hook(this->user_data(), item); +// } + +// void * My_Check_Browser::item_at(int index) const { +// return browser_item_at_hook(this->user_data(), index); +// } + +// void My_Check_Browser::item_select(void * item, int val) { +// browser_item_select_hook(this->user_data(), item, val); +// } + +// int My_Check_Browser::item_selected(void * item) const { +// return browser_item_selected_hook(this->user_data(), item); +// } + +// void My_Check_Browser::item_swap(void * a, void * b) { +// browser_item_swap_hook(this->user_data(), a, b); +// } + +// const char * My_Check_Browser::item_text(void * item) const { +// return browser_item_text_hook(this->user_data(), item); +// } + +// void My_Check_Browser::item_draw(void * item, int x, int y, int w, int h) const { +// browser_item_draw_hook(this->user_data(), item, x, y, w, h); +// } + + +void My_Check_Browser::draw() { + widget_draw_hook(this->user_data()); +} + +int My_Check_Browser::handle(int e) { + return widget_handle_hook(this->user_data(), e); +} + + + + +// Flattened C API begins here + +CHECKBROWSER new_fl_check_browser(int x, int y, int w, int h, char * label) { + My_Check_Browser *c = new My_Check_Browser(x, y, w, h, label); + return c; +} + +void free_fl_check_browser(CHECKBROWSER c) { + delete reinterpret_cast<My_Check_Browser*>(c); +} + + + + +int fl_check_browser_add(CHECKBROWSER c, const char * s, int b) { + return reinterpret_cast<Fl_Check_Browser*>(c)->add(s, b); +} + +int fl_check_browser_remove(CHECKBROWSER c, int i) { + return reinterpret_cast<Fl_Check_Browser*>(c)->remove(i); +} + +void fl_check_browser_clear(CHECKBROWSER c) { + reinterpret_cast<Fl_Check_Browser*>(c)->clear(); +} + +int fl_check_browser_nitems(CHECKBROWSER c) { + return reinterpret_cast<Fl_Check_Browser*>(c)->nitems(); +} + + + + +void fl_check_browser_check_all(CHECKBROWSER c) { + reinterpret_cast<Fl_Check_Browser*>(c)->check_all(); +} + +void fl_check_browser_check_none(CHECKBROWSER c) { + reinterpret_cast<Fl_Check_Browser*>(c)->check_none(); +} + +int fl_check_browser_get_checked(CHECKBROWSER c, int i) { + return reinterpret_cast<Fl_Check_Browser*>(c)->checked(i); +} + +void fl_check_browser_set_checked(CHECKBROWSER c, int i, int b) { + reinterpret_cast<Fl_Check_Browser*>(c)->checked(i, b); +} + +int fl_check_browser_nchecked(CHECKBROWSER c) { + return reinterpret_cast<Fl_Check_Browser*>(c)->nchecked(); +} + + + + +const char * fl_check_browser_text(CHECKBROWSER c, int i) { + return reinterpret_cast<Fl_Check_Browser*>(c)->text(i); +} + +int fl_check_browser_value(CHECKBROWSER c) { + return reinterpret_cast<Fl_Check_Browser*>(c)->value(); +} + + + + +// These have to be reimplemented due to relying on custom class extensions + +void * fl_check_browser_selection(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->selection(); +} + +int fl_check_browser_displayed(CHECKBROWSER c, void * i) { + return reinterpret_cast<My_Check_Browser*>(c)->displayed(i); +} + +void * fl_check_browser_find_item(CHECKBROWSER c, int y) { + // For whatever reason the Fl_Check_Browser version of find_item is private + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Browser_::find_item(y); +} + +void * fl_check_browser_top(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->top(); +} + + + + +void fl_check_browser_bbox(CHECKBROWSER c, int &x, int &y, int &w, int &h) { + reinterpret_cast<My_Check_Browser*>(c)->bbox(x, y, w, h); +} + +int fl_check_browser_leftedge(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->leftedge(); +} + +void fl_check_browser_redraw_line(CHECKBROWSER c, void * i) { + reinterpret_cast<My_Check_Browser*>(c)->redraw_line(i); +} + +void fl_check_browser_redraw_lines(CHECKBROWSER c) { + reinterpret_cast<My_Check_Browser*>(c)->redraw_lines(); +} + + + + +int fl_check_browser_full_width(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::full_width(); +} + +int fl_check_browser_full_height(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::full_height(); +} + +int fl_check_browser_incr_height(CHECKBROWSER c) { + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::incr_height(); +} + +int fl_check_browser_item_quick_height(CHECKBROWSER c, void * i) { + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_quick_height(i); +} + + + + +int fl_check_browser_item_width(CHECKBROWSER c, void * i) { + (void)c; (void)i; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_width(i); +} + +int fl_check_browser_item_height(CHECKBROWSER c, void * i) { + (void)c; (void)i; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_height(i); +} + +void * fl_check_browser_item_first(CHECKBROWSER c) { + (void)c; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_first(); +} + +// missing item_last + +void * fl_check_browser_item_next(CHECKBROWSER c, void * i) { + (void)c; (void)i; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_next(i); +} + +void * fl_check_browser_item_prev(CHECKBROWSER c, void * i) { + (void)c; (void)i; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_prev(i); +} + +// missing item_at + +void fl_check_browser_item_select(CHECKBROWSER c, void * i, int v) { + (void)c; (void)i; (void)v; + // reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_select(i, v); +} + +int fl_check_browser_item_selected(CHECKBROWSER c, void * i) { + (void)c; (void)i; + return 0; + // return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_selected(i); +} + +// missing item_swap +// missing item_text + +void fl_check_browser_item_draw(CHECKBROWSER c, void * item, int x, int y, int w, int h) { + (void)c; (void)item; (void)x; (void)y; (void)w; (void)h; + // reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::item_draw(item, x, y, w, h); +} + + + + +void fl_check_browser_new_list(CHECKBROWSER c) { + reinterpret_cast<My_Check_Browser*>(c)->new_list(); +} + +void fl_check_browser_inserting(CHECKBROWSER c, void * a1, void * a2) { + reinterpret_cast<My_Check_Browser*>(c)->inserting(a1, a2); +} + +void fl_check_browser_deleting(CHECKBROWSER c, void * item) { + reinterpret_cast<My_Check_Browser*>(c)->deleting(item); +} + +void fl_check_browser_replacing(CHECKBROWSER c, void * a1, void * a2) { + reinterpret_cast<My_Check_Browser*>(c)->replacing(a1, a2); +} + +void fl_check_browser_swapping(CHECKBROWSER c, void * a1, void * a2) { + reinterpret_cast<My_Check_Browser*>(c)->swapping(a1, a2); +} + + + + +void fl_check_browser_draw(CHECKBROWSER c) { + reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::draw(); +} + +int fl_check_browser_handle(CHECKBROWSER c, int e) { + return reinterpret_cast<My_Check_Browser*>(c)->Fl_Check_Browser::handle(e); +} + + diff --git a/src/c_fl_check_browser.h b/src/c_fl_check_browser.h new file mode 100644 index 0000000..c74808b --- /dev/null +++ b/src/c_fl_check_browser.h @@ -0,0 +1,82 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#ifndef FL_CHECK_BROWSER_GUARD +#define FL_CHECK_BROWSER_GUARD + + +typedef void* CHECKBROWSER; + + +extern "C" CHECKBROWSER new_fl_check_browser(int x, int y, int w, int h, char * label); +extern "C" void free_fl_check_browser(CHECKBROWSER c); + + +extern "C" int fl_check_browser_add(CHECKBROWSER c, const char * s, int b); +extern "C" int fl_check_browser_remove(CHECKBROWSER c, int i); +extern "C" void fl_check_browser_clear(CHECKBROWSER c); +extern "C" int fl_check_browser_nitems(CHECKBROWSER c); + + +extern "C" void fl_check_browser_check_all(CHECKBROWSER c); +extern "C" void fl_check_browser_check_none(CHECKBROWSER c); +extern "C" int fl_check_browser_get_checked(CHECKBROWSER c, int i); +extern "C" void fl_check_browser_set_checked(CHECKBROWSER c, int i, int b); +extern "C" int fl_check_browser_nchecked(CHECKBROWSER c); + + +extern "C" const char * fl_check_browser_text(CHECKBROWSER c, int i); +extern "C" int fl_check_browser_value(CHECKBROWSER c); + + +// reimp below here + +extern "C" void * fl_check_browser_selection(CHECKBROWSER c); +extern "C" int fl_check_browser_displayed(CHECKBROWSER c, void * i); +extern "C" void * fl_check_browser_find_item(CHECKBROWSER c, int y); +extern "C" void * fl_check_browser_top(CHECKBROWSER c); + + +extern "C" void fl_check_browser_bbox(CHECKBROWSER c, int &x, int &y, int &w, int &h); +extern "C" int fl_check_browser_leftedge(CHECKBROWSER c); +extern "C" void fl_check_browser_redraw_line(CHECKBROWSER c, void * i); +extern "C" void fl_check_browser_redraw_lines(CHECKBROWSER c); + + +extern "C" int fl_check_browser_full_width(CHECKBROWSER c); +extern "C" int fl_check_browser_full_height(CHECKBROWSER c); +extern "C" int fl_check_browser_incr_height(CHECKBROWSER c); +extern "C" int fl_check_browser_item_quick_height(CHECKBROWSER c, void * i); + + +extern "C" int fl_check_browser_item_width(CHECKBROWSER c, void * i); +extern "C" int fl_check_browser_item_height(CHECKBROWSER c, void * i); +extern "C" void * fl_check_browser_item_first(CHECKBROWSER c); +// missing item_last +extern "C" void * fl_check_browser_item_next(CHECKBROWSER c, void * i); +extern "C" void * fl_check_browser_item_prev(CHECKBROWSER c, void * i); +// missing item_at +extern "C" void fl_check_browser_item_select(CHECKBROWSER c, void * i, int v); +extern "C" int fl_check_browser_item_selected(CHECKBROWSER c, void * i); +// missing item_swap +// missing item_text +extern "C" void fl_check_browser_item_draw(CHECKBROWSER c, void * item, int x, int y, int w, int h); + + +extern "C" void fl_check_browser_new_list(CHECKBROWSER c); +extern "C" void fl_check_browser_inserting(CHECKBROWSER c, void * a1, void * a2); +extern "C" void fl_check_browser_deleting(CHECKBROWSER c, void * item); +extern "C" void fl_check_browser_replacing(CHECKBROWSER c, void * a1, void * a2); +extern "C" void fl_check_browser_swapping(CHECKBROWSER c, void * a1, void * a2); + + +extern "C" void fl_check_browser_draw(CHECKBROWSER c); +extern "C" int fl_check_browser_handle(CHECKBROWSER c, int e); + + +#endif + + diff --git a/src/fltk-widgets-groups-browsers-check.adb b/src/fltk-widgets-groups-browsers-check.adb new file mode 100644 index 0000000..3c9dd90 --- /dev/null +++ b/src/fltk-widgets-groups-browsers-check.adb @@ -0,0 +1,756 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Interfaces.C.Strings; + +use type + + Interfaces.C.int; + + +package body FLTK.Widgets.Groups.Browsers.Check is + + + ------------------------ + -- Functions From C -- + ------------------------ + + function new_fl_check_browser + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return Storage.Integer_Address; + pragma Import (C, new_fl_check_browser, "new_fl_check_browser"); + pragma Inline (new_fl_check_browser); + + procedure free_fl_check_browser + (C : in Storage.Integer_Address); + pragma Import (C, free_fl_check_browser, "free_fl_check_browser"); + pragma Inline (free_fl_check_browser); + + + + + function fl_check_browser_add + (C : in Storage.Integer_Address; + S : in Interfaces.C.char_array; + B : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_add, "fl_check_browser_add"); + pragma Inline (fl_check_browser_add); + + function fl_check_browser_remove + (C : in Storage.Integer_Address; + I : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_remove, "fl_check_browser_remove"); + pragma Inline (fl_check_browser_remove); + + procedure fl_check_browser_clear + (C : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_clear, "fl_check_browser_clear"); + pragma Inline (fl_check_browser_clear); + + function fl_check_browser_nitems + (C : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_nitems, "fl_check_browser_nitems"); + pragma Inline (fl_check_browser_nitems); + + + + + procedure fl_check_browser_check_all + (C : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_check_all, "fl_check_browser_check_all"); + pragma Inline (fl_check_browser_check_all); + + procedure fl_check_browser_check_none + (C : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_check_none, "fl_check_browser_check_none"); + pragma Inline (fl_check_browser_check_none); + + function fl_check_browser_get_checked + (C : in Storage.Integer_Address; + I : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_get_checked, "fl_check_browser_get_checked"); + pragma Inline (fl_check_browser_get_checked); + + procedure fl_check_browser_set_checked + (C : in Storage.Integer_Address; + I, B : in Interfaces.C.int); + pragma Import (C, fl_check_browser_set_checked, "fl_check_browser_set_checked"); + pragma Inline (fl_check_browser_set_checked); + + function fl_check_browser_nchecked + (C : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_nchecked, "fl_check_browser_nchecked"); + pragma Inline (fl_check_browser_nchecked); + + + + + function fl_check_browser_text + (C : in Storage.Integer_Address; + I : in Interfaces.C.int) + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_check_browser_text, "fl_check_browser_text"); + pragma Inline (fl_check_browser_text); + + function fl_check_browser_value + (C : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_value, "fl_check_browser_value"); + pragma Inline (fl_check_browser_value); + + + + + function fl_check_browser_selection + (B : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_selection, "fl_check_browser_selection"); + pragma Inline (fl_check_browser_selection); + + function fl_check_browser_displayed + (B, I : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_displayed, "fl_check_browser_displayed"); + pragma Inline (fl_check_browser_displayed); + + function fl_check_browser_find_item + (B : in Storage.Integer_Address; + Y : in Interfaces.C.int) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_find_item, "fl_check_browser_find_item"); + pragma Inline (fl_check_browser_find_item); + + function fl_check_browser_top + (B : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_top, "fl_check_browser_top"); + pragma Inline (fl_check_browser_top); + + + + + procedure fl_check_browser_bbox + (B : in Storage.Integer_Address; + X, Y, W, H : out Interfaces.C.int); + pragma Import (C, fl_check_browser_bbox, "fl_check_browser_bbox"); + pragma Inline (fl_check_browser_bbox); + + function fl_check_browser_leftedge + (B : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_leftedge, "fl_check_browser_leftedge"); + pragma Inline (fl_check_browser_leftedge); + + procedure fl_check_browser_redraw_line + (B, I : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_redraw_line, "fl_check_browser_redraw_line"); + pragma Inline (fl_check_browser_redraw_line); + + procedure fl_check_browser_redraw_lines + (B : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_redraw_lines, "fl_check_browser_redraw_lines"); + pragma Inline (fl_check_browser_redraw_lines); + + + + + function fl_check_browser_full_width + (B : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_full_width, "fl_check_browser_full_width"); + pragma Inline (fl_check_browser_full_width); + + function fl_check_browser_full_height + (B : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_full_height, "fl_check_browser_full_height"); + pragma Inline (fl_check_browser_full_height); + + function fl_check_browser_incr_height + (B : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_incr_height, "fl_check_browser_incr_height"); + pragma Inline (fl_check_browser_incr_height); + + function fl_check_browser_item_quick_height + (B, I : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_item_quick_height, "fl_check_browser_item_quick_height"); + pragma Inline (fl_check_browser_item_quick_height); + + + + + function fl_check_browser_item_width + (C, I : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_item_width, "fl_check_browser_item_width"); + pragma Inline (fl_check_browser_item_width); + + function fl_check_browser_item_height + (C, I : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_item_height, "fl_check_browser_item_height"); + pragma Inline (fl_check_browser_item_height); + + function fl_check_browser_item_first + (C : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_item_first, "fl_check_browser_item_first"); + pragma Inline (fl_check_browser_item_first); + + -- Missing item_last + + function fl_check_browser_item_next + (C, I : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_item_next, "fl_check_browser_item_next"); + pragma Inline (fl_check_browser_item_next); + + function fl_check_browser_item_prev + (C, I : in Storage.Integer_Address) + return Storage.Integer_Address; + pragma Import (C, fl_check_browser_item_prev, "fl_check_browser_item_prev"); + pragma Inline (fl_check_browser_item_prev); + + -- Missing item_at + + procedure fl_check_browser_item_select + (C, I : in Storage.Integer_Address; + V : in Interfaces.C.int); + pragma Import (C, fl_check_browser_item_select, "fl_check_browser_item_select"); + pragma Inline (fl_check_browser_item_select); + + function fl_check_browser_item_selected + (C, I : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_item_selected, "fl_check_browser_item_selected"); + pragma Inline (fl_check_browser_item_selected); + + -- Missing item_swap and item_text + + procedure fl_check_browser_item_draw + (C, I : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int); + pragma Import (C, fl_check_browser_item_draw, "fl_check_browser_item_draw"); + pragma Inline (fl_check_browser_item_draw); + + + + + procedure fl_check_browser_new_list + (B : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_new_list, "fl_check_browser_new_list"); + pragma Inline (fl_check_browser_new_list); + + procedure fl_check_browser_inserting + (B, A1, A2 : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_inserting, "fl_check_browser_inserting"); + pragma Inline (fl_check_browser_inserting); + + procedure fl_check_browser_deleting + (B, I : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_deleting, "fl_check_browser_deleting"); + pragma Inline (fl_check_browser_deleting); + + procedure fl_check_browser_replacing + (B, A1, A2 : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_replacing, "fl_check_browser_replacing"); + pragma Inline (fl_check_browser_replacing); + + procedure fl_check_browser_swapping + (B, A1, A2 : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_swapping, "fl_check_browser_swapping"); + pragma Inline (fl_check_browser_swapping); + + + + + procedure fl_check_browser_draw + (B : in Storage.Integer_Address); + pragma Import (C, fl_check_browser_draw, "fl_check_browser_draw"); + pragma Inline (fl_check_browser_draw); + + function fl_check_browser_handle + (B : in Storage.Integer_Address; + E : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_check_browser_handle, "fl_check_browser_handle"); + pragma Inline (fl_check_browser_handle); + + + + + ------------------- + -- Destructors -- + ------------------- + + procedure Extra_Final + (This : in out Check_Browser) is + begin + Extra_Final (Browser (This)); + end Extra_Final; + + + procedure Finalize + (This : in out Check_Browser) is + begin + Extra_Final (This); + if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then + free_fl_check_browser (This.Void_Ptr); + This.Void_Ptr := Null_Pointer; + end if; + end Finalize; + + + + + -------------------- + -- Constructors -- + -------------------- + + procedure Extra_Init + (This : in out Check_Browser; + X, Y, W, H : in Integer; + Text : in String) is + begin + Extra_Init (Browser (This), X, Y, W, H, Text); + end Extra_Init; + + + package body Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Check_Browser is + begin + return This : Check_Browser do + This.Void_Ptr := new_fl_check_browser + (Interfaces.C.int (X), + Interfaces.C.int (Y), + Interfaces.C.int (W), + Interfaces.C.int (H), + Interfaces.C.To_C (Text)); + Extra_Init (This, X, Y, W, H, Text); + end return; + end Create; + + end Forge; + + + + + ------------------------- + -- Check_Browser API -- + ------------------------- + + procedure Add + (This : in out Check_Browser; + Text : in String; + Checked : in Boolean := False) + is + Code : Interfaces.C.int := fl_check_browser_add + (This.Void_Ptr, + Interfaces.C.To_C (Text), + Boolean'Pos (Checked)); + begin + null; + end Add; + + + procedure Remove + (This : in out Check_Browser; + Index : in Positive) + is + Code : Interfaces.C.int := fl_check_browser_remove + (This.Void_Ptr, + Interfaces.C.int (Index)); + begin + null; + end Remove; + + + procedure Clear + (This : in out Check_Browser) is + begin + fl_check_browser_clear (This.Void_Ptr); + end Clear; + + + function Number_Of_Items + (This : in Check_Browser) + return Natural is + begin + return Natural (fl_check_browser_nitems (This.Void_Ptr)); + end Number_Of_Items; + + + + + procedure Check_All + (This : in out Check_Browser) is + begin + fl_check_browser_check_all (This.Void_Ptr); + end Check_All; + + + procedure Check_None + (This : in out Check_Browser) is + begin + fl_check_browser_check_none (This.Void_Ptr); + end Check_None; + + + function Is_Checked + (This : in Check_Browser; + Index : in Positive) + return Boolean is + begin + return fl_check_browser_get_checked (This.Void_Ptr, Interfaces.C.int (Index)) /= 0; + end Is_Checked; + + + procedure Set_Checked + (This : in out Check_Browser; + Index : in Positive; + State : in Boolean) is + begin + fl_check_browser_set_checked + (This.Void_Ptr, + Interfaces.C.int (Index), + Boolean'Pos (State)); + end Set_Checked; + + + function Number_Checked + (This : in Check_Browser) + return Natural is + begin + return Natural (fl_check_browser_nchecked (This.Void_Ptr)); + end Number_Checked; + + + + + function Item_Text + (This : in Check_Browser; + Index : in Positive) + return String is + begin + return Interfaces.C.Strings.Value + (fl_check_browser_text (This.Void_Ptr, Interfaces.C.int (Index))); + end Item_Text; + + + function Selected_Index + (This : in Check_Browser) + return Positive is + begin + return Positive (fl_check_browser_value (This.Void_Ptr)); + end Selected_Index; + + + + + function Current_Selection + (This : in Check_Browser) + return Item_Cursor is + begin + return Address_To_Cursor (fl_check_browser_selection (This.Void_Ptr)); + end Current_Selection; + + + function Is_Displayed + (This : in Check_Browser; + Item : in Item_Cursor) + return Boolean + is + Code : Interfaces.C.int := fl_check_browser_displayed + (This.Void_Ptr, + Cursor_To_Address (Item)); + begin + if Code not in 0 .. 1 then + raise Internal_FLTK_Error; + end if; + return Boolean'Val (Code); + end Is_Displayed; + + + function Find_Item + (This : in Check_Browser; + Y_Pos : in Integer) + return Item_Cursor is + begin + return Address_To_Cursor + (fl_check_browser_find_item (This.Void_Ptr, Interfaces.C.int (Y_Pos))); + end Find_Item; + + + function Top_Item + (This : in Check_Browser) + return Item_Cursor is + begin + return Address_To_Cursor (fl_check_browser_top (This.Void_Ptr)); + end Top_Item; + + + + + procedure Bounding_Box + (This : in Check_Browser; + X, Y, W, H : out Integer) is + begin + fl_check_browser_bbox + (This.Void_Ptr, + Interfaces.C.int (X), + Interfaces.C.int (Y), + Interfaces.C.int (W), + Interfaces.C.int (H)); + end Bounding_Box; + + + function Left_Edge + (This : in Check_Browser) + return Integer is + begin + return Integer (fl_check_browser_leftedge (This.Void_Ptr)); + end Left_Edge; + + + procedure Redraw_Line + (This : in out Check_Browser; + Item : in Item_Cursor) is + begin + fl_check_browser_redraw_line (This.Void_Ptr, Cursor_To_Address (Item)); + end Redraw_Line; + + + procedure Redraw_List + (This : in out Check_Browser) is + begin + fl_check_browser_redraw_lines (This.Void_Ptr); + end Redraw_List; + + + + + function Full_List_Width + (This : in Check_Browser) + return Integer is + begin + return Integer (fl_check_browser_full_width (This.Void_Ptr)); + end Full_List_Width; + + + function Full_List_Height + (This : in Check_Browser) + return Integer is + begin + return Integer (fl_check_browser_full_height (This.Void_Ptr)); + end Full_List_Height; + + + function Average_Item_Height + (This : in Check_Browser) + return Integer is + begin + return Integer (fl_check_browser_incr_height (This.Void_Ptr)); + end Average_Item_Height; + + + function Item_Quick_Height + (This : in Check_Browser; + Item : in Item_Cursor) + return Integer is + begin + return Integer (fl_check_browser_item_quick_height + (This.Void_Ptr, + Cursor_To_Address (Item))); + end Item_Quick_Height; + + + + + -- function Item_Width + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Integer is + -- begin + -- return Integer (fl_check_browser_item_width + -- (This.Void_Ptr, + -- Cursor_To_Address (Item))); + -- end Item_Width; + + + -- function Item_Height + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Integer is + -- begin + -- return Integer (fl_check_browser_item_height + -- (This.Void_Ptr, + -- Cursor_To_Address (Item))); + -- end Item_Height; + + + -- function Item_First + -- (This : in Check_Browser) + -- return Item_Cursor is + -- begin + -- return Address_To_Cursor (fl_check_browser_item_first (This.Void_Ptr)); + -- end Item_First; + + + -- Note that Item_Last is not implemented + + + -- function Item_Next + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Item_Cursor is + -- begin + -- return Address_To_Cursor (fl_check_browser_item_next + -- (This.Void_Ptr, + -- Cursor_To_Address (Item))); + -- end Item_Next; + + + -- function Item_Previous + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Item_Cursor is + -- begin + -- return Address_To_Cursor (fl_check_browser_item_prev + -- (This.Void_Ptr, + -- Cursor_To_Address (Item))); + -- end Item_Previous; + + + -- Note that Item_At is not implemented + + + -- procedure Item_Select + -- (This : in out Check_Browser; + -- Item : in Item_Cursor; + -- State : in Boolean := True) is + -- begin + -- fl_check_browser_item_select + -- (This.Void_Ptr, + -- Cursor_To_Address (Item), + -- Boolean'Pos (State)); + -- end Item_Select; + + + -- function Item_Selected + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Boolean is + -- begin + -- return fl_check_browser_selected (This.Void_Ptr, Cursor_To_Address (Item)) /= 0; + -- end Item_Selected; + + + -- Note that Item_Swap and Item_Text are not implemented + + + -- procedure Item_Draw + -- (This : in Check_Browser; + -- Item : in Item_Cursor; + -- X, Y, W, H : in Integer) is + -- begin + -- fl_check_browser_item_draw + -- (This.Void_Ptr, + -- Cursor_To_Address (Item), + -- Interfaces.C.int (X), + -- Interfaces.C.int (Y), + -- Interfaces.C.int (W), + -- Interfaces.C.int (H)); + -- end Item_Draw; + + + + + procedure New_List + (This : in out Check_Browser) is + begin + fl_check_browser_new_list (This.Void_Ptr); + end New_List; + + + procedure Inserting + (This : in out Check_Browser; + A, B : in Item_Cursor) is + begin + fl_check_browser_inserting + (This.Void_Ptr, + Cursor_To_Address (A), + Cursor_To_Address (B)); + end Inserting; + + + procedure Deleting + (This : in out Check_Browser; + Item : in Item_Cursor) is + begin + fl_check_browser_deleting + (This.Void_Ptr, + Cursor_To_Address (Item)); + end Deleting; + + + procedure Replacing + (This : in out Check_Browser; + A, B : in Item_Cursor) is + begin + fl_check_browser_replacing + (This.Void_Ptr, + Cursor_To_Address (A), + Cursor_To_Address (B)); + end Replacing; + + + procedure Swapping + (This : in out Check_Browser; + A, B : in Item_Cursor) is + begin + fl_check_browser_swapping + (This.Void_Ptr, + Cursor_To_Address (A), + Cursor_To_Address (B)); + end Swapping; + + + + + procedure Draw + (This : in out Check_Browser) is + begin + fl_check_browser_draw (This.Void_Ptr); + end Draw; + + + function Handle + (This : in out Check_Browser; + Event : in Event_Kind) + return Event_Outcome is + begin + return Event_Outcome'Val + (fl_check_browser_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + end Handle; + + +end FLTK.Widgets.Groups.Browsers.Check; + + diff --git a/src/fltk-widgets-groups-browsers-check.ads b/src/fltk-widgets-groups-browsers-check.ads new file mode 100644 index 0000000..7a5cfc7 --- /dev/null +++ b/src/fltk-widgets-groups-browsers-check.ads @@ -0,0 +1,328 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +package FLTK.Widgets.Groups.Browsers.Check is + + + -- Since the FLTK 1.3 implementation doesn't provide the following key functions: + -- + -- item_at / Item_At + -- item_last / Item_Last + -- item_swap / Item_Swap + -- item_text / Item_Text + -- + -- You can't use Sort on a Check_Browser unless you want a crash. The item_* + -- methods in C++ are also private which makes it nigh impossible to properly + -- bind to Ada, so you can't use those either. + -- + -- Find_Item is also private in C++ in 1.3 for whatever reason, so that might + -- have unexpected behaviour. + -- + -- So, uh, be aware of all that, I guess? Or wait until I get around to 1.4. + -- Using the equivalent of the C++ public API should still work fine right now. + + + type Check_Browser is new Browser with private; + + type Check_Browser_Reference (Data : not null access Check_Browser'Class) is + limited null record with Implicit_Dereference => Data; + + + + + package Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Check_Browser; + + end Forge; + + + + + -- Adding and removing + + procedure Add + (This : in out Check_Browser; + Text : in String; + Checked : in Boolean := False); + + procedure Remove + (This : in out Check_Browser; + Index : in Positive); + + procedure Clear + (This : in out Check_Browser); + + function Number_Of_Items + (This : in Check_Browser) + return Natural; + + + + + -- Checking and unchecking + + procedure Check_All + (This : in out Check_Browser); + + procedure Check_None + (This : in out Check_Browser); + + function Is_Checked + (This : in Check_Browser; + Index : in Positive) + return Boolean; + + procedure Set_Checked + (This : in out Check_Browser; + Index : in Positive; + State : in Boolean); + + function Number_Checked + (This : in Check_Browser) + return Natural; + + + + + -- Text and selection + + -- Don't confuse this with the missing Item_Cursor version + function Item_Text + (This : in Check_Browser; + Index : in Positive) + return String; + + function Selected_Index + (This : in Check_Browser) + return Positive; + + + + + -- Item related stuff reimplemented for binding-related reasons. + -- These subprograms are protected on the C++ side. + + function Current_Selection + (This : in Check_Browser) + return Item_Cursor; + + function Is_Displayed + (This : in Check_Browser; + Item : in Item_Cursor) + return Boolean; + + function Find_Item + (This : in Check_Browser; + Y_Pos : in Integer) + return Item_Cursor; + + function Top_Item + (This : in Check_Browser) + return Item_Cursor; + + + + + -- Graphical dimensions and redrawing reimplemented for binding-related reasons. + -- These subprograms are protected on the C++ side. + + procedure Bounding_Box + (This : in Check_Browser; + X, Y, W, H : out Integer); + + function Left_Edge + (This : in Check_Browser) + return Integer; + + procedure Redraw_Line + (This : in out Check_Browser; + Item : in Item_Cursor); + + procedure Redraw_List + (This : in out Check_Browser); + + + + + -- Optional overrides reimplemented for binding-related reasons. + -- These subprograms are protected on the C++ side. + + function Full_List_Width + (This : in Check_Browser) + return Integer; + + function Full_List_Height + (This : in Check_Browser) + return Integer; + + function Average_Item_Height + (This : in Check_Browser) + return Integer; + + function Item_Quick_Height + (This : in Check_Browser; + Item : in Item_Cursor) + return Integer; + + + + + -- These Item_* subprograms are disabled due to a bug in FLTK 1.3. + -- Should be able to bind them properly when 1.4 comes around. + + -- function Item_Width + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Integer; + + -- function Item_Height + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Integer; + + -- function Item_First + -- (This : in Check_Browser) + -- return Item_Cursor; + + -- Item_Last missing in 1.3 + + -- function Item_Next + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Item_Cursor; + + -- function Item_Previous + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Item_Cursor; + + -- Item_At missing in 1.3 + + -- procedure Item_Select + -- (This : in out Check_Browser; + -- Item : in Item_Cursor; + -- State : in Boolean := True); + + -- function Item_Selected + -- (This : in Check_Browser; + -- Item : in Item_Cursor) + -- return Boolean; + + -- Item_Swap and Item_Text missing in 1.3 + + -- procedure Item_Draw + -- (This : in Check_Browser; + -- Item : in Item_Cursor; + -- X, Y, W, H : in Integer); + + + + + -- Cache invalidation reimplemented for binding-related reasons. + -- These subprograms are protected on the C++ side. + + procedure New_List + (This : in out Check_Browser); + + procedure Inserting + (This : in out Check_Browser; + A, B : in Item_Cursor); + + procedure Deleting + (This : in out Check_Browser; + Item : in Item_Cursor); + + procedure Replacing + (This : in out Check_Browser; + A, B : in Item_Cursor); + + procedure Swapping + (This : in out Check_Browser; + A, B : in Item_Cursor); + + + + + procedure Draw + (This : in out Check_Browser); + + function Handle + (This : in out Check_Browser; + Event : in Event_Kind) + return Event_Outcome; + + +private + + + type Check_Browser is new Browser with null record; + + overriding procedure Finalize + (This : in out Check_Browser); + + procedure Extra_Init + (This : in out Check_Browser; + X, Y, W, H : in Integer; + Text : in String); + + procedure Extra_Final + (This : in out Check_Browser); + + + pragma Inline (Add); + pragma Inline (Remove); + pragma Inline (Clear); + pragma Inline (Number_Of_Items); + + pragma Inline (Check_All); + pragma Inline (Check_None); + pragma Inline (Is_Checked); + pragma Inline (Set_Checked); + pragma Inline (Number_Checked); + + pragma Inline (Item_Text); + pragma Inline (Selected_Index); + + pragma Inline (Current_Selection); + pragma Inline (Find_Item); + pragma Inline (Top_Item); + + pragma Inline (Bounding_Box); + pragma Inline (Left_Edge); + pragma Inline (Redraw_Line); + pragma Inline (Redraw_List); + + pragma Inline (Full_List_Width); + pragma Inline (Full_List_Height); + pragma Inline (Average_Item_Height); + pragma Inline (Item_Quick_Height); + + -- pragma Inline (Item_Width); + -- pragma Inline (Item_Height); + -- pragma Inline (Item_First); + -- pragma Inline (Item_Next); + -- pragma Inline (Item_Previous); + -- pragma Inline (Item_Select); + -- pragma Inline (Item_Selected); + -- pragma Inline (Item_Draw); + + pragma Inline (New_List); + pragma Inline (Inserting); + pragma Inline (Deleting); + pragma Inline (Replacing); + pragma Inline (Swapping); + + pragma Inline (Draw); + pragma Inline (Handle); + + +end FLTK.Widgets.Groups.Browsers.Check; + + |