summaryrefslogtreecommitdiff
path: root/src/fltk-devices-graphics.adb
blob: e267690d785298831ca666d247328cde85d0b582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168


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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    pragma Inline (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");
    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;