CustomStyleUnit.pas 3.5 KB

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