aboutsummaryrefslogtreecommitdiff
path: root/body/fltk-labels.adb
diff options
context:
space:
mode:
Diffstat (limited to 'body/fltk-labels.adb')
-rw-r--r--body/fltk-labels.adb52
1 files changed, 43 insertions, 9 deletions
diff --git a/body/fltk-labels.adb b/body/fltk-labels.adb
index 006db6b..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
@@ -16,6 +21,8 @@ package body FLTK.Labels is
-- Functions From C --
------------------------
+ -- Allocation --
+
function new_fl_label
(V : in Interfaces.C.Strings.chars_ptr;
F : in Interfaces.C.int;
@@ -35,6 +42,14 @@ 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);
@@ -114,6 +129,8 @@ package body FLTK.Labels is
+ -- Drawing --
+
procedure fl_label_draw
(L : in Storage.Integer_Address;
X, Y, W, H : in Interfaces.C.int;
@@ -130,26 +147,27 @@ package body FLTK.Labels is
- -----------------------------------
- -- Controlled Type Subprograms --
- -----------------------------------
+ -------------------
+ -- Destructors --
+ -------------------
procedure Finalize
(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;
- -----------------
- -- Label API --
- -----------------
+ --------------------
+ -- Constructors --
+ --------------------
package body Forge is
@@ -175,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;
@@ -183,11 +202,23 @@ package body FLTK.Labels is
+ -----------------------
+ -- API Subprograms --
+ -----------------------
+
+ -- Attributes --
+
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;
@@ -325,6 +356,8 @@ package body FLTK.Labels is
+ -- Drawing --
+
procedure Draw
(This : in out Label;
X, Y, W, H : in Integer;
@@ -339,6 +372,7 @@ package body FLTK.Labels is
Interfaces.C.unsigned (Place));
end Draw;
+
procedure Measure
(This : in Label;
W, H : out Integer) is