mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 17:39:44 +01:00
added TCustomSplitter.MoveSplitter and SetSplitterPosition and IDE ct defines editor now saves splitter positions
git-svn-id: trunk@9159 -
This commit is contained in:
parent
558d891d47
commit
f5abc1d817
@ -3216,16 +3216,20 @@ var
|
||||
begin
|
||||
// if TargetOS<>SrcOS
|
||||
IfTargetOSIsNotSrcOS:=TDefineTemplate.Create(
|
||||
'IF TargetOS is not SrcOS',
|
||||
'IF TargetOS<>SrcOS',
|
||||
ctsIfTargetOSIsNotSrcOS,'',''''+TargetOS+'''<>'''+SrcOS+'''',da_If);
|
||||
// rtl/$(#SrcOS)
|
||||
RTLSrcOSDir:=TDefineTemplate.Create('SrcOS',SrcOS,'',
|
||||
SrcOS,da_Directory);
|
||||
IfTargetOSIsNotSrcOS.AddChild(RTLSrcOSDir);
|
||||
RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path',
|
||||
'include path',
|
||||
ExternalMacroStart+'IncPath',IncPathMacro+';inc',
|
||||
da_Define));
|
||||
RTLSrcOSDir.AddChild(TDefineTemplate.Create('Include Path',
|
||||
'include path to TargetProcessor directories',
|
||||
ExternalMacroStart+'IncPath',IncPathMacro+';'+TargetProcessor,
|
||||
da_DefineRecurse));
|
||||
da_Define));
|
||||
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS);
|
||||
|
||||
// if TargetOS<>SrcOS2
|
||||
@ -3295,7 +3299,7 @@ begin
|
||||
ctsSrcPathInitialization,ExternalMacroStart+'SrcPath','',da_DefineRecurse);
|
||||
MainDir.AddChild(DefTempl);
|
||||
DefTempl:=TDefineTemplate.Create('Reset UnitPath',
|
||||
ctsSrcPathInitialization,ExternalMacroStart+'UnitPath','',da_DefineRecurse);
|
||||
ctsUnitPathInitialization,ExternalMacroStart+'UnitPath','',da_DefineRecurse);
|
||||
MainDir.AddChild(DefTempl);
|
||||
// turn Nested comments on
|
||||
DefTempl:=TDefineTemplate.Create('Nested Comments',
|
||||
|
||||
@ -91,6 +91,7 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
function GetRootClassName(out IsInherited: Boolean): string;
|
||||
function GetNextElement: TDOMElement; virtual;
|
||||
|
||||
{ All ReadXXX methods are called _after_ the value type has been read! }
|
||||
function NextValue: TValueType; override;
|
||||
@ -487,16 +488,50 @@ begin
|
||||
// TODO: IsInherited
|
||||
end;
|
||||
|
||||
function TXMLObjectReader.NextValue: TValueType;
|
||||
function TXMLObjectReader.GetNextElement: TDOMElement;
|
||||
var
|
||||
Node: TDOMNode;
|
||||
begin
|
||||
writeln('TXMLObjectReader.NextValue ');
|
||||
Result:=TDOMElement(FElement.FirstChild);
|
||||
if (Result is TDOMElement) then exit;
|
||||
Node:=FElement;
|
||||
while Node<>nil do begin
|
||||
Result:=TDOMElement(Node.NextSibling);
|
||||
if Result is TDOMElement then exit;
|
||||
Node:=Node.ParentNode;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TXMLObjectReader.NextValue: TValueType;
|
||||
var
|
||||
NextElement: TDOMElement;
|
||||
begin
|
||||
writeln('TXMLObjectReader.NextValue START');
|
||||
Result:=vaNull;
|
||||
NextElement:=GetNextElement;
|
||||
if NextElement<>nil then begin
|
||||
writeln('TXMLObjectReader.NextValue Value=',NextElement.NodeName);
|
||||
if NextElement.NodeName='extended' then
|
||||
Result:=vaExtended;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TXMLObjectReader.ReadValue: TValueType;
|
||||
var
|
||||
NextElement: TDOMElement;
|
||||
begin
|
||||
writeln('TXMLObjectReader.ReadValue ');
|
||||
writeln('TXMLObjectReader.ReadValue START');
|
||||
Result:=vaNull;
|
||||
NextElement:=GetNextElement;
|
||||
if NextElement<>nil then begin
|
||||
writeln('TXMLObjectReader.ReadValue Value=',NextElement.NodeName);
|
||||
if NextElement.NodeName='extended' then
|
||||
Result:=vaExtended;
|
||||
if Result<>vaNull then begin
|
||||
FElement:=NextElement;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TXMLObjectReader.BeginRootComponent;
|
||||
@ -544,8 +579,9 @@ end;
|
||||
|
||||
function TXMLObjectReader.BeginProperty: String;
|
||||
begin
|
||||
writeln('TXMLObjectReader.BeginProperty ');
|
||||
Result:='';
|
||||
ReadValue;
|
||||
Result:=FElement['name'];
|
||||
writeln('TXMLObjectReader.BeginProperty Result="',Result,'"');
|
||||
end;
|
||||
|
||||
procedure TXMLObjectReader.ReadBinary(const DestData: TMemoryStream);
|
||||
|
||||
@ -11,8 +11,8 @@ object StreamAsXMLForm: TStreamAsXMLForm
|
||||
Height = 434
|
||||
Top = 182
|
||||
Width = 493
|
||||
object GroupBox1: TGroupBox
|
||||
Caption = 'GroupBox1'
|
||||
object SourceGroupBox: TGroupBox
|
||||
Caption = 'SourceGroupBox'
|
||||
ClientHeight = 133
|
||||
ClientWidth = 271
|
||||
TabOrder = 0
|
||||
@ -49,4 +49,14 @@ object StreamAsXMLForm: TStreamAsXMLForm
|
||||
end
|
||||
end
|
||||
end
|
||||
object DestinationGroupBox: TGroupBox
|
||||
Caption = 'DestinationGroupBox'
|
||||
ClientHeight = 143
|
||||
ClientWidth = 267
|
||||
TabOrder = 1
|
||||
Left = 20
|
||||
Height = 160
|
||||
Top = 210
|
||||
Width = 271
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,21 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TStreamAsXMLForm','FORMDATA',[
|
||||
'TPF0'#16'TStreamAsXMLForm'#15'StreamAsXMLForm'#13'ActiveControl'#7#7'Button1'
|
||||
+#7'Caption'#6#15'StreamAsXMLForm'#12'ClientHeight'#3#178#1#11'ClientWidth'#3
|
||||
+#237#1#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'p'#18'HorzScrollBar.'
|
||||
+'Page'#3#236#1#18'VertScrollBar.Page'#3#177#1#4'Left'#3'N'#1#6'Height'#3#178
|
||||
+#1#3'Top'#3#182#0#5'Width'#3#237#1#0#9'TGroupBox'#9'GroupBox1'#7'Caption'#6#9
|
||||
+'GroupBox1'#12'ClientHeight'#3#133#0#11'ClientWidth'#3#15#1#8'TabOrder'#2#0#4
|
||||
+'Left'#2#16#6'Height'#3#150#0#3'Top'#2#16#5'Width'#3#19#1#0#7'TButton'#7'But'
|
||||
+'ton1'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#7'Button1'#8'TabOrder'
|
||||
+#2#0#4'Left'#2'!'#6'Height'#2#25#3'Top'#2#15#5'Width'#2'K'#0#0#9'TGroupBox'#9
|
||||
+'GroupBox2'#7'Caption'#6#9'GroupBox2'#12'ClientHeight'#2'P'#11'ClientWidth'#3
|
||||
+#128#0#8'TabOrder'#2#1#4'Left'#2'{'#6'Height'#2'a'#3'Top'#2#17#5'Width'#3#132
|
||||
+#0#0#7'TButton'#7'Button2'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#7
|
||||
+'Button2'#8'TabOrder'#2#0#4'Left'#2#27#6'Height'#2#25#3'Top'#2#21#5'Width'#2
|
||||
+'K'#0#0#0#0#0
|
||||
+#1#3'Top'#3#182#0#5'Width'#3#237#1#0#9'TGroupBox'#14'SourceGroupBox'#7'Capti'
|
||||
+'on'#6#14'SourceGroupBox'#12'ClientHeight'#3#133#0#11'ClientWidth'#3#15#1#8
|
||||
+'TabOrder'#2#0#4'Left'#2#16#6'Height'#3#150#0#3'Top'#2#16#5'Width'#3#19#1#0#7
|
||||
+'TButton'#7'Button1'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#7'Button'
|
||||
+'1'#8'TabOrder'#2#0#4'Left'#2'!'#6'Height'#2#25#3'Top'#2#15#5'Width'#2'K'#0#0
|
||||
+#9'TGroupBox'#9'GroupBox2'#7'Caption'#6#9'GroupBox2'#12'ClientHeight'#2'P'#11
|
||||
+'ClientWidth'#3#128#0#8'TabOrder'#2#1#4'Left'#2'{'#6'Height'#2'a'#3'Top'#2#17
|
||||
+#5'Width'#3#132#0#0#7'TButton'#7'Button2'#25'BorderSpacing.InnerBorder'#2#2#7
|
||||
+'Caption'#6#7'Button2'#8'TabOrder'#2#0#4'Left'#2#27#6'Height'#2#25#3'Top'#2
|
||||
+#21#5'Width'#2'K'#0#0#0#0#9'TGroupBox'#19'DestinationGroupBox'#7'Caption'#6
|
||||
+#19'DestinationGroupBox'#12'ClientHeight'#3#143#0#11'ClientWidth'#3#11#1#8'T'
|
||||
+'abOrder'#2#1#4'Left'#2#20#6'Height'#3#160#0#3'Top'#3#210#0#5'Width'#3#15#1#0
|
||||
+#0#0
|
||||
]);
|
||||
|
||||
@ -54,8 +54,9 @@ type
|
||||
TStreamAsXMLForm = class(TForm)
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
GroupBox1: TGroupBox;
|
||||
SourceGroupBox: TGroupBox;
|
||||
GroupBox2: TGroupBox;
|
||||
DestinationGroupBox: TGroupBox;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
FFilename: string;
|
||||
@ -64,6 +65,8 @@ type
|
||||
MyComponent: TMyComponent;
|
||||
procedure WriteComponents;
|
||||
procedure ReadComponents;
|
||||
procedure OnFindComponentClass(Reader: TReader; const AClassName: string;
|
||||
var ComponentClass: TComponentClass);
|
||||
property Filename: string read FFilename write SetFilename;
|
||||
end;
|
||||
|
||||
@ -151,7 +154,7 @@ begin
|
||||
Reader:=CreateXMLReader(XMLConfig.Document,Path,DestroyDriver);
|
||||
|
||||
// get root class
|
||||
AClassName:=Reader.GetRootClassName(IsInherited);
|
||||
AClassName:=(Reader.Driver as TXMLObjectReader).GetRootClassName(IsInherited);
|
||||
if IsInherited then begin
|
||||
// inherited is not supported by this simple function
|
||||
DebugLn('ReadComponentFromXMLConfig WARNING: "inherited" is not supported by this simple function');
|
||||
@ -218,9 +221,9 @@ begin
|
||||
DebugLn('TStreamAsXMLForm.WriteComponents ',Filename);
|
||||
XMLConfig:=TXMLConfig.Create(Filename);
|
||||
try
|
||||
WriteComponentToXMLConfig(XMLConfig,'Component',Self);
|
||||
//WriteComponentToXMLConfig(XMLConfig,'Component',MyComponent);
|
||||
//WriteComponentToXMLConfig(XMLConfig,'Component',GroupBox1);
|
||||
//WriteComponentToXMLConfig(XMLConfig,'Component',Self);
|
||||
WriteComponentToXMLConfig(XMLConfig,'Component',MyComponent);
|
||||
//WriteComponentToXMLConfig(XMLConfig,'Component',GroupBox2);
|
||||
XMLConfig.Flush;
|
||||
finally
|
||||
XMLConfig.Free;
|
||||
@ -242,7 +245,8 @@ begin
|
||||
XMLConfig:=TXMLConfig.Create(Filename);
|
||||
try
|
||||
NewComponent:=nil;
|
||||
ReadComponentFromXMLConfig(XMLConfig,'Component',NewComponent);
|
||||
ReadComponentFromXMLConfig(XMLConfig,'Component',NewComponent,
|
||||
@OnFindComponentClass,DestinationGroupBox);
|
||||
XMLConfig.Flush;
|
||||
finally
|
||||
XMLConfig.Free;
|
||||
@ -254,6 +258,17 @@ begin
|
||||
sl.Free;
|
||||
end;
|
||||
|
||||
procedure TStreamAsXMLForm.OnFindComponentClass(Reader: TReader;
|
||||
const AClassName: string; var ComponentClass: TComponentClass);
|
||||
begin
|
||||
if CompareText(AClassName,'TGroupBox')=0 then
|
||||
ComponentClass:=TGroupBox
|
||||
else if CompareText(AClassName,'TButton')=0 then
|
||||
ComponentClass:=TButton
|
||||
else if CompareText(AClassName,'TMyComponent')=0 then
|
||||
ComponentClass:=TMyComponent;
|
||||
end;
|
||||
|
||||
{ TMyComponent }
|
||||
|
||||
constructor TMyComponent.Create(TheOwner: TComponent);
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
object CodeToolsDefinesEditor: TCodeToolsDefinesEditor
|
||||
Left = 381
|
||||
Height = 461
|
||||
Top = 235
|
||||
Width = 500
|
||||
HorzScrollBar.Page = 499
|
||||
VertScrollBar.Page = 440
|
||||
ActiveControl = DefineTreeView
|
||||
BorderStyle = bsSizeToolWin
|
||||
Caption = 'CodeToolsDefinesEditor'
|
||||
ClientHeight = 441
|
||||
ClientWidth = 500
|
||||
ClientHeight = 476
|
||||
ClientWidth = 544
|
||||
KeyPreview = True
|
||||
Menu = MainMenu
|
||||
OnClose = FormClose
|
||||
OnKeyDown = CodeToolsDefinesEditorKeyDown
|
||||
OnKeyUp = CodeToolsDefinesEditorKeyUp
|
||||
PixelsPerInch = 96
|
||||
PixelsPerInch = 112
|
||||
Position = poScreenCenter
|
||||
HorzScrollBar.Page = 543
|
||||
VertScrollBar.Page = 475
|
||||
Left = 381
|
||||
Height = 500
|
||||
Top = 235
|
||||
Width = 544
|
||||
object DefineTreeView: TTreeView
|
||||
Left = 6
|
||||
Height = 123
|
||||
Top = 6
|
||||
Width = 488
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
DefaultItemHeight = 22
|
||||
@ -28,82 +25,90 @@ object CodeToolsDefinesEditor: TCodeToolsDefinesEditor
|
||||
StateImages = TheImageList
|
||||
TabOrder = 0
|
||||
OnSelectionChanged = DefineTreeViewSelectionChanged
|
||||
Left = 6
|
||||
Height = 123
|
||||
Top = 6
|
||||
Width = 532
|
||||
end
|
||||
object SelectedItemGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 291
|
||||
Top = 144
|
||||
Width = 488
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'SelectedItemGroupBox'
|
||||
ClientHeight = 273
|
||||
ClientWidth = 484
|
||||
ClientHeight = 309
|
||||
ClientWidth = 528
|
||||
TabOrder = 1
|
||||
Left = 6
|
||||
Height = 326
|
||||
Top = 144
|
||||
Width = 532
|
||||
object NameLabel: TLabel
|
||||
Left = 10
|
||||
Height = 14
|
||||
Top = 26
|
||||
Width = 53
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'NameLabel'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object DescriptionLabel: TLabel
|
||||
Left = 10
|
||||
Height = 14
|
||||
Top = 53
|
||||
Width = 79
|
||||
Top = 26
|
||||
Width = 53
|
||||
end
|
||||
object DescriptionLabel: TLabel
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'DescriptionLabel'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
Left = 10
|
||||
Height = 14
|
||||
Top = 53
|
||||
Width = 79
|
||||
end
|
||||
object TypeLabel: TLabel
|
||||
Left = 6
|
||||
Height = 14
|
||||
Top = 6
|
||||
Width = 472
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'TypeLabel'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
Left = 6
|
||||
Height = 14
|
||||
Top = 6
|
||||
Width = 516
|
||||
end
|
||||
object VariableLabel: TLabel
|
||||
Left = 10
|
||||
Height = 14
|
||||
Top = 78
|
||||
Width = 64
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'VariableLabel'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
Left = 10
|
||||
Height = 14
|
||||
Top = 78
|
||||
Width = 64
|
||||
end
|
||||
object ValueNoteBook: TNotebook
|
||||
Left = 6
|
||||
Height = 161
|
||||
Top = 106
|
||||
Width = 472
|
||||
Align = alBottom
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
OnPageChanged = ValueNoteBookPageChanged
|
||||
PageIndex = 1
|
||||
object Page1: TPage
|
||||
Caption = 'Page1'
|
||||
ClientWidth = 464
|
||||
ClientHeight = 135
|
||||
PageIndex = 0
|
||||
Left = 6
|
||||
Height = 197
|
||||
Top = 106
|
||||
Width = 516
|
||||
object ValueAsTextPage: TPage
|
||||
Caption = 'ValueAsTextPage'
|
||||
ClientWidth = 512
|
||||
ClientHeight = 167
|
||||
Left = 2
|
||||
Height = 167
|
||||
Top = 28
|
||||
Width = 512
|
||||
object ValueAsTextSynEdit: TSynEdit
|
||||
Name = 'ValueAsTextSynEdit'
|
||||
Height = 150
|
||||
Width = 464
|
||||
Align = alClient
|
||||
Font.Height = -16
|
||||
Font.Name = 'courier'
|
||||
Height = 167
|
||||
Name = 'ValueAsTextSynEdit'
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
Width = 512
|
||||
BookMarkOptions.Xoffset = -18
|
||||
Gutter.Visible = False
|
||||
Gutter.CodeFoldingWidth = 14
|
||||
@ -432,24 +437,30 @@ object CodeToolsDefinesEditor: TCodeToolsDefinesEditor
|
||||
'ValueAsTextSynEdit'
|
||||
)
|
||||
Options = [eoDragDropEditing, eoHalfPageScroll, eoScrollByOneLess, eoScrollPastEol, eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces, eoBracketHighlight, eoHideRightMargin]
|
||||
Cursor = crIBeam
|
||||
Height = 167
|
||||
Width = 512
|
||||
end
|
||||
end
|
||||
object Page2: TPage
|
||||
Caption = 'Page2'
|
||||
ClientWidth = 464
|
||||
ClientHeight = 135
|
||||
object ValueAsPathsPage: TPage
|
||||
Caption = 'ValueAsPathsPage'
|
||||
ClientWidth = 512
|
||||
ClientHeight = 167
|
||||
Left = 2
|
||||
Height = 167
|
||||
Top = 28
|
||||
Width = 512
|
||||
object ValueAsFilePathsSynEdit: TSynEdit
|
||||
Name = 'ValueAsFilePathsSynEdit'
|
||||
AnchorSideRight.Control = DeleteFilePathBitBtn
|
||||
Height = 135
|
||||
Width = 376
|
||||
Align = alLeft
|
||||
BorderSpacing.Right = 6
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Font.Height = -16
|
||||
Font.Name = 'courier'
|
||||
Height = 167
|
||||
Name = 'ValueAsFilePathsSynEdit'
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
Width = 424
|
||||
BookMarkOptions.Xoffset = -18
|
||||
BookMarkOptions.OnChange = nil
|
||||
Gutter.Visible = False
|
||||
@ -781,94 +792,101 @@ object CodeToolsDefinesEditor: TCodeToolsDefinesEditor
|
||||
)
|
||||
Options = [eoDragDropEditing, eoHalfPageScroll, eoScrollByOneLess, eoScrollPastEol, eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces, eoBracketHighlight, eoHideRightMargin]
|
||||
SelectedColor.OnChange = nil
|
||||
AnchorSideRight.Control = DeleteFilePathBitBtn
|
||||
Cursor = crIBeam
|
||||
Height = 167
|
||||
Width = 424
|
||||
end
|
||||
object MoveFilePathUpBitBtn: TBitBtn
|
||||
Left = 382
|
||||
Height = 30
|
||||
Top = 2
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'MoveFilePathUpBitBtn'
|
||||
NumGlyphs = 0
|
||||
OnClick = MoveFilePathUpBitBtnClick
|
||||
TabOrder = 1
|
||||
Left = 430
|
||||
Height = 30
|
||||
Top = 2
|
||||
Width = 75
|
||||
end
|
||||
object MoveFilePathDownBitBtn: TBitBtn
|
||||
Left = 382
|
||||
Height = 30
|
||||
Top = 34
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'MoveFilePathDownBitBtn'
|
||||
NumGlyphs = 0
|
||||
OnClick = MoveNodeDownMenuItemClick
|
||||
TabOrder = 2
|
||||
Left = 430
|
||||
Height = 30
|
||||
Top = 34
|
||||
Width = 75
|
||||
end
|
||||
object DeleteFilePathBitBtn: TBitBtn
|
||||
Left = 382
|
||||
Height = 30
|
||||
Top = 66
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'DeleteFilePathBitBtn'
|
||||
NumGlyphs = 0
|
||||
OnClick = DeleteFilePathBitBtnClick
|
||||
TabOrder = 3
|
||||
Left = 430
|
||||
Height = 30
|
||||
Top = 66
|
||||
Width = 75
|
||||
end
|
||||
object InsertFilePathBitBtn: TBitBtn
|
||||
Left = 382
|
||||
Height = 30
|
||||
Top = 98
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'InsertFilePathBitBtn'
|
||||
NumGlyphs = 0
|
||||
OnClick = InsertFilePathBitBtnClick
|
||||
TabOrder = 4
|
||||
Left = 430
|
||||
Height = 30
|
||||
Top = 98
|
||||
Width = 75
|
||||
end
|
||||
end
|
||||
end
|
||||
object NameEdit: TEdit
|
||||
Left = 128
|
||||
Height = 20
|
||||
Top = 23
|
||||
Width = 350
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 1
|
||||
Text = 'NameEdit'
|
||||
Left = 128
|
||||
Height = 20
|
||||
Top = 23
|
||||
Width = 394
|
||||
end
|
||||
object DescriptionEdit: TEdit
|
||||
Left = 128
|
||||
Height = 21
|
||||
Top = 50
|
||||
Width = 350
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 2
|
||||
Text = 'DescriptionEdit'
|
||||
end
|
||||
object VariableEdit: TEdit
|
||||
Left = 128
|
||||
Height = 21
|
||||
Top = 76
|
||||
Width = 350
|
||||
Top = 50
|
||||
Width = 394
|
||||
end
|
||||
object VariableEdit: TEdit
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 3
|
||||
Text = 'VariableEdit'
|
||||
Left = 128
|
||||
Height = 21
|
||||
Top = 76
|
||||
Width = 394
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
object MainSplitter: TSplitter
|
||||
Align = alTop
|
||||
Cursor = crVSplit
|
||||
Height = 3
|
||||
Width = 544
|
||||
ResizeAnchor = akTop
|
||||
Cursor = crVSplit
|
||||
Height = 3
|
||||
Top = 135
|
||||
Width = 500
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
Width = 544
|
||||
end
|
||||
object TheImageList: TImageList
|
||||
Height = 22
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -44,12 +44,13 @@ unit CodeToolsDefines;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLIntf, Forms, Controls, Buttons, StdCtrls, ComCtrls,
|
||||
LCLType, ExtCtrls, Menus, LResources, LCLProc, Graphics, Dialogs, SynEdit,
|
||||
Classes, SysUtils, Math, LCLIntf, Forms, Controls, Buttons, StdCtrls,
|
||||
ComCtrls, LCLType, ExtCtrls, Menus, LResources, LCLProc, Graphics, Dialogs,
|
||||
SynEdit,
|
||||
CodeToolManager, DefineTemplates,
|
||||
IDEWindowIntf,
|
||||
LazarusIDEStrConsts, DefineTemplates, CodeToolManager,
|
||||
CodeToolsOptions, CodeToolsDefPreview, TransferMacros, InputFileDialog,
|
||||
IDEOptionDefs, LazConf, IDEProcs;
|
||||
LazarusIDEStrConsts, CodeToolsOptions, CodeToolsDefPreview, TransferMacros,
|
||||
InputFileDialog, IDEOptionDefs, LazConf, IDEProcs;
|
||||
|
||||
type
|
||||
|
||||
@ -70,9 +71,9 @@ type
|
||||
MenuItem29: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MenuItem30: TMenuItem;
|
||||
Page1: TPage;
|
||||
Page2: TPage;
|
||||
Splitter1: TSplitter;
|
||||
ValueAsTextPage: TPage;
|
||||
ValueAsPathsPage: TPage;
|
||||
MainSplitter: TSplitter;
|
||||
TheImageList: TImageList;
|
||||
MainMenu: TMainMenu;
|
||||
|
||||
@ -183,6 +184,7 @@ type
|
||||
procedure CodeToolsDefinesEditorKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
procedure DefineTreeViewSelectionChanged(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
|
||||
// exit menu
|
||||
procedure SaveAndExitMenuItemClick(Sender: TObject);
|
||||
@ -285,7 +287,6 @@ end;
|
||||
|
||||
procedure TCodeToolsDefinesEditor.SaveAndExitMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
SaveSelectedValues;
|
||||
FLastSelectedNode:=nil;
|
||||
ModalResult:=mrOk;
|
||||
@ -293,7 +294,6 @@ end;
|
||||
|
||||
procedure TCodeToolsDefinesEditor.DontSaveAndExitMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
@ -316,6 +316,15 @@ begin
|
||||
ShowSelectedValues;
|
||||
end;
|
||||
|
||||
procedure TCodeToolsDefinesEditor.FormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
if CloseAction=caNone then ;
|
||||
CodeToolsOpts.DefinesEditMainSplitterTop:=MainSplitter.Top;
|
||||
CodeToolsOpts.Save;
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TCodeToolsDefinesEditor.ValueNoteBookPageChanged(Sender: TObject);
|
||||
begin
|
||||
if ValueNoteBook.PageIndex=0 then
|
||||
@ -1523,10 +1532,11 @@ begin
|
||||
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500,460);
|
||||
|
||||
|
||||
Caption:=lisCodeToolsDefsCodeToolsDefinesEditor;
|
||||
|
||||
CreateComponents;
|
||||
MainSplitter.SetSplitterPosition(
|
||||
Max(20,Min(ClientWidth-100,CodeToolsOpts.DefinesEditMainSplitterTop)));
|
||||
|
||||
FDefineTree:=TDefineTree.Create;
|
||||
end;
|
||||
|
||||
@ -42,6 +42,9 @@ uses
|
||||
IDEOptionDefs, EditDefineTree, LazarusIDEStrConsts, IDEProcs;
|
||||
|
||||
type
|
||||
|
||||
{ TCodeToolsOptions }
|
||||
|
||||
TCodeToolsOptions = class
|
||||
private
|
||||
FClassHeaderComments: boolean;
|
||||
@ -55,6 +58,7 @@ type
|
||||
|
||||
// Define Templates
|
||||
FGlobalDefineTemplates: TDefineTemplate;
|
||||
FDefinesEditMainSplitterTop: integer;
|
||||
|
||||
// CodeCreation
|
||||
FAddInheritedCodeToOverrideMethod: boolean;
|
||||
@ -104,6 +108,8 @@ type
|
||||
|
||||
// Define Templates
|
||||
property GlobalDefineTemplates: TDefineTemplate read FGlobalDefineTemplates;
|
||||
property DefinesEditMainSplitterTop: integer read FDefinesEditMainSplitterTop
|
||||
write FDefinesEditMainSplitterTop;
|
||||
|
||||
// CodeCreation
|
||||
property CompleteProperties: boolean
|
||||
@ -371,6 +377,25 @@ procedure TCodeToolsOptions.Load;
|
||||
var
|
||||
XMLConfig: TXMLConfig;
|
||||
FileVersion: integer;
|
||||
|
||||
procedure LoadGlobalDefineTemplates;
|
||||
begin
|
||||
// delete old one
|
||||
ClearGlobalDefineTemplates;
|
||||
// create empty one
|
||||
FGlobalDefineTemplates:=TDefineTemplate.Create;
|
||||
FGlobalDefineTemplates.Name:='';
|
||||
// load
|
||||
FGlobalDefineTemplates.LoadFromXMLConfig(XMLConfig,'CodeToolsGlobalDefines/',
|
||||
true,true);
|
||||
// delete if still empty
|
||||
if FGlobalDefineTemplates.Name='' then begin
|
||||
ClearGlobalDefineTemplates;
|
||||
end else begin
|
||||
FGlobalDefineTemplates.SetDefineOwner(Self,true);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
try
|
||||
XMLConfig:=TXMLConfig.Create(FFileName);
|
||||
@ -388,20 +413,9 @@ begin
|
||||
'CodeToolsOptions/CursorBeyondEOL/Value',true);
|
||||
|
||||
// Define templates
|
||||
// delete old one
|
||||
ClearGlobalDefineTemplates;
|
||||
// create empty one
|
||||
FGlobalDefineTemplates:=TDefineTemplate.Create;
|
||||
FGlobalDefineTemplates.Name:='';
|
||||
// load
|
||||
FGlobalDefineTemplates.LoadFromXMLConfig(XMLConfig,'CodeToolsGlobalDefines/',
|
||||
true,true);
|
||||
// delete if still empty
|
||||
if FGlobalDefineTemplates.Name='' then begin
|
||||
ClearGlobalDefineTemplates;
|
||||
end else begin
|
||||
FGlobalDefineTemplates.SetDefineOwner(Self,true);
|
||||
end;
|
||||
LoadGlobalDefineTemplates;
|
||||
FDefinesEditMainSplitterTop:=XMLConfig.GetValue(
|
||||
'CodeToolsOptions/DefinesEditMainSplitter/Top',100);
|
||||
|
||||
// CodeCreation
|
||||
FAddInheritedCodeToOverrideMethod:=XMLConfig.GetValue(
|
||||
@ -462,6 +476,14 @@ end;
|
||||
procedure TCodeToolsOptions.Save;
|
||||
var
|
||||
XMLConfig: TXMLConfig;
|
||||
|
||||
procedure SaveGlobalDefineTemplates;
|
||||
begin
|
||||
if FGlobalDefineTemplates<>nil then
|
||||
FGlobalDefineTemplates.SaveToXMLConfig(XMLConfig,
|
||||
'CodeToolsGlobalDefines/',true,false,true,false);
|
||||
end;
|
||||
|
||||
begin
|
||||
try
|
||||
InvalidateFileStateCache;
|
||||
@ -479,9 +501,9 @@ begin
|
||||
FCursorBeyondEOL,true);
|
||||
|
||||
// Define templates
|
||||
if FGlobalDefineTemplates<>nil then
|
||||
FGlobalDefineTemplates.SaveToXMLConfig(XMLConfig,
|
||||
'CodeToolsGlobalDefines/',true,false,true,false);
|
||||
SaveGlobalDefineTemplates;
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/DefinesEditMainSplitter/Top',
|
||||
FDefinesEditMainSplitterTop,100);
|
||||
|
||||
// CodeCreation
|
||||
XMLConfig.SetDeleteValue(
|
||||
@ -576,6 +598,7 @@ begin
|
||||
CodeToolsOpts.FGlobalDefineTemplates.CreateCopy(false,true,true);
|
||||
if FGlobalDefineTemplates<>nil then
|
||||
FGlobalDefineTemplates.SetDefineOwner(Self,true);
|
||||
FDefinesEditMainSplitterTop:=CodeToolsOpts.DefinesEditMainSplitterTop;
|
||||
|
||||
// CodeCreation
|
||||
FLineLength:=CodeToolsOpts.FLineLength;
|
||||
@ -612,6 +635,7 @@ begin
|
||||
|
||||
// define templates
|
||||
ClearGlobalDefineTemplates;
|
||||
FDefinesEditMainSplitterTop:=100;
|
||||
|
||||
// CodeCreation
|
||||
FAddInheritedCodeToOverrideMethod:=true;
|
||||
@ -659,6 +683,7 @@ begin
|
||||
// define templates
|
||||
and (FGlobalDefineTemplates.IsEqual(
|
||||
CodeToolsOpts.FGlobalDefineTemplates,true,true))
|
||||
and (FDefinesEditMainSplitterTop=CodeToolsOpts.fDefinesEditMainSplitterTop)
|
||||
|
||||
// CodeCreation
|
||||
and (FLineLength=CodeToolsOpts.FLineLength)
|
||||
|
||||
@ -417,6 +417,8 @@ type
|
||||
procedure AnchorSplitter(Kind: TAnchorKind; AControl: TControl);
|
||||
property ResizeControl: TControl read GetResizeControl write SetResizeControl;
|
||||
function GetOtherResizeControl: TControl;
|
||||
procedure MoveSplitter(Offset: integer);
|
||||
procedure SetSplitterPosition(NewPosition: integer);
|
||||
public
|
||||
property Align default alLeft;
|
||||
property ResizeStyle: TResizeStyle read FResizeStyle write SetResizeStyle default rsUpdate;
|
||||
|
||||
@ -16,106 +16,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
ToDo:
|
||||
- Fix changing Mouse cursor
|
||||
- Fix gtk look
|
||||
- ResizeStyle
|
||||
|
||||
}
|
||||
|
||||
{ TCustomSplitter }
|
||||
|
||||
procedure TCustomSplitter.SetResizeStyle(const AValue: TResizeStyle);
|
||||
begin
|
||||
if FResizeStyle=AValue then exit;
|
||||
FResizeStyle:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetAutoSnap(const AValue: boolean);
|
||||
begin
|
||||
if FAutoSnap=AValue then exit;
|
||||
FAutoSnap:=AValue;
|
||||
end;
|
||||
|
||||
function TCustomSplitter.GetResizeControl: TControl;
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then
|
||||
Result:=FindAlignControl
|
||||
else
|
||||
Result:=AnchorSide[ResizeAnchor].Control;
|
||||
end;
|
||||
|
||||
function TCustomSplitter.GetOtherResizeControl: TControl;
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then
|
||||
Result:=FindAlignOtherControl
|
||||
else
|
||||
Result:=AnchorSide[OppositeAnchor[ResizeAnchor]].Control;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetBeveled(const AValue: boolean);
|
||||
begin
|
||||
if FBeveled=AValue then exit;
|
||||
FBeveled:=AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetMinSize(const AValue: integer);
|
||||
begin
|
||||
if (FMinSize=AValue) or (AValue<1) then exit;
|
||||
FMinSize:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetResizeAnchor(const AValue: TAnchorKind);
|
||||
begin
|
||||
if FResizeAnchor=AValue then exit;
|
||||
FResizeAnchor:=AValue;
|
||||
if ResizeAnchor in [akLeft,akRight] then
|
||||
Cursor := crHSplit
|
||||
else
|
||||
Cursor := crVSplit;
|
||||
if not (csLoading in ComponentState) then begin
|
||||
Align:=alNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetResizeControl(const AValue: TControl);
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then begin
|
||||
if AValue<>nil then begin
|
||||
case Align of
|
||||
alLeft: Left:=AValue.Left+1;
|
||||
alTop: Top:=AValue.Top+1;
|
||||
alRight: Left:=AValue.Left-1;
|
||||
alBottom: Top:=AValue.Top-1;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
AnchorSide[ResizeAnchor].Control:=AValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.StartSplitterMove(Restart: boolean;
|
||||
const MouseXY: TPoint);
|
||||
begin
|
||||
if (not Restart) and FSplitDragging then exit;
|
||||
FSplitDragging := True;
|
||||
fSplitterStartMouseXY := MouseXY;
|
||||
fSplitterStartLeftTop := Point(Left,Top);
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
||||
Y: Integer);
|
||||
var
|
||||
MousePos: TPoint;
|
||||
begin
|
||||
inherited MouseDown(Button, Shift, X, Y);
|
||||
// While resizing X, Y are not valid. Use absolute mouse position.
|
||||
GetCursorPos(MousePos);
|
||||
StartSplitterMove(True,MousePos);
|
||||
end;
|
||||
|
||||
function FindOppositeControl(Control: TControl): TControl;
|
||||
var
|
||||
i,count: Integer;
|
||||
@ -220,7 +122,37 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
{ TCustomSplitter }
|
||||
|
||||
procedure TCustomSplitter.SetResizeStyle(const AValue: TResizeStyle);
|
||||
begin
|
||||
if FResizeStyle=AValue then exit;
|
||||
FResizeStyle:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetAutoSnap(const AValue: boolean);
|
||||
begin
|
||||
if FAutoSnap=AValue then exit;
|
||||
FAutoSnap:=AValue;
|
||||
end;
|
||||
|
||||
function TCustomSplitter.GetResizeControl: TControl;
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then
|
||||
Result:=FindAlignControl
|
||||
else
|
||||
Result:=AnchorSide[ResizeAnchor].Control;
|
||||
end;
|
||||
|
||||
function TCustomSplitter.GetOtherResizeControl: TControl;
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then
|
||||
Result:=FindAlignOtherControl
|
||||
else
|
||||
Result:=AnchorSide[OppositeAnchor[ResizeAnchor]].Control;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.MoveSplitter(Offset: integer);
|
||||
var
|
||||
CurResizeControl,
|
||||
LastControl, VirtualOppositeControl, CurOtherResizeControl: TControl;
|
||||
@ -232,7 +164,7 @@ var
|
||||
akTop, akBottom: Result := Parent.ClientHeight;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetControlMinPos(Control: TControl): Integer;
|
||||
begin
|
||||
if Assigned(Control)
|
||||
@ -247,7 +179,7 @@ var
|
||||
akRight,akBottom: Result := GetParentClientSize;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetControlSize(Control: TControl): Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
@ -257,7 +189,7 @@ var
|
||||
akTop, akBottom: Result := Control.Height;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetControlConstraintsMinSize(Control: TControl): Integer;
|
||||
begin
|
||||
case ResizeAnchor of
|
||||
@ -265,7 +197,7 @@ var
|
||||
akTop, akBottom: Result := Control.Constraints.EffectiveMinHeight;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetControlConstraintsMaxSize(Control: TControl): Integer;
|
||||
begin
|
||||
case ResizeAnchor of
|
||||
@ -305,7 +237,7 @@ var
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function CalcNewSize(StartSize, EndSize, Offset: Integer): Integer;
|
||||
var
|
||||
NewSize: Integer;
|
||||
@ -323,7 +255,7 @@ var
|
||||
then NewSize := StartSize;
|
||||
Result := NewSize;
|
||||
end;
|
||||
|
||||
|
||||
function GetVirtualControlMinPos(Control: TControl): Integer;
|
||||
begin
|
||||
case ResizeAnchor of
|
||||
@ -333,19 +265,7 @@ var
|
||||
akBottom: Result := Control.BoundsRect.Bottom;
|
||||
end;
|
||||
end;
|
||||
|
||||
function CalcOffset(X,Y: Integer): Integer;
|
||||
begin
|
||||
case ResizeAnchor of
|
||||
akLeft, akRight:
|
||||
Result := (X-fSplitterStartMouseXY.X)
|
||||
- (Self.Left-fSplitterStartLeftTop.X);
|
||||
akTop, akBottom:
|
||||
Result := (Y-fSplitterStartMouseXY.Y)
|
||||
- (Self.Top-fSplitterStartLeftTop.Y);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FindClientControl: TControl;
|
||||
var
|
||||
CurControl: TControl;
|
||||
@ -363,7 +283,7 @@ var
|
||||
end;
|
||||
end; // for count
|
||||
end; // function FindClientControl
|
||||
|
||||
|
||||
function FindLastControl(Control: TControl): TControl;
|
||||
var
|
||||
CurControl: TControl;
|
||||
@ -375,7 +295,7 @@ var
|
||||
end;
|
||||
Result := Control;
|
||||
end;
|
||||
|
||||
|
||||
function GetParentsClientLimit: integer;
|
||||
// returns the maximum size of the CurResizeControl due to parent's client
|
||||
// area
|
||||
@ -392,7 +312,7 @@ var
|
||||
Result:=Parent.ClientHeight-CurResizeControl.Top-Height;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function GetParentsClientSize: integer;
|
||||
begin
|
||||
if ResizeAnchor in [akLeft,akRight] then
|
||||
@ -402,137 +322,222 @@ var
|
||||
end;
|
||||
|
||||
var
|
||||
Offset: Integer;
|
||||
StartSize: Integer;
|
||||
EndSize: Integer;
|
||||
NewSize: Integer;
|
||||
MousePos: TPoint;
|
||||
i: Integer;
|
||||
OffsetMaxLower: integer;
|
||||
OffsetMaxUpper: integer;
|
||||
CurMaxShrink: integer;
|
||||
CurMaxEnlarge: integer;
|
||||
begin
|
||||
if Offset = 0 then Exit;
|
||||
|
||||
if Align in [alLeft,alTop,alRight,alBottom] then begin
|
||||
// aligned Splitter
|
||||
// -> consider aligned siblings for minimum and maximum movement
|
||||
|
||||
// get the control to resize
|
||||
CurResizeControl := GetResizeControl;
|
||||
if not Assigned(CurResizeControl) then Exit;
|
||||
CurOtherResizeControl := GetOtherResizeControl;
|
||||
|
||||
// calculate minimum size
|
||||
StartSize := 1;
|
||||
if not fAutoSnap
|
||||
then Inc(StartSize,
|
||||
Max(fMinSize, GetControlConstraintsMinSize(CurResizeControl)));
|
||||
if StartSize > 1 then Dec(StartSize);
|
||||
|
||||
// calculate maximum size
|
||||
if Assigned(CurOtherResizeControl)
|
||||
then EndSize := GetControlSize(CurResizeControl)
|
||||
+ GetControlSize(CurOtherResizeControl)
|
||||
- fMinSize
|
||||
else begin
|
||||
VirtualOppositeControl := FindVirtualOppositeControl(Self);
|
||||
LastControl := FindLastControl(Self);
|
||||
case ResizeAnchor of
|
||||
akLeft, akTop: begin
|
||||
if Assigned(VirtualOppositeControl) then
|
||||
begin
|
||||
EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetControlMinPos(VirtualOppositeControl)
|
||||
- (GetControlMinPos(LastControl)
|
||||
+ GetControlSize(LastControl)));
|
||||
end
|
||||
else EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetParentClientSize
|
||||
- GetControlMinPos(LastControl)
|
||||
- GetControlSize(LastControl))
|
||||
end;
|
||||
|
||||
akRight, akBottom: begin
|
||||
if Assigned(VirtualOppositeControl) then
|
||||
EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetControlMinPos(LastControl)
|
||||
- (GetControlMinPos(VirtualOppositeControl)
|
||||
+ GetControlSize(VirtualOppositeControl)))
|
||||
else EndSize := GetControlSize(CurResizeControl)
|
||||
+ GetControlMinPos(LastControl);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
NewSize := CalcNewSize(StartSize, EndSize, Offset);
|
||||
|
||||
// OnCanResize event
|
||||
if CheckNewSize(NewSize)
|
||||
then SetAlignControlSize(NewSize);
|
||||
|
||||
end else begin
|
||||
// anchored Splitter
|
||||
// -> consider anchored siblings for minimum and maximum movement
|
||||
|
||||
// OffsetMaxLower = maximum the Splitter can be moved top/left
|
||||
OffsetMaxLower := Max(0,GetControlMinPos(Self)-fMinSize);
|
||||
// OffsetMaxUpper = maximum the Splitter can be moved bottom/right
|
||||
OffsetMaxUpper := Max(0,GetParentsClientSize
|
||||
-GetControlSize(Self)-GetControlMinPos(Self));
|
||||
|
||||
for i:=0 to AnchoredControlCount-1 do begin
|
||||
CurResizeControl:=AnchoredControls[i];
|
||||
//debugln('TCustomSplitter.MoveSplitter ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl));
|
||||
if (CurResizeControl.AnchorSide[ResizeAnchor].Control=Self)
|
||||
or (CurResizeControl.AnchorSide[OppositeAnchor[ResizeAnchor]].Control=Self)
|
||||
then begin
|
||||
// this control uses this Splitter as anchor
|
||||
// => moving the Splitter will resize CurResizeControl
|
||||
// => consider the constraints of CurResizeControl
|
||||
// for minimum and maximum movement
|
||||
|
||||
// calculate how much the CurResizeControl can be shrinked
|
||||
CurMaxShrink:=Max(0,GetControlSize(CurResizeControl)-
|
||||
GetControlConstraintsMinSize(CurResizeControl));
|
||||
// calculate how much the CurResizeControl can be enlarged
|
||||
CurMaxEnlarge:=Max(0,GetControlConstraintsMaxSize(CurResizeControl)
|
||||
-GetControlSize(CurResizeControl));
|
||||
if CurMaxEnlarge=0 then
|
||||
CurMaxEnlarge:=GetParentsClientSize;
|
||||
//debugln('TCustomSplitter.MoveSplitter ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl),' CurMaxShrink=',dbgs(CurMaxShrink),' CurMaxEnlarge=',dbgs(CurMaxEnlarge),' ',dbgs(GetControlConstraintsMaxSize(CurResizeControl)));
|
||||
|
||||
// apply to the offset boundaries
|
||||
if (CurResizeControl.AnchorSide[akLeft].Control=Self)
|
||||
or (CurResizeControl.AnchorSide[akTop].Control=Self) then begin
|
||||
OffsetMaxLower:=Min(OffsetMaxLower,CurMaxShrink);
|
||||
OffsetMaxUpper:=Min(OffsetMaxUpper,CurMaxEnlarge);
|
||||
end else begin
|
||||
OffsetMaxLower:=Min(OffsetMaxLower,CurMaxEnlarge);
|
||||
OffsetMaxUpper:=Min(OffsetMaxUpper,CurMaxShrink);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// apply the offset boundaries to the offset
|
||||
Offset:=Max(Min(Offset,OffsetMaxUpper),-OffsetMaxLower);
|
||||
|
||||
// move splitter
|
||||
if ResizeAnchor in [akLeft,akRight] then begin
|
||||
Left:=Left+Offset;
|
||||
end else begin
|
||||
Top:=Top+Offset;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetSplitterPosition(NewPosition: integer);
|
||||
begin
|
||||
if ResizeAnchor in [akLeft,akRight] then
|
||||
MoveSplitter(NewPosition-Left)
|
||||
else
|
||||
MoveSplitter(NewPosition-Top);
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetBeveled(const AValue: boolean);
|
||||
begin
|
||||
if FBeveled=AValue then exit;
|
||||
FBeveled:=AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetMinSize(const AValue: integer);
|
||||
begin
|
||||
if (FMinSize=AValue) or (AValue<1) then exit;
|
||||
FMinSize:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetResizeAnchor(const AValue: TAnchorKind);
|
||||
begin
|
||||
if FResizeAnchor=AValue then exit;
|
||||
FResizeAnchor:=AValue;
|
||||
if ResizeAnchor in [akLeft,akRight] then
|
||||
Cursor := crHSplit
|
||||
else
|
||||
Cursor := crVSplit;
|
||||
if not (csLoading in ComponentState) then begin
|
||||
Align:=alNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.SetResizeControl(const AValue: TControl);
|
||||
begin
|
||||
if Align in [alLeft,alRight,alTop,alBottom] then begin
|
||||
if AValue<>nil then begin
|
||||
case Align of
|
||||
alLeft: Left:=AValue.Left+1;
|
||||
alTop: Top:=AValue.Top+1;
|
||||
alRight: Left:=AValue.Left-1;
|
||||
alBottom: Top:=AValue.Top-1;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
AnchorSide[ResizeAnchor].Control:=AValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.StartSplitterMove(Restart: boolean;
|
||||
const MouseXY: TPoint);
|
||||
begin
|
||||
if (not Restart) and FSplitDragging then exit;
|
||||
FSplitDragging := True;
|
||||
fSplitterStartMouseXY := MouseXY;
|
||||
fSplitterStartLeftTop := Point(Left,Top);
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
||||
Y: Integer);
|
||||
var
|
||||
MousePos: TPoint;
|
||||
begin
|
||||
inherited MouseDown(Button, Shift, X, Y);
|
||||
// While resizing X, Y are not valid. Use absolute mouse position.
|
||||
GetCursorPos(MousePos);
|
||||
StartSplitterMove(True,MousePos);
|
||||
end;
|
||||
|
||||
procedure TCustomSplitter.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
Offset: Integer;
|
||||
MousePos: TPoint;
|
||||
begin
|
||||
inherited MouseMove(Shift, X, Y);
|
||||
if (ssLeft in Shift) and (Parent <> nil) then begin
|
||||
|
||||
// While resizing X, Y are not valid. Use absolute mouse position.
|
||||
// While resizing X, Y are not valid. Use the absolute mouse position.
|
||||
GetCursorPos(MousePos);
|
||||
StartSplitterMove(False,MousePos);
|
||||
|
||||
Offset := CalcOffset(MousePos.X, MousePos.Y);
|
||||
case ResizeAnchor of
|
||||
akLeft, akRight:
|
||||
Offset := (MousePos.X-fSplitterStartMouseXY.X)
|
||||
- (Self.Left-fSplitterStartLeftTop.X);
|
||||
akTop, akBottom:
|
||||
Offset := (MousePos.Y-fSplitterStartMouseXY.Y)
|
||||
- (Self.Top-fSplitterStartLeftTop.Y);
|
||||
end;
|
||||
|
||||
if Offset = 0 then Exit;
|
||||
|
||||
if Align in [alLeft,alTop,alRight,alBottom] then begin
|
||||
// aligned Splitter
|
||||
// -> consider aligned siblings for minimum and maximum movement
|
||||
|
||||
// get the control to resize
|
||||
CurResizeControl := GetResizeControl;
|
||||
if not Assigned(CurResizeControl) then Exit;
|
||||
CurOtherResizeControl := GetOtherResizeControl;
|
||||
|
||||
// calculate minimum size
|
||||
StartSize := 1;
|
||||
if not fAutoSnap
|
||||
then Inc(StartSize,
|
||||
Max(fMinSize, GetControlConstraintsMinSize(CurResizeControl)));
|
||||
if StartSize > 1 then Dec(StartSize);
|
||||
|
||||
// calculate maximum size
|
||||
if Assigned(CurOtherResizeControl)
|
||||
then EndSize := GetControlSize(CurResizeControl)
|
||||
+ GetControlSize(CurOtherResizeControl)
|
||||
- fMinSize
|
||||
else begin
|
||||
VirtualOppositeControl := FindVirtualOppositeControl(Self);
|
||||
LastControl := FindLastControl(Self);
|
||||
case ResizeAnchor of
|
||||
akLeft, akTop: begin
|
||||
if Assigned(VirtualOppositeControl) then
|
||||
begin
|
||||
EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetControlMinPos(VirtualOppositeControl)
|
||||
- (GetControlMinPos(LastControl)
|
||||
+ GetControlSize(LastControl)));
|
||||
end
|
||||
else EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetParentClientSize
|
||||
- GetControlMinPos(LastControl)
|
||||
- GetControlSize(LastControl))
|
||||
end;
|
||||
|
||||
akRight, akBottom: begin
|
||||
if Assigned(VirtualOppositeControl) then
|
||||
EndSize := GetControlSize(CurResizeControl)
|
||||
+ (GetControlMinPos(LastControl)
|
||||
- (GetControlMinPos(VirtualOppositeControl)
|
||||
+ GetControlSize(VirtualOppositeControl)))
|
||||
else EndSize := GetControlSize(CurResizeControl)
|
||||
+ GetControlMinPos(LastControl);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
NewSize := CalcNewSize(StartSize, EndSize, Offset);
|
||||
|
||||
// OnCanResize event
|
||||
if CheckNewSize(NewSize)
|
||||
then SetAlignControlSize(NewSize);
|
||||
|
||||
end else begin
|
||||
// anchored Splitter
|
||||
// -> consider anchored siblings for minimum and maximum movement
|
||||
|
||||
// OffsetMaxLower = maximum the Splitter can be moved top/left
|
||||
OffsetMaxLower := Max(0,GetControlMinPos(Self)-fMinSize);
|
||||
// OffsetMaxUpper = maximum the Splitter can be moved bottom/right
|
||||
OffsetMaxUpper := Max(0,GetParentsClientSize
|
||||
-GetControlSize(Self)-GetControlMinPos(Self));
|
||||
|
||||
for i:=0 to AnchoredControlCount-1 do begin
|
||||
CurResizeControl:=AnchoredControls[i];
|
||||
//debugln('TCustomSplitter.MouseMove ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl));
|
||||
if (CurResizeControl.AnchorSide[ResizeAnchor].Control=Self)
|
||||
or (CurResizeControl.AnchorSide[OppositeAnchor[ResizeAnchor]].Control=Self)
|
||||
then begin
|
||||
// this control uses this Splitter as anchor
|
||||
// => moving the Splitter will resize CurResizeControl
|
||||
// => consider the constraints of CurResizeControl
|
||||
// for minimum and maximum movement
|
||||
|
||||
// calculate how much the CurResizeControl can be shrinked
|
||||
CurMaxShrink:=Max(0,GetControlSize(CurResizeControl)-
|
||||
GetControlConstraintsMinSize(CurResizeControl));
|
||||
// calculate how much the CurResizeControl can be enlarged
|
||||
CurMaxEnlarge:=Max(0,GetControlConstraintsMaxSize(CurResizeControl)
|
||||
-GetControlSize(CurResizeControl));
|
||||
if CurMaxEnlarge=0 then
|
||||
CurMaxEnlarge:=GetParentsClientSize;
|
||||
//debugln('TCustomSplitter.MouseMove ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl),' CurMaxShrink=',dbgs(CurMaxShrink),' CurMaxEnlarge=',dbgs(CurMaxEnlarge),' ',dbgs(GetControlConstraintsMaxSize(CurResizeControl)));
|
||||
|
||||
// apply to the offset boundaries
|
||||
if (CurResizeControl.AnchorSide[akLeft].Control=Self)
|
||||
or (CurResizeControl.AnchorSide[akTop].Control=Self) then begin
|
||||
OffsetMaxLower:=Min(OffsetMaxLower,CurMaxShrink);
|
||||
OffsetMaxUpper:=Min(OffsetMaxUpper,CurMaxEnlarge);
|
||||
end else begin
|
||||
OffsetMaxLower:=Min(OffsetMaxLower,CurMaxEnlarge);
|
||||
OffsetMaxUpper:=Min(OffsetMaxUpper,CurMaxShrink);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// apply the offset boundaries to the offset
|
||||
Offset:=Max(Min(Offset,OffsetMaxUpper),-OffsetMaxLower);
|
||||
|
||||
// move splitter
|
||||
if ResizeAnchor in [akLeft,akRight] then begin
|
||||
Left:=Left+Offset;
|
||||
end else begin
|
||||
Top:=Top+Offset;
|
||||
end;
|
||||
end;
|
||||
MoveSplitter(Offset);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user