summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2022-12-10 02:02:35 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2022-12-10 02:02:35 +1300
commitc477cd9b9879692a03178e67e71448fc97033b66 (patch)
treeacbfcd7bcf0dd138196e00a79800c22ae923f6b2 /src
parent5c4cea0152fca573e7b2832799ead10afd0697a6 (diff)
Reworked menu popup and pulldown subprograms to no longer need exceptions
Diffstat (limited to 'src')
-rw-r--r--src/fltk-widgets-menus-menu_buttons.adb15
-rw-r--r--src/fltk-widgets-menus-menu_buttons.ads2
-rw-r--r--src/fltk-widgets-menus.adb18
-rw-r--r--src/fltk-widgets-menus.ads4
4 files changed, 18 insertions, 21 deletions
diff --git a/src/fltk-widgets-menus-menu_buttons.adb b/src/fltk-widgets-menus-menu_buttons.adb
index babf75f..890d847 100644
--- a/src/fltk-widgets-menus-menu_buttons.adb
+++ b/src/fltk-widgets-menus-menu_buttons.adb
@@ -53,6 +53,12 @@ package body FLTK.Widgets.Menus.Menu_Buttons is
pragma Import (C, fl_menu_button_popup, "fl_menu_button_popup");
pragma Inline (fl_menu_button_popup);
+ function fl_menu_find_index2
+ (M, I : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_menu_find_index2, "fl_menu_find_index2");
+ pragma Inline (fl_menu_find_index2);
+
@@ -126,11 +132,12 @@ package body FLTK.Widgets.Menus.Menu_Buttons is
function Popup
(This : in out Menu_Button)
- return FLTK.Menu_Items.Menu_Item is
+ return Extended_Index
+ is
+ use type Interfaces.C.int;
+ Ptr : System.Address := fl_menu_button_popup (This.Void_Ptr);
begin
- return Item : FLTK.Menu_Items.Menu_Item do
- Wrapper (Item).Void_Ptr := fl_menu_button_popup (This.Void_Ptr);
- end return;
+ return Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
end Popup;
diff --git a/src/fltk-widgets-menus-menu_buttons.ads b/src/fltk-widgets-menus-menu_buttons.ads
index 31e4347..bccb8f7 100644
--- a/src/fltk-widgets-menus-menu_buttons.ads
+++ b/src/fltk-widgets-menus-menu_buttons.ads
@@ -37,7 +37,7 @@ package FLTK.Widgets.Menus.Menu_Buttons is
function Popup
(This : in out Menu_Button)
- return FLTK.Menu_Items.Menu_Item;
+ return Extended_Index;
diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb
index 4ff0f94..817776e 100644
--- a/src/fltk-widgets-menus.adb
+++ b/src/fltk-widgets-menus.adb
@@ -731,7 +731,7 @@ package body FLTK.Widgets.Menus is
X, Y : in Integer;
Title : in String := "";
Initial : in Extended_Index := No_Index)
- return FLTK.Menu_Items.Menu_Item_Reference
+ return Extended_Index
is
Ptr : System.Address := fl_menu_popup
(This.Void_Ptr,
@@ -739,13 +739,8 @@ package body FLTK.Widgets.Menus is
Interfaces.C.int (Y),
Interfaces.C.To_C (Title),
Interfaces.C.int (Initial) - 1);
- Place : Extended_Index := Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
begin
- if Place = No_Index then
- raise No_Reference;
- end if;
- Wrapper (This.My_Items (Place).all).Void_Ptr := Ptr;
- return (Data => This.My_Items (Place));
+ return Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
end Popup;
@@ -753,7 +748,7 @@ package body FLTK.Widgets.Menus is
(This : in Menu;
X, Y, W, H : in Integer;
Initial : in Extended_Index := No_Index)
- return FLTK.Menu_Items.Menu_Item_Reference
+ return Extended_Index
is
Ptr : System.Address := fl_menu_pulldown
(This.Void_Ptr,
@@ -762,13 +757,8 @@ package body FLTK.Widgets.Menus is
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Initial) - 1);
- Place : Extended_Index := Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
begin
- if Place = No_Index then
- raise No_Reference;
- end if;
- Wrapper (This.My_Items (Place).all).Void_Ptr := Ptr;
- return (Data => This.My_Items (Place));
+ return Extended_Index (fl_menu_find_index2 (This.Void_Ptr, Ptr) + 1);
end Pulldown;
diff --git a/src/fltk-widgets-menus.ads b/src/fltk-widgets-menus.ads
index eb2d17a..7eb56d2 100644
--- a/src/fltk-widgets-menus.ads
+++ b/src/fltk-widgets-menus.ads
@@ -206,13 +206,13 @@ package FLTK.Widgets.Menus is
X, Y : in Integer;
Title : in String := "";
Initial : in Extended_Index := No_Index)
- return FLTK.Menu_Items.Menu_Item_Reference;
+ return Extended_Index;
function Pulldown
(This : in Menu;
X, Y, W, H : in Integer;
Initial : in Extended_Index := No_Index)
- return FLTK.Menu_Items.Menu_Item_Reference;
+ return Extended_Index;