summaryrefslogtreecommitdiff
path: root/src/fltk-devices-surfaces-paged-printers.adb
blob: 6114cae2576f6437a1d1e68214a95282c9983db9 (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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346


with

    Interfaces.C,
    System;

use type

    Interfaces.C.int,
    System.Address;


package body FLTK.Devices.Surfaces.Paged.Printers is


    function new_fl_printer
        return System.Address;
    pragma Import (C, new_fl_printer, "new_fl_printer");

    procedure free_fl_printer
           (D : in System.Address);
    pragma Import (C, free_fl_printer, "free_fl_printer");




    function fl_printer_start_job
           (D : in System.Address;
            C : in Interfaces.C.int)
        return Interfaces.C.int;
    pragma Import (C, fl_printer_start_job, "fl_printer_start_job");

    function fl_printer_start_job2
           (D       : in System.Address;
            C, F, T : in Interfaces.C.int)
        return Interfaces.C.int;
    pragma Import (C, fl_printer_start_job2, "fl_printer_start_job2");

    procedure fl_printer_end_job
           (D : in System.Address);
    pragma Import (C, fl_printer_end_job, "fl_printer_end_job");

    function fl_printer_start_page
           (D : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_printer_start_page, "fl_printer_start_page");

    function fl_printer_end_page
           (D : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_printer_end_page, "fl_printer_end_page");




    procedure fl_printer_margins
           (D          : in     System.Address;
            L, T, R, B :    out Interfaces.C.int);
    pragma Import (C, fl_printer_margins, "fl_printer_margins");

    function fl_printer_printable_rect
           (D    : in     System.Address;
            W, H :    out Interfaces.C.int)
        return Interfaces.C.int;
    pragma Import (C, fl_printer_printable_rect, "fl_printer_printable_rect");

    procedure fl_printer_get_origin
           (D    : in     System.Address;
            X, Y :    out Interfaces.C.int);
    pragma Import (C, fl_printer_get_origin, "fl_printer_get_origin");

    procedure fl_printer_set_origin
           (D    : in System.Address;
            X, Y : in Interfaces.C.int);
    pragma Import (C, fl_printer_set_origin, "fl_printer_set_origin");

    procedure fl_printer_rotate
           (D : in System.Address;
            R : in Interfaces.C.C_float);
    pragma Import (C, fl_printer_rotate, "fl_printer_rotate");

    procedure fl_printer_scale
           (D    : in System.Address;
            X, Y : in Interfaces.C.C_float);
    pragma Import (C, fl_printer_scale, "fl_printer_scale");

    procedure fl_printer_translate
           (D    : in System.Address;
            X, Y : in Interfaces.C.int);
    pragma Import (C, fl_printer_translate, "fl_printer_translate");

    procedure fl_printer_untranslate
           (D : in System.Address);
    pragma Import (C, fl_printer_untranslate, "fl_printer_untranslate");




    procedure fl_printer_print_widget
           (D, I   : in System.Address;
            DX, DY : in Interfaces.C.int);
    pragma Import (C, fl_printer_print_widget, "fl_printer_print_widget");

    procedure fl_printer_print_window_part
           (D, I               : in System.Address;
            X, Y, W, H, DX, DY : in Interfaces.C.int);
    pragma Import (C, fl_printer_print_window_part, "fl_printer_print_window_part");




    procedure fl_printer_set_current
           (D : in System.Address);
    pragma Import (C, fl_printer_set_current, "fl_printer_set_current");




    procedure Finalize
           (This : in out Printer) is
    begin
        if  This.Void_Ptr /= System.Null_Address and then
            This in Printer'Class
        then
            free_fl_printer (This.Void_Ptr);
            This.Void_Ptr := System.Null_Address;
        end if;
        Finalize (Paged_Surface (This));
    end Finalize;




    package body Forge is

        function Create
            return Printer is
        begin
            return This : Printer do
                This.Void_Ptr := new_fl_printer;
            end return;
        end Create;

    end Forge;




    procedure Start_Job
           (This  : in out Printer;
            Count : in     Natural) is
    begin
        if fl_printer_start_job
            (This.Void_Ptr, Interfaces.C.int (Count)) /= 0
        then
            raise Page_Error;
        end if;
    end Start_Job;


    procedure Start_Job
           (This     : in out Printer;
            Count    : in     Natural;
            From, To : in     Positive) is
    begin
        if fl_printer_start_job2
           (This.Void_Ptr,
            Interfaces.C.int (Count),
            Interfaces.C.int (From),
            Interfaces.C.int (To)) /= 0
        then
            raise Page_Error;
        end if;
    end Start_Job;


    procedure End_Job
           (This : in out Printer) is
    begin
        fl_printer_end_job (This.Void_Ptr);
    end End_Job;


    procedure Start_Page
           (This : in out Printer) is
    begin
        if fl_printer_start_page (This.Void_Ptr) /= 0 then
            raise Page_Error;
        end if;
    end Start_Page;


    procedure End_Page
           (This : in out Printer) is
    begin
        if fl_printer_end_page (This.Void_Ptr) /= 0 then
            raise Page_Error;
        end if;
    end End_Page;




    procedure Get_Margins
           (This                     : in     Printer;
            Left, Top, Right, Bottom :    out Integer)
    is
        L, T, R, B : Interfaces.C.int;
    begin
        fl_printer_margins (This.Void_Ptr, L, T, R, B);
        Left := Integer (L);
        Top := Integer (T);
        Right := Integer (R);
        Bottom := Integer (B);
    end Get_Margins;


    procedure Get_Printable_Rect
           (This : in     Printer;
            W, H :    out Integer)
    is
        Wid, Hei : Interfaces.C.int;
    begin
        if fl_printer_printable_rect (This.Void_Ptr, Wid, Hei) /= 0 then
            raise Page_Error;
        else
            W := Integer (Wid);
            H := Integer (Hei);
        end if;
    end Get_Printable_Rect;


    procedure Get_Origin
           (This : in     Printer;
            X, Y :    out Integer)
    is
        Eks, Why : Interfaces.C.int;
    begin
        fl_printer_get_origin (This.Void_Ptr, Eks, Why);
        X := Integer (Eks);
        Y := Integer (Why);
    end Get_Origin;


    procedure Set_Origin
           (This : in out Printer;
            X, Y : in     Integer) is
    begin
        fl_printer_set_origin
           (This.Void_Ptr,
            Interfaces.C.int (X),
            Interfaces.C.int (Y));
    end Set_Origin;


    procedure Rotate
           (This    : in out Printer;
            Degrees : in     Float) is
    begin
        fl_printer_rotate (This.Void_Ptr, Interfaces.C.C_float (Degrees));
    end Rotate;


    procedure Scale
           (This   : in out Printer;
            Factor : in     Float) is
    begin
        fl_printer_scale (This.Void_Ptr, Interfaces.C.C_float (Factor), 0.0);
    end Scale;


    procedure Scale
           (This               : in out Printer;
            Factor_X, Factor_Y : in     Float) is
    begin
        fl_printer_scale
           (This.Void_Ptr,
            Interfaces.C.C_float (Factor_X),
            Interfaces.C.C_float (Factor_Y));
    end Scale;


    procedure Translate
           (This             : in out Printer;
            Delta_X, Delta_Y : in     Integer) is
    begin
        fl_printer_translate
           (This.Void_Ptr,
            Interfaces.C.int (Delta_X),
            Interfaces.C.int (Delta_Y));
    end Translate;


    procedure Untranslate
           (This : in out Printer) is
    begin
        fl_printer_untranslate (This.Void_Ptr);
    end Untranslate;




    procedure Print_Widget
           (This               : in out Printer;
            Item               : in     FLTK.Widgets.Widget'Class;
            Offset_X, Offset_Y : in     Integer := 0) is
    begin
        fl_printer_print_widget
           (This.Void_Ptr,
            Wrapper (Item).Void_Ptr,
            Interfaces.C.int (Offset_X),
            Interfaces.C.int (Offset_Y));
    end Print_Widget;


    procedure Print_Window_Part
           (This               : in out Printer;
            Item               : in     FLTK.Widgets.Groups.Windows.Window'Class;
            X, Y, W, H         : in     Integer;
            Offset_X, Offset_Y : in     Integer := 0) is
    begin
        fl_printer_print_window_part
           (This.Void_Ptr,
            Wrapper (Item).Void_Ptr,
            Interfaces.C.int (X),
            Interfaces.C.int (Y),
            Interfaces.C.int (W),
            Interfaces.C.int (H),
            Interfaces.C.int (Offset_X),
            Interfaces.C.int (Offset_Y));
    end Print_Window_Part;




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


end FLTK.Devices.Surfaces.Paged.Printers;