PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

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