envprint.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. Program EnvPrint;
  2. (*
  3. * OpenTriton -- A free release of the triton.library source code
  4. * Copyright (C) 1993-1998 Stefan Zeiger
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. * MA 02110-1301, USA.
  20. *
  21. * envprint.c - Envprint 2.0 GUI created with Triton
  22. *
  23. * As you can see below, it is possible to mix the tag format with
  24. * the C pre-processor macro format. (Actually I was just too lazy
  25. * to transform the whole project definition from tags to macros ;)
  26. *
  27. *)
  28. {
  29. A demo in FPC Pascal using triton.library
  30. Updated for fpc 1.0.7.
  31. Added const null and made use of the updated
  32. tritonmacros.
  33. 09 Jan 2003.
  34. [email protected]
  35. }
  36. uses triton, tritonmacros,utility;
  37. const
  38. null : longint = longint(nil);
  39. var
  40. Triton_App : pTR_App;
  41. PROCEDURE do_demo;
  42. VAR
  43. close_me : BOOLEAN;
  44. trmsg : pTR_Message;
  45. dummy : Longint;
  46. Project : pTR_Project;
  47. BEGIN
  48. ProjectStart;
  49. WindowID(1); WindowPosition(TRWP_CENTERDISPLAY);
  50. WindowTitle('EnvPrint 2.0 <THIS IS ONLY A NON-FUNCTIONAL GUI DEMO>');
  51. BeginMenu('Project');
  52. BeginSub('Load');
  53. SubItem('S_Load sender...',1);
  54. SubItem('D_Load addressee...',2);
  55. SubItem('C_Load comment...',3);
  56. BeginSub('Save');
  57. SubItem('O_Load sender',4);
  58. SubItem('E_Load addressee',5);
  59. SubItem('M_Load comment',6);
  60. BeginSub('Sace as');
  61. SubItem('U_Load sender as...',7);
  62. SubItem('T_Load addressee as...',8);
  63. SubItem('N_Load comment as...',9);
  64. MenuItem('F_Delete file...',10);
  65. ItemBarlabel;
  66. MenuItem('P_Print...',11);
  67. MenuItem('R_Preferences...',12);
  68. ItemBarlabel;
  69. MenuItem('?_About...',13);
  70. ItemBarlabel;
  71. MenuItem('Q_Quit',14);
  72. BeginMenu('Edit');
  73. MenuItem('W_Swap',15);
  74. MenuItem('X_Clear',16);
  75. HorizGroupA;
  76. Space;
  77. VertGroupA;
  78. HorizGroupEAC;
  79. VertGroupA;
  80. Space;
  81. NamedSeparatorI('Se_nder',101);
  82. SetTRTag(TROB_Space, null);
  83. HorizGroup;
  84. StringGadget(NIL,101);
  85. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  86. GetEntryButtonS('_1',1101);
  87. EndGroup;
  88. EndGroup;
  89. SpaceS;
  90. HorizGroup;
  91. StringGadget(NIL,102);
  92. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  93. GetEntryButtonS('_2',1102);
  94. EndGroup;
  95. EndGroup;
  96. SpaceS;
  97. HorizGroup;
  98. StringGadget(NIL,103);
  99. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  100. GetEntryButtonS('_3',1103);
  101. EndGroup;
  102. EndGroup;
  103. SetTRTag(TROB_Space, TRST_SMALL);
  104. HorizGroup;
  105. StringGadget(NIL,104);
  106. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  107. GetEntryButtonS('_4',1104);
  108. EndGroup;
  109. EndGroup;
  110. SetTRTag(TROB_Space, TRST_SMALL);
  111. HorizGroup;
  112. StringGadget(NIL,105);
  113. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  114. GetEntryButtonS('_5',1105);
  115. EndGroup;
  116. EndGroup;
  117. SetTRTag(TROB_Space, TRST_SMALL);
  118. HorizGroup;
  119. StringGadget(NIL,106);
  120. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  121. GetEntryButtonS('_6',1106);
  122. EndGroup;
  123. EndGroup;
  124. SetTRTag(TROB_Space, TRST_SMALL);
  125. HorizGroup;
  126. StringGadget(NIL,107);
  127. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  128. GetEntryButtonS('_7',1107);
  129. EndGroup;
  130. EndGroup;
  131. SetTRTag(TROB_Space, TRST_SMALL);
  132. HorizGroup;
  133. StringGadget(NIL,108);
  134. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  135. GetEntryButtonS('_8',1108);
  136. EndGroup;
  137. EndGroup;
  138. SetTRTag(TROB_Space, null);
  139. SetTRTag(TRGR_End, null);
  140. SetTRTag(TROB_Space, null);
  141. SetTRTag(TRGR_Vert, TRGR_PROPSHARE OR TRGR_ALIGN);
  142. SetTRTag(TROB_Space, null);
  143. NamedSeparatorI('Add_ressee',201);
  144. SetTRTag(TROB_Space, null);
  145. HorizGroup;
  146. StringGadget(NIL,201);
  147. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  148. GetEntryButtonS('_!',1201);
  149. EndGroup;
  150. EndGroup;
  151. SpaceS;
  152. HorizGroup;
  153. StringGadget(NIL,202);
  154. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  155. GetEntryButtonS('_''',1202);
  156. EndGroup;
  157. EndGroup;
  158. SpaceS;
  159. HorizGroup;
  160. StringGadget(NIL,203);
  161. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  162. GetEntryButtonS('_§',1203);
  163. EndGroup;
  164. EndGroup;
  165. SetTRTag(TROB_Space, TRST_SMALL);
  166. HorizGroup;
  167. StringGadget(NIL,204);
  168. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  169. GetEntryButtonS('_$',1204);
  170. EndGroup;
  171. EndGroup;
  172. SetTRTag(TROB_Space, TRST_SMALL);
  173. HorizGroup;
  174. StringGadget(NIL,205);
  175. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  176. GetEntryButtonS('_%%',1205);
  177. EndGroup;
  178. EndGroup;
  179. SetTRTag(TROB_Space, TRST_SMALL);
  180. HorizGroup;
  181. StringGadget(NIL,206);
  182. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  183. GetEntryButtonS('_&',1206);
  184. EndGroup;
  185. EndGroup;
  186. SetTRTag(TROB_Space, TRST_SMALL);
  187. HorizGroup;
  188. StringGadget(NIL,207);
  189. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  190. GetEntryButtonS('_/',1207);
  191. EndGroup;
  192. EndGroup;
  193. SetTRTag(TROB_Space, TRST_SMALL);
  194. HorizGroup;
  195. StringGadget(NIL,208);
  196. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  197. GetEntryButtonS('_(',1208);
  198. EndGroup;
  199. EndGroup;
  200. SetTRTag(TROB_Space, null);
  201. SetTRTag(TRGR_End, null);
  202. SetTRTag(TRGR_End, null);
  203. NamedSeparatorI('Co_mment',301);
  204. SetTRTag(TROB_Space, null);
  205. HorizGroup;
  206. StringGadget(NIL,301);
  207. SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  208. GetEntryButtonS('_0',1301);
  209. EndGroup;
  210. EndGroup;
  211. SetTRTag(TROB_Space, null);
  212. SetTRTag(TRGR_End, null);
  213. SetTRTag(TROB_Space, null);
  214. SetTRTag(TROB_Line, TROF_VERT OR TROF_RAISED);
  215. SetTRTag(TROB_Space, TRST_BIG);
  216. SetTRTag(TRGR_Vert, TRGR_PROPSHARE OR TRGR_ALIGN OR TRGR_FIXHORIZ);
  217. SetTRTag(TROB_Space, null);
  218. SetTRTag(TRGR_Horiz, TRGR_EQUALSHARE OR TRGR_CENTER);
  219. SetTRTag(TROB_Line, TROF_HORIZ);
  220. SetTRTag(TROB_Space, null);
  221. SetTRTag(TROB_Text, null); SetTRTag(TRAT_Text, 'Load'); SetTRTag(TRAT_Flags, TRTX_TITLE);
  222. SetTRTag(TROB_Space, null);
  223. SetTRTag(TROB_Line, TROF_HORIZ);
  224. SetTRTag(TRGR_End, null);
  225. SetTRTag(TROB_Space, null);
  226. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, '_Sender...'); SetTRTag(TRAT_ID, 501);
  227. SetTRTag(TROB_Space, TRST_SMALL);
  228. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, '_Addressee...'); SetTRTag(TRAT_ID, 502);
  229. SetTRTag(TROB_Space, TRST_SMALL);
  230. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, '_Comment...'); SetTRTag(TRAT_ID, 503);
  231. SetTRTag(TROB_Space, null);
  232. SetTRTag(TRGR_Horiz, TRGR_EQUALSHARE OR TRGR_CENTER);
  233. SetTRTag(TROB_Line, TROF_HORIZ);
  234. SetTRTag(TROB_Space, null);
  235. SetTRTag(TROB_Text, null); SetTRTag(TRAT_Text, 'Save'); SetTRTag(TRAT_Flags, TRTX_TITLE);
  236. SetTRTag(TROB_Space, null);
  237. SetTRTag(TROB_Line, TROF_HORIZ);
  238. SetTRTag(TRGR_End, null);
  239. SetTRTag(TROB_Space, null);
  240. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'S_ender...'); SetTRTag(TRAT_ID, 504);
  241. SetTRTag(TROB_Space, TRST_SMALL);
  242. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'A_ddressee...'); SetTRTag(TRAT_ID, 505);
  243. SetTRTag(TROB_Space, TRST_SMALL);
  244. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'C_omment...'); SetTRTag(TRAT_ID, 506);
  245. SetTRTag(TROB_Space, TRST_BIG);
  246. SetTRTag(TROB_Line, TROF_HORIZ);
  247. SetTRTag(TROB_Space, TRST_BIG);
  248. SetTRTag(TRGR_Horiz, TRGR_EQUALSHARE);
  249. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, '_Print...'); SetTRTag(TRAT_ID, 507);
  250. SetTRTag(TROB_Space, TRST_SMALL);
  251. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'S_wap'); SetTRTag(TRAT_ID, 508);
  252. SetTRTag(TRGR_End, null);
  253. SetTRTag(TROB_Space, TRST_SMALL);
  254. SetTRTag(TRGR_Horiz, TRGR_EQUALSHARE);
  255. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'Pre_fs...'); SetTRTag(TRAT_ID, 509);
  256. SetTRTag(TROB_Space, TRST_SMALL);
  257. SetTRTag(TROB_Button, null); SetTRTag(TRAT_Text, 'C_lear'); SetTRTag(TRAT_ID, 510);
  258. SetTRTag(TRGR_End, null);
  259. SetTRTag(TROB_Space, null);
  260. SetTRTag(TRGR_End, null);
  261. SetTRTag(TROB_Space, null);
  262. SetTRTag(TRGR_End, null);
  263. EndProject;
  264. Project := TR_OpenProject(Triton_App,@tritontags);
  265. IF Project <> NIL THEN BEGIN
  266. close_me := FALSE;
  267. WHILE NOT close_me DO BEGIN
  268. dummy := TR_Wait(Triton_App,0);
  269. REPEAT
  270. trmsg := TR_GetMsg(Triton_App);
  271. IF trmsg <> NIL THEN BEGIN
  272. IF (trmsg^.trm_Project = Project) THEN BEGIN
  273. CASE trmsg^.trm_Class OF
  274. TRMS_CLOSEWINDOW : close_me := True;
  275. TRMS_ERROR: WriteLN(TR_GetErrorString(trmsg^.trm_Data));
  276. END;
  277. END;
  278. TR_ReplyMsg(trmsg);
  279. END;
  280. UNTIL close_me OR (trmsg = NIL);
  281. END;
  282. TR_CloseProject(Project);
  283. END ELSE WriteLN(TR_GetErrorString(TR_GetLastError(Triton_App)));
  284. END;
  285. begin
  286. if not Assigned(TritonBase) then
  287. begin
  288. writeln('cannot open ' + TRITONNAME);
  289. Halt(5);
  290. end;
  291. Triton_App := TR_CreateAppTags([
  292. TRCA_Name, AsTag('Envprint'),
  293. TRCA_LongName, AsTag('EnvPrint GUI demo'),
  294. TRCA_Version, AsTag('2.0'),
  295. TAG_END]);
  296. if Triton_App <> nil then begin
  297. do_demo;
  298. TR_DeleteApp(Triton_App);
  299. END
  300. ELSE writeln('Can''t create application');
  301. END.