progindex.pas 3.6 KB

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