summaryrefslogtreecommitdiff
path: root/test/button.adb
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-02-03 14:38:29 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-02-03 14:38:29 +1300
commit2bc98da4d5b964de2d0d5e40927aa777704f2f29 (patch)
tree95b47d4e1462e96945a9b9c40e247e361144fa57 /test/button.adb
parente2e976c7f4716034673e5939fa9f60797bf401fd (diff)
More test programs added: button, buttons, clock, color_chooser, cursor, curve, hello
Diffstat (limited to 'test/button.adb')
-rw-r--r--test/button.adb67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/button.adb b/test/button.adb
new file mode 100644
index 0000000..9ca6102
--- /dev/null
+++ b/test/button.adb
@@ -0,0 +1,67 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+
+-- Button/callback test program functionality reproduced in Ada
+
+
+with
+
+ Ada.Command_Line,
+ FLTK.Asks,
+ FLTK.Widgets.Buttons,
+ FLTK.Widgets.Groups.Windows;
+
+
+function Button
+ return Integer
+is
+
+
+ package ACom renames Ada.Command_Line;
+
+ package Ask renames FLTK.Asks;
+ package Wdg renames FLTK.Widgets;
+ package Btn renames FLTK.Widgets.Buttons;
+ package Win renames FLTK.Widgets.Groups.Windows;
+
+
+ procedure Beep_Callback
+ (This : in out Wdg.Widget'Class) is
+ begin
+ Ask.Beep;
+ end Beep_Callback;
+
+
+ The_Window : Win.Window := Win.Forge.Create (320, 65);
+
+
+ procedure Exit_Callback
+ (This : in out Wdg.Widget'Class) is
+ begin
+ ACom.Set_Exit_Status (ACom.Success);
+ The_Window.Hide;
+ end Exit_Callback;
+
+
+ Button_One : Btn.Button := Btn.Forge.Create (The_Window, 20, 20, 80, 25, "&Beep");
+ Button_Two : Btn.Button := Btn.Forge.Create (The_Window, 120, 20, 80, 25, "&No Op");
+ Button_Three : Btn.Button := Btn.Forge.Create (The_Window, 220, 20, 80, 25, "E&xit");
+
+
+begin
+
+
+ Button_One.Set_Callback (Beep_Callback'Unrestricted_Access);
+ Button_Three.Set_Callback (Exit_Callback'Unrestricted_Access);
+
+ The_Window.Show_With_Args;
+
+ return FLTK.Run;
+
+
+end Button;
+
+