diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2024-02-06 14:53:15 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2024-02-06 14:53:15 +1300 |
commit | e924af80410c3d9fafc72a1e8217b71ce99c8830 (patch) | |
tree | 51cba786b2310b62d808f6323fbd67db9aa38286 | |
parent | 3eab055f80aeefc4db7564889a7c6fe172883422 (diff) |
Fl_Overlay_Window bound
-rw-r--r-- | doc/fl_overlay_window.html | 150 | ||||
-rw-r--r-- | doc/index.html | 3 | ||||
-rw-r--r-- | src/c_fl_overlay_window.cpp | 117 | ||||
-rw-r--r-- | src/c_fl_overlay_window.h | 42 | ||||
-rw-r--r-- | src/fltk-widgets-groups-windows-double-overlay.adb | 262 | ||||
-rw-r--r-- | src/fltk-widgets-groups-windows-double-overlay.ads | 110 |
6 files changed, 683 insertions, 1 deletions
diff --git a/doc/fl_overlay_window.html b/doc/fl_overlay_window.html new file mode 100644 index 0000000..fd0bcea --- /dev/null +++ b/doc/fl_overlay_window.html @@ -0,0 +1,150 @@ + +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Fl_Overlay_Window Binding Map</title> + <link href="map.css" rel="stylesheet"> + </head> + + <body> + + +<h2>Fl_Overlay_Window Binding Map</h2> + + +<table class="package"> + <tr><th colspan="2">Package name</th></tr> + + <tr> + <td>Fl_Overlay_Window</td> + <td>FLTK.Widgets.Groups.Windows.Double.Overlay</td> + </tr> + +</table> + + + +<table class="type"> + <tr><th colspan="2">Types</th></tr> + + <tr> + <td>Fl_Overlay_Window</td> + <td>Overlay_Window</td> + </tr> + + <tr> + <td> </td> + <td>Overlay_Window_Reference</td> + </tr> + +</table> + + + +<table class="function"> + <tr><th colspan="2">Functions and Procedures</th></tr> + + <tr> +<td><pre> +Fl_Overlay_Window(int W, int H, const char *l=0); +</pre></td> +<td><pre> +function Create + (W, H : in Integer; + Text : in String := "") + return Overlay_Window; +</pre></td> + </tr> + + <tr> +<td><pre> +Fl_Overlay_Window(int X, int Y, int W, int H, const char *l=0); +</pre></td> +<td><pre> +function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Overlay_Window; +</pre></td> + </tr> + + <tr> +<td><pre> +int can_do_overlay(); +</pre></td> +<td><pre> +function Can_Do_Overlay + (This : in Overlay_Window) + return Boolean; +</pre></td> + </tr> + + <tr> +<td><pre> +virtual void draw_overlay()=0; +</pre></td> +<td><pre> +procedure Draw_Overlay + (This : in out Overlay_Window) is null; +</pre></td> + </tr> + + <tr> +<td><pre> +void flush(); +</pre></td> +<td><pre> +procedure Flush + (This : in out Overlay_Window); +</pre></td> + </tr> + + <tr> +<td><pre> +void hide(); +</pre></td> +<td><pre> +procedure Hide + (This : in out Overlay_Window); +</pre></td> + </tr> + + <tr> +<td><pre> +void redraw_overlay(); +</pre></td> +<td><pre> +procedure Redraw_Overlay + (This : in out Overlay_Window); +</pre></td> + </tr> + + <tr> +<td><pre> +void resize(int, int, int, int); +</pre></td> +<td> +Use Resize/Reposition from FLTK.Widgets instead +</td> + </tr> + + <tr> +<td><pre> +void show(); + +void show(int a, char **b); +</pre></td> +<td><pre> +procedure Show + (This : in out Overlay_Window); +</pre></td> + </tr> + +</table> + + + </body> +</html> + diff --git a/doc/index.html b/doc/index.html index f8a52c1..75d659f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -80,7 +80,7 @@ <li><a href="fl_multiline_output.html">Fl_Multiline_Output</a></li> <li><a href="fl_nice_slider.html">Fl_Nice_Slider</a></li> <li><a href="fl_output.html">Fl_Output</a></li> - <li>Fl_Overlay_Window</li> + <li><a href="fl_overlay_window.html">Fl_Overlay_Window</a></li> <li><a href="fl_pack.html">Fl_Pack</a></li> <li><a href="fl_paged_device.html">Fl_Paged_Device</a></li> <li><a href="fl_pixmap.html">Fl_Pixmap</a></li> @@ -192,6 +192,7 @@ <li><a href="fl_tile.html">FLTK.Widgets.Groups.Tiled</a></li> <li><a href="fl_window.html">FLTK.Widgets.Groups.Windows</a></li> <li><a href="fl_double_window.html">FLTK.Widgets.Groups.Windows.Double</a></li> + <li><a href="fl_overlay_window.html">FLTK.Widgets.Groups.Windows.Double.Overlay</a></li> <li><a href="fl_gl_window.html">FLTK.Widgets.Groups.Windows.OpenGL</a></li> <li><a href="fl_single_window.html">FLTK.Widgets.Groups.Windows.Single</a></li> <li><a href="fl_menu_window.html">FLTK.Widgets.Groups.Windows.Single.Menu</a></li> diff --git a/src/c_fl_overlay_window.cpp b/src/c_fl_overlay_window.cpp new file mode 100644 index 0000000..84a65f2 --- /dev/null +++ b/src/c_fl_overlay_window.cpp @@ -0,0 +1,117 @@ + + +#include <FL/Fl_Overlay_Window.H> +#include "c_fl_overlay_window.h" +#include "c_fl_type.h" + + + + +class My_Overlay_Window : public Fl_Overlay_Window { + public: + using Fl_Overlay_Window::Fl_Overlay_Window; + friend void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d); + friend void fl_overlay_window_draw(OVERLAYWINDOW w); + friend void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d); + friend void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h); + friend int fl_overlay_window_handle(OVERLAYWINDOW w, int e); + 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); + protected: + void draw(); + void real_draw(); + void draw_overlay(); + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + d_hook_p draw_overlay_hook; + h_hook_p handle_hook; +}; + +void My_Overlay_Window::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Overlay_Window::real_draw() { + Fl_Overlay_Window::draw(); +} + +void My_Overlay_Window::draw_overlay() { + (*draw_overlay_hook)(this->user_data()); +} + +int My_Overlay_Window::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Overlay_Window::real_handle(int e) { + return Fl_Overlay_Window::handle(e); +} + +void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d) { + reinterpret_cast<My_Overlay_Window*>(w)->draw_hook = reinterpret_cast<d_hook_p>(d); +} + +void fl_overlay_window_draw(OVERLAYWINDOW w) { + reinterpret_cast<My_Overlay_Window*>(w)->real_draw(); +} + +void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d) { + reinterpret_cast<My_Overlay_Window*>(w)->draw_overlay_hook = reinterpret_cast<d_hook_p>(d); +} + +void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h) { + reinterpret_cast<My_Overlay_Window*>(w)->handle_hook = reinterpret_cast<h_hook_p>(h); +} + +int fl_overlay_window_handle(OVERLAYWINDOW w, int e) { + return reinterpret_cast<My_Overlay_Window*>(w)->real_handle(e); +} + + + + +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 reinterpret_cast<My_Overlay_Window*>(w); +} + + + + +int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w) { + return reinterpret_cast<Fl_Overlay_Window*>(w)->can_do_overlay(); +} + + + + +void fl_overlay_window_show(OVERLAYWINDOW w) { + reinterpret_cast<Fl_Overlay_Window*>(w)->show(); +} + +void fl_overlay_window_hide(OVERLAYWINDOW w) { + reinterpret_cast<Fl_Overlay_Window*>(w)->hide(); +} + +void fl_overlay_window_flush(OVERLAYWINDOW w) { + reinterpret_cast<Fl_Overlay_Window*>(w)->flush(); +} + + + + +void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w) { + reinterpret_cast<Fl_Overlay_Window*>(w)->redraw_overlay(); +} + + diff --git a/src/c_fl_overlay_window.h b/src/c_fl_overlay_window.h new file mode 100644 index 0000000..ab8cb70 --- /dev/null +++ b/src/c_fl_overlay_window.h @@ -0,0 +1,42 @@ + + +#ifndef FL_OVERLAY_WINDOW_GUARD +#define FL_OVERLAY_WINDOW_GUARD + + + + +typedef void* OVERLAYWINDOW; + + + + +extern "C" void overlay_window_set_draw_hook(OVERLAYWINDOW w, void * d); +extern "C" void fl_overlay_window_draw(OVERLAYWINDOW w); +extern "C" void overlay_window_set_draw_overlay_hook(OVERLAYWINDOW w, void * d); +extern "C" void overlay_window_set_handle_hook(OVERLAYWINDOW w, void * h); +extern "C" int fl_overlay_window_handle(OVERLAYWINDOW w, int e); + + + + +extern "C" OVERLAYWINDOW new_fl_overlay_window(int x, int y, int w, int h, char *label); +extern "C" OVERLAYWINDOW new_fl_overlay_window2(int w, int h, char *label); +extern "C" void free_fl_overlay_window(OVERLAYWINDOW w); + + + + +extern "C" int fl_overlay_window_can_do_overlay(OVERLAYWINDOW w); + + +extern "C" void fl_overlay_window_show(OVERLAYWINDOW w); +extern "C" void fl_overlay_window_hide(OVERLAYWINDOW w); +extern "C" void fl_overlay_window_flush(OVERLAYWINDOW w); + + +extern "C" void fl_overlay_window_redraw_overlay(OVERLAYWINDOW w); + + +#endif + diff --git a/src/fltk-widgets-groups-windows-double-overlay.adb b/src/fltk-widgets-groups-windows-double-overlay.adb new file mode 100644 index 0000000..e61782a --- /dev/null +++ b/src/fltk-widgets-groups-windows-double-overlay.adb @@ -0,0 +1,262 @@ + + +with + + Interfaces.C, + System.Address_To_Access_Conversions; + +use type + + Interfaces.C.int, + System.Address; + + +package body FLTK.Widgets.Groups.Windows.Double.Overlay is + + + procedure overlay_window_set_draw_hook + (W, D : in System.Address); + pragma Import (C, overlay_window_set_draw_hook, "overlay_window_set_draw_hook"); + pragma Inline (overlay_window_set_draw_hook); + + procedure overlay_window_set_draw_overlay_hook + (W, D : in System.Address); + pragma Import (C, overlay_window_set_draw_overlay_hook, + "overlay_window_set_draw_overlay_hook"); + pragma Inline (overlay_window_set_draw_overlay_hook); + + procedure overlay_window_set_handle_hook + (W, H : in System.Address); + pragma Import (C, overlay_window_set_handle_hook, "overlay_window_set_handle_hook"); + pragma Inline (overlay_window_set_handle_hook); + + + + + function new_fl_overlay_window + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_overlay_window, "new_fl_overlay_window"); + pragma Inline (new_fl_overlay_window); + + function new_fl_overlay_window2 + (W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_overlay_window2, "new_fl_overlay_window2"); + pragma Inline (new_fl_overlay_window2); + + procedure free_fl_overlay_window + (S : in System.Address); + pragma Import (C, free_fl_overlay_window, "free_fl_overlay_window"); + pragma Inline (free_fl_overlay_window); + + + + + procedure fl_overlay_window_show + (W : in System.Address); + pragma Import (C, fl_overlay_window_show, "fl_overlay_window_show"); + pragma Inline (fl_overlay_window_show); + + procedure fl_overlay_window_hide + (W : in System.Address); + pragma Import (C, fl_overlay_window_hide, "fl_overlay_window_hide"); + pragma Inline (fl_overlay_window_hide); + + procedure fl_overlay_window_flush + (W : in System.Address); + pragma Import (C, fl_overlay_window_flush, "fl_overlay_window_flush"); + pragma Inline (fl_overlay_window_flush); + + + + + function fl_overlay_window_can_do_overlay + (W : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_overlay_window_can_do_overlay, "fl_overlay_window_can_do_overlay"); + pragma Inline (fl_overlay_window_can_do_overlay); + + + + + procedure fl_overlay_window_draw + (W : in System.Address); + pragma Import (C, fl_overlay_window_draw, "fl_overlay_window_draw"); + pragma Inline (fl_overlay_window_draw); + + procedure fl_overlay_window_redraw_overlay + (W : in System.Address); + pragma Import (C, fl_overlay_window_redraw_overlay, "fl_overlay_window_redraw_overlay"); + pragma Inline (fl_overlay_window_redraw_overlay); + + function fl_overlay_window_handle + (W : in System.Address; + E : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_overlay_window_handle, "fl_overlay_window_handle"); + pragma Inline (fl_overlay_window_handle); + + + + + package Over_Convert is new System.Address_To_Access_Conversions (Overlay_Window'Class); + + + procedure Draw_Overlay_Hook + (U : in System.Address) + is + Overlay_Widget : access Overlay_Window'Class := + Over_Convert.To_Pointer (U); + begin + Overlay_Widget.Draw_Overlay; + end Draw_Overlay_Hook; + + + + + procedure Finalize + (This : in out Overlay_Window) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Overlay_Window'Class + then + This.Clear; + free_fl_overlay_window (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Double_Window (This)); + end Finalize; + + + + + -------------------- + -- Constructors -- + -------------------- + + package body Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Overlay_Window is + begin + return This : Overlay_Window do + This.Void_Ptr := new_fl_overlay_window + (Interfaces.C.int (X), + Interfaces.C.int (Y), + Interfaces.C.int (W), + Interfaces.C.int (H), + Interfaces.C.To_C (Text)); + fl_group_end (This.Void_Ptr); + fl_widget_set_user_data + (This.Void_Ptr, + Widget_Convert.To_Address (This'Unchecked_Access)); + overlay_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + overlay_window_set_draw_overlay_hook (This.Void_Ptr, Draw_Overlay_Hook'Address); + overlay_window_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + fl_widget_set_label (This.Void_Ptr, Interfaces.C.To_C (Text)); + end return; + end Create; + + + function Create + (W, H : in Integer; + Text : in String := "") + return Overlay_Window is + begin + return This : Overlay_Window do + This.Void_Ptr := new_fl_overlay_window2 + (Interfaces.C.int (W), + Interfaces.C.int (H), + Interfaces.C.To_C (Text)); + fl_group_end (This.Void_Ptr); + fl_widget_set_user_data + (This.Void_Ptr, + Widget_Convert.To_Address (This'Unchecked_Access)); + overlay_window_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + overlay_window_set_draw_overlay_hook (This.Void_Ptr, Draw_Overlay_Hook'Address); + overlay_window_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + fl_widget_set_label (This.Void_Ptr, Interfaces.C.To_C (Text)); + end return; + end Create; + + end Forge; + + + + + --------------- + -- Display -- + --------------- + + procedure Show + (This : in out Overlay_Window) is + begin + fl_overlay_window_show (This.Void_Ptr); + end Show; + + + procedure Hide + (This : in out Overlay_Window) is + begin + fl_overlay_window_hide (This.Void_Ptr); + end Hide; + + + procedure Flush + (This : in out Overlay_Window) is + begin + fl_overlay_window_flush (This.Void_Ptr); + end Flush; + + + + + ------------- + -- Other -- + ------------- + + function Can_Do_Overlay + (This : in Overlay_Window) + return Boolean is + begin + return fl_overlay_window_can_do_overlay (This.Void_Ptr) /= 0; + end Can_Do_Overlay; + + + + + ---------------------------------- + -- Drawing and Event Handling -- + ---------------------------------- + + procedure Draw + (This : in out Overlay_Window) is + begin + fl_overlay_window_draw (This.Void_Ptr); + end Draw; + + + procedure Redraw_Overlay + (This : in out Overlay_Window) is + begin + fl_overlay_window_redraw_overlay (This.Void_Ptr); + end Redraw_Overlay; + + + function Handle + (This : in out Overlay_Window; + Event : in Event_Kind) + return Event_Outcome is + begin + return Event_Outcome'Val + (fl_overlay_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + end Handle; + + +end FLTK.Widgets.Groups.Windows.Double.Overlay; + diff --git a/src/fltk-widgets-groups-windows-double-overlay.ads b/src/fltk-widgets-groups-windows-double-overlay.ads new file mode 100644 index 0000000..fa7fe1d --- /dev/null +++ b/src/fltk-widgets-groups-windows-double-overlay.ads @@ -0,0 +1,110 @@ + + +package FLTK.Widgets.Groups.Windows.Double.Overlay is + + + ------------- + -- Types -- + ------------- + + type Overlay_Window is new Double_Window with private; + + type Overlay_Window_Reference (Data : not null access Overlay_Window'Class) is + limited null record with Implicit_Dereference => Data; + + + + + -------------------- + -- Constructors -- + -------------------- + + package Forge is + + function Create + (X, Y, W, H : in Integer; + Text : in String := "") + return Overlay_Window; + + function Create + (W, H : in Integer; + Text : in String := "") + return Overlay_Window; + + end Forge; + + + + + --------------- + -- Display -- + --------------- + + procedure Show + (This : in out Overlay_Window); + + procedure Hide + (This : in out Overlay_Window); + + procedure Flush + (This : in out Overlay_Window); + + + + + ------------- + -- Other -- + ------------- + + function Can_Do_Overlay + (This : in Overlay_Window) + return Boolean; + + + + + ---------------------------------- + -- Drawing and Event Handling -- + ---------------------------------- + + procedure Draw + (This : in out Overlay_Window); + + procedure Draw_Overlay + (This : in out Overlay_Window) is null; + + procedure Redraw_Overlay + (This : in out Overlay_Window); + + function Handle + (This : in out Overlay_Window; + Event : in Event_Kind) + return Event_Outcome; + + +private + + + type Overlay_Window is new Double_Window with null record; + + overriding procedure Finalize + (This : in out Overlay_Window); + + + + + pragma Inline (Show); + pragma Inline (Hide); + pragma Inline (Flush); + + + pragma Inline (Can_Do_Overlay); + + + pragma Inline (Draw); + pragma Inline (Redraw_Overlay); + pragma Inline (Handle); + + +end FLTK.Widgets.Groups.Windows.Double.Overlay; + |