summaryrefslogtreecommitdiff
path: root/src/fltk-devices-surfaces-image.adb
blob: 1955bf3f9c5f93e11f0ac83cbf96857105c3222b (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


with

    Interfaces.C,
    System;

use type

    System.Address;


package body FLTK.Devices.Surfaces.Image is


    function new_fl_image_surface
           (W, H, R : in Interfaces.C.int)
        return System.Address;
    pragma Import (C, new_fl_image_surface, "new_fl_image_surface");

    procedure free_fl_image_surface
           (S : in System.Address);
    pragma Import (C, free_fl_image_surface, "free_fl_image_surface");




    procedure fl_image_surface_draw
           (S, I   : in System.Address;
            OX, OY : in Interfaces.C.int);
    pragma Import (C, fl_image_surface_draw, "fl_image_surface_draw");

    procedure fl_image_surface_draw_decorated_window
           (S, I   : in System.Address;
            OX, OY : in Interfaces.C.int);
    pragma Import (C, fl_image_surface_draw_decorated_window,
        "fl_image_surface_draw_decorated_window");




    function fl_image_surface_image
           (S : in System.Address)
        return System.Address;
    pragma Import (C, fl_image_surface_image, "fl_image_surface_image");

    function fl_image_surface_highres_image
           (S : in System.Address)
        return System.Address;
    pragma Import (C, fl_image_surface_highres_image, "fl_image_surface_highres_image");




    procedure fl_image_surface_set_current
           (S : in System.Address);
    pragma Import (C, fl_image_surface_set_current, "fl_image_surface_set_current");




    procedure Finalize
           (This : in out Image_Surface) is
    begin
        if  This.Void_Ptr /= System.Null_Address and then
            This in Image_Surface'Class
        then
            free_fl_image_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 Integer;
                Highres : in Boolean := False)
            return Image_Surface is
        begin
            return This : Image_Surface do
                This.Void_Ptr := new_fl_image_surface
                   (Interfaces.C.int (W),
                    Interfaces.C.int (H),
                    Boolean'Pos (Highres));
                This.High := Highres;
            end return;
        end Create;

    end Forge;




    function Is_Highres
           (This : in Image_Surface)
        return Boolean is
    begin
        return This.High;
    end Is_Highres;




    procedure Draw_Widget
           (This               : in out Image_Surface;
            Item               : in     FLTK.Widgets.Widget'Class;
            Offset_X, Offset_Y : in     Integer := 0) is
    begin
        fl_image_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 Image_Surface;
            Item               : in     FLTK.Widgets.Groups.Windows.Window'Class;
            Offset_X, Offset_Y : in     Integer := 0) is
    begin
        fl_image_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;




    function Get_Image
           (This : in Image_Surface)
        return FLTK.Images.RGB.RGB_Image is
    begin
        return Img : FLTK.Images.RGB.RGB_Image do
            Wrapper (Img).Void_Ptr := fl_image_surface_image (This.Void_Ptr);
        end return;
    end Get_Image;


    function Get_Highres_Image
           (This : in Image_Surface)
        return FLTK.Images.Shared.Shared_Image is
    begin
        return Img : FLTK.Images.Shared.Shared_Image do
            Wrapper (Img).Void_Ptr := fl_image_surface_highres_image (This.Void_Ptr);
        end return;
    end Get_Highres_Image;




    procedure Set_Current
           (This : in out Image_Surface) is
    begin
        fl_image_surface_set_current (This.Void_Ptr);
        Current_Ptr := This'Unchecked_Access;
    end Set_Current;


end FLTK.Devices.Surfaces.Image;