summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/amunits/examples/otherlibs/envprint.pas
blob: e45e4141e975ec7b17105392ddd2712c77c87a39 (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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
Program EnvPrint;

(*
 *  OpenTriton -- A free release of the triton.library source code
 *  Copyright (C) 1993-1998  Stefan Zeiger
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  envprint.c - Envprint 2.0 GUI created with Triton
 *
 *  As you can see below, it is possible to mix the tag format with
 *  the C pre-processor macro format. (Actually I was just too lazy
 *  to transform the whole project definition from tags to macros ;)
 *
 *)

{
   A demo in FPC Pascal using triton.library

   Updated for fpc 1.0.7.
   Added const null and made use of the updated
   tritonmacros.
   09 Jan 2003.

   nils.sjoholm@mailbox.swipnet.se
}


uses triton, tritonmacros,utility;

const
    null : longint = longint(nil);

var
    Triton_App : pTR_App;

PROCEDURE do_demo;
VAR
    close_me   : BOOLEAN;
    trmsg      : pTR_Message;
    dummy      : Longint;
    Project    : pTR_Project;

BEGIN
  ProjectStart;
  WindowID(1); WindowPosition(TRWP_CENTERDISPLAY);
  WindowTitle('EnvPrint 2.0 <THIS IS ONLY A NON-FUNCTIONAL GUI DEMO>');

  BeginMenu('Project');
    BeginSub('Load');
      SubItem('S_Load sender...',1);
      SubItem('D_Load addressee...',2);
      SubItem('C_Load comment...',3);
    BeginSub('Save');
      SubItem('O_Load sender',4);
      SubItem('E_Load addressee',5);
      SubItem('M_Load comment',6);
    BeginSub('Sace as');
      SubItem('U_Load sender as...',7);
      SubItem('T_Load addressee as...',8);
      SubItem('N_Load comment as...',9);
    MenuItem('F_Delete file...',10);
    ItemBarlabel;
    MenuItem('P_Print...',11);
    MenuItem('R_Preferences...',12);
    ItemBarlabel;
    MenuItem('?_About...',13);
    ItemBarlabel;
    MenuItem('Q_Quit',14);

  BeginMenu('Edit');
    MenuItem('W_Swap',15);
    MenuItem('X_Clear',16);

  HorizGroupA;
    Space;
    VertGroupA;
      HorizGroupEAC;
        VertGroupA;

          Space;

          NamedSeparatorI('Se_nder',101);

          SetTRTag(TROB_Space,          null);

          HorizGroup;
            StringGadget(NIL,101);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_1',1101);
              EndGroup;
            EndGroup;

          SpaceS;

          HorizGroup;
            StringGadget(NIL,102);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_2',1102);
              EndGroup;
            EndGroup;

          SpaceS;

          HorizGroup;
            StringGadget(NIL,103);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_3',1103);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,104);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_4',1104);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,105);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_5',1105);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,106);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_6',1106);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,107);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_7',1107);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,108);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_8',1108);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          null);

          SetTRTag(TRGR_End,            null);

        SetTRTag(TROB_Space,            null);

        SetTRTag(TRGR_Vert,             TRGR_PROPSHARE OR TRGR_ALIGN);

          SetTRTag(TROB_Space,          null);

          NamedSeparatorI('Add_ressee',201);

          SetTRTag(TROB_Space,          null);

          HorizGroup;
            StringGadget(NIL,201);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_!',1201);
              EndGroup;
            EndGroup;

          SpaceS;

          HorizGroup;
            StringGadget(NIL,202);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_''',1202);
              EndGroup;
            EndGroup;

          SpaceS;

          HorizGroup;
            StringGadget(NIL,203);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_§',1203);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,204);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_$',1204);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,205);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_%%',1205);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,206);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_&',1206);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,207);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_/',1207);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          TRST_SMALL);

          HorizGroup;
            StringGadget(NIL,208);
            SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
              GetEntryButtonS('_(',1208);
              EndGroup;
            EndGroup;

          SetTRTag(TROB_Space,          null);

          SetTRTag(TRGR_End,            null);

        SetTRTag(TRGR_End,              null);

      NamedSeparatorI('Co_mment',301);

      SetTRTag(TROB_Space,              null);

      HorizGroup;
        StringGadget(NIL,301);
        SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
          GetEntryButtonS('_0',1301);
          EndGroup;
        EndGroup;

      SetTRTag(TROB_Space,              null);

      SetTRTag(TRGR_End,                null);

    SetTRTag(TROB_Space,                null);
    SetTRTag(TROB_Line,                 TROF_VERT OR TROF_RAISED);

    SetTRTag(TROB_Space,                TRST_BIG);

    SetTRTag(TRGR_Vert,                 TRGR_PROPSHARE OR TRGR_ALIGN OR TRGR_FIXHORIZ);
      SetTRTag(TROB_Space,              null);
      SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE OR TRGR_CENTER);
        SetTRTag(TROB_Line,             TROF_HORIZ);
        SetTRTag(TROB_Space,            null);
        SetTRTag(TROB_Text,             null); SetTRTag(TRAT_Text,  'Load'); SetTRTag(TRAT_Flags, TRTX_TITLE);
        SetTRTag(TROB_Space,            null);
        SetTRTag(TROB_Line,             TROF_HORIZ);
        SetTRTag(TRGR_End,              null);
      SetTRTag(TROB_Space,              null);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  '_Sender...'); SetTRTag(TRAT_ID, 501);
      SetTRTag(TROB_Space,              TRST_SMALL);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  '_Addressee...'); SetTRTag(TRAT_ID, 502);
      SetTRTag(TROB_Space,              TRST_SMALL);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  '_Comment...'); SetTRTag(TRAT_ID, 503);
      SetTRTag(TROB_Space,              null);
      SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE OR TRGR_CENTER);
        SetTRTag(TROB_Line,             TROF_HORIZ);
        SetTRTag(TROB_Space,            null);
        SetTRTag(TROB_Text,             null); SetTRTag(TRAT_Text,  'Save'); SetTRTag(TRAT_Flags, TRTX_TITLE);
        SetTRTag(TROB_Space,            null);
        SetTRTag(TROB_Line,             TROF_HORIZ);
        SetTRTag(TRGR_End,              null);
      SetTRTag(TROB_Space,              null);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  'S_ender...'); SetTRTag(TRAT_ID, 504);
      SetTRTag(TROB_Space,              TRST_SMALL);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  'A_ddressee...'); SetTRTag(TRAT_ID, 505);
      SetTRTag(TROB_Space,              TRST_SMALL);
      SetTRTag(TROB_Button,             null); SetTRTag(TRAT_Text,  'C_omment...'); SetTRTag(TRAT_ID, 506);
      SetTRTag(TROB_Space,              TRST_BIG);
      SetTRTag(TROB_Line,               TROF_HORIZ);
      SetTRTag(TROB_Space,              TRST_BIG);
      SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE);
        SetTRTag(TROB_Button,           null); SetTRTag(TRAT_Text,  '_Print...'); SetTRTag(TRAT_ID, 507);
        SetTRTag(TROB_Space,            TRST_SMALL);
        SetTRTag(TROB_Button,           null); SetTRTag(TRAT_Text,  'S_wap'); SetTRTag(TRAT_ID, 508);
        SetTRTag(TRGR_End,              null);
      SetTRTag(TROB_Space,              TRST_SMALL);
      SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE);
        SetTRTag(TROB_Button,           null); SetTRTag(TRAT_Text,  'Pre_fs...'); SetTRTag(TRAT_ID, 509);
        SetTRTag(TROB_Space,            TRST_SMALL);
        SetTRTag(TROB_Button,           null); SetTRTag(TRAT_Text,  'C_lear'); SetTRTag(TRAT_ID, 510);
        SetTRTag(TRGR_End,              null);
      SetTRTag(TROB_Space,              null);
    SetTRTag(TRGR_End,                  null);

    SetTRTag(TROB_Space,                null);

  SetTRTag(TRGR_End,                    null);

  EndProject;

  Project := TR_OpenProject(Triton_App,@tritontags);
    IF Project <> NIL THEN BEGIN
      close_me := FALSE;
      WHILE NOT close_me DO BEGIN
        dummy := TR_Wait(Triton_App,0);
        REPEAT
          trmsg := TR_GetMsg(Triton_App);
          IF trmsg <> NIL THEN BEGIN
            IF (trmsg^.trm_Project = Project) THEN BEGIN
               CASE trmsg^.trm_Class OF
                 TRMS_CLOSEWINDOW : close_me := True;
                 TRMS_ERROR:        WriteLN(TR_GetErrorString(trmsg^.trm_Data));
               END;
            END;
            TR_ReplyMsg(trmsg);
          END;
        UNTIL close_me OR (trmsg = NIL);
      END;
      TR_CloseProject(Project);
    END ELSE WriteLN(TR_GetErrorString(TR_GetLastError(Triton_App)));
END;

begin
  Triton_App := TR_CreateAppTags([
                TRCA_Name,'Envprint',
                TRCA_LongName,'EnvPrint GUI demo',
                TRCA_Version,'2.0',
                TAG_END]);

  if Triton_App <> nil then begin
     do_demo;
     TR_DeleteApp(Triton_App);
  END
  ELSE writeln('Can''t create application');
END.