summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2018-03-19 22:11:39 +1100
committerJed Barber <jjbarber@y7mail.com>2018-03-19 22:11:39 +1100
commitc1dcb4c61e79b1ddd98c0ef84f2d36be7f7fd736 (patch)
treedbc06e9612ec7757286831a79fe617278da50adb
parent24c57b72a3a8edb92d2861cd8c88bb81bd936ae9 (diff)
Added FLTK.Widgets.Groups.Packed
-rw-r--r--progress.txt2
-rw-r--r--src/c_fl_pack.cpp81
-rw-r--r--src/c_fl_pack.h33
-rw-r--r--src/fltk-widgets-groups-packed.adb146
-rw-r--r--src/fltk-widgets-groups-packed.ads53
5 files changed, 314 insertions, 1 deletions
diff --git a/progress.txt b/progress.txt
index d757afa..425431e 100644
--- a/progress.txt
+++ b/progress.txt
@@ -36,6 +36,7 @@ FLTK.Widgets.Clocks.Updated
FLTK.Widgets.Clocks.Updated.Round
FLTK.Widgets.Groups.Color_Choosers
FLTK.Widgets.Groups.Input_Choices
+FLTK.Widgets.Groups.Packed
FLTK.Widgets.Groups.Scrolls
FLTK.Widgets.Groups.Spinners
FLTK.Widgets.Groups.Tabbed
@@ -107,7 +108,6 @@ FL_Hold_Browser
FL_Multi_Browser
FL_Select_Browser
FL_Help_View (several methods have ABI_VERSION bugs)
-FL_Pack
FL_Table
FL_Table_Row
FL_Tree
diff --git a/src/c_fl_pack.cpp b/src/c_fl_pack.cpp
new file mode 100644
index 0000000..26e3a7b
--- /dev/null
+++ b/src/c_fl_pack.cpp
@@ -0,0 +1,81 @@
+
+
+#include <FL/Fl_Pack.H>
+#include "c_fl_pack.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Pack : public Fl_Pack {
+ public:
+ using Fl_Pack::Fl_Pack;
+ friend void pack_set_draw_hook(PACK n, void * d);
+ friend void fl_pack_draw(PACK n);
+ friend void pack_set_handle_hook(PACK n, void * h);
+ friend int fl_pack_handle(PACK n, int e);
+ protected:
+ void draw();
+ void real_draw();
+ int handle(int e);
+ int real_handle(int e);
+ d_hook_p draw_hook;
+ h_hook_p handle_hook;
+};
+
+void My_Pack::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Pack::real_draw() {
+ Fl_Pack::draw();
+}
+
+int My_Pack::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Pack::real_handle(int e) {
+ return Fl_Pack::handle(e);
+}
+
+void pack_set_draw_hook(PACK n, void * d) {
+ reinterpret_cast<My_Pack*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_pack_draw(PACK n) {
+ reinterpret_cast<My_Pack*>(n)->real_draw();
+}
+
+void pack_set_handle_hook(PACK n, void * h) {
+ reinterpret_cast<My_Pack*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_pack_handle(PACK n, int e) {
+ return reinterpret_cast<My_Pack*>(n)->real_handle(e);
+}
+
+
+
+
+PACK new_fl_pack(int x, int y, int w, int h, char* label) {
+ My_Pack *b = new My_Pack(x, y, w, h, label);
+ return b;
+}
+
+void free_fl_pack(PACK p) {
+ delete reinterpret_cast<My_Pack*>(p);
+}
+
+
+
+
+int fl_pack_get_spacing(PACK p) {
+ return reinterpret_cast<My_Pack*>(p)->spacing();
+}
+
+void fl_pack_set_spacing(PACK p, int t) {
+ reinterpret_cast<My_Pack*>(p)->spacing(t);
+}
+
+
diff --git a/src/c_fl_pack.h b/src/c_fl_pack.h
new file mode 100644
index 0000000..debb69c
--- /dev/null
+++ b/src/c_fl_pack.h
@@ -0,0 +1,33 @@
+
+
+#ifndef FL_PACK_GUARD
+#define FL_PACK_GUARD
+
+
+
+
+typedef void* PACK;
+
+
+
+
+extern "C" void pack_set_draw_hook(PACK n, void * d);
+extern "C" void fl_pack_draw(PACK n);
+extern "C" void pack_set_handle_hook(PACK n, void * h);
+extern "C" int fl_pack_handle(PACK n, int e);
+
+
+
+
+extern "C" PACK new_fl_pack(int x, int y, int w, int h, char * label);
+extern "C" void free_fl_pack(PACK p);
+
+
+
+
+extern "C" int fl_pack_get_spacing(PACK p);
+extern "C" void fl_pack_set_spacing(PACK p, int t);
+
+
+#endif
+
diff --git a/src/fltk-widgets-groups-packed.adb b/src/fltk-widgets-groups-packed.adb
new file mode 100644
index 0000000..0507bb3
--- /dev/null
+++ b/src/fltk-widgets-groups-packed.adb
@@ -0,0 +1,146 @@
+
+
+with
+
+ Interfaces.C,
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Widgets.Groups.Packed is
+
+
+ procedure pack_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, pack_set_draw_hook, "pack_set_draw_hook");
+
+ procedure pack_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, pack_set_handle_hook, "pack_set_handle_hook");
+
+
+
+
+ function new_fl_pack
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_pack, "new_fl_pack");
+
+ procedure free_fl_pack
+ (B : in System.Address);
+ pragma Import (C, free_fl_pack, "free_fl_pack");
+
+
+
+
+ function fl_pack_get_spacing
+ (P : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_pack_get_spacing, "fl_pack_get_spacing");
+
+ procedure fl_pack_set_spacing
+ (P : in System.Address;
+ S : in Interfaces.C.int);
+ pragma Import (C, fl_pack_set_spacing, "fl_pack_set_spacing");
+
+
+
+
+ procedure fl_pack_draw
+ (W : in System.Address);
+ pragma Import (C, fl_pack_draw, "fl_pack_draw");
+
+ function fl_pack_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_pack_handle, "fl_pack_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Packed_Group) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Packed_Group'Class
+ then
+ This.Clear;
+ free_fl_pack (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Group (This));
+ end Finalize;
+
+
+
+
+ package body Forge is
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Packed_Group is
+ begin
+ return This : Packed_Group do
+ This.Void_Ptr := new_fl_pack
+ (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));
+ pack_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ pack_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+ end Forge;
+
+
+
+
+ function Get_Spacing
+ (This : in Packed_Group)
+ return Integer is
+ begin
+ return Integer (fl_pack_get_spacing (This.Void_Ptr));
+ end Get_Spacing;
+
+
+ procedure Set_Spacing
+ (This : in out Packed_Group;
+ To : in Integer) is
+ begin
+ fl_pack_set_spacing (This.Void_Ptr, Interfaces.C.int (To));
+ end Set_Spacing;
+
+
+
+
+ procedure Draw
+ (This : in out Packed_Group) is
+ begin
+ fl_pack_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Packed_Group;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_pack_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Groups.Packed;
+
diff --git a/src/fltk-widgets-groups-packed.ads b/src/fltk-widgets-groups-packed.ads
new file mode 100644
index 0000000..92ed137
--- /dev/null
+++ b/src/fltk-widgets-groups-packed.ads
@@ -0,0 +1,53 @@
+
+
+package FLTK.Widgets.Groups.Packed is
+
+
+ type Packed_Group is new Group with private;
+
+
+
+
+ package Forge is
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Packed_Group;
+
+ end Forge;
+
+
+
+
+ function Get_Spacing
+ (This : in Packed_Group)
+ return Integer;
+
+ procedure Set_Spacing
+ (This : in out Packed_Group;
+ To : in Integer);
+
+
+
+
+ procedure Draw
+ (This : in out Packed_Group);
+
+ function Handle
+ (This : in out Packed_Group;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Packed_Group is new Group with null record;
+
+ overriding procedure Finalize
+ (This : in out Packed_Group);
+
+
+end FLTK.Widgets.Groups.Packed;
+