summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-05-01 11:49:21 +1000
committerJed Barber <jjbarber@y7mail.com>2017-05-01 11:49:21 +1000
commit9348c8013431bbd5de165d8fbac13b783d983324 (patch)
tree45f10677e9748547665e44ff5de47cbf4e61d9a6 /src
parentf37664163c9dfa33416845ddd78695c33e6fdaef (diff)
Draw method implemented for all Window subpackages
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_double_window.cpp52
-rw-r--r--src/c_fl_double_window.h3
-rw-r--r--src/c_fl_menu_window.cpp60
-rw-r--r--src/c_fl_menu_window.h3
-rw-r--r--src/c_fl_single_window.cpp52
-rw-r--r--src/c_fl_single_window.h3
-rw-r--r--src/fltk-widgets-groups-windows-double.adb34
-rw-r--r--src/fltk-widgets-groups-windows-double.ads8
-rw-r--r--src/fltk-widgets-groups-windows-single-menu.adb34
-rw-r--r--src/fltk-widgets-groups-windows-single-menu.ads8
-rw-r--r--src/fltk-widgets-groups-windows-single.adb34
-rw-r--r--src/fltk-widgets-groups-windows-single.ads8
12 files changed, 280 insertions, 19 deletions
diff --git a/src/c_fl_double_window.cpp b/src/c_fl_double_window.cpp
index 7f29af8..ff9a596 100644
--- a/src/c_fl_double_window.cpp
+++ b/src/c_fl_double_window.cpp
@@ -4,29 +4,71 @@
#include "c_fl_double_window.h"
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Double_Window : public Fl_Double_Window {
+ public:
+ using Fl_Double_Window::Fl_Double_Window;
+ friend void double_window_set_draw_hook(DOUBLEWINDOW n, void * d);
+ friend void fl_double_window_draw(DOUBLEWINDOW n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Double_Window::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Double_Window::real_draw() {
+ Fl_Double_Window::draw();
+}
+
+
+void double_window_set_draw_hook(DOUBLEWINDOW n, void * d) {
+ reinterpret_cast<My_Double_Window*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_double_window_draw(DOUBLEWINDOW n) {
+ reinterpret_cast<My_Double_Window*>(n)->real_draw();
+}
+
+
+
+
DOUBLEWINDOW new_fl_double_window(int x, int y, int w, int h, char* label) {
- Fl_Double_Window *d = new Fl_Double_Window(x, y, w, h, label);
+ My_Double_Window *d = new My_Double_Window(x, y, w, h, label);
return d;
}
DOUBLEWINDOW new_fl_double_window2(int w, int h) {
- Fl_Double_Window *d = new Fl_Double_Window(w, h);
+ My_Double_Window *d = new My_Double_Window(w, h);
return d;
}
void free_fl_double_window(DOUBLEWINDOW d) {
- delete reinterpret_cast<Fl_Double_Window*>(d);
+ delete reinterpret_cast<My_Double_Window*>(d);
}
+
+
void fl_double_window_show(DOUBLEWINDOW d) {
- reinterpret_cast<Fl_Double_Window*>(d)->show();
+ reinterpret_cast<My_Double_Window*>(d)->show();
}
void fl_double_window_hide(DOUBLEWINDOW d) {
- reinterpret_cast<Fl_Double_Window*>(d)->hide();
+ reinterpret_cast<My_Double_Window*>(d)->hide();
}
diff --git a/src/c_fl_double_window.h b/src/c_fl_double_window.h
index 3be3588..7cadafb 100644
--- a/src/c_fl_double_window.h
+++ b/src/c_fl_double_window.h
@@ -7,6 +7,9 @@
typedef void* DOUBLEWINDOW;
+extern "C" void double_window_set_draw_hook(DOUBLEWINDOW n, void * d);
+extern "C" void fl_double_window_draw(DOUBLEWINDOW n);
+
extern "C" DOUBLEWINDOW new_fl_double_window(int x, int y, int w, int h, char* label);
extern "C" DOUBLEWINDOW new_fl_double_window2(int w, int h);
extern "C" void free_fl_double_window(DOUBLEWINDOW d);
diff --git a/src/c_fl_menu_window.cpp b/src/c_fl_menu_window.cpp
index 66ad6f3..8445978 100644
--- a/src/c_fl_menu_window.cpp
+++ b/src/c_fl_menu_window.cpp
@@ -4,49 +4,91 @@
#include "c_fl_menu_window.h"
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Menu_Window : public Fl_Menu_Window {
+ public:
+ using Fl_Menu_Window::Fl_Menu_Window;
+ friend void menu_window_set_draw_hook(MENUWINDOW n, void * d);
+ friend void fl_menu_window_draw(MENUWINDOW n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Menu_Window::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Menu_Window::real_draw() {
+ Fl_Menu_Window::draw();
+}
+
+
+void menu_window_set_draw_hook(MENUWINDOW n, void * d) {
+ reinterpret_cast<My_Menu_Window*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_menu_window_draw(MENUWINDOW n) {
+ reinterpret_cast<My_Menu_Window*>(n)->real_draw();
+}
+
+
+
+
MENUWINDOW new_fl_menu_window(int x, int y, int w, int h, char* label) {
- Fl_Menu_Window *m = new Fl_Menu_Window(x, y, w, h, label);
+ My_Menu_Window *m = new My_Menu_Window(x, y, w, h, label);
return m;
}
MENUWINDOW new_fl_menu_window2(int w, int h) {
- Fl_Menu_Window *m = new Fl_Menu_Window(w, h);
+ My_Menu_Window *m = new My_Menu_Window(w, h);
return m;
}
void free_fl_menu_window(MENUWINDOW m) {
- delete reinterpret_cast<Fl_Menu_Window*>(m);
+ delete reinterpret_cast<My_Menu_Window*>(m);
}
+
+
void fl_menu_window_show(MENUWINDOW m) {
- reinterpret_cast<Fl_Menu_Window*>(m)->show();
+ reinterpret_cast<My_Menu_Window*>(m)->show();
}
void fl_menu_window_hide(MENUWINDOW m) {
- reinterpret_cast<Fl_Menu_Window*>(m)->hide();
+ reinterpret_cast<My_Menu_Window*>(m)->hide();
}
void fl_menu_window_flush(MENUWINDOW m) {
- reinterpret_cast<Fl_Menu_Window*>(m)->flush();
+ reinterpret_cast<My_Menu_Window*>(m)->flush();
}
void fl_menu_window_set_overlay(MENUWINDOW m) {
- reinterpret_cast<Fl_Menu_Window*>(m)->set_overlay();
+ reinterpret_cast<My_Menu_Window*>(m)->set_overlay();
}
void fl_menu_window_clear_overlay(MENUWINDOW m) {
- reinterpret_cast<Fl_Menu_Window*>(m)->clear_overlay();
+ reinterpret_cast<My_Menu_Window*>(m)->clear_overlay();
}
unsigned int fl_menu_window_overlay(MENUWINDOW m) {
- return reinterpret_cast<Fl_Menu_Window*>(m)->overlay();
+ return reinterpret_cast<My_Menu_Window*>(m)->overlay();
}
diff --git a/src/c_fl_menu_window.h b/src/c_fl_menu_window.h
index 3322b29..89d02c3 100644
--- a/src/c_fl_menu_window.h
+++ b/src/c_fl_menu_window.h
@@ -7,6 +7,9 @@
typedef void* MENUWINDOW;
+extern "C" void menu_window_set_draw_hook(MENUWINDOW n, void * d);
+extern "C" void fl_menu_window_draw(MENUWINDOW n);
+
extern "C" MENUWINDOW new_fl_menu_window(int x, int y, int w, int h, char* label);
extern "C" MENUWINDOW new_fl_menu_window2(int w, int h);
extern "C" void free_fl_menu_window(MENUWINDOW m);
diff --git a/src/c_fl_single_window.cpp b/src/c_fl_single_window.cpp
index ec9a315..75fbd67 100644
--- a/src/c_fl_single_window.cpp
+++ b/src/c_fl_single_window.cpp
@@ -4,29 +4,71 @@
#include "c_fl_single_window.h"
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Single_Window : public Fl_Single_Window {
+ public:
+ using Fl_Single_Window::Fl_Single_Window;
+ friend void single_window_set_draw_hook(SINGLEWINDOW n, void * d);
+ friend void fl_single_window_draw(SINGLEWINDOW n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Single_Window::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Single_Window::real_draw() {
+ Fl_Single_Window::draw();
+}
+
+
+void single_window_set_draw_hook(SINGLEWINDOW n, void * d) {
+ reinterpret_cast<My_Single_Window*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_single_window_draw(SINGLEWINDOW n) {
+ reinterpret_cast<My_Single_Window*>(n)->real_draw();
+}
+
+
+
+
SINGLEWINDOW new_fl_single_window(int x, int y, int w, int h, char* label) {
- Fl_Single_Window *sw = new Fl_Single_Window(x, y, w, h, label);
+ My_Single_Window *sw = new My_Single_Window(x, y, w, h, label);
return sw;
}
SINGLEWINDOW new_fl_single_window2(int x, int y) {
- Fl_Single_Window *sw = new Fl_Single_Window(x, y);
+ My_Single_Window *sw = new My_Single_Window(x, y);
return sw;
}
void free_fl_single_window(SINGLEWINDOW w) {
- delete reinterpret_cast<Fl_Single_Window*>(w);
+ delete reinterpret_cast<My_Single_Window*>(w);
}
+
+
void fl_single_window_show(SINGLEWINDOW w) {
- reinterpret_cast<Fl_Single_Window*>(w)->show();
+ reinterpret_cast<My_Single_Window*>(w)->show();
}
void fl_single_window_flush(SINGLEWINDOW w) {
- reinterpret_cast<Fl_Single_Window*>(w)->flush();
+ reinterpret_cast<My_Single_Window*>(w)->flush();
}
diff --git a/src/c_fl_single_window.h b/src/c_fl_single_window.h
index 96f6d5b..a0af35b 100644
--- a/src/c_fl_single_window.h
+++ b/src/c_fl_single_window.h
@@ -7,6 +7,9 @@
typedef void* SINGLEWINDOW;
+extern "C" void single_window_set_draw_hook(SINGLEWINDOW n, void * d);
+extern "C" void fl_single_window_draw(SINGLEWINDOW n);
+
extern "C" SINGLEWINDOW new_fl_single_window(int x, int y, int w, int h, char* label);
extern "C" SINGLEWINDOW new_fl_single_window2(int x, int y);
extern "C" void free_fl_single_window(SINGLEWINDOW w);
diff --git a/src/fltk-widgets-groups-windows-double.adb b/src/fltk-widgets-groups-windows-double.adb
index 407c018..3fc13a4 100644
--- a/src/fltk-widgets-groups-windows-double.adb
+++ b/src/fltk-widgets-groups-windows-double.adb
@@ -8,6 +8,14 @@ use type System.Address;
package body FLTK.Widgets.Groups.Windows.Double is
+ procedure double_window_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, double_window_set_draw_hook, "double_window_set_draw_hook");
+
+ procedure fl_double_window_draw
+ (W : in System.Address);
+ pragma Import (C, fl_double_window_draw, "fl_double_window_draw");
+
function new_fl_double_window
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
@@ -34,6 +42,30 @@ package body FLTK.Widgets.Groups.Windows.Double is
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ Ada_Window : access Double_Window'Class :=
+ Double_Window_Convert.To_Pointer (U);
+ begin
+ Ada_Window.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Double_Window) is
+ begin
+ fl_double_window_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
procedure Finalize
(This : in out Double_Window) is
begin
@@ -64,6 +96,7 @@ package body FLTK.Widgets.Groups.Windows.Double is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ double_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
@@ -82,6 +115,7 @@ package body FLTK.Widgets.Groups.Windows.Double is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ double_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
diff --git a/src/fltk-widgets-groups-windows-double.ads b/src/fltk-widgets-groups-windows-double.ads
index 214f698..802e067 100644
--- a/src/fltk-widgets-groups-windows-double.ads
+++ b/src/fltk-widgets-groups-windows-double.ads
@@ -28,6 +28,10 @@ package FLTK.Widgets.Groups.Windows.Double is
private
+ procedure Draw
+ (This : in out Double_Window);
+
+
type Double_Window is new Window with null record;
@@ -35,5 +39,9 @@ private
(This : in out Double_Window);
+ package Double_Window_Convert is new System.Address_To_Access_Conversions
+ (Double_Window'Class);
+
+
end FLTK.Widgets.Groups.Windows.Double;
diff --git a/src/fltk-widgets-groups-windows-single-menu.adb b/src/fltk-widgets-groups-windows-single-menu.adb
index 8345308..9d38a37 100644
--- a/src/fltk-widgets-groups-windows-single-menu.adb
+++ b/src/fltk-widgets-groups-windows-single-menu.adb
@@ -9,6 +9,14 @@ use type Interfaces.C.unsigned;
package body FLTK.Widgets.Groups.Windows.Single.Menu is
+ procedure menu_window_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, menu_window_set_draw_hook, "menu_window_set_draw_hook");
+
+ procedure fl_menu_window_draw
+ (W : in System.Address);
+ pragma Import (C, fl_menu_window_draw, "fl_menu_window_draw");
+
function new_fl_menu_window
(X, Y, W, H : in Interfaces.C.int;
Label : in Interfaces.C.char_array)
@@ -52,6 +60,30 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ Ada_Window : access Menu_Window'Class :=
+ Menu_Window_Convert.To_Pointer (U);
+ begin
+ Ada_Window.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Menu_Window) is
+ begin
+ fl_menu_window_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
procedure Finalize
(This : in out Menu_Window) is
begin
@@ -82,6 +114,7 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ menu_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
@@ -100,6 +133,7 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ menu_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
diff --git a/src/fltk-widgets-groups-windows-single-menu.ads b/src/fltk-widgets-groups-windows-single-menu.ads
index f5d88e7..c7fa063 100644
--- a/src/fltk-widgets-groups-windows-single-menu.ads
+++ b/src/fltk-widgets-groups-windows-single-menu.ads
@@ -42,6 +42,10 @@ package FLTK.Widgets.Groups.Windows.Single.Menu is
private
+ procedure Draw
+ (This : in out Menu_Window);
+
+
type Menu_Window is new Single_Window with null record;
@@ -49,5 +53,9 @@ private
(This : in out Menu_Window);
+ package Menu_Window_Convert is new System.Address_To_Access_Conversions
+ (Menu_Window'Class);
+
+
end FLTK.Widgets.Groups.Windows.Single.Menu;
diff --git a/src/fltk-widgets-groups-windows-single.adb b/src/fltk-widgets-groups-windows-single.adb
index 16c5f44..320ea3c 100644
--- a/src/fltk-widgets-groups-windows-single.adb
+++ b/src/fltk-widgets-groups-windows-single.adb
@@ -8,6 +8,14 @@ use type System.Address;
package body FLTK.Widgets.Groups.Windows.Single is
+ procedure single_window_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, single_window_set_draw_hook, "single_window_set_draw_hook");
+
+ procedure fl_single_window_draw
+ (W : in System.Address);
+ pragma Import (C, fl_single_window_draw, "fl_single_window_draw");
+
function new_fl_single_window
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
@@ -34,6 +42,30 @@ package body FLTK.Widgets.Groups.Windows.Single is
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ Ada_Window : access Single_Window'Class :=
+ Single_Window_Convert.To_Pointer (U);
+ begin
+ Ada_Window.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Single_Window) is
+ begin
+ fl_single_window_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
procedure Finalize
(This : in out Single_Window) is
begin
@@ -64,6 +96,7 @@ package body FLTK.Widgets.Groups.Windows.Single is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ single_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
@@ -82,6 +115,7 @@ package body FLTK.Widgets.Groups.Windows.Single is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ single_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
diff --git a/src/fltk-widgets-groups-windows-single.ads b/src/fltk-widgets-groups-windows-single.ads
index 07a2bca..32b5c65 100644
--- a/src/fltk-widgets-groups-windows-single.ads
+++ b/src/fltk-widgets-groups-windows-single.ads
@@ -28,6 +28,10 @@ package FLTK.Widgets.Groups.Windows.Single is
private
+ procedure Draw
+ (This : in out Single_Window);
+
+
type Single_Window is new Window with null record;
@@ -35,5 +39,9 @@ private
(This : in out Single_Window);
+ package Single_Window_Convert is new System.Address_To_Access_Conversions
+ (Single_Window'Class);
+
+
end FLTK.Widgets.Groups.Windows.Single;