IDEIntf: find options editor via groupindex and index, codetools indent options: jump to default indent

git-svn-id: trunk@25685 -
This commit is contained in:
mattias 2010-05-27 10:35:58 +00:00
parent 41bfebe276
commit d9820994b8
6 changed files with 132 additions and 59 deletions

View File

@ -13,14 +13,14 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 58
Height = 57
Top = 0
Width = 552
Align = alTop
AutoSize = True
Caption = 'SrcPathGroupBox'
ClientHeight = 39
ClientWidth = 548
ClientWidth = 544
TabOrder = 0
object SrcPathEdit: TEdit
AnchorSideLeft.Control = SrcPathGroupBox
@ -28,7 +28,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Left = 6
Height = 27
Top = 6
Width = 513
Width = 509
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -42,7 +42,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SrcPathEdit
AnchorSideBottom.Side = asrBottom
Left = 519
Left = 515
Height = 27
Top = 6
Width = 23
@ -61,8 +61,8 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 119
Top = 64
Height = 118
Top = 63
Width = 552
Align = alTop
AutoSize = True
@ -71,7 +71,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 100
ClientWidth = 548
ClientWidth = 544
TabOrder = 1
object AdjustTopLineDueToCommentCheckBox: TCheckBox
AnchorSideLeft.Control = JumpingGroupBox
@ -79,7 +79,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Left = 6
Height = 22
Top = 6
Width = 277
Width = 287
Caption = 'AdjustTopLineDueToCommentCheckBox'
TabOrder = 0
end
@ -90,7 +90,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Left = 6
Height = 22
Top = 28
Width = 178
Width = 185
Caption = 'JumpCenteredCheckBox'
TabOrder = 1
end
@ -101,7 +101,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Left = 6
Height = 22
Top = 50
Width = 202
Width = 209
Caption = 'CursorBeyondEOLCheckBox'
TabOrder = 2
end
@ -112,23 +112,23 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Left = 6
Height = 22
Top = 72
Width = 244
Width = 256
Caption = 'SkipForwardDeclarationsCheckBox'
TabOrder = 3
end
end
object IndentationGroupBox: TGroupBox[2]
Left = 0
Height = 132
Top = 183
Height = 147
Top = 181
Width = 552
Align = alTop
AutoSize = True
Caption = 'IndentationGroupBox'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 113
ClientWidth = 548
ClientHeight = 129
ClientWidth = 544
TabOrder = 2
object IndentFileLabel: TLabel
AnchorSideLeft.Control = IndentationGroupBox
@ -136,8 +136,8 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 83
Width = 95
Top = 100
Width = 100
BorderSpacing.Left = 6
Caption = 'IndentFileLabel'
ParentColor = False
@ -148,10 +148,10 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Control = IndentFileButton
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = IndentFileButton
Left = 107
Left = 112
Height = 27
Top = 79
Width = 320
Top = 96
Width = 301
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -164,10 +164,10 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = IndentationGroupBox
AnchorSideRight.Side = asrBottom
Left = 427
Height = 29
Top = 78
Width = 115
Left = 413
Height = 27
Top = 96
Width = 125
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 6
@ -183,18 +183,19 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 50
Width = 235
Top = 68
Width = 245
Caption = 'IndentContextSensitiveCheckBox'
TabOrder = 2
end
object IndentOnLineBreakCheckBox: TCheckBox
AnchorSideLeft.Control = IndentationGroupBox
AnchorSideTop.Control = IndentationGroupBox
AnchorSideTop.Control = GeneralAutoIndent
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 6
Width = 208
Top = 24
Width = 217
Caption = 'IndentOnLineBreakCheckBox'
OnChange = IndentOnLineBreakCheckBoxChange
TabOrder = 3
@ -205,11 +206,25 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 28
Width = 180
Top = 46
Width = 187
Caption = 'IndentOnPasteCheckBox'
OnChange = IndentOnPasteCheckBoxChange
TabOrder = 4
end
object GeneralAutoIndent: TLabel
Cursor = crHandPoint
Left = 6
Height = 18
Top = 6
Width = 123
Caption = 'GeneralAutoIndent'
Font.Color = clBlue
ParentColor = False
ParentFont = False
OnClick = GeneralAutoIndentClick
OnMouseEnter = GeneralAutoIndentMouseEnter
OnMouseLeave = GeneralAutoIndentMouseLeave
end
end
end

View File

@ -26,7 +26,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, Buttons,
Dialogs, ExtCtrls,
Dialogs, ExtCtrls, Graphics,
IDEDialogs, PathEditorDlg,
CodeToolsOptions, LazarusIDEStrConsts, IDEOptionsIntf;
@ -36,6 +36,7 @@ type
TCodetoolsGeneralOptionsFrame = class(TAbstractIDEOptionsEditor)
AdjustTopLineDueToCommentCheckBox: TCheckBox;
GeneralAutoIndent: TLabel;
IndentOnPasteCheckBox: TCheckBox;
IndentOnLineBreakCheckBox: TCheckBox;
IndentContextSensitiveCheckBox: TCheckBox;
@ -50,11 +51,15 @@ type
SrcPathButton: TSpeedButton;
SrcPathEdit: TEdit;
SrcPathGroupBox: TGroupBox;
procedure GeneralAutoIndentClick(Sender: TObject);
procedure GeneralAutoIndentMouseEnter(Sender: TObject);
procedure GeneralAutoIndentMouseLeave(Sender: TObject);
procedure IndentOnLineBreakCheckBoxChange(Sender: TObject);
procedure IndentFileButtonClick(Sender: TObject);
procedure IndentOnPasteCheckBoxChange(Sender: TObject);
procedure SrcPathButtonClick(Sender: TObject);
private
FDialog: TAbstractOptionsEditorDialog;
procedure VisualizeIndentEnabled;
public
function GetTitle: String; override;
@ -124,6 +129,25 @@ begin
VisualizeIndentEnabled;
end;
procedure TCodetoolsGeneralOptionsFrame.GeneralAutoIndentClick(Sender: TObject);
begin
FDialog.OpenEditor(GroupEditor,EdtOptionsGeneral);
end;
procedure TCodetoolsGeneralOptionsFrame.GeneralAutoIndentMouseEnter(
Sender: TObject);
begin
(Sender as TLabel).Font.Underline := True;
(Sender as TLabel).Font.Color := clRed;
end;
procedure TCodetoolsGeneralOptionsFrame.GeneralAutoIndentMouseLeave(
Sender: TObject);
begin
(Sender as TLabel).Font.Underline := False;
(Sender as TLabel).Font.Color := clBlue;
end;
function TCodetoolsGeneralOptionsFrame.GetTitle: String;
begin
Result := lisMenuInsertGeneral;
@ -131,24 +155,17 @@ end;
procedure TCodetoolsGeneralOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
with SrcPathGroupBox do
Caption:=dlgAdditionalSrcPath;
with JumpingGroupBox do
Caption:=dlgJumpingETC;
with AdjustTopLineDueToCommentCheckBox do
Caption:=dlgAdjustTopLine;
with JumpCenteredCheckBox do
Caption:=dlgcentercursorline;
with CursorBeyondEOLCheckBox do
Caption:=dlgcursorbeyondeol;
FDialog:=ADialog;
SrcPathGroupBox.Caption:=dlgAdditionalSrcPath;
JumpingGroupBox.Caption:=dlgJumpingETC;
AdjustTopLineDueToCommentCheckBox.Caption:=dlgAdjustTopLine;
JumpCenteredCheckBox.Caption:=dlgcentercursorline;
CursorBeyondEOLCheckBox.Caption:=dlgcursorbeyondeol;
SkipForwardDeclarationsCheckBox.Caption:=dlgSkipForwardDeclarations;
IndentationGroupBox.Caption:=lisIndentation;
IndentationGroupBox.Caption:=lisIndentationForPascalSources;
GeneralAutoIndent.Caption:=lisSetupDefaultIdentation;
IndentOnLineBreakCheckBox.Caption:=lisOnBreakLineIEReturnOrEnterKey;
IndentOnPasteCheckBox.Caption:=lisOnPasteFromClipboard;
IndentFileLabel.Caption:=lisExampleFile;

View File

@ -27,7 +27,7 @@ interface
uses
Classes, SysUtils, LCLProc, LCLType, StdCtrls, Controls, ExtCtrls, Graphics,
EditorOptions, LazarusIDEStrConsts, IDEProcs, IDEOptionsIntf,
SynEdit, SynBeautifier, codetools_general_options;
SynEdit, SynBeautifier;
type
TPreviewEditor = TSynEdit;
@ -349,7 +349,7 @@ end;
procedure TEditorGeneralOptionsFrame.AutoIndentLinkClick(Sender: TObject);
begin
FDialog.OpenEditor(TCodetoolsGeneralOptionsFrame);
FDialog.OpenEditor(GroupCodetools,CdtOptionsGeneral);
end;
procedure TEditorGeneralOptionsFrame.AutoIndentLinkMouseEnter(Sender: TObject);

View File

@ -53,11 +53,10 @@ type
FOnSaveOptions: TOnSaveIDEOptions;
FOptionsFilter: TAbstractIDEOptionsClass;
PrevEditor: TAbstractIDEOptionsEditor;
FEditorToOpen: TAbstractIDEOptionsEditorClass;
FEditorsCreated: Boolean;
function CheckValues: boolean;
procedure DoOpenEditor;
procedure DoOpenEditor(EditorToOpen: TAbstractIDEOptionsEditorClass);
procedure LoadIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions);
procedure SaveIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions);
procedure CreateEditors;
@ -70,7 +69,10 @@ type
function AddButton: TBitBtn; override;
function AddControl(AControlClass: TControlClass): TControl; override;
procedure OpenEditor(AEditor: TAbstractIDEOptionsEditorClass); override;
procedure OpenEditor(GroupIndex, AIndex: integer); override;
function FindEditor(AEditor: TAbstractIDEOptionsEditorClass): TAbstractIDEOptionsEditor; override;
function FindEditor(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditor; override;
function FindEditorClass(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditorClass; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions);
procedure WriteSettings(AOptions: TAbstractIDEOptions);
procedure ReadAll;
@ -94,7 +96,6 @@ constructor TIDEOptionsDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
PrevEditor := nil;
FEditorToOpen := nil;
FEditorsCreated := False;
IDEDialogLayoutList.ApplyLayout(Self, Width, Height);
@ -440,14 +441,14 @@ begin
Result := True;
end;
procedure TIDEOptionsDialog.DoOpenEditor;
procedure TIDEOptionsDialog.DoOpenEditor(EditorToOpen: TAbstractIDEOptionsEditorClass);
var
Node: TTreeNode;
begin
if FEditorToOpen = nil then
if EditorToOpen = nil then
Node := CategoryTree.Items.GetFirstNode
else
Node := SearchEditorNode(FEditorToOpen);
Node := SearchEditorNode(EditorToOpen);
if Node <> nil then
CategoryTree.Selected := Node;
end;
@ -457,7 +458,7 @@ begin
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TIDEOptionsDialog.ShowModal'){$ENDIF};
try
CreateEditors;
DoOpenEditor;
DoOpenEditor(nil);
finally
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TIDEOptionsDialog.ShowModal'){$ENDIF};
end;
@ -489,9 +490,13 @@ end;
procedure TIDEOptionsDialog.OpenEditor(AEditor: TAbstractIDEOptionsEditorClass);
begin
FEditorToOpen := AEditor;
if Visible then
DoOpenEditor;
if IsVisible then
DoOpenEditor(AEditor);
end;
procedure TIDEOptionsDialog.OpenEditor(GroupIndex, AIndex: integer);
begin
DoOpenEditor(FindEditorClass(GroupIndex,AIndex));
end;
function TIDEOptionsDialog.FindEditor(AEditor: TAbstractIDEOptionsEditorClass): TAbstractIDEOptionsEditor;
@ -505,5 +510,36 @@ begin
Result := nil;
end;
function TIDEOptionsDialog.FindEditor(GroupIndex, AIndex: integer
): TAbstractIDEOptionsEditor;
var
EditorClass: TAbstractIDEOptionsEditorClass;
begin
EditorClass:=FindEditorClass(GroupIndex,AIndex);
if EditorClass<>nil then
Result:=FindEditor(EditorClass)
else
Result:=nil;
end;
function TIDEOptionsDialog.FindEditorClass(GroupIndex, AIndex: integer
): TAbstractIDEOptionsEditorClass;
var
Grp: PIDEOptionsGroupRec;
i: Integer;
begin
Result:=nil;
Grp:=IDEEditorGroups.GetByIndex(GroupIndex);
if (Grp=nil) or (Grp^.Items=nil) then exit;
for i:=0 to Grp^.Items.Count-1 do
begin
if Grp^.Items[i]^.Index=AIndex then
begin
Result:=Grp^.Items[i]^.EditorClass;
exit;
end;
end;
end;
end.

View File

@ -4742,6 +4742,8 @@ resourcestring
lisAddUnitNotRecommended = 'Add unit (not recommended)';
lisAddPackageToProject = 'Add package %s to project?';
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
lisSetupDefaultIdentation = '(Setup default identation)';
lisIndentationForPascalSources = 'Indentation for pascal sources';
lisOnPasteFromClipboard = 'On paste from clipboard';
lisImpossible = 'Impossible';
lisAProjectUnitCanNotBeUsedByOtherPackagesProjects = 'A project unit can '

View File

@ -141,7 +141,10 @@ type
function AddButton: TBitBtn; virtual; abstract;
function AddControl(AControlClass: TControlClass): TControl; virtual; abstract; reintroduce;
function FindEditor(AEditor: TAbstractIDEOptionsEditorClass): TAbstractIDEOptionsEditor; virtual; abstract;
function FindEditor(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditor; virtual; abstract;
function FindEditorClass(GroupIndex, AIndex: integer): TAbstractIDEOptionsEditorClass; virtual; abstract;
procedure OpenEditor(AEditor: TAbstractIDEOptionsEditorClass); virtual; abstract;
procedure OpenEditor(GroupIndex, AIndex: integer); virtual; abstract;
end;
function GetFreeIDEOptionsGroupIndex(AStartIndex: Integer): Integer;