summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_graphics_driver.cpp52
-rw-r--r--src/c_fl_graphics_driver.h30
-rw-r--r--src/fltk-devices-graphics.adb159
-rw-r--r--src/fltk-devices-graphics.ads70
-rw-r--r--src/fltk-devices.ads16
5 files changed, 327 insertions, 0 deletions
diff --git a/src/c_fl_graphics_driver.cpp b/src/c_fl_graphics_driver.cpp
new file mode 100644
index 0000000..187ece9
--- /dev/null
+++ b/src/c_fl_graphics_driver.cpp
@@ -0,0 +1,52 @@
+
+
+#include <FL/Fl_Device.H>
+#include <FL/Fl_Image.H>
+#include "c_fl_graphics_driver.h"
+
+
+
+
+unsigned int fl_graphics_driver_color(GRAPHICS_DRIVER g) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->color();
+}
+
+
+
+
+int fl_graphics_driver_descent(GRAPHICS_DRIVER g) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->descent();
+}
+
+int fl_graphics_driver_height(GRAPHICS_DRIVER g) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->height();
+}
+
+double fl_graphics_driver_width(GRAPHICS_DRIVER g, unsigned int c) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->width(c);
+}
+
+double fl_graphics_driver_width2(GRAPHICS_DRIVER g, const char * s, int l) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->width(s,l);
+}
+
+int fl_graphics_driver_get_font(GRAPHICS_DRIVER g) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->font();
+}
+
+int fl_graphics_driver_size(GRAPHICS_DRIVER g) {
+ return reinterpret_cast<Fl_Graphics_Driver*>(g)->size();
+}
+
+void fl_graphics_driver_set_font(GRAPHICS_DRIVER g, int f, int s) {
+ reinterpret_cast<Fl_Graphics_Driver*>(g)->font(f,s);
+}
+
+
+
+
+void fl_graphics_driver_draw_scaled(GRAPHICS_DRIVER g, void * i, int x, int y, int w, int h) {
+ reinterpret_cast<Fl_Graphics_Driver*>(g)->draw_scaled(reinterpret_cast<Fl_Image*>(i),x,y,w,h);
+}
+
+
diff --git a/src/c_fl_graphics_driver.h b/src/c_fl_graphics_driver.h
new file mode 100644
index 0000000..d255400
--- /dev/null
+++ b/src/c_fl_graphics_driver.h
@@ -0,0 +1,30 @@
+
+
+#ifndef FL_GRAPHICS_DRIVER_GUARD
+#define FL_GRAPHICS_DRIVER_GUARD
+
+
+
+
+typedef void* GRAPHICS_DRIVER;
+
+
+
+
+extern "C" unsigned int fl_graphics_driver_color(GRAPHICS_DRIVER g);
+
+
+extern "C" int fl_graphics_driver_descent(GRAPHICS_DRIVER g);
+extern "C" int fl_graphics_driver_height(GRAPHICS_DRIVER g);
+extern "C" double fl_graphics_driver_width(GRAPHICS_DRIVER g, unsigned int c);
+extern "C" double fl_graphics_driver_width2(GRAPHICS_DRIVER g, const char * s, int l);
+extern "C" int fl_graphics_driver_get_font(GRAPHICS_DRIVER g);
+extern "C" int fl_graphics_driver_size(GRAPHICS_DRIVER g);
+extern "C" void fl_graphics_driver_set_font(GRAPHICS_DRIVER g, int f, int s);
+
+
+extern "C" void fl_graphics_driver_draw_scaled(GRAPHICS_DRIVER g, void * i, int x, int y, int w, int h);
+
+
+#endif
+
diff --git a/src/fltk-devices-graphics.adb b/src/fltk-devices-graphics.adb
new file mode 100644
index 0000000..1341d67
--- /dev/null
+++ b/src/fltk-devices-graphics.adb
@@ -0,0 +1,159 @@
+
+
+with
+
+ Interfaces.C,
+ System;
+
+
+package body FLTK.Devices.Graphics is
+
+
+ function fl_graphics_driver_color
+ (G : in System.Address)
+ return Interfaces.C.unsigned;
+ pragma Import (C, fl_graphics_driver_color, "fl_graphics_driver_color");
+
+
+
+
+ function fl_graphics_driver_descent
+ (G : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_graphics_driver_descent, "fl_graphics_driver_descent");
+
+ function fl_graphics_driver_height
+ (G : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_graphics_driver_height, "fl_graphics_driver_height");
+
+ function fl_graphics_driver_width
+ (G : in System.Address;
+ C : in Interfaces.C.unsigned)
+ return Interfaces.C.double;
+ pragma Import (C, fl_graphics_driver_width, "fl_graphics_driver_width");
+
+ function fl_graphics_driver_width2
+ (G : in System.Address;
+ S : in Interfaces.C.char_array;
+ L : in Interfaces.C.int)
+ return Interfaces.C.double;
+ pragma Import (C, fl_graphics_driver_width2, "fl_graphics_driver_width2");
+
+ function fl_graphics_driver_get_font
+ (G : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_graphics_driver_get_font, "fl_graphics_driver_get_font");
+
+ function fl_graphics_driver_size
+ (G : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_graphics_driver_size, "fl_graphics_driver_size");
+
+ procedure fl_graphics_driver_set_font
+ (G : in System.Address;
+ K, S : in Interfaces.C.int);
+ pragma Import (C, fl_graphics_driver_set_font, "fl_graphics_driver_set_font");
+
+
+
+
+ procedure fl_graphics_driver_draw_scaled
+ (G, I : in System.Address;
+ X, Y, W, H : in Interfaces.C.int);
+ pragma Import (C, fl_graphics_driver_draw_scaled, "fl_graphics_driver_draw_scaled");
+
+
+
+
+ function Get_Color
+ (This : in Graphics_Driver)
+ return Color is
+ begin
+ return Color (fl_graphics_driver_color (This.Void_Ptr));
+ end Get_Color;
+
+
+
+
+ function Get_Text_Descent
+ (This : in Graphics_Driver)
+ return Integer is
+ begin
+ return Integer (fl_graphics_driver_descent (This.Void_Ptr));
+ end Get_Text_Descent;
+
+
+ function Get_Line_Height
+ (This : in Graphics_Driver)
+ return Integer is
+ begin
+ return Integer (fl_graphics_driver_height (This.Void_Ptr));
+ end Get_Line_Height;
+
+
+ function Get_Width
+ (This : in Graphics_Driver;
+ Char : in Character)
+ return Long_Float is
+ begin
+ return Long_Float (fl_graphics_driver_width (This.Void_Ptr, Character'Pos (Char)));
+ end Get_Width;
+
+
+ function Get_Width
+ (This : in Graphics_Driver;
+ Str : in String)
+ return Long_Float is
+ begin
+ return Long_Float (fl_graphics_driver_width2
+ (This.Void_Ptr,
+ Interfaces.C.To_C (Str),
+ Str'Length));
+ end Get_Width;
+
+
+ function Get_Font_Kind
+ (This : in Graphics_Driver)
+ return Font_Kind is
+ begin
+ return Font_Kind'Val (fl_graphics_driver_get_font (This.Void_Ptr));
+ end Get_Font_Kind;
+
+
+ function Get_Font_Size
+ (This : in Graphics_Driver)
+ return Font_Size is
+ begin
+ return Font_Size (fl_graphics_driver_size (This.Void_Ptr));
+ end Get_Font_Size;
+
+
+ procedure Set_Font
+ (This : in Graphics_Driver;
+ Face : in Font_Kind;
+ Size : in Font_Size) is
+ begin
+ fl_graphics_driver_set_font (This.Void_Ptr, Font_Kind'Pos (Face), Interfaces.C.int (Size));
+ end Set_Font;
+
+
+
+
+ procedure Draw_Scaled_Image
+ (This : in Graphics_Driver;
+ Img : in FLTK.Images.Image'Class;
+ X, Y, W, H : in Integer) is
+ begin
+ fl_graphics_driver_draw_scaled
+ (This.Void_Ptr,
+ Wrapper (Img).Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H));
+ end Draw_Scaled_Image;
+
+
+end FLTK.Devices.Graphics;
+
diff --git a/src/fltk-devices-graphics.ads b/src/fltk-devices-graphics.ads
new file mode 100644
index 0000000..b407da4
--- /dev/null
+++ b/src/fltk-devices-graphics.ads
@@ -0,0 +1,70 @@
+
+
+with
+
+ FLTK.Images;
+
+
+package FLTK.Devices.Graphics is
+
+
+ type Graphics_Driver is new Device with private;
+
+
+
+
+ function Get_Color
+ (This : in Graphics_Driver)
+ return Color;
+
+
+
+
+ function Get_Text_Descent
+ (This : in Graphics_Driver)
+ return Integer;
+
+ function Get_Line_Height
+ (This : in Graphics_Driver)
+ return Integer;
+
+ function Get_Width
+ (This : in Graphics_Driver;
+ Char : in Character)
+ return Long_Float;
+
+ function Get_Width
+ (This : in Graphics_Driver;
+ Str : in String)
+ return Long_Float;
+
+ function Get_Font_Kind
+ (This : in Graphics_Driver)
+ return Font_Kind;
+
+ function Get_Font_Size
+ (This : in Graphics_Driver)
+ return Font_Size;
+
+ procedure Set_Font
+ (This : in Graphics_Driver;
+ Face : in Font_Kind;
+ Size : in Font_Size);
+
+
+
+
+ procedure Draw_Scaled_Image
+ (This : in Graphics_Driver;
+ Img : in FLTK.Images.Image'Class;
+ X, Y, W, H : in Integer);
+
+
+private
+
+
+ type Graphics_Driver is new Device with null record;
+
+
+end FLTK.Devices.Graphics;
+
diff --git a/src/fltk-devices.ads b/src/fltk-devices.ads
new file mode 100644
index 0000000..fcf9848
--- /dev/null
+++ b/src/fltk-devices.ads
@@ -0,0 +1,16 @@
+
+
+package FLTK.Devices is
+
+
+ type Device is new Wrapper with private;
+
+
+private
+
+
+ type Device is new Wrapper with null record;
+
+
+end FLTK.Devices;
+