summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fltkada.gpr2
-rw-r--r--src/c_fl_window.cpp64
-rw-r--r--src/c_fl_window.h3
-rw-r--r--src/fltk-widgets-groups-windows.adb34
-rw-r--r--src/fltk-widgets-groups-windows.ads7
5 files changed, 99 insertions, 11 deletions
diff --git a/fltkada.gpr b/fltkada.gpr
index 0b3a80a..ad9b81d 100644
--- a/fltkada.gpr
+++ b/fltkada.gpr
@@ -15,7 +15,7 @@ library project FLTKAda is
package Compiler is
for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM99nprt");
- for Default_Switches("C++") use ("-Wall","-Wextra");
+ for Default_Switches("C++") use ("-Wall","-Wextra","-std=c++11");
end Compiler;
diff --git a/src/c_fl_window.cpp b/src/c_fl_window.cpp
index fbce39b..eda235a 100644
--- a/src/c_fl_window.cpp
+++ b/src/c_fl_window.cpp
@@ -5,54 +5,98 @@
#include "c_fl_window.h"
+
+
+typedef void (hook)(void*);
+typedef hook* hook_p;
+
+
+
+
+class My_Window : public Fl_Window {
+ public:
+ using Fl_Window::Fl_Window;
+ friend void window_set_draw_hook(WINDOW n, void * d);
+ friend void fl_window_draw(WINDOW n);
+ protected:
+ void draw();
+ void real_draw();
+ hook_p draw_hook;
+};
+
+
+void My_Window::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+
+void My_Window::real_draw() {
+ Fl_Window::draw();
+}
+
+
+void window_set_draw_hook(WINDOW n, void * d) {
+ reinterpret_cast<My_Window*>(n)->draw_hook = reinterpret_cast<hook_p>(d);
+}
+
+
+void fl_window_draw(WINDOW n) {
+ reinterpret_cast<My_Window*>(n)->real_draw();
+}
+
+
+
+
WINDOW new_fl_window(int x, int y, int w, int h, char* label) {
- Fl_Window *n = new Fl_Window(x, y, w, h, label);
+ My_Window *n = new My_Window(x, y, w, h, label);
return n;
}
WINDOW new_fl_window2(int w, int h) {
- Fl_Window *n = new Fl_Window(w, h);
+ My_Window *n = new My_Window(w, h);
return n;
}
void free_fl_window(WINDOW n) {
- delete reinterpret_cast<Fl_Window*>(n);
+ delete reinterpret_cast<My_Window*>(n);
}
+
+
void fl_window_show(WINDOW n) {
- reinterpret_cast<Fl_Window*>(n)->show();
+ reinterpret_cast<My_Window*>(n)->show();
}
void fl_window_hide(WINDOW n) {
- reinterpret_cast<Fl_Window*>(n)->hide();
+ reinterpret_cast<My_Window*>(n)->hide();
}
void fl_window_set_label(WINDOW n, char* text) {
- reinterpret_cast<Fl_Window*>(n)->copy_label(text);
+ reinterpret_cast<My_Window*>(n)->copy_label(text);
}
void fl_window_size_range(WINDOW n, int lw, int lh, int hw, int hh, int dw, int dh, int a) {
- reinterpret_cast<Fl_Window*>(n)->size_range(lw, lh, hw, hh, dw, dh, a);
+ reinterpret_cast<My_Window*>(n)->size_range(lw, lh, hw, hh, dw, dh, a);
}
void fl_window_set_icon(WINDOW n, void * img) {
- reinterpret_cast<Fl_Window*>(n)->icon(reinterpret_cast<Fl_RGB_Image*>(img));
+ reinterpret_cast<My_Window*>(n)->icon(reinterpret_cast<Fl_RGB_Image*>(img));
}
void fl_window_set_modal(WINDOW n) {
- reinterpret_cast<Fl_Window*>(n)->set_modal();
+ reinterpret_cast<My_Window*>(n)->set_modal();
}
void fl_window_set_non_modal(WINDOW n) {
- reinterpret_cast<Fl_Window*>(n)->set_non_modal();
+ reinterpret_cast<My_Window*>(n)->set_non_modal();
}
diff --git a/src/c_fl_window.h b/src/c_fl_window.h
index c382919..39bd0ac 100644
--- a/src/c_fl_window.h
+++ b/src/c_fl_window.h
@@ -7,6 +7,9 @@
typedef void* WINDOW;
+extern "C" void window_set_draw_hook(WINDOW n, void * d);
+extern "C" void fl_window_draw(WINDOW n);
+
extern "C" WINDOW new_fl_window(int x, int y, int w, int h, char* label);
extern "C" WINDOW new_fl_window2(int w, int h);
extern "C" void free_fl_window(WINDOW n);
diff --git a/src/fltk-widgets-groups-windows.adb b/src/fltk-widgets-groups-windows.adb
index 2d93bdd..f217403 100644
--- a/src/fltk-widgets-groups-windows.adb
+++ b/src/fltk-widgets-groups-windows.adb
@@ -9,6 +9,14 @@ use type System.Address;
package body FLTK.Widgets.Groups.Windows is
+ procedure window_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, window_set_draw_hook, "window_set_draw_hook");
+
+ procedure fl_window_draw
+ (W : in System.Address);
+ pragma Import (C, fl_window_draw, "fl_window_draw");
+
function new_fl_window
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
@@ -57,6 +65,30 @@ package body FLTK.Widgets.Groups.Windows is
+ procedure Draw_Hook (U : in System.Address);
+ pragma Convention (C, Draw_Hook);
+
+ procedure Draw_Hook
+ (U : in System.Address)
+ is
+ Ada_Window : access Window'Class :=
+ Window_Convert.To_Pointer (U);
+ begin
+ Ada_Window.Draw;
+ end Draw_Hook;
+
+
+
+
+ procedure Draw
+ (This : in out Window) is
+ begin
+ fl_window_draw (This.Void_Ptr);
+ end Draw;
+
+
+
+
procedure Finalize
(This : in out Window) is
begin
@@ -87,6 +119,7 @@ package body FLTK.Widgets.Groups.Windows is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
@@ -105,6 +138,7 @@ package body FLTK.Widgets.Groups.Windows is
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
+ window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
end return;
end Create;
diff --git a/src/fltk-widgets-groups-windows.ads b/src/fltk-widgets-groups-windows.ads
index 96047ee..294450a 100644
--- a/src/fltk-widgets-groups-windows.ads
+++ b/src/fltk-widgets-groups-windows.ads
@@ -56,6 +56,10 @@ package FLTK.Widgets.Groups.Windows is
private
+ procedure Draw
+ (This : in out Window);
+
+
type Window is new Group with null record;
@@ -63,5 +67,8 @@ private
(This : in out Window);
+ package Window_Convert is new System.Address_To_Access_Conversions (Window'Class);
+
+
end FLTK.Widgets.Groups.Windows;