2
0

progwin.pp 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {$mode objfpc}{$h+}
  2. unit ProgWin;
  3. interface
  4. {$IFDEF FPC_DOTTEDUNITS}
  5. uses Fpgtk, Api.Gtk1.Gtk, System.Classes;
  6. {$ELSE FPC_DOTTEDUNITS}
  7. uses FPgtk, gtk, classes;
  8. {$ENDIF FPC_DOTTEDUNITS}
  9. type
  10. TProgressWindow = class (TFPgtkWindow)
  11. private
  12. Bar : TFPgtkProgressbar;
  13. procedure ComposeWindow;
  14. public
  15. procedure StepIt;
  16. procedure SetMax (max : integer);
  17. constructor create;
  18. end;
  19. implementation
  20. {$IFDEF FPC_DOTTEDUNITS}
  21. uses Gtkdeftexts;
  22. {$ELSE FPC_DOTTEDUNITS}
  23. uses gtkDefTexts;
  24. {$ENDIF FPC_DOTTEDUNITS}
  25. procedure TProgressWindow.ComposeWindow;
  26. begin
  27. Title := ProgressWinTitle;
  28. border := 20;
  29. bar := TFPgtkProgressBar.Create (nil);
  30. bar.FormatString := '- %p%% -';
  31. add (bar);
  32. end;
  33. procedure TProgressWindow.StepIt;
  34. begin
  35. with bar do
  36. CurrentValue := CurrentValue + 1.0;
  37. end;
  38. procedure TProgressWindow.SetMax (max : integer);
  39. begin
  40. bar.Configure (0.0,0.0,max);
  41. end;
  42. constructor TProgressWindow.create;
  43. begin
  44. inherited create (gtk_window_dialog);
  45. ComposeWindow;
  46. end;
  47. end.