summaryrefslogtreecommitdiff
path: root/src/fltk-devices-surface-paged-postscript.ads
blob: a7ea51cdec90702c9ca91dcb3af1df16d504f9a5 (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


--  Programmed by Jedidiah Barber
--  Released into the public domain


with

    FLTK.Devices.Graphics;

private with

    Ada.Finalization,
    Interfaces.C.Strings;


package FLTK.Devices.Surface.Paged.Postscript is


    type Postscript_File_Device is new Paged_Device with private;

    type Postscript_File_Device_Reference (Data : not null access Postscript_File_Device'Class) is
        limited null record with Implicit_Dereference => Data;


    --  This will autoclose when it goes out of scope.
    type File_Type is tagged limited private;

    --  Calling this on a file already open will close it then open the new name.
    procedure Open
           (File : in out File_Type;
            Name : in     String);

    function Is_Open
           (File : in File_Type)
        return Boolean;

    --  Calling this on a file already closed will have no effect.
    procedure Close
           (File : in out File_Type);


    File_Open_Error   : exception;

    File_Close_Error  : exception;

    User_Cancel_Error : exception;




    --  The initial Graphics_Driver this is supposed to have upon construction
    --  is not currently implemented properly. Please wait warmly until the
    --  binding for the Graphics sub-hierarchy is done.




    package Forge is

        function Create
            return Postscript_File_Device;

    end Forge;




    function Get_File_Chooser_Title
        return String;

    procedure Set_File_Chooser_Title
           (Value : in String);




    --  Not currently implemented,
    --  will return a Postscript_Graphics_Driver when done.
    function Get_Postscript_Driver
           (This : in out Postscript_File_Device)
        return FLTK.Devices.Graphics.Graphics_Driver_Reference;




    --  Docs say don't use this version.
    procedure Start_Job
           (This  : in out Postscript_File_Device;
            Count : in     Natural := 0);

    --  Docs say don't use this version.
    procedure Start_Job
           (This     : in out Postscript_File_Device;
            Count    : in     Natural := 0;
            From, To :    out Positive);

    procedure Start_Job
           (This   : in out Postscript_File_Device;
            Output : in     File_Type'Class;
            Count  : in     Natural := 0;
            Format : in     Page_Format := A4;
            Layout : in     Page_Layout := Portrait)
    with Pre => Output.Is_Open;

    procedure Start_Job
           (This   : in out Postscript_File_Device;
            Count  : in     Natural := 0;
            Format : in     Page_Format := A4;
            Layout : in     Page_Layout := Portrait);

    procedure End_Job
           (This : in out Postscript_File_Device);

    procedure Start_Page
           (This : in out Postscript_File_Device);

    procedure End_Page
           (This : in out Postscript_File_Device);




    procedure Get_Margins
           (This                     : in     Postscript_File_Device;
            Left, Top, Right, Bottom :    out Integer);

    procedure Get_Printable_Rect
           (This : in     Postscript_File_Device;
            W, H :    out Integer);

    procedure Get_Origin
           (This : in     Postscript_File_Device;
            X, Y :    out Integer);

    procedure Set_Origin
           (This : in out Postscript_File_Device;
            X, Y : in     Integer);

    procedure Rotate
           (This    : in out Postscript_File_Device;
            Degrees : in     Float);

    procedure Scale
           (This   : in out Postscript_File_Device;
            Factor : in     Float);

    procedure Scale
           (This               : in out Postscript_File_Device;
            Factor_X, Factor_Y : in     Float);

    procedure Translate
           (This             : in out Postscript_File_Device;
            Delta_X, Delta_Y : in     Integer);

    procedure Untranslate
           (This : in out Postscript_File_Device);


private


    type File_Type is new Ada.Finalization.Limited_Controlled with record
        C_File     : Storage.Integer_Address;
        Open_State : Boolean := False;
    end record;

    overriding procedure Finalize
           (This : in out File_Type);


    type Postscript_File_Device is new Paged_Device with null record;

    overriding procedure Finalize
           (This : in out Postscript_File_Device);


    File_Chooser_Title : Interfaces.C.Strings.chars_ptr;


    pragma Inline (Is_Open);

    pragma Inline (Get_File_Chooser_Title);

    pragma Inline (Get_Postscript_Driver);

    pragma Inline (Start_Job);
    pragma Inline (End_Job);
    pragma Inline (Start_Page);
    pragma Inline (End_Page);

    pragma Inline (Get_Margins);
    pragma Inline (Get_Printable_Rect);
    pragma Inline (Get_Origin);
    pragma Inline (Set_Origin);
    pragma Inline (Rotate);
    pragma Inline (Scale);
    pragma Inline (Translate);
    pragma Inline (Untranslate);


    --  Needed to ensure chars_ptr storage is properly cleaned up
    type Postscript_File_Device_Final_Controller is new Ada.Finalization.Limited_Controlled
        with null record;

    overriding procedure Finalize
           (This : in out Postscript_File_Device_Final_Controller);

    Cleanup : Postscript_File_Device_Final_Controller;


end FLTK.Devices.Surface.Paged.Postscript;