From b4438b2fbe895694be98e6e8426103deefc51448 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Tue, 21 Jan 2025 21:04:54 +1300 Subject: Split public API and private implementation files into different directories --- body/c_fl_overlay_window.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 body/c_fl_overlay_window.cpp (limited to 'body/c_fl_overlay_window.cpp') diff --git a/body/c_fl_overlay_window.cpp b/body/c_fl_overlay_window.cpp new file mode 100644 index 0000000..0d434c3 --- /dev/null +++ b/body/c_fl_overlay_window.cpp @@ -0,0 +1,116 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#include +#include "c_fl_overlay_window.h" + + + + +// Exports from Ada + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + +extern "C" void overlay_window_draw_overlay_hook(void * ud); + + + + +// Attaching all relevant hooks and friends + +class My_Overlay_Window : public Fl_Overlay_Window { +public: + using Fl_Overlay_Window::Fl_Overlay_Window; + + friend OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label); + friend OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label); + + friend void fl_overlay_window_draw(OVERLAYWINDOW w); + friend int fl_overlay_window_handle(OVERLAYWINDOW w, int e); + + void draw(); + void draw_overlay(); + int handle(int e); +}; + +void My_Overlay_Window::draw() { + widget_draw_hook(this->user_data()); +} + +void My_Overlay_Window::draw_overlay() { + overlay_window_draw_overlay_hook(this->user_data()); +} + +int My_Overlay_Window::handle(int e) { + return widget_handle_hook(this->user_data(), e); +} + + + + +// Flattened C API + +OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label) { + My_Overlay_Window *ow = new My_Overlay_Window(x, y, w, h, label); + return ow; +} + +OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label) { + My_Overlay_Window *ow = new My_Overlay_Window(w, h, label); + return ow; +} + +void free_fl_overlay_window(OVERLAYWINDOW w) { + delete static_cast(w); +} + + + + +int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w) { + return static_cast(w)->can_do_overlay(); +} + +void fl_overlay_window_resize(OVERLAYWINDOW ow, int x, int y, int w, int h) { + static_cast(ow)->resize(x, y, w, h); +} + + + + +void fl_overlay_window_show(OVERLAYWINDOW w) { + static_cast(w)->show(); +} + +void fl_overlay_window_show2(OVERLAYWINDOW w, int c, void * v) { + static_cast(w)->show(c, static_cast(v)); +} + +void fl_overlay_window_hide(OVERLAYWINDOW w) { + static_cast(w)->hide(); +} + +void fl_overlay_window_flush(OVERLAYWINDOW w) { + static_cast(w)->flush(); +} + + + + +void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w) { + static_cast(w)->redraw_overlay(); +} + +void fl_overlay_window_draw(OVERLAYWINDOW w) { + static_cast(w)->Fl_Overlay_Window::draw(); +} + +int fl_overlay_window_handle(OVERLAYWINDOW w, int e) { + return static_cast(w)->Fl_Overlay_Window::handle(e); +} + + -- cgit