diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-22 21:43:02 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-22 21:43:02 +1300 |
commit | 904cb29183f7753ba5fc103296b24163ebe2fa0b (patch) | |
tree | cd469ba398582f03d1f3057c65fc2f45982bb525 | |
parent | d6458841c9134a3b6d8ca260766fca64a72740aa (diff) |
Improved Alignment values and Button State checking
-rw-r--r-- | body/c_fl.cpp | 28 | ||||
-rw-r--r-- | body/c_fl.h | 26 | ||||
-rw-r--r-- | body/fltk-widgets-buttons.adb | 8 | ||||
-rw-r--r-- | body/fltk.adb | 18 | ||||
-rw-r--r-- | doc/fl_button.html | 4 | ||||
-rw-r--r-- | spec/fltk-widgets-buttons.ads | 5 | ||||
-rw-r--r-- | spec/fltk.ads | 70 |
7 files changed, 148 insertions, 11 deletions
diff --git a/body/c_fl.cpp b/body/c_fl.cpp index 50eed9e..ec5f7e5 100644 --- a/body/c_fl.cpp +++ b/body/c_fl.cpp @@ -11,6 +11,34 @@ +const short fl_align_center = FL_ALIGN_CENTER; +const short fl_align_top = FL_ALIGN_TOP; +const short fl_align_bottom = FL_ALIGN_BOTTOM; +const short fl_align_left = FL_ALIGN_LEFT; +const short fl_align_right = FL_ALIGN_RIGHT; +const short fl_align_inside = FL_ALIGN_INSIDE; +const short fl_align_text_over_image = FL_ALIGN_TEXT_OVER_IMAGE; +const short fl_align_image_over_text = FL_ALIGN_IMAGE_OVER_TEXT; +const short fl_align_clip = FL_ALIGN_CLIP; +const short fl_align_wrap = FL_ALIGN_WRAP; +const short fl_align_image_next_to_text = FL_ALIGN_IMAGE_NEXT_TO_TEXT; +const short fl_align_text_next_to_image = FL_ALIGN_TEXT_NEXT_TO_IMAGE; +const short fl_align_image_backdrop = FL_ALIGN_IMAGE_BACKDROP; +const short fl_align_top_left = FL_ALIGN_TOP_LEFT; +const short fl_align_top_right = FL_ALIGN_TOP_RIGHT; +const short fl_align_bottom_left = FL_ALIGN_BOTTOM_LEFT; +const short fl_align_bottom_right = FL_ALIGN_BOTTOM_RIGHT; +const short fl_align_left_top = FL_ALIGN_LEFT_TOP; +const short fl_align_right_top = FL_ALIGN_RIGHT_TOP; +const short fl_align_left_bottom = FL_ALIGN_LEFT_BOTTOM; +const short fl_align_right_bottom = FL_ALIGN_RIGHT_BOTTOM; +const short fl_align_nowrap = FL_ALIGN_NOWRAP; +const short fl_align_all_position = FL_ALIGN_POSITION_MASK; +const short fl_align_all_image = FL_ALIGN_IMAGE_MASK; + + + + const short fl_mod_command = FL_COMMAND >> 16; diff --git a/body/c_fl.h b/body/c_fl.h index 8ef9df5..9f79979 100644 --- a/body/c_fl.h +++ b/body/c_fl.h @@ -8,6 +8,32 @@ #define FL_GUARD +extern "C" const short fl_align_center; +extern "C" const short fl_align_top; +extern "C" const short fl_align_bottom; +extern "C" const short fl_align_left; +extern "C" const short fl_align_right; +extern "C" const short fl_align_inside; +extern "C" const short fl_align_text_over_image; +extern "C" const short fl_align_image_over_text; +extern "C" const short fl_align_clip; +extern "C" const short fl_align_wrap; +extern "C" const short fl_align_image_next_to_text; +extern "C" const short fl_align_text_next_to_image; +extern "C" const short fl_align_image_backdrop; +extern "C" const short fl_align_top_left; +extern "C" const short fl_align_top_right; +extern "C" const short fl_align_bottom_left; +extern "C" const short fl_align_bottom_right; +extern "C" const short fl_align_left_top; +extern "C" const short fl_align_right_top; +extern "C" const short fl_align_left_bottom; +extern "C" const short fl_align_right_bottom; +extern "C" const short fl_align_nowrap; +extern "C" const short fl_align_all_position; +extern "C" const short fl_align_all_image; + + extern "C" const short fl_mod_command; diff --git a/body/fltk-widgets-buttons.adb b/body/fltk-widgets-buttons.adb index 11a57de..1e7ef60 100644 --- a/body/fltk-widgets-buttons.adb +++ b/body/fltk-widgets-buttons.adb @@ -226,6 +226,14 @@ package body FLTK.Widgets.Buttons is -- API Subprograms -- ----------------------- + function Is_On + (This : in Button) + return Boolean is + begin + return This.Get_State = On; + end Is_On; + + function Get_State (This : in Button) return State is diff --git a/body/fltk.adb b/body/fltk.adb index f302b47..d729364 100644 --- a/body/fltk.adb +++ b/body/fltk.adb @@ -122,6 +122,24 @@ package body FLTK is + function "+" + (Left, Right : in Alignment) + return Alignment is + begin + return Left or Right; + end "+"; + + + function "-" + (Left, Right : in Alignment) + return Alignment is + begin + return Left and (not Right); + end "-"; + + + + function Press (Key : in Pressable_Key) return Keypress is diff --git a/doc/fl_button.html b/doc/fl_button.html index 9397807..cc7b94d 100644 --- a/doc/fl_button.html +++ b/doc/fl_button.html @@ -214,6 +214,10 @@ procedure Set_State char value() const; </pre></td> <td><pre> +function Is_On + (This : in Button) + return Boolean; + function Get_State (This : in Button) return State; diff --git a/spec/fltk-widgets-buttons.ads b/spec/fltk-widgets-buttons.ads index 4c3b633..c5fb917 100644 --- a/spec/fltk-widgets-buttons.ads +++ b/spec/fltk-widgets-buttons.ads @@ -40,6 +40,10 @@ package FLTK.Widgets.Buttons is + function Is_On + (This : in Button) + return Boolean; + function Get_State (This : in Button) return State; @@ -110,6 +114,7 @@ private with Inline; + pragma Inline (Is_On); pragma Inline (Get_State); pragma Inline (Set_State); pragma Inline (Set_Only); diff --git a/spec/fltk.ads b/spec/fltk.ads index 785ad23..6e5ef0f 100644 --- a/spec/fltk.ads +++ b/spec/fltk.ads @@ -90,12 +90,36 @@ package FLTK is + -- This should be a bitmask, except there are magic values... type Alignment is private; - Align_Center : constant Alignment; - Align_Top : constant Alignment; - Align_Bottom : constant Alignment; - Align_Left : constant Alignment; - Align_Right : constant Alignment; + + function "+" (Left, Right : in Alignment) return Alignment; + function "-" (Left, Right : in Alignment) return Alignment; + + Align_Center : constant Alignment; + Align_Top : constant Alignment; + Align_Bottom : constant Alignment; + Align_Left : constant Alignment; + Align_Right : constant Alignment; + Align_Inside : constant Alignment; + Align_Text_Over_Image : constant Alignment; + Align_Image_Over_Text : constant Alignment; + Align_Clip : constant Alignment; + Align_Wrap : constant Alignment; + Align_Image_Next_To_Text : constant Alignment; + Align_Text_Next_To_Image : constant Alignment; + Align_Image_Backdrop : constant Alignment; + Align_Top_Left : constant Alignment; + Align_Top_Right : constant Alignment; + Align_Bottom_Left : constant Alignment; + Align_Bottom_Right : constant Alignment; + Align_Left_Top : constant Alignment; + Align_Right_Top : constant Alignment; + Align_Left_Bottom : constant Alignment; + Align_Right_Bottom : constant Alignment; + Align_Nowrap : constant Alignment; + Align_All_Position : constant Alignment; + Align_All_Image : constant Alignment; @@ -432,12 +456,36 @@ private - type Alignment is new Interfaces.Unsigned_16; - Align_Center : constant Alignment := 0; - Align_Top : constant Alignment := 1; - Align_Bottom : constant Alignment := 2; - Align_Left : constant Alignment := 4; - Align_Right : constant Alignment := 8; + -- Default value here is Align_Center + type Alignment is mod 2 ** 16 + with Default_Value => 0; + + for Alignment'Size use 16; + + pragma Import (C, Align_Center, "fl_align_center"); + pragma Import (C, Align_Top, "fl_align_top"); + pragma Import (C, Align_Bottom, "fl_align_bottom"); + pragma Import (C, Align_Left, "fl_align_left"); + pragma Import (C, Align_Right, "fl_align_right"); + pragma Import (C, Align_Inside, "fl_align_inside"); + pragma Import (C, Align_Text_Over_Image, "fl_align_text_over_image"); + pragma Import (C, Align_Image_Over_Text, "fl_align_image_over_text"); + pragma Import (C, Align_Clip, "fl_align_clip"); + pragma Import (C, Align_Wrap, "fl_align_wrap"); + pragma Import (C, Align_Image_Next_To_Text, "fl_align_image_next_to_text"); + pragma Import (C, Align_Text_Next_To_Image, "fl_align_text_next_to_image"); + pragma Import (C, Align_Image_Backdrop, "fl_align_image_backdrop"); + pragma Import (C, Align_Top_Left, "fl_align_top_left"); + pragma Import (C, Align_Top_Right, "fl_align_top_right"); + pragma Import (C, Align_Bottom_Left, "fl_align_bottom_left"); + pragma Import (C, Align_Bottom_Right, "fl_align_bottom_right"); + pragma Import (C, Align_Left_Top, "fl_align_left_top"); + pragma Import (C, Align_Right_Top, "fl_align_right_top"); + pragma Import (C, Align_Left_Bottom, "fl_align_left_bottom"); + pragma Import (C, Align_Right_Bottom, "fl_align_right_bottom"); + pragma Import (C, Align_Nowrap, "fl_align_nowrap"); + pragma Import (C, Align_All_Position, "fl_align_all_position"); + pragma Import (C, Align_All_Image, "fl_align_all_image"); |