diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_fl_copy_surface.cpp | 49 | ||||
-rw-r--r-- | src/c_fl_copy_surface.h | 32 | ||||
-rw-r--r-- | src/fltk-devices-surfaces-copy.adb | 150 | ||||
-rw-r--r-- | src/fltk-devices-surfaces-copy.ads | 65 |
4 files changed, 296 insertions, 0 deletions
diff --git a/src/c_fl_copy_surface.cpp b/src/c_fl_copy_surface.cpp new file mode 100644 index 0000000..c3be255 --- /dev/null +++ b/src/c_fl_copy_surface.cpp @@ -0,0 +1,49 @@ + + +#include <FL/Fl_Copy_Surface.H> +#include <FL/Fl_Widget.H> +#include <FL/Fl_Window.H> +#include "c_fl_copy_surface.h" + + + + +COPY_SURFACE new_fl_copy_surface(int w, int h) { + Fl_Copy_Surface *c = new Fl_Copy_Surface(w,h); + return c; +} + +void free_fl_copy_surface(COPY_SURFACE c) { + delete reinterpret_cast<Fl_Copy_Surface*>(c); +} + + + + +int fl_copy_surface_get_w(COPY_SURFACE c) { + return reinterpret_cast<Fl_Copy_Surface*>(c)->w(); +} + +int fl_copy_surface_get_h(COPY_SURFACE c) { + return reinterpret_cast<Fl_Copy_Surface*>(c)->h(); +} + + + + +void fl_copy_surface_draw(COPY_SURFACE c, void * w, int dx, int dy) { + reinterpret_cast<Fl_Copy_Surface*>(c)->draw(reinterpret_cast<Fl_Widget*>(w),dx,dy); +} + +void fl_copy_surface_draw_decorated_window(COPY_SURFACE c, void * w, int dx, int dy) { + reinterpret_cast<Fl_Copy_Surface*>(c)->draw_decorated_window(reinterpret_cast<Fl_Window*>(w),dx,dy); +} + + + + +void fl_copy_surface_set_current(COPY_SURFACE c) { + reinterpret_cast<Fl_Copy_Surface*>(c)->set_current(); +} + + diff --git a/src/c_fl_copy_surface.h b/src/c_fl_copy_surface.h new file mode 100644 index 0000000..c323533 --- /dev/null +++ b/src/c_fl_copy_surface.h @@ -0,0 +1,32 @@ + + +#ifndef FL_COPY_SURFACE_GUARD +#define CL_COPY_SURFACE_GUARD + + + + +typedef void* COPY_SURFACE; + + + + +extern "C" COPY_SURFACE new_fl_copy_surface(int w, int h); +extern "C" void free_fl_copy_surface(COPY_SURFACE c); + + + + +extern "C" int fl_copy_surface_get_w(COPY_SURFACE c); +extern "C" int fl_copy_surface_get_h(COPY_SURFACE c); + + +extern "C" void fl_copy_surface_draw(COPY_SURFACE c, void * w, int dx, int dy); +extern "C" void fl_copy_surface_draw_decorated_window(COPY_SURFACE c, void * w, int dx, int dy); + + +extern "C" void fl_copy_surface_set_current(COPY_SURFACE c); + + +#endif + diff --git a/src/fltk-devices-surfaces-copy.adb b/src/fltk-devices-surfaces-copy.adb new file mode 100644 index 0000000..d5a31f1 --- /dev/null +++ b/src/fltk-devices-surfaces-copy.adb @@ -0,0 +1,150 @@ + + +with + + Interfaces.C, + System; + +use type + + System.Address; + + +package body FLTK.Devices.Surfaces.Copy is + + + function new_fl_copy_surface + (W, H : in Interfaces.C.int) + return System.Address; + pragma Import (C, new_fl_copy_surface, "new_fl_copy_surface"); + + procedure free_fl_copy_surface + (S : in System.Address); + pragma Import (C, free_fl_copy_surface, "free_fl_copy_surface"); + + + + + function fl_copy_surface_get_w + (S : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_copy_surface_get_w, "fl_copy_surface_get_w"); + + function fl_copy_surface_get_h + (S : in System.Address) + return Interfaces.C.int; + pragma Import (C, fl_copy_surface_get_h, "fl_copy_surface_get_h"); + + + + + procedure fl_copy_surface_draw + (S, W : in System.Address; + OX, OY : in Interfaces.C.int); + pragma Import (C, fl_copy_surface_draw, "fl_copy_surface_draw"); + + procedure fl_copy_surface_draw_decorated_window + (S, W : in System.Address; + OX, OY : in Interfaces.C.int); + pragma Import (C, fl_copy_surface_draw_decorated_window, + "fl_copy_surface_draw_decorated_window"); + + + + + procedure fl_copy_surface_set_current + (S : in System.Address); + pragma Import (C, fl_copy_surface_set_current, "fl_copy_surface_set_current"); + + + + + procedure Finalize + (This : in out Copy_Surface) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Copy_Surface'Class + then + free_fl_copy_surface (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Surface_Device (This)); + end Finalize; + + + + + package body Forge is + + function Create + (W, H : in Natural) + return Copy_Surface is + begin + return This : Copy_Surface do + This.Void_Ptr := new_fl_copy_surface + (Interfaces.C.int (W), + Interfaces.C.int (H)); + end return; + end Create; + + end Forge; + + + + + function Get_W + (This : in Copy_Surface) + return Integer is + begin + return Integer (fl_copy_surface_get_w (This.Void_Ptr)); + end Get_W; + + + function Get_H + (This : in Copy_Surface) + return Integer is + begin + return Integer (fl_copy_surface_get_h (This.Void_Ptr)); + end Get_H; + + + + + procedure Draw_Widget + (This : in out Copy_Surface; + Item : in FLTK.Widgets.Widget'Class; + Offset_X, Offset_Y : in Integer := 0) is + begin + fl_copy_surface_draw + (This.Void_Ptr, + Wrapper (Item).Void_Ptr, + Interfaces.C.int (Offset_X), + Interfaces.C.int (Offset_Y)); + end Draw_Widget; + + + procedure Draw_Decorated_Window + (This : in out Copy_Surface; + Item : in FLTK.Widgets.Groups.Windows.Window'Class; + Offset_X, Offset_Y : in Integer := 0) is + begin + fl_copy_surface_draw_decorated_window + (This.Void_Ptr, + Wrapper (Item).Void_Ptr, + Interfaces.C.int (Offset_X), + Interfaces.C.int (Offset_Y)); + end Draw_Decorated_Window; + + + + + procedure Set_Current + (This : in out Copy_Surface) is + begin + fl_copy_surface_set_current (This.Void_Ptr); + Current_Ptr := This'Unchecked_Access; + end Set_Current; + + +end FLTK.Devices.Surfaces.Copy; + diff --git a/src/fltk-devices-surfaces-copy.ads b/src/fltk-devices-surfaces-copy.ads new file mode 100644 index 0000000..deafe8d --- /dev/null +++ b/src/fltk-devices-surfaces-copy.ads @@ -0,0 +1,65 @@ + + +with + + FLTK.Widgets.Groups.Windows; + + +package FLTK.Devices.Surfaces.Copy is + + + type Copy_Surface is new Surface_Device with private; + + + + + package Forge is + + function Create + (W, H : in Natural) + return Copy_Surface; + + end Forge; + + + + + function Get_W + (This : in Copy_Surface) + return Integer; + + function Get_H + (This : in Copy_Surface) + return Integer; + + + + + procedure Draw_Widget + (This : in out Copy_Surface; + Item : in FLTK.Widgets.Widget'Class; + Offset_X, Offset_Y : in Integer := 0); + + procedure Draw_Decorated_Window + (This : in out Copy_Surface; + Item : in FLTK.Widgets.Groups.Windows.Window'Class; + Offset_X, Offset_Y : in Integer := 0); + + + + + procedure Set_Current + (This : in out Copy_Surface); + + +private + + + type Copy_Surface is new Surface_Device with null record; + + overriding procedure Finalize + (This : in out Copy_Surface); + + +end FLTK.Devices.Surfaces.Copy; + |