summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2016-11-14 12:07:00 +1100
committerJed Barber <jjbarber@y7mail.com>2016-11-14 12:07:00 +1100
commit1e205182f6ed6a2dcae68179aadff8c4b82b5c53 (patch)
tree6f8576401552c4d2954d118897323bc017afff3c /src
parenta8bebb0ece482e5e15f9178b01a4b085e52d9f1c (diff)
Added Menu_Buttons to FLTK binding, added rightclick menu to Editor
Diffstat (limited to 'src')
-rw-r--r--src/adapad.adb14
-rw-r--r--src/fltk_binding/c_fl_menu_button.cpp21
-rw-r--r--src/fltk_binding/c_fl_menu_button.h18
-rw-r--r--src/fltk_binding/fltk-widgets-menus-menu_buttons.adb73
-rw-r--r--src/fltk_binding/fltk-widgets-menus-menu_buttons.ads35
-rw-r--r--src/windows-editor.adb23
-rw-r--r--src/windows-editor.ads9
7 files changed, 188 insertions, 5 deletions
diff --git a/src/adapad.adb b/src/adapad.adb
index e197097..dd5afd5 100644
--- a/src/adapad.adb
+++ b/src/adapad.adb
@@ -516,7 +516,7 @@ begin
declare
use FLTK.Widgets.Menus;
- Bar : Menu_Cursor := Editor.Get_Menu;
+ Bar : Menu_Cursor := Editor.Get_Menu_Bar;
begin
Bar.Add (Text => "&File", Flags => Flag_Submenu);
Bar.Add ("File/&New", New_CB'Access, Mod_Ctrl + 'n');
@@ -550,6 +550,18 @@ begin
end;
+ declare
+ use FLTK.Widgets.Menus;
+ Pop : Menu_Cursor := Editor.Get_Rightclick_Menu;
+ begin
+ Pop.Add ("Cu&t", Cut_CB'Access);
+ Pop.Add ("&Copy", Copy_CB'Access);
+ Pop.Add ("&Paste", Paste_CB'Access);
+ Pop.Add ("&Delete", Delete_CB'Access, No_Key, Flag_Divider);
+ Pop.Add ("Select &All", Select_All_CB'Access);
+ end;
+
+
Find.Set_Find_Callback (Do_Find_CB'Access);
Replace.Set_Replace_Callback (Do_Replace_CB'Access);
Buffer.Add_Modify_Callback (Mod_CB'Access);
diff --git a/src/fltk_binding/c_fl_menu_button.cpp b/src/fltk_binding/c_fl_menu_button.cpp
new file mode 100644
index 0000000..864dd3e
--- /dev/null
+++ b/src/fltk_binding/c_fl_menu_button.cpp
@@ -0,0 +1,21 @@
+
+
+#include <FL/Fl_Menu_Button.H>
+#include "c_fl_menu_button.h"
+
+
+MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label) {
+ Fl_Menu_Button *m = new Fl_Menu_Button(x, y, w, h, label);
+ return m;
+}
+
+
+void free_fl_menu_button(MENUBUTTON m) {
+ delete reinterpret_cast<Fl_Menu_Button*>(m);
+}
+
+
+void fl_menu_button_type(MENUBUTTON m, unsigned int t) {
+ reinterpret_cast<Fl_Menu_Button*>(m)->type(t);
+}
+
diff --git a/src/fltk_binding/c_fl_menu_button.h b/src/fltk_binding/c_fl_menu_button.h
new file mode 100644
index 0000000..8c089b6
--- /dev/null
+++ b/src/fltk_binding/c_fl_menu_button.h
@@ -0,0 +1,18 @@
+
+
+#ifndef FL_MENU_BUTTON_GUARD
+#define FL_MENU_BUTTON_GUARD
+
+
+typedef void* MENUBUTTON;
+
+
+extern "C" MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_menu_button(MENUBUTTON m);
+
+
+extern "C" void fl_menu_button_type(MENUBUTTON m, unsigned int t);
+
+
+#endif
+
diff --git a/src/fltk_binding/fltk-widgets-menus-menu_buttons.adb b/src/fltk_binding/fltk-widgets-menus-menu_buttons.adb
new file mode 100644
index 0000000..8347099
--- /dev/null
+++ b/src/fltk_binding/fltk-widgets-menus-menu_buttons.adb
@@ -0,0 +1,73 @@
+
+
+with Interfaces.C;
+with System;
+use type System.Address;
+
+
+package body FLTK.Widgets.Menus.Menu_Buttons is
+
+
+ function new_fl_menu_button
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_menu_button, "new_fl_menu_button");
+
+ procedure free_fl_menu_button
+ (M : in System.Address);
+ pragma Import (C, free_fl_menu_button, "free_fl_menu_button");
+
+ procedure fl_menu_button_type
+ (M : in System.Address;
+ T : in Interfaces.C.unsigned);
+ pragma Import (C, fl_menu_button_type, "fl_menu_button_type");
+
+
+
+
+ procedure Finalize
+ (This : in out Menu_Button) is
+ begin
+ Finalize (Menu (This));
+ if This.Void_Ptr /= System.Null_Address then
+ if This in Menu_Button then
+ free_fl_menu_button (This.Void_Ptr);
+ end if;
+ end if;
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Menu_Button is
+ begin
+ return This : Menu_Button do
+ This.Void_Ptr := new_fl_menu_button
+ (Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.To_C (Text));
+ fl_widget_set_user_data
+ (This.Void_Ptr,
+ Widget_Convert.To_Address (This'Unchecked_Access));
+ end return;
+ end Create;
+
+
+
+
+ procedure Set_Popup_Kind
+ (This : in out Menu_Button;
+ Pop : in Popup_Buttons) is
+ begin
+ fl_menu_button_type (This.Void_Ptr, Popup_Buttons'Pos (Pop));
+ end Set_Popup_Kind;
+
+
+end FLTK.Widgets.Menus.Menu_Buttons;
+
diff --git a/src/fltk_binding/fltk-widgets-menus-menu_buttons.ads b/src/fltk_binding/fltk-widgets-menus-menu_buttons.ads
new file mode 100644
index 0000000..5527abc
--- /dev/null
+++ b/src/fltk_binding/fltk-widgets-menus-menu_buttons.ads
@@ -0,0 +1,35 @@
+
+
+package FLTK.Widgets.Menus.Menu_Buttons is
+
+
+ type Menu_Button is new Menu with private;
+
+
+ -- signifies which mouse buttons cause the menu to appear
+ type Popup_Buttons is (No_Popup, Popup1, Popup2, Popup12, Popup3, Popup13, Popup23, Popup123);
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Menu_Button;
+
+
+ procedure Set_Popup_Kind
+ (This : in out Menu_Button;
+ Pop : in Popup_Buttons);
+
+
+private
+
+
+ type Menu_Button is new Menu with null record;
+
+
+ overriding procedure Finalize
+ (This : in out Menu_Button);
+
+
+end FLTK.Widgets.Menus.Menu_Buttons;
+
diff --git a/src/windows-editor.adb b/src/windows-editor.adb
index d995f7a..ca4bacf 100644
--- a/src/windows-editor.adb
+++ b/src/windows-editor.adb
@@ -4,6 +4,7 @@ with FLTK.Enums; use FLTK.Enums;
with FLTK.Widgets.Groups.Windows.Double;
with FLTK.Widgets.Groups.Text_Displays.Text_Editors;
with FLTK.Widgets.Menus.Menu_Bars;
+with FLTK.Widgets.Menus.Menu_Buttons;
with FLTK.Text_Buffers;
@@ -14,6 +15,7 @@ package body Windows.Editor is
package TD renames FLTK.Widgets.Groups.Text_Displays;
package TE renames FLTK.Widgets.Groups.Text_Displays.Text_Editors;
package MB renames FLTK.Widgets.Menus.Menu_Bars;
+ package MU renames FLTK.Widgets.Menus.Menu_Buttons;
@@ -41,13 +43,18 @@ package body Windows.Editor is
Editor => TE.Text_Editor'(TE.Create
(0, Menu_Height, Width, Height - Menu_Height, "")),
Bar => MB.Menu_Bar'(MB.Create
- (0, 0, Width, Menu_Height, ""))) do
+ (0, 0, Width, Menu_Height, "")),
+ Popup => MU.Menu_Button'(MU.Create
+ (0, 0, Width, Height, ""))) do
This.Add (This.Editor);
This.Add (This.Bar);
This.Bar.Set_Box (No_Box);
+ This.Editor.Add (This.Popup);
+ This.Popup.Set_Popup_Kind (MU.Popup3);
This.Editor.Set_Text_Font (Courier);
This.Set_Resizable (This.Editor);
+ This.Editor.Set_Resizable (This.Popup);
This.Set_Size_Range (Min_Editor_Width, Min_Editor_Height);
This.Set_Icon (Logo);
end return;
@@ -86,12 +93,22 @@ package body Windows.Editor is
- function Get_Menu
+ function Get_Menu_Bar
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Cursor is
begin
return Ref : FLTK.Widgets.Menus.Menu_Cursor (This.Bar'Access);
- end Get_Menu;
+ end Get_Menu_Bar;
+
+
+
+
+ function Get_Rightclick_Menu
+ (This : in out Editor_Window)
+ return FLTK.Widgets.Menus.Menu_Cursor is
+ begin
+ return Ref : FLTK.Widgets.Menus.Menu_Cursor (This.Popup'Access);
+ end Get_Rightclick_Menu;
diff --git a/src/windows-editor.ads b/src/windows-editor.ads
index 8012e09..e3d36e0 100644
--- a/src/windows-editor.ads
+++ b/src/windows-editor.ads
@@ -6,6 +6,7 @@ with FLTK.Text_Buffers;
with FLTK.Widgets.Groups.Text_Displays;
private with FLTK.Widgets.Groups.Text_Displays.Text_Editors;
private with FLTK.Widgets.Menus.Menu_Bars;
+private with FLTK.Widgets.Menus.Menu_Buttons;
package Windows.Editor is
@@ -42,7 +43,12 @@ package Windows.Editor is
Buff : in out FLTK.Text_Buffers.Text_Buffer);
- function Get_Menu
+ function Get_Menu_Bar
+ (This : in out Editor_Window)
+ return FLTK.Widgets.Menus.Menu_Cursor;
+
+
+ function Get_Rightclick_Menu
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Cursor;
@@ -106,6 +112,7 @@ private
type Editor_Window is new FLTK.Widgets.Groups.Windows.Double.Double_Window with
record
Bar : aliased FLTK.Widgets.Menus.Menu_Bars.Menu_Bar;
+ Popup : aliased FLTK.Widgets.Menus.Menu_Buttons.Menu_Button;
Editor : FLTK.Widgets.Groups.Text_Displays.Text_Editors.Text_Editor;
end record;