summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-12 15:45:37 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-12 15:45:37 +1300
commit8b01c23e0ba1fd22e0bfc797d6ca540c79079674 (patch)
tree007c84462e326b8030ba04cba875532f7419c565 /src
parente324057cbd9b02704172bb5db4163f4a0c276288 (diff)
Format string methods for Fl_Spinner
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_spinner.cpp27
-rw-r--r--src/c_fl_spinner.h8
-rw-r--r--src/fltk-widgets-groups-spinners.adb102
-rw-r--r--src/fltk-widgets-groups-spinners.ads41
4 files changed, 127 insertions, 51 deletions
diff --git a/src/c_fl_spinner.cpp b/src/c_fl_spinner.cpp
index a09ed17..71d86f8 100644
--- a/src/c_fl_spinner.cpp
+++ b/src/c_fl_spinner.cpp
@@ -127,14 +127,6 @@ void fl_spinner_set_step(SPINNER n, double t) {
reinterpret_cast<Fl_Spinner*>(n)->step(t);
}
-int fl_spinner_get_type(SPINNER n) {
- return reinterpret_cast<Fl_Spinner*>(n)->type();
-}
-
-void fl_spinner_set_type(SPINNER n, int t) {
- reinterpret_cast<Fl_Spinner*>(n)->type(t);
-}
-
double fl_spinner_get_value(SPINNER n) {
return reinterpret_cast<Fl_Spinner*>(n)->value();
}
@@ -146,6 +138,25 @@ void fl_spinner_set_value(SPINNER n, double t) {
+const char * fl_spinner_get_format(SPINNER n) {
+ return reinterpret_cast<Fl_Spinner*>(n)->format();
+}
+
+void fl_spinner_set_format(SPINNER n, const char * f) {
+ reinterpret_cast<Fl_Spinner*>(n)->format(f);
+}
+
+int fl_spinner_get_type(SPINNER n) {
+ return reinterpret_cast<Fl_Spinner*>(n)->type();
+}
+
+void fl_spinner_set_type(SPINNER n, int t) {
+ reinterpret_cast<Fl_Spinner*>(n)->type(t);
+}
+
+
+
+
void fl_spinner_resize(SPINNER n, int x, int y, int w, int h) {
reinterpret_cast<Fl_Spinner*>(n)->resize(x, y, w, h);
}
diff --git a/src/c_fl_spinner.h b/src/c_fl_spinner.h
index 2c5e97d..d92e6e1 100644
--- a/src/c_fl_spinner.h
+++ b/src/c_fl_spinner.h
@@ -34,12 +34,16 @@ extern "C" void fl_spinner_set_maximum(SPINNER n, double t);
extern "C" void fl_spinner_range(SPINNER n, double a, double b);
extern "C" double fl_spinner_get_step(SPINNER n);
extern "C" void fl_spinner_set_step(SPINNER n, double t);
-extern "C" int fl_spinner_get_type(SPINNER n);
-extern "C" void fl_spinner_set_type(SPINNER n, int t);
extern "C" double fl_spinner_get_value(SPINNER n);
extern "C" void fl_spinner_set_value(SPINNER n, double t);
+extern "C" const char * fl_spinner_get_format(SPINNER n);
+extern "C" void fl_spinner_set_format(SPINNER n, const char * f);
+extern "C" int fl_spinner_get_type(SPINNER n);
+extern "C" void fl_spinner_set_type(SPINNER n, int t);
+
+
extern "C" void fl_spinner_resize(SPINNER n, int x, int y, int w, int h);
diff --git a/src/fltk-widgets-groups-spinners.adb b/src/fltk-widgets-groups-spinners.adb
index 1ddc806..e9d2f28 100644
--- a/src/fltk-widgets-groups-spinners.adb
+++ b/src/fltk-widgets-groups-spinners.adb
@@ -6,11 +6,12 @@
with
- Interfaces.C;
+ Interfaces.C.Strings;
use type
- Interfaces.C.int;
+ Interfaces.C.int,
+ Interfaces.C.Strings.chars_ptr;
package body FLTK.Widgets.Groups.Spinners is
@@ -140,18 +141,6 @@ package body FLTK.Widgets.Groups.Spinners is
pragma Import (C, fl_spinner_set_step, "fl_spinner_set_step");
pragma Inline (fl_spinner_set_step);
- function fl_spinner_get_type
- (S : in Storage.Integer_Address)
- return Interfaces.C.int;
- pragma Import (C, fl_spinner_get_type, "fl_spinner_get_type");
- pragma Inline (fl_spinner_get_type);
-
- procedure fl_spinner_set_type
- (S : in Storage.Integer_Address;
- T : in Interfaces.C.int);
- pragma Import (C, fl_spinner_set_type, "fl_spinner_set_type");
- pragma Inline (fl_spinner_set_type);
-
function fl_spinner_get_value
(S : in Storage.Integer_Address)
return Interfaces.C.double;
@@ -167,6 +156,33 @@ package body FLTK.Widgets.Groups.Spinners is
+ function fl_spinner_get_format
+ (S : in Storage.Integer_Address)
+ return Interfaces.C.Strings.chars_ptr;
+ pragma Import (C, fl_spinner_get_format, "fl_spinner_get_format");
+ pragma Inline (fl_spinner_get_format);
+
+ procedure fl_spinner_set_format
+ (S : in Storage.Integer_Address;
+ F : in Interfaces.C.Strings.chars_ptr);
+ pragma Import (C, fl_spinner_set_format, "fl_spinner_set_format");
+ pragma Inline (fl_spinner_set_format);
+
+ function fl_spinner_get_type
+ (S : in Storage.Integer_Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_spinner_get_type, "fl_spinner_get_type");
+ pragma Inline (fl_spinner_get_type);
+
+ procedure fl_spinner_set_type
+ (S : in Storage.Integer_Address;
+ T : in Interfaces.C.int);
+ pragma Import (C, fl_spinner_set_type, "fl_spinner_set_type");
+ pragma Inline (fl_spinner_set_type);
+
+
+
+
procedure fl_spinner_resize
(S : in Storage.Integer_Address;
X, Y, W, H : in Interfaces.C.int);
@@ -413,22 +429,6 @@ package body FLTK.Widgets.Groups.Spinners is
end Set_Step;
- function Get_Type
- (This : in Spinner)
- return Spinner_Kind is
- begin
- return Spinner_Kind'Val (fl_spinner_get_type (This.Void_Ptr) - 1);
- end Get_Type;
-
-
- procedure Set_Type
- (This : in out Spinner;
- To : in Spinner_Kind) is
- begin
- fl_spinner_set_type (This.Void_Ptr, Spinner_Kind'Pos (To) + 1);
- end Set_Type;
-
-
function Get_Value
(This : in Spinner)
return Long_Float is
@@ -447,6 +447,48 @@ package body FLTK.Widgets.Groups.Spinners is
+ function Get_Format
+ (This : in Spinner)
+ return String
+ is
+ Result : Interfaces.C.Strings.chars_ptr := fl_spinner_get_format (This.Void_Ptr);
+ begin
+ if Result = Interfaces.C.Strings.Null_Ptr then
+ return "";
+ else
+ return Interfaces.C.Strings.Value (Result);
+ end if;
+ end Get_Format;
+
+
+ procedure Set_Format
+ (This : in out Spinner;
+ To : in String) is
+ begin
+ Interfaces.C.Strings.Free (This.Format_Str);
+ This.Format_Str := Interfaces.C.Strings.New_String (To);
+ fl_spinner_set_format (This.Void_Ptr, This.Format_Str);
+ end Set_Format;
+
+
+ function Get_Type
+ (This : in Spinner)
+ return Spinner_Kind is
+ begin
+ return Spinner_Kind'Val (fl_spinner_get_type (This.Void_Ptr) - 1);
+ end Get_Type;
+
+
+ procedure Set_Type
+ (This : in out Spinner;
+ To : in Spinner_Kind) is
+ begin
+ fl_spinner_set_type (This.Void_Ptr, Spinner_Kind'Pos (To) + 1);
+ end Set_Type;
+
+
+
+
procedure Resize
(This : in out Spinner;
X, Y, W, H : in Integer) is
diff --git a/src/fltk-widgets-groups-spinners.ads b/src/fltk-widgets-groups-spinners.ads
index 5c6233e..39ed4b3 100644
--- a/src/fltk-widgets-groups-spinners.ads
+++ b/src/fltk-widgets-groups-spinners.ads
@@ -4,6 +4,11 @@
-- Released into the public domain
+private with
+
+ Interfaces.C.Strings;
+
+
package FLTK.Widgets.Groups.Spinners is
@@ -104,14 +109,6 @@ package FLTK.Widgets.Groups.Spinners is
(This : in out Spinner;
To : in Long_Float);
- function Get_Type
- (This : in Spinner)
- return Spinner_Kind;
-
- procedure Set_Type
- (This : in out Spinner;
- To : in Spinner_Kind);
-
function Get_Value
(This : in Spinner)
return Long_Float;
@@ -123,6 +120,25 @@ package FLTK.Widgets.Groups.Spinners is
+ function Get_Format
+ (This : in Spinner)
+ return String;
+
+ procedure Set_Format
+ (This : in out Spinner;
+ To : in String);
+
+ function Get_Type
+ (This : in Spinner)
+ return Spinner_Kind;
+
+ procedure Set_Type
+ (This : in out Spinner;
+ To : in Spinner_Kind);
+
+
+
+
procedure Resize
(This : in out Spinner;
X, Y, W, H : in Integer);
@@ -139,7 +155,9 @@ package FLTK.Widgets.Groups.Spinners is
private
- type Spinner is new Group with null record;
+ type Spinner is new Group with record
+ Format_Str : Interfaces.C.Strings.chars_ptr;
+ end record;
overriding procedure Initialize
(This : in out Spinner);
@@ -176,11 +194,12 @@ private
pragma Inline (Set_Range);
pragma Inline (Get_Step);
pragma Inline (Set_Step);
- pragma Inline (Get_Type);
- pragma Inline (Set_Type);
pragma Inline (Get_Value);
pragma Inline (Set_Value);
+ pragma Inline (Get_Type);
+ pragma Inline (Set_Type);
+
pragma Inline (Resize);
pragma Inline (Handle);