summaryrefslogtreecommitdiff
path: root/src/c_fl_single_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_fl_single_window.cpp')
-rw-r--r--src/c_fl_single_window.cpp77
1 files changed, 39 insertions, 38 deletions
diff --git a/src/c_fl_single_window.cpp b/src/c_fl_single_window.cpp
index 0eb6d1c..4968e46 100644
--- a/src/c_fl_single_window.cpp
+++ b/src/c_fl_single_window.cpp
@@ -6,62 +6,44 @@
#include <FL/Fl_Single_Window.H>
#include "c_fl_single_window.h"
-#include "c_fl_type.h"
-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);
- friend void single_window_set_handle_hook(SINGLEWINDOW n, void * h);
- friend int fl_single_window_handle(SINGLEWINDOW n, int e);
- protected:
- void draw();
- void real_draw();
- int handle(int e);
- int real_handle(int e);
- d_hook_p draw_hook;
- h_hook_p handle_hook;
-};
+// Exports from Ada
-void My_Single_Window::draw() {
- (*draw_hook)(this->user_data());
-}
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
-void My_Single_Window::real_draw() {
- Fl_Single_Window::draw();
-}
-int My_Single_Window::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Single_Window::real_handle(int e) {
- return Fl_Single_Window::handle(e);
-}
-void single_window_set_draw_hook(SINGLEWINDOW n, void * d) {
- reinterpret_cast<My_Single_Window*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_single_window_draw(SINGLEWINDOW n) {
- reinterpret_cast<My_Single_Window*>(n)->real_draw();
-}
+class My_Single_Window : public Fl_Single_Window {
+public:
+ using Fl_Single_Window::Fl_Single_Window;
+
+ friend void fl_single_window_draw(SINGLEWINDOW n);
+ friend int fl_single_window_handle(SINGLEWINDOW n, int e);
-void single_window_set_handle_hook(SINGLEWINDOW n, void * h) {
- reinterpret_cast<My_Single_Window*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ void draw();
+ int handle(int e);
+};
+
+void My_Single_Window::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_single_window_handle(SINGLEWINDOW n, int e) {
- return reinterpret_cast<My_Single_Window*>(n)->real_handle(e);
+int My_Single_Window::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
+// Flattened C API
+
SINGLEWINDOW new_fl_single_window(int x, int y, int w, int h, char* label) {
My_Single_Window *sw = new My_Single_Window(x, y, w, h, label);
return sw;
@@ -87,3 +69,22 @@ void fl_single_window_flush(SINGLEWINDOW w) {
reinterpret_cast<Fl_Single_Window*>(w)->flush();
}
+
+
+
+void fl_single_window_make_current(SINGLEWINDOW w) {
+ reinterpret_cast<Fl_Single_Window*>(w)->Fl_Window::make_current();
+}
+
+
+
+
+void fl_single_window_draw(SINGLEWINDOW n) {
+ reinterpret_cast<My_Single_Window*>(n)->Fl_Single_Window::draw();
+}
+
+int fl_single_window_handle(SINGLEWINDOW n, int e) {
+ return reinterpret_cast<My_Single_Window*>(n)->Fl_Single_Window::handle(e);
+}
+
+