summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-06-01 20:22:09 +1000
committerJed Barber <jjbarber@y7mail.com>2017-06-01 20:22:09 +1000
commitfbdf22f733d8fafd7193bee3080e2eaeab95b86f (patch)
tree88bc1a56542d181c9df5211b636f87b61562efbd /src
parentb2aed4668c563b5649614938b22bf417b0b7f0bc (diff)
Moved Menu_Item code to separate FLTK child package
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_menu.cpp18
-rw-r--r--src/c_fl_menu.h5
-rw-r--r--src/c_fl_menuitem.cpp22
-rw-r--r--src/c_fl_menuitem.h16
-rw-r--r--src/fltk-menu_items.adb53
-rw-r--r--src/fltk-menu_items.ads29
-rw-r--r--src/fltk-widgets-menus.adb55
-rw-r--r--src/fltk-widgets-menus.ads27
8 files changed, 130 insertions, 95 deletions
diff --git a/src/c_fl_menu.cpp b/src/c_fl_menu.cpp
index a037ccb..5b5fe8f 100644
--- a/src/c_fl_menu.cpp
+++ b/src/c_fl_menu.cpp
@@ -1,7 +1,6 @@
#include <FL/Fl_Menu_.H>
-#include <FL/Fl_Menu_Item.H>
#include "c_fl_menu.h"
#include "c_fl_type.h"
@@ -70,20 +69,3 @@ const void * fl_menu_mvalue(MENU m) {
return reinterpret_cast<Fl_Menu_*>(m)->mvalue();
}
-
-
-
-int fl_menuitem_value(void * mi) {
- return reinterpret_cast<Fl_Menu_Item*>(mi)->value();
-}
-
-
-void fl_menuitem_activate(void * mi) {
- reinterpret_cast<Fl_Menu_Item*>(mi)->activate();
-}
-
-
-void fl_menuitem_deactivate(void * mi) {
- reinterpret_cast<Fl_Menu_Item*>(mi)->deactivate();
-}
-
diff --git a/src/c_fl_menu.h b/src/c_fl_menu.h
index 72d9e73..ba1fc56 100644
--- a/src/c_fl_menu.h
+++ b/src/c_fl_menu.h
@@ -21,10 +21,5 @@ extern "C" const void * fl_menu_find_item(MENU m, const char * t);
extern "C" const void * fl_menu_mvalue(MENU m);
-extern "C" int fl_menuitem_value(void * mi);
-extern "C" void fl_menuitem_activate(void * mi);
-extern "C" void fl_menuitem_deactivate(void * mi);
-
-
#endif
diff --git a/src/c_fl_menuitem.cpp b/src/c_fl_menuitem.cpp
new file mode 100644
index 0000000..12f0d71
--- /dev/null
+++ b/src/c_fl_menuitem.cpp
@@ -0,0 +1,22 @@
+
+
+#include <FL/Fl_Menu_Item.H>
+#include "c_fl_menuitem.h"
+
+
+
+
+int fl_menuitem_value(MENUITEM mi) {
+ return reinterpret_cast<Fl_Menu_Item*>(mi)->value();
+}
+
+
+void fl_menuitem_activate(MENUITEM mi) {
+ reinterpret_cast<Fl_Menu_Item*>(mi)->activate();
+}
+
+
+void fl_menuitem_deactivate(MENUITEM mi) {
+ reinterpret_cast<Fl_Menu_Item*>(mi)->deactivate();
+}
+
diff --git a/src/c_fl_menuitem.h b/src/c_fl_menuitem.h
new file mode 100644
index 0000000..e381e27
--- /dev/null
+++ b/src/c_fl_menuitem.h
@@ -0,0 +1,16 @@
+
+
+#ifndef FL_MENUITEM_GUARD
+#define FL_MENUITEM_GUARD
+
+
+typedef void* MENUITEM;
+
+
+extern "C" int fl_menuitem_value(MENUITEM mi);
+extern "C" void fl_menuitem_activate(MENUITEM mi);
+extern "C" void fl_menuitem_deactivate(MENUITEM mi);
+
+
+#endif
+
diff --git a/src/fltk-menu_items.adb b/src/fltk-menu_items.adb
new file mode 100644
index 0000000..4c42efc
--- /dev/null
+++ b/src/fltk-menu_items.adb
@@ -0,0 +1,53 @@
+
+
+with Interfaces.C;
+use type Interfaces.C.int;
+
+
+package body FLTK.Menu_Items is
+
+
+ function fl_menuitem_value
+ (MI : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_menuitem_value, "fl_menuitem_value");
+
+ procedure fl_menuitem_activate
+ (MI : in System.Address);
+ pragma Import (C, fl_menuitem_activate, "fl_menuitem_activate");
+
+ procedure fl_menuitem_deactivate
+ (MI : in System.Address);
+ pragma Import (C, fl_menuitem_deactivate, "fl_menuitem_deactivate");
+
+
+
+
+ function Value
+ (Item : in Menu_Item)
+ return Boolean is
+ begin
+ return fl_menuitem_value (Item.Void_Ptr) /= 0;
+ end Value;
+
+
+
+
+ procedure Activate
+ (Item : in Menu_Item) is
+ begin
+ fl_menuitem_activate (Item.Void_Ptr);
+ end Activate;
+
+
+
+
+ procedure Deactivate
+ (Item : in Menu_Item) is
+ begin
+ fl_menuitem_deactivate (Item.Void_Ptr);
+ end Deactivate;
+
+
+end FLTK.Menu_Items;
+
diff --git a/src/fltk-menu_items.ads b/src/fltk-menu_items.ads
new file mode 100644
index 0000000..98a9d9d
--- /dev/null
+++ b/src/fltk-menu_items.ads
@@ -0,0 +1,29 @@
+
+
+package FLTK.Menu_Items is
+
+
+ type Menu_Item is new Wrapper with private;
+
+
+ function Value
+ (Item : in Menu_Item)
+ return Boolean;
+
+
+ procedure Activate
+ (Item : in Menu_Item);
+
+
+ procedure Deactivate
+ (Item : in Menu_Item);
+
+
+private
+
+
+ type Menu_Item is new Wrapper with null record;
+
+
+end FLTK.Menu_Items;
+
diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb
index b97c966..d0c0ed7 100644
--- a/src/fltk-widgets-menus.adb
+++ b/src/fltk-widgets-menus.adb
@@ -2,6 +2,7 @@
with Interfaces.C;
with System;
+with FLTK.Menu_Items;
use type System.Address;
use type Interfaces.C.int;
use type Interfaces.C.unsigned_long;
@@ -61,20 +62,6 @@ package body FLTK.Widgets.Menus is
pragma Import (C, fl_menu_mvalue, "fl_menu_mvalue");
- function fl_menuitem_value
- (MI : in System.Address)
- return Interfaces.C.int;
- pragma Import (C, fl_menuitem_value, "fl_menuitem_value");
-
- procedure fl_menuitem_activate
- (MI : in System.Address);
- pragma Import (C, fl_menuitem_activate, "fl_menuitem_activate");
-
- procedure fl_menuitem_deactivate
- (MI : in System.Address);
- pragma Import (C, fl_menuitem_deactivate, "fl_menuitem_deactivate");
-
-
procedure Item_Hook
@@ -161,10 +148,10 @@ package body FLTK.Widgets.Menus is
function Find_Item
(This : in Menu'Class;
Name : in String)
- return Menu_Item is
+ return FLTK.Menu_Items.Menu_Item is
begin
- return Item : Menu_Item do
- Item.Void_Ptr := fl_menu_find_item
+ return Item : FLTK.Menu_Items.Menu_Item do
+ Wrapper (Item).Void_Ptr := fl_menu_find_item
(This.Void_Ptr,
Interfaces.C.To_C (Name));
end return;
@@ -175,10 +162,10 @@ package body FLTK.Widgets.Menus is
function Chosen
(This : in Menu'Class)
- return Menu_Item is
+ return FLTK.Menu_Items.Menu_Item is
begin
- return Item : Menu_Item do
- Item.Void_Ptr := fl_menu_mvalue (This.Void_Ptr);
+ return Item : FLTK.Menu_Items.Menu_Item do
+ Wrapper (Item).Void_Ptr := fl_menu_mvalue (This.Void_Ptr);
end return;
end Chosen;
@@ -194,33 +181,5 @@ package body FLTK.Widgets.Menus is
end Handle;
-
-
- function Value
- (Item : in Menu_Item)
- return Boolean is
- begin
- return fl_menuitem_value (Item.Void_Ptr) /= 0;
- end Value;
-
-
-
-
- procedure Activate
- (Item : in Menu_Item) is
- begin
- fl_menuitem_activate (Item.Void_Ptr);
- end Activate;
-
-
-
-
- procedure Deactivate
- (Item : in Menu_Item) is
- begin
- fl_menuitem_deactivate (Item.Void_Ptr);
- end Deactivate;
-
-
end FLTK.Widgets.Menus;
diff --git a/src/fltk-widgets-menus.ads b/src/fltk-widgets-menus.ads
index ec2c979..706d188 100644
--- a/src/fltk-widgets-menus.ads
+++ b/src/fltk-widgets-menus.ads
@@ -2,6 +2,7 @@
private with Interfaces;
private with System;
+with FLTK.Menu_Items;
package FLTK.Widgets.Menus is
@@ -14,9 +15,6 @@ package FLTK.Widgets.Menus is
with Implicit_Dereference => Data;
- type Menu_Item is tagged limited private;
-
-
type Index is new Positive;
@@ -49,25 +47,12 @@ package FLTK.Widgets.Menus is
function Find_Item
(This : in Menu'Class;
Name : in String)
- return Menu_Item;
+ return FLTK.Menu_Items.Menu_Item;
function Chosen
(This : in Menu'Class)
- return Menu_Item;
-
-
- function Value
- (Item : in Menu_Item)
- return Boolean;
-
-
- procedure Activate
- (Item : in Menu_Item);
-
-
- procedure Deactivate
- (Item : in Menu_Item);
+ return FLTK.Menu_Items.Menu_Item;
procedure Draw
@@ -94,12 +79,6 @@ private
(This : in out Menu);
- type Menu_Item is tagged limited
- record
- Void_Ptr : System.Address;
- end record;
-
-
type Menu_Flag is new Interfaces.Unsigned_8;
Flag_Normal : constant Menu_Flag := 2#00000000#;
Flag_Inactive : constant Menu_Flag := 2#00000001#;