/components/jcf2/Ui/Settings/frPreProcessor.pas

http://github.com/graemeg/lazarus · Pascal · 125 lines · 76 code · 20 blank · 29 comment · 0 complexity · ff35dee50452c52ff3a34bd6b91353c5 MD5 · raw file

  1. unit frPreProcessor;
  2. {(*}
  3. (*------------------------------------------------------------------------------
  4. Delphi Code formatter source code
  5. The Original Code is frPreProcessor.pas.
  6. The Initial Developer of the Original Code is Anthony Steele.
  7. Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
  8. All Rights Reserved.
  9. Contributor(s): Anthony Steele.
  10. The contents of this file are subject to the Mozilla Public License Version 1.1
  11. (the "License"). you may not use this file except in compliance with the License.
  12. You may obtain a copy of the License at http://www.mozilla.org/NPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied.
  15. See the License for the specific language governing rights and limitations
  16. under the License.
  17. Alternatively, the contents of this file may be used under the terms of
  18. the GNU General Public License Version 2 or later (the "GPL")
  19. See http://www.gnu.org/licenses/gpl.html
  20. ------------------------------------------------------------------------------*)
  21. {*)}
  22. {$I JcfGlobal.inc}
  23. interface
  24. { preprocessor symbols }
  25. uses
  26. Classes, StdCtrls, IDEOptionsIntf;
  27. type
  28. { TfPreProcessor }
  29. TfPreProcessor = class(TAbstractIDEOptionsEditor)
  30. mSymbols: TMemo;
  31. cbEnable: TCheckBox;
  32. lblSymbols: TLabel;
  33. mOptions: TMemo;
  34. lblCompilerOptions: TLabel;
  35. procedure cbEnableChange(Sender: TObject);
  36. procedure FrameResize(Sender: TObject);
  37. public
  38. constructor Create(AOwner: TComponent); override;
  39. function GetTitle: String; override;
  40. procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
  41. procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
  42. procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
  43. class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
  44. end;
  45. implementation
  46. {$R *.lfm}
  47. uses
  48. JcfSettings, jcfuiconsts;
  49. constructor TfPreProcessor.Create(AOwner: TComponent);
  50. begin
  51. inherited;
  52. //fiHelpContext := HELP_CLARIFY;
  53. end;
  54. function TfPreProcessor.GetTitle: String;
  55. begin
  56. Result := lisPrpPreProcessor;
  57. end;
  58. procedure TfPreProcessor.Setup(ADialog: TAbstractOptionsEditorDialog);
  59. begin
  60. cbEnable.Caption := lisPrpEnablePreprocessorParsing;
  61. lblSymbols.Caption := lisPrpSymbolsDefinedForConditionalCompilation;
  62. lblCompilerOptions.Caption := lisPrpCompilerOptionsDefinedForConditionalCompilation;
  63. cbEnableChange(cbEnable);
  64. end;
  65. procedure TfPreProcessor.ReadSettings(AOptions: TAbstractIDEOptions);
  66. begin
  67. with FormatSettings.PreProcessor do
  68. begin
  69. cbEnable.Checked := Enabled;
  70. mSymbols.Lines.Assign(DefinedSymbols);
  71. mOptions.Lines.Assign(DefinedOptions);
  72. end;
  73. end;
  74. procedure TfPreProcessor.WriteSettings(AOptions: TAbstractIDEOptions);
  75. begin
  76. with FormatSettings.PreProcessor do
  77. begin
  78. Enabled := cbEnable.Checked;
  79. DefinedSymbols.Assign(mSymbols.Lines);
  80. DefinedOptions.Assign(mOptions.Lines);
  81. end;
  82. end;
  83. class function TfPreProcessor.SupportedOptionsClass: TAbstractIDEOptionsClass;
  84. begin
  85. Result := TFormatSettings;
  86. end;
  87. procedure TfPreProcessor.FrameResize(Sender: TObject);
  88. begin
  89. mSymbols.Height := (mSymbols.Height+mOptions.Height) div 2;
  90. end;
  91. procedure TfPreProcessor.cbEnableChange(Sender: TObject);
  92. var
  93. b: Boolean;
  94. begin
  95. b := (Sender as TCheckBox).Checked;
  96. mSymbols.Enabled := b;
  97. mOptions.Enabled := b;
  98. end;
  99. initialization
  100. RegisterIDEOptionsEditor(JCFOptionsGroup, TfPreProcessor, JCFOptionPreProcessor);
  101. end.