summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2018-03-05 15:58:41 +1100
committerJed Barber <jjbarber@y7mail.com>2018-03-05 15:58:41 +1100
commit2068f3a8edf5947864ac9a19a9684b81c0ce3f83 (patch)
treeef6521d63045bb60c8fcfe4376c0313dc6371d29 /src
parentb737f061a40c2546e1addadee1611d2281a4a1f7 (diff)
Added FLTK.Widgets.Groups.Tabbed
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_tabs.cpp99
-rw-r--r--src/c_fl_tabs.h39
-rw-r--r--src/fltk-widgets-groups-tabbed.adb230
-rw-r--r--src/fltk-widgets-groups-tabbed.ads70
4 files changed, 438 insertions, 0 deletions
diff --git a/src/c_fl_tabs.cpp b/src/c_fl_tabs.cpp
new file mode 100644
index 0000000..452be6d
--- /dev/null
+++ b/src/c_fl_tabs.cpp
@@ -0,0 +1,99 @@
+
+
+#include <FL/Fl_Tabs.H>
+#include "c_fl_tabs.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Tabs : public Fl_Tabs {
+ public:
+ using Fl_Tabs::Fl_Tabs;
+ friend void tabs_set_draw_hook(TABS t, void * d);
+ friend void fl_tabs_draw(TABS t);
+ friend void tabs_set_handle_hook(TABS t, void * h);
+ friend int fl_tabs_handle(TABS t, int e);
+ protected:
+ void draw();
+ void real_draw();
+ int handle(int e);
+ int real_handle(int e);
+ d_hook_p draw_hook;
+ h_hook_p handle_hook;
+};
+
+void My_Tabs::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Tabs::real_draw() {
+ Fl_Tabs::draw();
+}
+
+int My_Tabs::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Tabs::real_handle(int e) {
+ return Fl_Tabs::handle(e);
+}
+
+void tabs_set_draw_hook(TABS t, void * d) {
+ reinterpret_cast<My_Tabs*>(t)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_tabs_draw(TABS t) {
+ reinterpret_cast<My_Tabs*>(t)->real_draw();
+}
+
+void tabs_set_handle_hook(TABS t, void * h) {
+ reinterpret_cast<My_Tabs*>(t)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_tabs_handle(TABS t, int e) {
+ return reinterpret_cast<My_Tabs*>(t)->real_handle(e);
+}
+
+
+
+
+TABS new_fl_tabs(int x, int y, int w, int h, char* label) {
+ My_Tabs *t = new My_Tabs(x, y, w, h, label);
+ return t;
+}
+
+void free_fl_tabs(TABS t) {
+ delete reinterpret_cast<My_Tabs*>(t);
+}
+
+
+
+
+void fl_tabs_client_area(TABS t, int * x, int * y, int * w, int * h, int i) {
+ reinterpret_cast<My_Tabs*>(t)->client_area(*x,*y,*w,*h,i);
+}
+
+
+
+
+void * fl_tabs_get_push(TABS t) {
+ return reinterpret_cast<My_Tabs*>(t)->push();
+}
+
+void fl_tabs_set_push(TABS t, void * w) {
+ reinterpret_cast<My_Tabs*>(t)->push(reinterpret_cast<Fl_Widget*>(w));
+}
+
+void * fl_tabs_get_value(TABS t) {
+ return reinterpret_cast<My_Tabs*>(t)->value();
+}
+
+void fl_tabs_set_value(TABS t, void * w) {
+ reinterpret_cast<My_Tabs*>(t)->value(reinterpret_cast<Fl_Widget*>(w));
+}
+
+void * fl_tabs_which(TABS t, int x, int y) {
+ return reinterpret_cast<My_Tabs*>(t)->which(x,y);
+}
+
diff --git a/src/c_fl_tabs.h b/src/c_fl_tabs.h
new file mode 100644
index 0000000..2d12500
--- /dev/null
+++ b/src/c_fl_tabs.h
@@ -0,0 +1,39 @@
+
+
+#ifndef FL_TABS_GUARD
+#define FL_TABS_GUARD
+
+
+
+
+typedef void* TABS;
+
+
+
+
+extern "C" void tabs_set_draw_hook(TABS t, void * d);
+extern "C" void fl_tabs_draw(TABS t);
+extern "C" void tabs_set_handle_hook(TABS t, void * h);
+extern "C" int fl_tabs_handle(TABS t, int e);
+
+
+
+
+extern "C" TABS new_fl_tabs(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_tabs(TABS t);
+
+
+
+
+extern "C" void fl_tabs_client_area(TABS t, int * x, int * y, int * w, int * h, int i);
+
+
+extern "C" void * fl_tabs_get_push(TABS t);
+extern "C" void fl_tabs_set_push(TABS t, void * w);
+extern "C" void * fl_tabs_get_value(TABS t);
+extern "C" void fl_tabs_set_value(TABS t, void * w);
+extern "C" void * fl_tabs_which(TABS t, int x, int y);
+
+
+#endif
+
diff --git a/src/fltk-widgets-groups-tabbed.adb b/src/fltk-widgets-groups-tabbed.adb
new file mode 100644
index 0000000..70bfdc6
--- /dev/null
+++ b/src/fltk-widgets-groups-tabbed.adb
@@ -0,0 +1,230 @@
+
+
+with
+
+ Interfaces.C,
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Widgets.Groups.Tabbed is
+
+
+ procedure tabs_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, tabs_set_draw_hook, "tabs_set_draw_hook");
+
+ procedure tabs_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, tabs_set_handle_hook, "tabs_set_handle_hook");
+
+
+
+
+ function new_fl_tabs
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_tabs, "new_fl_tabs");
+
+ procedure free_fl_tabs
+ (S : in System.Address);
+ pragma Import (C, free_fl_tabs, "free_fl_tabs");
+
+
+
+
+ procedure fl_tabs_client_area
+ (T : in System.Address;
+ X, Y, W, H : out Interfaces.C.int;
+ I : in Interfaces.C.int);
+ pragma Import (C, fl_tabs_client_area, "fl_tabs_client_area");
+
+
+
+
+ function fl_tabs_get_push
+ (T : in System.Address)
+ return System.Address;
+ pragma Import (C, fl_tabs_get_push, "fl_tabs_get_push");
+
+ procedure fl_tabs_set_push
+ (T, I : in System.Address);
+ pragma Import (C, fl_tabs_set_push, "fl_tabs_set_push");
+
+ function fl_tabs_get_value
+ (T : in System.Address)
+ return System.Address;
+ pragma Import (C, fl_tabs_get_value, "fl_tabs_get_value");
+
+ procedure fl_tabs_set_value
+ (T, V : in System.Address);
+ pragma Import (C, fl_tabs_set_value, "fl_tabs_set_value");
+
+ function fl_tabs_which
+ (T : in System.Address;
+ X, Y : in Interfaces.C.int)
+ return System.Address;
+ pragma Import (C, fl_tabs_which, "fl_tabs_which");
+
+
+
+
+ procedure fl_tabs_draw
+ (W : in System.Address);
+ pragma Import (C, fl_tabs_draw, "fl_tabs_draw");
+
+ function fl_tabs_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_tabs_handle, "fl_tabs_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Tabs) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Tabs'Class
+ then
+ This.Clear;
+ free_fl_tabs (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Group (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Tabs is
+ begin
+ return This : Tabs do
+ This.Void_Ptr := new_fl_tabs
+ (Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.To_C (Text));
+ fl_group_end (This.Void_Ptr);
+ fl_widget_set_user_data
+ (This.Void_Ptr,
+ Widget_Convert.To_Address (This'Unchecked_Access));
+ tabs_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ tabs_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+ procedure Get_Client_Area
+ (This : in Tabs;
+ Tab_Height : in Natural;
+ X, Y, W, H : out Integer)
+ is
+ RX, RY, RW, RH : Interfaces.C.int;
+ begin
+ fl_tabs_client_area (This.Void_Ptr, RX, RY, RW, RH, Interfaces.C.int (Tab_Height));
+ X := Integer (RX);
+ Y := Integer (RY);
+ W := Integer (RW);
+ H := Integer (RH);
+ end Get_Client_Area;
+
+
+
+
+ function Get_Push
+ (This : in Tabs)
+ return access Widget'Class
+ is
+ Widget_Ptr : System.Address :=
+ fl_tabs_get_push (This.Void_Ptr);
+ Actual_Widget : access Widget'Class :=
+ Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
+ begin
+ return Actual_Widget;
+ end Get_Push;
+
+
+ procedure Set_Push
+ (This : in out Tabs;
+ Item : access Widget'Class) is
+ begin
+ if Item = null then
+ fl_tabs_set_push (This.Void_Ptr, System.Null_Address);
+ else
+ fl_tabs_set_push (This.Void_Ptr, Item.Void_Ptr);
+ end if;
+ end Set_Push;
+
+
+ function Get_Visible
+ (This : in Tabs)
+ return access Widget'Class
+ is
+ Widget_Ptr : System.Address :=
+ fl_tabs_get_value (This.Void_Ptr);
+ Actual_Widget : access Widget'Class :=
+ Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
+ begin
+ return Actual_Widget;
+ end Get_Visible;
+
+
+ procedure Set_Visible
+ (This : in out Tabs;
+ Item : access Widget'Class) is
+ begin
+ if Item = null then
+ fl_tabs_set_value (This.Void_Ptr, System.Null_Address);
+ else
+ fl_tabs_set_value (This.Void_Ptr, Item.Void_Ptr);
+ end if;
+ end Set_Visible;
+
+
+ function Get_Which
+ (This : in Tabs;
+ Event_X, Event_Y : in Integer)
+ return access Widget'Class
+ is
+ Widget_Ptr : System.Address :=
+ fl_tabs_which (This.Void_Ptr, Interfaces.C.int (Event_X), Interfaces.C.int (Event_Y));
+ Actual_Widget : access Widget'Class :=
+ Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
+ begin
+ return Actual_Widget;
+ end Get_Which;
+
+
+
+
+ procedure Draw
+ (This : in out Tabs) is
+ begin
+ fl_tabs_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Tabs;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_tabs_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Groups.Tabbed;
+
diff --git a/src/fltk-widgets-groups-tabbed.ads b/src/fltk-widgets-groups-tabbed.ads
new file mode 100644
index 0000000..d11d9fd
--- /dev/null
+++ b/src/fltk-widgets-groups-tabbed.ads
@@ -0,0 +1,70 @@
+
+
+package FLTK.Widgets.Groups.Tabbed is
+
+
+ type Tabs is new Group with private;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Tabs;
+
+
+
+
+ procedure Get_Client_Area
+ (This : in Tabs;
+ Tab_Height : in Natural;
+ X, Y, W, H : out Integer);
+
+
+
+
+ function Get_Push
+ (This : in Tabs)
+ return access Widget'Class;
+
+ procedure Set_Push
+ (This : in out Tabs;
+ Item : access Widget'Class);
+
+ function Get_Visible
+ (This : in Tabs)
+ return access Widget'Class;
+
+ procedure Set_Visible
+ (This : in out Tabs;
+ Item : access Widget'Class);
+
+ function Get_Which
+ (This : in Tabs;
+ Event_X, Event_Y : in Integer)
+ return access Widget'Class;
+
+
+
+
+ procedure Draw
+ (This : in out Tabs);
+
+ function Handle
+ (This : in out Tabs;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Tabs is new Group with null record;
+
+ overriding procedure Finalize
+ (This : in out Tabs);
+
+
+end FLTK.Widgets.Groups.Tabbed;
+