summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2018-03-24 14:36:52 +1100
committerJed Barber <jjbarber@y7mail.com>2018-03-24 14:36:52 +1100
commit5aa2cbc50e016fd833b35603c73b0a88692607f3 (patch)
treedf95b0f519d536e28ec567feb0e28b510001b725
parent7251c3cbd8587fc1aad05c0ba0ce23b68a920312 (diff)
Added FLTK.Devices.Surfaces
-rw-r--r--progress.txt2
-rw-r--r--src/c_fl_surface.cpp38
-rw-r--r--src/c_fl_surface.h25
-rw-r--r--src/fltk-devices-surfaces.adb96
-rw-r--r--src/fltk-devices-surfaces.ads48
5 files changed, 208 insertions, 1 deletions
diff --git a/progress.txt b/progress.txt
index dc46f26..69411a0 100644
--- a/progress.txt
+++ b/progress.txt
@@ -90,6 +90,7 @@ Partially Done:
FLTK
FLTK.Devices.Graphics
+FLTK.Devices.Surfaces
FLTK.Menu_Items
FLTK.Screen
FLTK.Text_Buffers
@@ -119,7 +120,6 @@ FL_Help_View (several methods have ABI_VERSION bugs)
FL_Table
FL_Table_Row
FL_Tree
-FL_Surface_Device
FL_Copy_Surface
FL_Image_Surface
FL_Paged_Device
diff --git a/src/c_fl_surface.cpp b/src/c_fl_surface.cpp
new file mode 100644
index 0000000..89d661f
--- /dev/null
+++ b/src/c_fl_surface.cpp
@@ -0,0 +1,38 @@
+
+
+#include <FL/Fl_Device.H>
+#include "c_fl_surface.h"
+
+
+
+
+class My_Surface_Device : public Fl_Surface_Device {
+ public:
+ using Fl_Surface_Device::Fl_Surface_Device;
+ friend SURFACE new_fl_surface(void * g);
+};
+
+
+
+
+SURFACE new_fl_surface(void * g) {
+ My_Surface_Device *s = new My_Surface_Device(reinterpret_cast<Fl_Graphics_Driver*>(g));
+ return s;
+}
+
+void free_fl_surface(SURFACE s) {
+ delete reinterpret_cast<My_Surface_Device*>(s);
+}
+
+
+
+
+void fl_surface_set_current(SURFACE s) {
+ reinterpret_cast<Fl_Surface_Device*>(s)->set_current();
+}
+
+SURFACE fl_surface_get_surface(void) {
+ return Fl_Surface_Device::surface();
+}
+
+
diff --git a/src/c_fl_surface.h b/src/c_fl_surface.h
new file mode 100644
index 0000000..dd8d8e9
--- /dev/null
+++ b/src/c_fl_surface.h
@@ -0,0 +1,25 @@
+
+
+#ifndef FL_SURFACE_GUARD
+#define FL_SURFACE_GUARD
+
+
+
+
+typedef void* SURFACE;
+
+
+
+
+extern "C" SURFACE new_fl_surface(void * g);
+extern "C" void free_fl_surface(SURFACE s);
+
+
+
+
+extern "C" void fl_surface_set_current(SURFACE s);
+extern "C" SURFACE fl_surface_get_surface(void);
+
+
+#endif
+
diff --git a/src/fltk-devices-surfaces.adb b/src/fltk-devices-surfaces.adb
new file mode 100644
index 0000000..a0c5042
--- /dev/null
+++ b/src/fltk-devices-surfaces.adb
@@ -0,0 +1,96 @@
+
+
+with
+
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Devices.Surfaces is
+
+
+ function new_fl_surface
+ (G : in System.Address)
+ return System.Address;
+ pragma Import (C, new_fl_surface, "new_fl_surface");
+
+ procedure free_fl_surface
+ (S : in System.Address);
+ pragma Import (C, free_fl_surface, "free_fl_surface");
+
+
+
+
+ procedure fl_surface_set_current
+ (S : in System.Address);
+ pragma Import (C, fl_surface_set_current, "fl_surface_set_current");
+
+ function fl_surface_get_surface
+ return System.Address;
+ pragma Import (C, fl_surface_get_surface, "fl_surface_get_surface");
+
+
+
+
+ procedure Finalize
+ (This : in out Surface_Device) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Surface_Device'Class
+ then
+ if This.Needs_Dealloc then
+ free_fl_surface (This.Void_Ptr);
+ end if;
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Device (This));
+ end Finalize;
+
+
+
+
+ package body Forge is
+
+ function Create
+ (Graphics : in out FLTK.Devices.Graphics.Graphics_Driver)
+ return Surface_Device is
+ begin
+ return This : Surface_Device do
+ This.Void_Ptr := new_fl_surface (Wrapper (Graphics).Void_Ptr);
+ end return;
+ end Create;
+
+ end Forge;
+
+
+
+
+ function Get_Current
+ return access Surface_Device is
+ begin
+ return Current_Ptr;
+ end Get_Current;
+
+
+ procedure Set_Current
+ (This : in out Surface_Device) is
+ begin
+ fl_surface_set_current (This.Void_Ptr);
+ Current_Ptr := This'Unchecked_Access;
+ end Set_Current;
+
+
+
+
+begin
+
+
+ Original_Surface.Void_Ptr := fl_surface_get_surface;
+ Original_Surface.Needs_Dealloc := False;
+
+
+end FLTK.Devices.Surfaces;
+
diff --git a/src/fltk-devices-surfaces.ads b/src/fltk-devices-surfaces.ads
new file mode 100644
index 0000000..da3d0a6
--- /dev/null
+++ b/src/fltk-devices-surfaces.ads
@@ -0,0 +1,48 @@
+
+
+with
+
+ FLTK.Devices.Graphics;
+
+
+package FLTK.Devices.Surfaces is
+
+
+ type Surface_Device is new Device with private;
+
+
+
+
+ package Forge is
+
+ function Create
+ (Graphics : in out FLTK.Devices.Graphics.Graphics_Driver)
+ return Surface_Device;
+
+ end Forge;
+
+
+
+
+ function Get_Current
+ return access Surface_Device;
+
+ procedure Set_Current
+ (This : in out Surface_Device);
+
+
+private
+
+
+ type Surface_Device is new Device with null record;
+
+ overriding procedure Finalize
+ (This : in out Surface_Device);
+
+
+ Original_Surface : aliased Surface_Device;
+ Current_Ptr : access Surface_Device := Original_Surface'Access;
+
+
+end FLTK.Devices.Surfaces;
+