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/fltk-devices-graphics.adb | 171 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 body/fltk-devices-graphics.adb (limited to 'body/fltk-devices-graphics.adb') diff --git a/body/fltk-devices-graphics.adb b/body/fltk-devices-graphics.adb new file mode 100644 index 0000000..f97cebe --- /dev/null +++ b/body/fltk-devices-graphics.adb @@ -0,0 +1,171 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Interfaces.C; + + +package body FLTK.Devices.Graphics is + + + function fl_graphics_driver_color + (G : in Storage.Integer_Address) + return Interfaces.C.unsigned; + pragma Import (C, fl_graphics_driver_color, "fl_graphics_driver_color"); + pragma Inline (fl_graphics_driver_color); + + + + + function fl_graphics_driver_descent + (G : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_graphics_driver_descent, "fl_graphics_driver_descent"); + pragma Inline (fl_graphics_driver_descent); + + function fl_graphics_driver_height + (G : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_graphics_driver_height, "fl_graphics_driver_height"); + pragma Inline (fl_graphics_driver_height); + + function fl_graphics_driver_width + (G : in Storage.Integer_Address; + C : in Interfaces.C.unsigned) + return Interfaces.C.double; + pragma Import (C, fl_graphics_driver_width, "fl_graphics_driver_width"); + pragma Inline (fl_graphics_driver_width); + + function fl_graphics_driver_width2 + (G : in Storage.Integer_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"); + pragma Inline (fl_graphics_driver_width2); + + function fl_graphics_driver_get_font + (G : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_graphics_driver_get_font, "fl_graphics_driver_get_font"); + pragma Inline (fl_graphics_driver_get_font); + + function fl_graphics_driver_size + (G : in Storage.Integer_Address) + return Interfaces.C.int; + pragma Import (C, fl_graphics_driver_size, "fl_graphics_driver_size"); + pragma Inline (fl_graphics_driver_size); + + procedure fl_graphics_driver_set_font + (G : in Storage.Integer_Address; + K, S : in Interfaces.C.int); + pragma Import (C, fl_graphics_driver_set_font, "fl_graphics_driver_set_font"); + pragma Inline (fl_graphics_driver_set_font); + + + + + procedure fl_graphics_driver_draw_scaled + (G, I : in Storage.Integer_Address; + X, Y, W, H : in Interfaces.C.int); + pragma Import (C, fl_graphics_driver_draw_scaled, "fl_graphics_driver_draw_scaled"); + pragma Inline (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; + -- cgit