summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2016-11-13 14:41:26 +1100
committerJed Barber <jjbarber@y7mail.com>2016-11-13 14:41:26 +1100
commit0f9b0b9259ada50de7f8866f9591ce4ad3e7eadc (patch)
treecfcafa0c09eb9f9543e40dfe15a17d384d5e12ef
parentfa22b74c2e6528b4315909377f277ef193e19d11 (diff)
Added word wrap feature
-rw-r--r--c_fl_menu.cpp13
-rw-r--r--c_fl_menu.h5
-rw-r--r--c_fl_text_display.cpp5
-rw-r--r--c_fl_text_display.h1
-rw-r--r--fltk-widgets-groups-text_displays.adb19
-rw-r--r--fltk-widgets-groups-text_displays.ads9
-rw-r--r--fltk-widgets-menus.adb32
-rw-r--r--fltk-widgets-menus.ads19
8 files changed, 99 insertions, 4 deletions
diff --git a/c_fl_menu.cpp b/c_fl_menu.cpp
index e8cbe58..0455e51 100644
--- a/c_fl_menu.cpp
+++ b/c_fl_menu.cpp
@@ -1,6 +1,7 @@
#include <FL/Fl_Menu_.H>
+#include <FL/Fl_Menu_Item.H>
#include "c_fl_menu.h"
@@ -8,3 +9,15 @@ int fl_menu_add(MENU m, const char * t, unsigned long s, void * c, void * u, uns
return reinterpret_cast<Fl_Menu_*>(m)->add(t, s, reinterpret_cast<Fl_Callback_p>(c), u, f);
}
+
+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();
+}
+
diff --git a/c_fl_menu.h b/c_fl_menu.h
index d8e8b90..1599334 100644
--- a/c_fl_menu.h
+++ b/c_fl_menu.h
@@ -5,9 +5,14 @@
typedef void* MENU;
+// typedef void* MENUITEM;
extern "C" int fl_menu_add(MENU m, const char * t, unsigned long s, void * c, void * u, unsigned long f);
+extern "C" const void * fl_menu_mvalue(MENU m);
+
+
+extern "C" int fl_menuitem_value(void * mi);
#endif
diff --git a/c_fl_text_display.cpp b/c_fl_text_display.cpp
index 5104869..d1785e2 100644
--- a/c_fl_text_display.cpp
+++ b/c_fl_text_display.cpp
@@ -83,3 +83,8 @@ void fl_text_display_previous_word(TEXTDISPLAY td) {
reinterpret_cast<Fl_Text_Display*>(td)->previous_word();
}
+
+void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m) {
+ reinterpret_cast<Fl_Text_Display*>(td)->wrap_mode(w, m);
+}
+
diff --git a/c_fl_text_display.h b/c_fl_text_display.h
index f42ada9..2f8e089 100644
--- a/c_fl_text_display.h
+++ b/c_fl_text_display.h
@@ -25,6 +25,7 @@ extern "C" void fl_text_display_set_insert_pos(TEXTDISPLAY td, int p);
extern "C" void fl_text_display_show_insert_pos(TEXTDISPLAY td);
extern "C" void fl_text_display_next_word(TEXTDISPLAY td);
extern "C" void fl_text_display_previous_word(TEXTDISPLAY td);
+extern "C" void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m);
#endif
diff --git a/fltk-widgets-groups-text_displays.adb b/fltk-widgets-groups-text_displays.adb
index f8418d6..71aeee0 100644
--- a/fltk-widgets-groups-text_displays.adb
+++ b/fltk-widgets-groups-text_displays.adb
@@ -80,6 +80,11 @@ package body FLTK.Widgets.Groups.Text_Displays is
(TD : in System.Address);
pragma Import (C, fl_text_display_previous_word, "fl_text_display_previous_word");
+ procedure fl_text_display_wrap_mode
+ (TD : in System.Address;
+ W, M : in Interfaces.C.int);
+ pragma Import (C, fl_text_display_wrap_mode, "fl_text_display_wrap_mode");
+
@@ -245,5 +250,19 @@ package body FLTK.Widgets.Groups.Text_Displays is
end Previous_Word;
+
+
+ procedure Set_Wrap_Mode
+ (This : in out Text_Display;
+ Mode : in Wrap_Mode;
+ Margin : in Natural := 0) is
+ begin
+ fl_text_display_wrap_mode
+ (This.Void_Ptr,
+ Wrap_Mode'Pos (Mode),
+ Interfaces.C.int (Margin));
+ end Set_Wrap_Mode;
+
+
end FLTK.Widgets.Groups.Text_Displays;
diff --git a/fltk-widgets-groups-text_displays.ads b/fltk-widgets-groups-text_displays.ads
index 3eea299..a55b28f 100644
--- a/fltk-widgets-groups-text_displays.ads
+++ b/fltk-widgets-groups-text_displays.ads
@@ -10,6 +10,9 @@ package FLTK.Widgets.Groups.Text_Displays is
type Text_Display is new Group with private;
+ type Wrap_Mode is (Wrap_None, Wrap_At_Column, Wrap_At_Pixel, Wrap_At_Bounds);
+
+
function Create
(X, Y, W, H : in Integer;
Text : in String)
@@ -78,6 +81,12 @@ package FLTK.Widgets.Groups.Text_Displays is
(This : in out Text_Display);
+ procedure Set_Wrap_Mode
+ (This : in out Text_Display;
+ Mode : in Wrap_Mode;
+ Margin : in Natural := 0);
+
+
private
diff --git a/fltk-widgets-menus.adb b/fltk-widgets-menus.adb
index 0f50fc8..169e71d 100644
--- a/fltk-widgets-menus.adb
+++ b/fltk-widgets-menus.adb
@@ -91,6 +91,16 @@ package body FLTK.Widgets.Menus is
return Interfaces.C.int;
pragma Import (C, fl_menu_add, "fl_menu_add");
+ function fl_menu_mvalue
+ (M : in System.Address)
+ return System.Address;
+ 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");
+
@@ -138,5 +148,27 @@ package body FLTK.Widgets.Menus is
end Add;
+
+
+ function Chosen
+ (This : in Menu'Class)
+ return Menu_Item is
+ begin
+ return Item : Menu_Item do
+ Item.Void_Ptr := fl_menu_mvalue (This.Void_Ptr);
+ end return;
+ end Chosen;
+
+
+
+
+ function Value
+ (Item : in Menu_Item)
+ return Boolean is
+ begin
+ return fl_menuitem_value (Item.Void_Ptr) /= 0;
+ end Value;
+
+
end FLTK.Widgets.Menus;
diff --git a/fltk-widgets-menus.ads b/fltk-widgets-menus.ads
index 27b9d4a..cf6fcf7 100644
--- a/fltk-widgets-menus.ads
+++ b/fltk-widgets-menus.ads
@@ -12,9 +12,7 @@ package FLTK.Widgets.Menus is
with Implicit_Dereference => Data;
- type Menu_Item is private;
- type Menu_Item_Cursor (Data : access Menu_Item) is limited null record
- with Implicit_Dereference => Data;
+ type Menu_Item is tagged limited private;
type Index is new Positive;
@@ -62,13 +60,26 @@ package FLTK.Widgets.Menus is
Flags : in Menu_Flag := Flag_Normal);
+ function Chosen
+ (This : in Menu'Class)
+ return Menu_Item;
+
+
+ function Value
+ (Item : in Menu_Item)
+ return Boolean;
+
+
private
type Menu is abstract new Widget with null record;
- type Menu_Item is new System.Address;
+ type Menu_Item is tagged limited
+ record
+ Void_Ptr : System.Address;
+ end record;
-- these values designed to align with FLTK enumeration types