String_frMain.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. (* _ _
  2. * | |__ _ __ ___ ___ | | __
  3. * | '_ \| '__/ _ \ / _ \| |/ /
  4. * | |_) | | | (_) | (_) | <
  5. * |_.__/|_| \___/ \___/|_|\_\
  6. *
  7. * Microframework which helps to develop web Pascal applications.
  8. *
  9. * Copyright (c) 2012-2020 Silvio Clecio <[email protected]>
  10. *
  11. * Brook framework is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2.1 of the License, or (at your option) any later version.
  15. *
  16. * Brook framework is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with Brook framework; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *)
  25. unit String_frMain;
  26. interface
  27. uses
  28. System.SysUtils,
  29. System.Classes,
  30. FMX.Types,
  31. FMX.StdCtrls,
  32. FMX.Controls,
  33. FMX.Controls.Presentation,
  34. FMX.Dialogs,
  35. FMX.Forms,
  36. BrookHandledClasses,
  37. BrookString;
  38. type
  39. TfrMain = class(TForm)
  40. lbDesc: TLabel;
  41. btAddNow: TButton;
  42. btShowContent: TButton;
  43. btClear: TButton;
  44. procedure FormCreate(Sender: TObject);
  45. procedure FormDestroy(Sender: TObject);
  46. procedure btAddNowClick(Sender: TObject);
  47. procedure btShowContentClick(Sender: TObject);
  48. procedure btClearClick(Sender: TObject);
  49. procedure BrookLibraryLoader1Load(Sender: TObject);
  50. private
  51. FString: TBrookString;
  52. protected
  53. procedure UpdateButtons;
  54. end;
  55. var
  56. frMain: TfrMain;
  57. implementation
  58. {$R *.fmx}
  59. procedure TfrMain.FormCreate(Sender: TObject);
  60. begin
  61. FString := TBrookString.Create(nil);
  62. end;
  63. procedure TfrMain.FormDestroy(Sender: TObject);
  64. begin
  65. FString.Free;
  66. end;
  67. procedure TfrMain.UpdateButtons;
  68. begin
  69. btShowContent.Enabled := FString.Length > 0;
  70. btClear.Enabled := btShowContent.Enabled;
  71. end;
  72. procedure TfrMain.BrookLibraryLoader1Load(Sender: TObject);
  73. begin
  74. btAddNow.Enabled := True;
  75. end;
  76. procedure TfrMain.btAddNowClick(Sender: TObject);
  77. begin
  78. FString.Write(Format('%s%s',
  79. [FormatDateTime('hh:nn:ss.zzz', Now), sLineBreak]));
  80. UpdateButtons;
  81. end;
  82. procedure TfrMain.btShowContentClick(Sender: TObject);
  83. begin
  84. ShowMessageFmt('All clicks:%s%s%s', [sLineBreak, sLineBreak, FString.Text]);
  85. end;
  86. procedure TfrMain.btClearClick(Sender: TObject);
  87. begin
  88. FString.Clear;
  89. UpdateButtons;
  90. end;
  91. end.