IDE, Editor options, Mouse Actions: Added Import/Export

git-svn-id: trunk@20560 -
This commit is contained in:
martin 2009-06-09 21:25:02 +00:00
parent a680b1a84b
commit cafbf3f6fd
4 changed files with 164 additions and 20 deletions

View File

@ -1,26 +1,26 @@
inherited EditorMouseOptionsFrame: TEditorMouseOptionsFrame
Height = 415
Height = 420
Width = 610
Anchors = [akTop]
ClientHeight = 415
ClientHeight = 420
ClientWidth = 610
Visible = False
DesignLeft = 246
DesignTop = 209
object p2: TPanel[0]
Left = 0
Height = 378
Height = 352
Top = 0
Width = 610
Align = alClient
BevelOuter = bvNone
ClientHeight = 378
ClientHeight = 352
ClientWidth = 610
TabOrder = 0
object ActionGrid: TStringGrid
AnchorSideBottom.Control = p3
Left = 135
Height = 378
Height = 352
Top = 0
Width = 475
Align = alClient
@ -44,7 +44,7 @@ inherited EditorMouseOptionsFrame: TEditorMouseOptionsFrame
end
object ContextTree: TTreeView
Left = 0
Height = 378
Height = 352
Top = 0
Width = 130
Align = alLeft
@ -59,7 +59,7 @@ inherited EditorMouseOptionsFrame: TEditorMouseOptionsFrame
end
object Splitter1: TSplitter
Left = 130
Height = 378
Height = 352
Top = 0
Width = 5
AutoSnap = False
@ -71,13 +71,13 @@ inherited EditorMouseOptionsFrame: TEditorMouseOptionsFrame
AnchorSideBottom.Control = p2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 37
Top = 378
Height = 68
Top = 352
Width = 610
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 37
ClientHeight = 68
ClientWidth = 610
TabOrder = 1
object DelButton: TButton
@ -123,5 +123,47 @@ inherited EditorMouseOptionsFrame: TEditorMouseOptionsFrame
OnClick = UpdateButtonClick
TabOrder = 1
end
object BtnExport: TButton
AnchorSideTop.Control = UpdateButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = p3
AnchorSideRight.Side = asrBottom
Left = 510
Height = 25
Top = 37
Width = 100
Anchors = [akTop, akRight]
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
Caption = 'BtnExport'
OnClick = BtnExportClick
TabOrder = 3
end
object BtnImport: TButton
AnchorSideTop.Control = BtnExport
AnchorSideRight.Control = BtnExport
Left = 429
Height = 25
Top = 37
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'BtnImport'
OnClick = BtnImportClick
TabOrder = 4
end
end
object SaveDialog1: TSaveDialog[2]
DefaultExt = '.xml'
Filter = 'xml|*.xml|any|*.*'
Options = [ofOverwritePrompt, ofPathMustExist, ofEnableSizing, ofViewDetail]
left = 176
top = 368
end
object OpenDialog1: TOpenDialog[3]
DefaultExt = '.xml'
Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 264
top = 368
end
end

View File

@ -2,12 +2,12 @@
LazarusResources.Add('TEditorMouseOptionsFrame','FORMDATA',[
'TPF0'#241#24'TEditorMouseOptionsFrame'#23'EditorMouseOptionsFrame'#6'Height'
+#3#159#1#5'Width'#3'b'#2#7'Anchors'#11#5'akTop'#0#12'ClientHeight'#3#159#1#11
+#3#164#1#5'Width'#3'b'#2#7'Anchors'#11#5'akTop'#0#12'ClientHeight'#3#164#1#11
+'ClientWidth'#3'b'#2#7'Visible'#8#10'DesignLeft'#3#246#0#9'DesignTop'#3#209#0
+#0#242#2#0#6'TPanel'#2'p2'#4'Left'#2#0#6'Height'#3'z'#1#3'Top'#2#0#5'Width'#3
+'b'#2#5'Align'#7#8'alClient'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#3'z'
+#0#242#2#0#6'TPanel'#2'p2'#4'Left'#2#0#6'Height'#3'`'#1#3'Top'#2#0#5'Width'#3
+'b'#2#5'Align'#7#8'alClient'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#3'`'
+#1#11'ClientWidth'#3'b'#2#8'TabOrder'#2#0#0#11'TStringGrid'#10'ActionGrid'#24
+'AnchorSideBottom.Control'#7#2'p3'#4'Left'#3#135#0#6'Height'#3'z'#1#3'Top'#2
+'AnchorSideBottom.Control'#7#2'p3'#4'Left'#3#135#0#6'Height'#3'`'#1#3'Top'#2
+#0#5'Width'#3#219#1#5'Align'#7#8'alClient'#8'AutoEdit'#8#8'ColCount'#2#10#14
+'ExtendedSelect'#8#9'FixedCols'#2#0#7'Options'#11#15'goFixedVertLine'#15'goF'
+'ixedHorzLine'#10'goVertLine'#10'goHorzLine'#13'goRangeSelect'#11'goColSizin'
@ -18,17 +18,17 @@ LazarusResources.Add('TEditorMouseOptionsFrame','FORMDATA',[
+'aderSized'#7#21'ActionGridHeaderSized'#11'OnMouseDown'#7#19'ActionGridMouse'
+'Down'#11'OnMouseMove'#7#19'ActionGridMouseMove'#9'OnMouseUp'#7#17'ActionGri'
+'dMouseUp'#8'OnResize'#7#16'ActionGridResize'#0#0#9'TTreeView'#11'ContextTre'
+'e'#4'Left'#2#0#6'Height'#3'z'#1#3'Top'#2#0#5'Width'#3#130#0#5'Align'#7#6'al'
+'e'#4'Left'#2#0#6'Height'#3'`'#1#3'Top'#2#0#5'Width'#3#130#0#5'Align'#7#6'al'
+'Left'#10'AutoExpand'#9#20'Constraints.MinWidth'#2'2'#17'DefaultItemHeight'#2
+#17#8'ReadOnly'#9#8'ShowRoot'#8#8'TabOrder'#2#1#8'OnChange'#7#17'ContextTree'
+'Change'#7'Options'#11#13'tvoAutoExpand'#17'tvoAutoItemHeight'#16'tvoHideSel'
+'ection'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'#14'tvoShowButtons'#12'tvo'
+'ShowLines'#11'tvoToolTips'#0#0#0#9'TSplitter'#9'Splitter1'#4'Left'#3#130#0#6
+'Height'#3'z'#1#3'Top'#2#0#5'Width'#2#5#8'AutoSnap'#8#0#0#0#242#2#1#6'TPanel'
+'Height'#3'`'#1#3'Top'#2#0#5'Width'#2#5#8'AutoSnap'#8#0#0#0#242#2#1#6'TPanel'
+#2'p3'#23'AnchorSideRight.Control'#7#2'p2'#20'AnchorSideRight.Side'#7#9'asrB'
+'ottom'#24'AnchorSideBottom.Control'#7#2'p2'#21'AnchorSideBottom.Side'#7#9'a'
+'srBottom'#4'Left'#2#0#6'Height'#2'%'#3'Top'#3'z'#1#5'Width'#3'b'#2#5'Align'
+#7#8'alBottom'#8'AutoSize'#9#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'%'
+'srBottom'#4'Left'#2#0#6'Height'#2'D'#3'Top'#3'`'#1#5'Width'#3'b'#2#5'Align'
+#7#8'alBottom'#8'AutoSize'#9#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'D'
+#11'ClientWidth'#3'b'#2#8'TabOrder'#2#1#0#7'TButton'#9'DelButton'#22'AnchorS'
+'ideLeft.Control'#7#2'p3'#21'AnchorSideTop.Control'#7#2'p3'#4'Left'#2#0#6'He'
+'ight'#2#25#3'Top'#2#6#5'Width'#2'O'#8'AutoSize'#9#17'BorderSpacing.Top'#2#6
@ -42,5 +42,20 @@ LazarusResources.Add('TEditorMouseOptionsFrame','FORMDATA',[
+'Left'#3#140#1#6'Height'#2#25#3'Top'#2#6#5'Width'#2'd'#7'Anchors'#11#5'akTop'
+#7'akRight'#0#8'AutoSize'#9#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'
+#2#6#20'BorderSpacing.Bottom'#2#6#7'Caption'#6#12'UpdateButton'#7'OnClick'#7
+#17'UpdateButtonClick'#8'TabOrder'#2#1#0#0#0#0
+#17'UpdateButtonClick'#8'TabOrder'#2#1#0#0#7'TButton'#9'BtnExport'#21'Anchor'
+'SideTop.Control'#7#12'UpdateButton'#18'AnchorSideTop.Side'#7#9'asrBottom'#23
+'AnchorSideRight.Control'#7#2'p3'#20'AnchorSideRight.Side'#7#9'asrBottom'#4
+'Left'#3#254#1#6'Height'#2#25#3'Top'#2'%'#5'Width'#2'd'#7'Anchors'#11#5'akTo'
+'p'#7'akRight'#0#17'BorderSpacing.Top'#2#6#20'BorderSpacing.Bottom'#2#6#7'Ca'
+'ption'#6#9'BtnExport'#7'OnClick'#7#14'BtnExportClick'#8'TabOrder'#2#3#0#0#7
+'TButton'#9'BtnImport'#21'AnchorSideTop.Control'#7#9'BtnExport'#23'AnchorSid'
+'eRight.Control'#7#9'BtnExport'#4'Left'#3#173#1#6'Height'#2#25#3'Top'#2'%'#5
+'Width'#2'K'#7'Anchors'#11#5'akTop'#7'akRight'#0#19'BorderSpacing.Right'#2#6
+#7'Caption'#6#9'BtnImport'#7'OnClick'#7#14'BtnImportClick'#8'TabOrder'#2#4#0
+#0#0#242#2#2#11'TSaveDialog'#11'SaveDialog1'#10'DefaultExt'#6#4'.xml'#6'Filt'
+'er'#6#17'xml|*.xml|any|*.*'#7'Options'#11#17'ofOverwritePrompt'#15'ofPathMu'
+'stExist'#14'ofEnableSizing'#12'ofViewDetail'#0#4'left'#3#176#0#3'top'#3'p'#1
+#0#0#242#2#3#11'TOpenDialog'#11'OpenDialog1'#10'DefaultExt'#6#4'.xml'#7'Opti'
+'ons'#11#15'ofPathMustExist'#15'ofFileMustExist'#14'ofEnableSizing'#12'ofVie'
+'wDetail'#0#4'left'#3#8#1#3'top'#3'p'#1#0#0#0
]);

View File

@ -26,7 +26,7 @@ interface
uses
LResources, EditorOptions, LazarusIDEStrConsts, IDEOptionsIntf, sysutils,
StdCtrls, ExtCtrls, Classes, Controls, LCLProc, Grids, ComCtrls, Dialogs,
StdCtrls, ExtCtrls, Classes, Controls, LCLProc, Grids, ComCtrls, Dialogs, ButtonPanel,
SynEditMouseCmds, MouseActionDialog, math, KeyMapping;
type
@ -34,7 +34,11 @@ type
{ TEditorMouseOptionsFrame }
TEditorMouseOptionsFrame = class(TAbstractIDEOptionsEditor)
BtnExport: TButton;
BtnImport: TButton;
DelButton: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Splitter1: TSplitter;
UpdateButton: TButton;
AddNewButton: TButton;
@ -50,6 +54,8 @@ type
procedure ActionGridMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure ActionGridMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
procedure BtnExportClick(Sender: TObject);
procedure BtnImportClick(Sender: TObject);
procedure ContextTreeChange(Sender: TObject; Node: TTreeNode);
procedure AddNewButtonClick(Sender: TObject);
procedure UpdateButtonClick(Sender: TObject);
@ -316,6 +322,81 @@ begin
FIsHeaderSizing := False;
end;
procedure TEditorMouseOptionsFrame.BtnExportClick(Sender: TObject);
var
xml: TRttiXMLConfig;
Procedure SaveMouseAct(Path: String; MActions: TSynEditMouseActions);
var
i: Integer;
begin
for i := 0 to MActions.Count - 1 do
xml.WriteObject(Path + 'M' + IntToStr(i) + '/', MActions[i]);
xml.SetValue(Path + 'Count', MActions.Count);
end;
begin
if SaveDialog1.Execute then begin
xml := TRttiXMLConfig.CreateClean(SaveDialog1.FileName);
SaveMouseAct('Mouse/Main/', FMainActions);
SaveMouseAct('Mouse/MainSel/', FSelActions);
SaveMouseAct('Mouse/Gutter/', FGutterActions);
SaveMouseAct('Mouse/GutterFold/', FGutterActionsFold);
SaveMouseAct('Mouse/GutterFoldExp/', FGutterActionsFoldExp);
SaveMouseAct('Mouse/GutterFoldCol/', FGutterActionsFoldCol);
SaveMouseAct('Mouse/GutterLineNum/', FGutterActionsLines);
xml.Flush;
xml.Free;
end;
end;
procedure TEditorMouseOptionsFrame.BtnImportClick(Sender: TObject);
var
xml: TRttiXMLConfig;
Procedure LoadMouseAct(Path: String; MActions: TSynEditMouseActions);
var
i, c: Integer;
MAct: TSynEditMouseAction;
begin
MActions.Clear;
c := xml.GetValue(Path + 'Count', 0);
for i := 0 to c - 1 do begin
try
MActions.IncAssertLock;
try
MAct := MActions.Add;
xml.ReadObject(Path + 'M' + IntToStr(i) + '/', MAct);
finally
MActions.DecAssertLock;
end;
MActions.AssertNoConflict(MAct);
except
MActions.Delete(MActions.Count-1);
MessageDlg(dlgMouseOptErrorDup, dlgMouseOptErrorDupText + LineEnding
+ Path + 'M' + IntToStr(i) + LineEnding + MAct.DisplayName,
mtError, [mbOk], 0);
end;
end;
end;
begin
if OpenDialog1.Execute then begin
xml := TRttiXMLConfig.Create(OpenDialog1.FileName);
LoadMouseAct('Mouse/Main/', FMainActions);
LoadMouseAct('Mouse/MainSel/', FSelActions);
LoadMouseAct('Mouse/Gutter/', FGutterActions);
LoadMouseAct('Mouse/GutterFold/', FGutterActionsFold);
LoadMouseAct('Mouse/GutterFoldExp/', FGutterActionsFoldExp);
LoadMouseAct('Mouse/GutterFoldCol/', FGutterActionsFoldCol);
LoadMouseAct('Mouse/GutterLineNum/', FGutterActionsLines);
xml.Free;
ContextTree.Selected := FMainNode;
ContextTreeChange(nil, FMainNode);
end;
end;
procedure TEditorMouseOptionsFrame.ActionGridMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
@ -398,6 +479,10 @@ begin
DelButton.Caption := dlgMouseOptBtnDel;
UpdateButton.Caption := dlgMouseOptBtnUdp;
AddNewButton.Caption := dlgMouseOptBtnAdd;
BtnImport.Caption := dlgMouseOptBtnImport;
BtnExport.Caption := dlgMouseOptBtnExport;
OpenDialog1.Title := dlgMouseOptBtnImport;
SaveDialog1.Title := dlgMouseOptBtnExport;
end;
procedure TEditorMouseOptionsFrame.ReadSettings(

View File

@ -1204,6 +1204,8 @@ resourcestring
dlgMouseOptBtnDel = 'Delete';
dlgMouseOptBtnUdp = 'Change';
dlgMouseOptBtnAdd = 'Add';
dlgMouseOptBtnImport = 'Import';
dlgMouseOptBtnExport = 'Export';
dlgMouseOptBtnOk = 'Ok';
dlgMouseOptBtnCancel = 'Cancel';
dlgMouseOptBtnModDef = 'Make Fallback';