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