progindex.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. program ProgIndex;
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * progind.c - Progress indicator demo
  21. *
  22. *)
  23. {
  24. A demo in FPC Pascal using triton.library
  25. Updated for fpc 1.0.7
  26. 11 Jan 2003.
  27. [email protected]
  28. }
  29. uses triton, tritonmacros, amigados, utility;
  30. const
  31. ID_MAIN_GADGET_STOP = 1;
  32. ID_MAIN_PROGIND = 2;
  33. var
  34. Triton_App : pTR_App;
  35. procedure do_main;
  36. var
  37. close_me : boolean;
  38. trmsg : pTR_Message;
  39. project : pTR_Project;
  40. i : Longint;
  41. begin
  42. close_me := false;
  43. i := 0;
  44. ProjectStart;
  45. WindowID(1);
  46. WindowTitle('Progress Indicator Demo');
  47. WindowPosition(TRWP_CENTERDISPLAY);
  48. WindowFlags(TRWF_NOCLOSEGADGET OR TRWF_NOESCCLOSE);
  49. VertGroupA;
  50. Space; CenteredText('Working...');
  51. Space; HorizGroupA;
  52. Space; Progress(100,0,ID_MAIN_PROGIND); (* A per cent progress indicator *)
  53. Space; EndGroup;
  54. SpaceS;HorizGroupA;
  55. Space; HorizGroupSA; TextN('000%'); Space; TextN('050%'); Space; TextN('100%'); EndGroup;
  56. Space; EndGroup;
  57. Space; HorizGroupSA;
  58. Space; ButtonE('_Stop',ID_MAIN_GADGET_STOP);
  59. Space; EndGroup;
  60. Space; EndGroup;
  61. EndProject;
  62. project := TR_OpenProject(Triton_App,@tritontags);
  63. IF Project <> NIL THEN BEGIN
  64. WHILE NOT close_me DO BEGIN
  65. TR_SetAttribute(project,ID_MAIN_PROGIND,TRAT_Value,i);
  66. DOSDelay(10);
  67. REPEAT
  68. trmsg := TR_GetMsg(Triton_App);
  69. IF trmsg <> NIL THEN BEGIN
  70. IF (trmsg^.trm_Project = Project) THEN BEGIN
  71. CASE trmsg^.trm_Class OF
  72. TRMS_ERROR: WriteLN(TR_GetErrorString(trmsg^.trm_Data));
  73. TRMS_ACTION :
  74. BEGIN
  75. CASE trmsg^.trm_ID OF
  76. ID_MAIN_GADGET_STOP : close_me := True;
  77. END;
  78. END;
  79. ELSE
  80. END;
  81. END;
  82. TR_ReplyMsg(trmsg);
  83. END;
  84. UNTIL close_me OR (trmsg = NIL);
  85. inc(i);
  86. if i = 101 then close_me := true;
  87. END;
  88. TR_CloseProject(project);
  89. END ELSE WriteLN(TR_GetErrorString(TR_GetLastError(Triton_App)));
  90. end;
  91. (* /////////////////////////////////////////////////////////////////////////////////////////////////////// *)
  92. (* ////////////////////////////////////////////////////////////////////////////////////// Main function // *)
  93. (* /////////////////////////////////////////////////////////////////////////////////////////////////////// *)
  94. begin
  95. Triton_App := TR_CreateAppTags([
  96. TRCA_Name,'trProgIndDemo',
  97. TRCA_Version,'1.0',
  98. TAG_END]);
  99. if Triton_App <> nil then begin
  100. do_main;
  101. TR_DeleteApp(Triton_App);
  102. end
  103. else writeln('Can''t create application');
  104. end.