CustomStyleUnit.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. TIGCC IDE
  3. Copyright (C) 2000-2004 Sebastian Reichelt
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. }
  16. unit CustomStyleUnit;
  17. interface
  18. uses
  19. SourceEditUnit,
  20. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  21. StdCtrls, ExtCtrls;
  22. type
  23. TCustomStyleForm = class(TForm)
  24. Button1: TButton;
  25. Button2: TButton;
  26. Bevel1: TBevel;
  27. Label1: TLabel;
  28. Label2: TLabel;
  29. Label3: TLabel;
  30. BeginEdit: TEdit;
  31. EndEdit: TEdit;
  32. IgnoreEdit: TEdit;
  33. Bevel2: TBevel;
  34. Button3: TButton;
  35. Button4: TButton;
  36. ColorDlg: TColorDialog;
  37. SwitchableCheckBox: TCheckBox;
  38. procedure FormCreate(Sender: TObject);
  39. procedure FormDestroy(Sender: TObject);
  40. procedure BeginEditChange(Sender: TObject);
  41. procedure EndEditChange(Sender: TObject);
  42. procedure IgnoreEditChange(Sender: TObject);
  43. procedure SwitchableCheckBoxClick(Sender: TObject);
  44. procedure Button1Click(Sender: TObject);
  45. procedure Button2Click(Sender: TObject);
  46. procedure FormShow(Sender: TObject);
  47. private
  48. public
  49. Style: TCustomStyle;
  50. end;
  51. implementation
  52. {$R *.DFM}
  53. uses
  54. StyleSelectionUnit;
  55. procedure TCustomStyleForm.FormCreate(Sender: TObject);
  56. begin
  57. Style := TCustomStyle.Create (nil);
  58. end;
  59. procedure TCustomStyleForm.FormDestroy(Sender: TObject);
  60. begin
  61. Style.Free;
  62. end;
  63. procedure TCustomStyleForm.BeginEditChange(Sender: TObject);
  64. begin
  65. Style.BeginText := BeginEdit.Text;
  66. end;
  67. procedure TCustomStyleForm.EndEditChange(Sender: TObject);
  68. begin
  69. Style.EndText := EndEdit.Text;
  70. end;
  71. procedure TCustomStyleForm.IgnoreEditChange(Sender: TObject);
  72. begin
  73. Style.IgnoreChar := IgnoreEdit.Text;
  74. end;
  75. procedure TCustomStyleForm.SwitchableCheckBoxClick(Sender: TObject);
  76. begin
  77. Style.Switchable := SwitchableCheckBox.Checked;
  78. end;
  79. procedure TCustomStyleForm.Button1Click(Sender: TObject);
  80. begin
  81. ColorDlg.Color := Style.Color;
  82. if ColorDlg.Execute then begin
  83. Style.Color := ColorDlg.Color;
  84. Style.CustomColor := True;
  85. end;
  86. end;
  87. procedure TCustomStyleForm.Button2Click(Sender: TObject);
  88. begin
  89. with TStyleSelectionForm.Create (Self) do try
  90. CustomStyle := Self.Style.CustomStyle;
  91. Style := Self.Style.Style;
  92. if ShowModal = mrOK then begin
  93. Self.Style.CustomStyle := CustomStyle;
  94. Self.Style.Style := Style;
  95. end;
  96. finally
  97. Free;
  98. end;
  99. end;
  100. procedure TCustomStyleForm.FormShow(Sender: TObject);
  101. begin
  102. if Style.BeginText = #13 then
  103. BeginEdit.Text := '#13'
  104. else
  105. BeginEdit.Text := Style.BeginText;
  106. if Style.EndText = #13 then
  107. EndEdit.Text := '#13'
  108. else
  109. EndEdit.Text := Style.EndText;
  110. IgnoreEdit.Text := Style.IgnoreChar;
  111. SwitchableCheckBox.Checked := Style.Switchable;
  112. end;
  113. end.