PageRenderTime 16ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/components/jcf2/Ui/Settings/frObfuscateSettings.pas

http://github.com/graemeg/lazarus
Pascal | 139 lines | 89 code | 21 blank | 29 comment | 0 complexity | dbe7b75d2b0a47507a9ce4f449696872 MD5 | raw file
  1{(*}
  2(*------------------------------------------------------------------------------
  3 Delphi Code formatter source code 
  4
  5The Original Code is frObfuscateSettings.pas, released April 2000.
  6The Initial Developer of the Original Code is Anthony Steele. 
  7Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
  8All Rights Reserved. 
  9Contributor(s): Anthony Steele. 
 10
 11The contents of this file are subject to the Mozilla Public License Version 1.1
 12(the "License"). you may not use this file except in compliance with the License.
 13You may obtain a copy of the License at http://www.mozilla.org/NPL/
 14
 15Software distributed under the License is distributed on an "AS IS" basis,
 16WITHOUT WARRANTY OF ANY KIND, either express or implied.
 17See the License for the specific language governing rights and limitations 
 18under the License.
 19
 20Alternatively, the contents of this file may be used under the terms of
 21the GNU General Public License Version 2 or later (the "GPL") 
 22See http://www.gnu.org/licenses/gpl.html
 23------------------------------------------------------------------------------*)
 24{*)}
 25
 26unit frObfuscateSettings;
 27
 28{$I JcfGlobal.inc}
 29
 30interface
 31
 32uses
 33  Classes, StdCtrls, ExtCtrls,
 34  IDEOptionsIntf;
 35
 36type
 37  { TfObfuscateSettings }
 38
 39  TfObfuscateSettings = class(TAbstractIDEOptionsEditor)
 40    cbRemoveWhiteSpace: TCheckBox;
 41    cbRemoveComments: TCheckBox;
 42    rgObfuscateCaps: TRadioGroup;
 43    cbRebreak: TCheckBox;
 44    cbRemoveIndent: TCheckBox;
 45    cbEnabled: TCheckBox;
 46    procedure cbEnabledChange(Sender: TObject);
 47  public
 48    constructor Create(AOwner: TComponent); override;
 49
 50    function GetTitle: String; override;
 51    procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
 52    procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
 53    procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
 54    class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
 55  end;
 56
 57implementation
 58
 59{$R *.lfm}
 60
 61uses
 62  JcfSettings, SettingsTypes, jcfuiconsts;
 63
 64{ TfObfuscateSettings }
 65
 66procedure TfObfuscateSettings.cbEnabledChange(Sender: TObject);
 67var
 68  b: Boolean;
 69begin
 70  b := (Sender as TCheckBox).Checked;
 71  rgObfuscateCaps.Enabled := b;
 72  cbRemoveWhiteSpace.Enabled := b;
 73  cbRemoveComments.Enabled := b;
 74  cbRemoveIndent.Enabled := b;
 75  cbRebreak.Enabled := b;
 76end;
 77
 78constructor TfObfuscateSettings.Create(AOwner: TComponent);
 79begin
 80  inherited;
 81  //fiHelpContext := HELP_OBFUSCATE_SETTINGS;
 82end;
 83
 84function TfObfuscateSettings.GetTitle: String;
 85begin
 86  Result := lisObfsObfuscate;
 87end;
 88
 89procedure TfObfuscateSettings.Setup(ADialog: TAbstractOptionsEditorDialog);
 90begin
 91  cbEnabled.Caption := lisObfsObfuscateMode;
 92
 93  rgObfuscateCaps.Caption := lisObfsObfuscateWordCaps;
 94  rgObfuscateCaps.Items[0] := lisObfsAllCapitals;
 95  rgObfuscateCaps.Items[1] := lisObfsAllLowerCase;
 96  rgObfuscateCaps.Items[2] := lisObfsMixedCase;
 97  rgObfuscateCaps.Items[3] := lisObfsLeaveAlone;
 98
 99  cbRemoveWhiteSpace.Caption := lisObfsRemoveWhiteSpace;
100  cbRemoveComments.Caption := lisObfsRemoveComments;
101  cbRemoveIndent.Caption := lisObfsRemoveIndent;
102  cbRebreak.Caption := lisObfsRebreakLines;
103  cbEnabledChange(cbEnabled);
104end;
105
106procedure TfObfuscateSettings.ReadSettings(AOptions: TAbstractIDEOptions);
107begin
108  with FormatSettings.Obfuscate do
109  begin
110    cbEnabled.Checked      := Enabled;
111    rgObfuscateCaps.ItemIndex := Ord(Caps);
112    cbRemoveWhiteSpace.Checked := RemoveWhiteSpace;
113    cbRemoveComments.Checked := RemoveComments;
114    cbRemoveIndent.Checked := RemoveIndent;
115    cbRebreak.Checked      := RebreakLines;
116  end;
117end;
118
119procedure TfObfuscateSettings.WriteSettings(AOptions: TAbstractIDEOptions);
120begin
121  with FormatSettings.Obfuscate do
122  begin
123    Enabled := cbEnabled.Checked;
124    Caps    := TCapitalisationType(rgObfuscateCaps.ItemIndex);
125    RemoveWhiteSpace := cbRemoveWhiteSpace.Checked;
126    RemoveComments := cbRemoveComments.Checked;
127    RemoveIndent := CbRemoveIndent.Checked;
128    RebreakLines := cbRebreak.Checked;
129  end;
130end;
131
132class function TfObfuscateSettings.SupportedOptionsClass: TAbstractIDEOptionsClass;
133begin
134  Result := TFormatSettings;
135end;
136
137initialization
138  RegisterIDEOptionsEditor(JCFOptionsGroup, TfObfuscateSettings, JCFOptionObfuscate);
139end.