mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-02 16:51:03 +02:00
started saving of anchor docking state
git-svn-id: trunk@8750 -
This commit is contained in:
parent
b146339036
commit
31550f7501
@ -1,11 +1,12 @@
|
||||
object DockForm1: TDockForm1
|
||||
object MainForm: TMainForm
|
||||
Left = 292
|
||||
Height = 300
|
||||
Top = 209
|
||||
Width = 400
|
||||
HorzScrollBar.Page = 399
|
||||
VertScrollBar.Page = 299
|
||||
Caption = 'DockForm1'
|
||||
ActiveControl = CreateNewFormButton
|
||||
Caption = 'MainForm'
|
||||
ClientHeight = 300
|
||||
ClientWidth = 400
|
||||
OnCreate = FormCreate
|
||||
@ -27,9 +28,5 @@ object DockForm1: TDockForm1
|
||||
object MainPopupMenu: TPopupMenu
|
||||
left = 142
|
||||
top = 141
|
||||
object HideMenuItem: TMenuItem
|
||||
Caption = 'Hide Form'
|
||||
OnClick = HideMenuItemClick
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,15 +1,14 @@
|
||||
{ Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei }
|
||||
|
||||
LazarusResources.Add('TDockForm1','FORMDATA',[
|
||||
'TPF0'#10'TDockForm1'#9'DockForm1'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3
|
||||
+#209#0#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'
|
||||
+#3'+'#1#7'Caption'#6#9'DockForm1'#12'ClientHeight'#3','#1#11'ClientWidth'#3
|
||||
+#144#1#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnPaint'
|
||||
+#7#9'FormPaint'#13'PixelsPerInch'#2'_'#9'PopupMenu'#7#13'MainPopupMenu'#0#7
|
||||
+'TButton'#19'CreateNewFormButton'#4'Left'#2'8'#6'Height'#2#26#3'Top'#2'"'#5
|
||||
+'Width'#3#135#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6
|
||||
+#19'CreateNewFormButton'#7'OnClick'#7#24'CreateNewFormButtonClick'#8'TabOrde'
|
||||
+'r'#2#0#0#0#10'TPopupMenu'#13'MainPopupMenu'#4'left'#3#142#0#3'top'#3#141#0#0
|
||||
+#9'TMenuItem'#12'HideMenuItem'#7'Caption'#6#9'Hide Form'#7'OnClick'#7#17'Hid'
|
||||
+'eMenuItemClick'#0#0#0#0
|
||||
LazarusResources.Add('TMainForm','FORMDATA',[
|
||||
'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3#209#0
|
||||
+#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'
|
||||
+#1#13'ActiveControl'#7#19'CreateNewFormButton'#7'Caption'#6#8'MainForm'#12'C'
|
||||
+'lientHeight'#3','#1#11'ClientWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#9
|
||||
+'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#13'PixelsPerInch'#2
|
||||
+'_'#9'PopupMenu'#7#13'MainPopupMenu'#0#7'TButton'#19'CreateNewFormButton'#4
|
||||
+'Left'#2'8'#6'Height'#2#26#3'Top'#2'"'#5'Width'#3#135#0#8'AutoSize'#9#25'Bor'
|
||||
+'derSpacing.InnerBorder'#2#2#7'Caption'#6#19'CreateNewFormButton'#7'OnClick'
|
||||
+#7#24'CreateNewFormButtonClick'#8'TabOrder'#2#0#0#0#10'TPopupMenu'#13'MainPo'
|
||||
+'pupMenu'#4'left'#3#142#0#3'top'#3#141#0#0#0#0
|
||||
]);
|
||||
|
@ -6,21 +6,19 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
DockForm2Unit, Buttons, LDockTree, Menus, LDockCtrl;
|
||||
DockForm2Unit, Buttons, Menus, LDockCtrl;
|
||||
|
||||
type
|
||||
|
||||
{ TDockForm1 }
|
||||
{ TMainForm }
|
||||
|
||||
TDockForm1 = class(TForm)
|
||||
TMainForm = class(TForm)
|
||||
CreateNewFormButton: TButton;
|
||||
MainPopupMenu: TPopupMenu;
|
||||
HideMenuItem: TMenuItem;
|
||||
procedure CreateNewFormButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure HideMenuItemClick(Sender: TObject);
|
||||
private
|
||||
function CreateNewForm: TCustomForm;
|
||||
public
|
||||
@ -29,37 +27,32 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
DockForm1: TDockForm1;
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{ TDockForm1 }
|
||||
{ TMainForm }
|
||||
|
||||
procedure TDockForm1.FormPaint(Sender: TObject);
|
||||
procedure TMainForm.FormPaint(Sender: TObject);
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
PaintBoundaries(Self,clBlue);
|
||||
end;
|
||||
|
||||
procedure TDockForm1.HideMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
Hide;
|
||||
end;
|
||||
|
||||
function TDockForm1.CreateNewForm: TCustomForm;
|
||||
function TMainForm.CreateNewForm: TCustomForm;
|
||||
begin
|
||||
Result:=TDockFormX.Create(Self);
|
||||
TDockFormX(Result).Docker.Manager:=DockingManager;
|
||||
TDockFormX(Result).Caption:=TDockFormX(Result).Docker.DockerName;
|
||||
end;
|
||||
|
||||
procedure TDockForm1.CreateNewFormButtonClick(Sender: TObject);
|
||||
procedure TMainForm.CreateNewFormButtonClick(Sender: TObject);
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
CreateNewForm;
|
||||
end;
|
||||
|
||||
procedure TDockForm1.FormCreate(Sender: TObject);
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
Form2: TCustomForm;
|
||||
Form3: TCustomForm;
|
||||
@ -76,7 +69,7 @@ begin
|
||||
DockingManager.Manager.InsertControl(Form3,alBottom,Self);
|
||||
end;
|
||||
|
||||
procedure TDockForm1.FormDestroy(Sender: TObject);
|
||||
procedure TMainForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
DockingManager.Free;
|
||||
|
@ -1,4 +1,10 @@
|
||||
object DockFormX: TDockFormX
|
||||
Left = 490
|
||||
Height = 127
|
||||
Top = 215
|
||||
Width = 224
|
||||
HorzScrollBar.Page = 223
|
||||
VertScrollBar.Page = 126
|
||||
ActiveControl = Button1
|
||||
Caption = 'DockFormX'
|
||||
ChildSizing.LeftRightSpacing = 1
|
||||
@ -10,34 +16,32 @@ object DockFormX: TDockFormX
|
||||
PixelsPerInch = 95
|
||||
PopupMenu = PopupMenu1
|
||||
Visible = True
|
||||
HorzScrollBar.Page = 223
|
||||
VertScrollBar.Page = 126
|
||||
Left = 490
|
||||
Height = 127
|
||||
Top = 215
|
||||
Width = 224
|
||||
object Button1: TButton
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'Button1'
|
||||
TabOrder = 0
|
||||
Left = 24
|
||||
Height = 25
|
||||
Top = 48
|
||||
Width = 75
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Caption = 'Button1'
|
||||
TabOrder = 0
|
||||
end
|
||||
object GroupBox1: TGroupBox
|
||||
Left = 118
|
||||
Height = 125
|
||||
Top = 1
|
||||
Width = 105
|
||||
Align = alRight
|
||||
Caption = 'GroupBox1'
|
||||
ClientHeight = 108
|
||||
ClientWidth = 101
|
||||
TabOrder = 1
|
||||
Left = 118
|
||||
Height = 125
|
||||
Top = 1
|
||||
Width = 105
|
||||
end
|
||||
object PopupMenu1: TPopupMenu
|
||||
left = 86
|
||||
top = 52
|
||||
object HideMenuItem: TMenuItem
|
||||
Caption = 'Hide'
|
||||
OnClick = HideMenuItemClick
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,16 +1,17 @@
|
||||
{ Dies ist eine automatisch erzeugte Lazarus-Ressourcendatei }
|
||||
|
||||
LazarusResources.Add('TDockFormX','FORMDATA',[
|
||||
'TPF0'#10'TDockFormX'#9'DockFormX'#13'ActiveControl'#7#7'Button1'#7'Caption'#6
|
||||
+#9'DockFormX'#28'ChildSizing.LeftRightSpacing'#2#1#28'ChildSizing.TopBottomS'
|
||||
+'pacing'#2#1#12'ClientHeight'#2''#11'ClientWidth'#3#224#0#8'OnCreate'#7#10
|
||||
+'FormCreate'#7'OnPaint'#7#9'FormPaint'#13'PixelsPerInch'#2'_'#9'PopupMenu'#7
|
||||
+#10'PopupMenu1'#7'Visible'#9#18'HorzScrollBar.Page'#3#223#0#18'VertScrollBar'
|
||||
+'.Page'#2'~'#4'Left'#3#234#1#6'Height'#2''#3'Top'#3#215#0#5'Width'#3#224#0#0
|
||||
+#7'TButton'#7'Button1'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#7'Butt'
|
||||
+'on1'#8'TabOrder'#2#0#4'Left'#2#24#6'Height'#2#25#3'Top'#2'0'#5'Width'#2'K'#0
|
||||
+#0#9'TGroupBox'#9'GroupBox1'#5'Align'#7#7'alRight'#7'Caption'#6#9'GroupBox1'
|
||||
+#12'ClientHeight'#2'l'#11'ClientWidth'#2'e'#8'TabOrder'#2#1#4'Left'#2'v'#6'H'
|
||||
+'eight'#2'}'#3'Top'#2#1#5'Width'#2'i'#0#0#10'TPopupMenu'#10'PopupMenu1'#4'le'
|
||||
+'ft'#2'V'#3'top'#2'4'#0#0#0
|
||||
'TPF0'#10'TDockFormX'#9'DockFormX'#4'Left'#3#234#1#6'Height'#2''#3'Top'#3#215
|
||||
+#0#5'Width'#3#224#0#18'HorzScrollBar.Page'#3#223#0#18'VertScrollBar.Page'#2
|
||||
+'~'#13'ActiveControl'#7#7'Button1'#7'Caption'#6#9'DockFormX'#28'ChildSizing.'
|
||||
+'LeftRightSpacing'#2#1#28'ChildSizing.TopBottomSpacing'#2#1#12'ClientHeight'
|
||||
+#2''#11'ClientWidth'#3#224#0#8'OnCreate'#7#10'FormCreate'#7'OnPaint'#7#9'Fo'
|
||||
+'rmPaint'#13'PixelsPerInch'#2'_'#9'PopupMenu'#7#10'PopupMenu1'#7'Visible'#9#0
|
||||
+#7'TButton'#7'Button1'#4'Left'#2#24#6'Height'#2#25#3'Top'#2'0'#5'Width'#2'K'
|
||||
+#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#7'Button1'#8'TabOrder'#2#0#0
|
||||
+#0#9'TGroupBox'#9'GroupBox1'#4'Left'#2'v'#6'Height'#2'}'#3'Top'#2#1#5'Width'
|
||||
+#2'i'#5'Align'#7#7'alRight'#7'Caption'#6#9'GroupBox1'#12'ClientHeight'#2'l'
|
||||
+#11'ClientWidth'#2'e'#8'TabOrder'#2#1#0#0#10'TPopupMenu'#10'PopupMenu1'#4'le'
|
||||
+'ft'#2'V'#3'top'#2'4'#0#9'TMenuItem'#12'HideMenuItem'#7'Caption'#6#4'Hide'#7
|
||||
+'OnClick'#7#17'HideMenuItemClick'#0#0#0#0
|
||||
]);
|
||||
|
@ -15,9 +15,11 @@ type
|
||||
TDockFormX = class(TForm)
|
||||
Button1: TButton;
|
||||
GroupBox1: TGroupBox;
|
||||
HideMenuItem: TMenuItem;
|
||||
PopupMenu1: TPopupMenu;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure HideMenuItemClick(Sender: TObject);
|
||||
private
|
||||
public
|
||||
Docker: TLazControlDocker;
|
||||
@ -45,6 +47,12 @@ begin
|
||||
PaintBoundaries(Self,clRed);
|
||||
end;
|
||||
|
||||
procedure TDockFormX.HideMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
Hide;
|
||||
end;
|
||||
|
||||
procedure TDockFormX.FormCreate(Sender: TObject);
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
|
@ -34,7 +34,7 @@
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="dockform1unit.pas"/>
|
||||
<ComponentName Value="DockForm1"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceFilename Value="dockform1unit.lrs"/>
|
||||
<UnitName Value="DockForm1Unit"/>
|
||||
|
@ -9,7 +9,7 @@ uses
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TDockForm1, DockForm1);
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
@ -731,7 +731,8 @@ type
|
||||
TControlHandlerType = (
|
||||
chtOnResize,
|
||||
chtOnChangeBounds,
|
||||
chtVisibleChanging
|
||||
chtOnVisibleChanging,
|
||||
chtOnVisibleChanged
|
||||
);
|
||||
|
||||
{* Note on TControl.Caption
|
||||
@ -1030,6 +1031,7 @@ type
|
||||
Function GetPopupMenu: TPopupMenu; dynamic;
|
||||
procedure DoOnShowHint(HintInfo: Pointer);
|
||||
procedure VisibleChanging; dynamic;
|
||||
procedure VisibleChanged; dynamic;
|
||||
procedure AddHandler(HandlerType: TControlHandlerType;
|
||||
const AMethod: TMethod; AsLast: boolean = false);
|
||||
procedure RemoveHandler(HandlerType: TControlHandlerType;
|
||||
@ -1173,6 +1175,12 @@ type
|
||||
procedure AddHandlerOnChangeBounds(const OnChangeBoundsEvent: TNotifyEvent;
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnChangeBounds(const OnChangeBoundsEvent: TNotifyEvent);
|
||||
procedure AddHandlerOnVisibleChanging(const OnVisibleChangingEvent: TNotifyEvent;
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnVisibleChanging(const OnVisibleChangingEvent: TNotifyEvent);
|
||||
procedure AddHandlerOnVisibleChanged(const OnVisibleChangedEvent: TNotifyEvent;
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnVisibleChanged(const OnVisibleChangedEvent: TNotifyEvent);
|
||||
public
|
||||
// standard properties, which should be supported by all descendants
|
||||
property Action: TBasicAction read GetAction write SetAction;
|
||||
|
@ -848,13 +848,9 @@ end;
|
||||
Call events
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.DoOnResize;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if Assigned(FOnResize) then FOnResize(Self);
|
||||
i:=FControlHandlers[chtOnResize].Count;
|
||||
while FControlHandlers[chtOnResize].NextDownIndex(i) do
|
||||
TNotifyEvent(FControlHandlers[chtOnResize][i])(Self);
|
||||
DoCallNotifyHandler(chtOnResize);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -863,13 +859,9 @@ end;
|
||||
Call events
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.DoOnChangeBounds;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if Assigned(FOnChangeBounds) then FOnChangeBounds(Self);
|
||||
i:=FControlHandlers[chtOnChangeBounds].Count;
|
||||
while FControlHandlers[chtOnChangeBounds].NextDownIndex(i) do
|
||||
TNotifyEvent(FControlHandlers[chtOnChangeBounds][i])(Self);
|
||||
DoCallNotifyHandler(chtOnChangeBounds);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1296,7 +1288,12 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.VisibleChanging;
|
||||
begin
|
||||
DoCallNotifyHandler(chtOnVisibleChanging);
|
||||
end;
|
||||
|
||||
procedure TControl.VisibleChanged;
|
||||
begin
|
||||
DoCallNotifyHandler(chtOnVisibleChanged);
|
||||
end;
|
||||
|
||||
procedure TControl.AddHandler(HandlerType: TControlHandlerType;
|
||||
@ -1314,8 +1311,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TControl.DoCallNotifyHandler(HandlerType: TControlHandlerType);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
|
||||
i:=FControlHandlers[HandlerType].Count;
|
||||
while FControlHandlers[HandlerType].NextDownIndex(i) do
|
||||
TNotifyEvent(FControlHandlers[HandlerType][i])(Self);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -2972,12 +2973,16 @@ begin
|
||||
if FVisible <> Value then begin
|
||||
VisibleChanging;
|
||||
FVisible := Value;
|
||||
Perform(CM_VISIBLECHANGED, WParam(Ord(Value)), 0);
|
||||
Include(FControlFlags,cfRequestAlignNeeded);
|
||||
if FVisible then
|
||||
AdjustSize;
|
||||
if cfRequestAlignNeeded in FControlFlags then
|
||||
RequestAlign;
|
||||
try
|
||||
Perform(CM_VISIBLECHANGED, WParam(Ord(Value)), 0);
|
||||
Include(FControlFlags,cfRequestAlignNeeded);
|
||||
if FVisible then
|
||||
AdjustSize;
|
||||
if cfRequestAlignNeeded in FControlFlags then
|
||||
RequestAlign;
|
||||
finally
|
||||
VisibleChanged;
|
||||
end;
|
||||
end;
|
||||
if (csLoading in ComponentState) then
|
||||
ControlState:=ControlState+[csVisibleSetInLoading];
|
||||
@ -3251,6 +3256,30 @@ begin
|
||||
RemoveHandler(chtOnChangeBounds,TMethod(OnChangeBoundsEvent));
|
||||
end;
|
||||
|
||||
procedure TControl.AddHandlerOnVisibleChanging(
|
||||
const OnVisibleChangingEvent: TNotifyEvent; AsLast: boolean);
|
||||
begin
|
||||
AddHandler(chtOnVisibleChanging,TMethod(OnVisibleChangingEvent));
|
||||
end;
|
||||
|
||||
procedure TControl.RemoveHandlerOnVisibleChanging(
|
||||
const OnVisibleChangingEvent: TNotifyEvent);
|
||||
begin
|
||||
RemoveHandler(chtOnVisibleChanging,TMethod(OnVisibleChangingEvent));
|
||||
end;
|
||||
|
||||
procedure TControl.AddHandlerOnVisibleChanged(
|
||||
const OnVisibleChangedEvent: TNotifyEvent; AsLast: boolean);
|
||||
begin
|
||||
AddHandler(chtOnVisibleChanged,TMethod(OnVisibleChangedEvent));
|
||||
end;
|
||||
|
||||
procedure TControl.RemoveHandlerOnVisibleChanged(
|
||||
const OnVisibleChangedEvent: TNotifyEvent);
|
||||
begin
|
||||
RemoveHandler(chtOnVisibleChanged,TMethod(OnVisibleChangedEvent));
|
||||
end;
|
||||
|
||||
procedure TControl.RemoveAllHandlersOfObject(AnObject: TObject);
|
||||
var
|
||||
HandlerType: TControlHandlerType;
|
||||
|
@ -35,6 +35,45 @@ uses
|
||||
LDockCtrlEdit, LDockTree;
|
||||
|
||||
type
|
||||
TLDConfigNodeType = (
|
||||
ldcntControl,
|
||||
ldcntSplitter,
|
||||
ldcntPages,
|
||||
ldcntPage
|
||||
);
|
||||
|
||||
{ TLazDockConfigNode }
|
||||
|
||||
TLazDockConfigNode = class
|
||||
private
|
||||
FBounds: TRect;
|
||||
FName: string;
|
||||
FParent: TLazDockConfigNode;
|
||||
FSides: array[TAnchorKind] of TLazDockConfigNode;
|
||||
FTheType: TLDConfigNodeType;
|
||||
FChilds: TFPList;
|
||||
function GetChildCount: Integer;
|
||||
function GetChilds(Index: integer): TLazDockConfigNode;
|
||||
function GetSides(Side: TAnchorKind): TLazDockConfigNode;
|
||||
procedure SetBounds(const AValue: TRect);
|
||||
procedure SetName(const AValue: string);
|
||||
procedure SetParent(const AValue: TLazDockConfigNode);
|
||||
procedure SetSides(Side: TAnchorKind; const AValue: TLazDockConfigNode);
|
||||
procedure SetTheType(const AValue: TLDConfigNodeType);
|
||||
public
|
||||
constructor Create(const AName: string);
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
public
|
||||
property TheType: TLDConfigNodeType read FTheType write SetTheType;
|
||||
property Name: string read FName write SetName;
|
||||
property Bounds: TRect read FBounds write SetBounds;
|
||||
property Parent: TLazDockConfigNode read FParent write SetParent;
|
||||
property Sides[Side: TAnchorKind]: TLazDockConfigNode read GetSides write SetSides;
|
||||
property ChildCount: Integer read GetChildCount;
|
||||
property Childs[Index: integer]: TLazDockConfigNode read GetChilds;
|
||||
end;
|
||||
|
||||
TCustomLazControlDocker = class;
|
||||
|
||||
{ TCustomLazDockingManager }
|
||||
@ -53,9 +92,12 @@ type
|
||||
destructor Destroy; override;
|
||||
function FindDockerByName(const ADockerName: string;
|
||||
Ignore: TCustomLazControlDocker): TCustomLazControlDocker;
|
||||
function FindDockerByControl(AControl: TControl;
|
||||
Ignore: TCustomLazControlDocker): TCustomLazControlDocker;
|
||||
function CreateUniqueName(const AName: string;
|
||||
Ignore: TCustomLazControlDocker): string;
|
||||
procedure SaveToStream(Stream: TStream);
|
||||
function GetControlConfigName(AControl: TControl): string;
|
||||
public
|
||||
property Manager: TAnchoredDockManager read FManager;
|
||||
property DockerCount: Integer read GetDockerCount;
|
||||
@ -72,6 +114,8 @@ type
|
||||
|
||||
TCustomLazControlDocker = class(TComponent)
|
||||
private
|
||||
FConfigRootNode: TLazDockConfigNode;
|
||||
FConfigSelfNode: TLazDockConfigNode;
|
||||
FControl: TControl;
|
||||
FDockerName: string;
|
||||
FExtendPopupMenu: boolean;
|
||||
@ -89,6 +133,10 @@ type
|
||||
procedure Loaded; override;
|
||||
procedure ShowDockingEditor; virtual;
|
||||
function GetLocalizedName: string;
|
||||
procedure ControlVisibleChanging(Sender: TObject);
|
||||
procedure ControlVisibleChanged(Sender: TObject);
|
||||
procedure GetLayoutFromControl;
|
||||
procedure ClearConfigNodes;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
property Control: TControl read FControl write SetControl;
|
||||
@ -97,6 +145,8 @@ type
|
||||
property PopupMenuItem: TMenuItem read FPopupMenuItem;
|
||||
property LocalizedName: string read FLocalizedName write SetLocalizedName;
|
||||
property DockerName: string read FDockerName write SetDockerName;
|
||||
property ConfigRootNode: TLazDockConfigNode read FConfigRootNode;
|
||||
property ConfigSelfNode: TLazDockConfigNode read FConfigSelfNode;
|
||||
end;
|
||||
|
||||
{ TLazControlDocker }
|
||||
@ -251,6 +301,96 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomLazControlDocker.ControlVisibleChanging(Sender: TObject);
|
||||
begin
|
||||
if Control<>Sender then begin
|
||||
DebugLn('TCustomLazControlDocker.ControlVisibleChanging WARNING: ',
|
||||
DbgSName(Control),'<>',DbgSName(Sender));
|
||||
exit;
|
||||
end;
|
||||
if Control.Visible then begin
|
||||
// control will be hidden -> the layout will change
|
||||
// save the layout for restore
|
||||
GetLayoutFromControl;
|
||||
end else begin
|
||||
// the control will become visible -> dock it to restore the last layout
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomLazControlDocker.ControlVisibleChanged(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCustomLazControlDocker.GetLayoutFromControl;
|
||||
|
||||
function AddNode(AControl: TControl): TLazDockConfigNode;
|
||||
var
|
||||
i: Integer;
|
||||
CurChildControl: TControl;
|
||||
NeedChildNodes: boolean;
|
||||
begin
|
||||
Result:=TLazDockConfigNode.Create(Manager.GetControlConfigName(AControl));
|
||||
if AControl=Control then
|
||||
FConfigSelfNode:=Result;
|
||||
|
||||
// The Type
|
||||
if AControl is TLazDockSplitter then
|
||||
Result.FTheType:=ldcntSplitter
|
||||
else if AControl is TLazDockPages then
|
||||
Result.FTheType:=ldcntPages
|
||||
else if AControl is TLazDockPage then
|
||||
Result.FTheType:=ldcntPage
|
||||
else
|
||||
Result.FTheType:=ldcntControl;
|
||||
|
||||
// Bounds
|
||||
Result.FBounds:=AControl.BoundsRect;
|
||||
|
||||
// Childs
|
||||
if (AControl is TWinControl) then begin
|
||||
// check if childs need nodes
|
||||
NeedChildNodes:=(AControl is TLazDockPages)
|
||||
or (AControl is TLazDockPage);
|
||||
if not NeedChildNodes then begin
|
||||
for i:=0 to TWinControl(AControl).ControlCount-1 do begin
|
||||
CurChildControl:=TWinControl(AControl).Controls[i];
|
||||
if Manager.GetControlConfigName(CurChildControl)<>'' then begin
|
||||
NeedChildNodes:=true;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// add child nodes
|
||||
if NeedChildNodes then begin
|
||||
for i:=0 to TWinControl(AControl).ControlCount-1 do begin
|
||||
CurChildControl:=TWinControl(AControl).Controls[i];
|
||||
AddNode(CurChildControl);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
RootControl: TControl;
|
||||
begin
|
||||
ClearConfigNodes;
|
||||
if (Control=nil) or (Manager=nil) then exit;
|
||||
|
||||
RootControl:=Control;
|
||||
while RootControl<>nil do RootControl:=RootControl.Parent;
|
||||
FConfigRootNode:=AddNode(RootControl);
|
||||
end;
|
||||
|
||||
procedure TCustomLazControlDocker.ClearConfigNodes;
|
||||
begin
|
||||
FConfigSelfNode:=nil;
|
||||
FConfigRootNode.Free;
|
||||
FConfigRootNode:=nil;
|
||||
end;
|
||||
|
||||
constructor TCustomLazControlDocker.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
@ -269,7 +409,13 @@ end;
|
||||
procedure TCustomLazControlDocker.SetControl(const AValue: TControl);
|
||||
begin
|
||||
if FControl=AValue then exit;
|
||||
if FControl<>nil then
|
||||
FControl.RemoveAllHandlersOfObject(Self);
|
||||
FControl:=AValue;
|
||||
if FControl=nil then begin
|
||||
FControl.AddHandlerOnVisibleChanging(@ControlVisibleChanging);
|
||||
FControl.AddHandlerOnVisibleChanged(@ControlVisibleChanged);
|
||||
end;
|
||||
if DockerName='' then
|
||||
DockerName:=AValue.Name;
|
||||
UpdatePopupMenu;
|
||||
@ -356,6 +502,21 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TCustomLazDockingManager.FindDockerByControl(AControl: TControl;
|
||||
Ignore: TCustomLazControlDocker): TCustomLazControlDocker;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=DockerCount-1;
|
||||
while (i>=0) do begin
|
||||
Result:=Dockers[i];
|
||||
if (Result.Control=AControl) and (Ignore<>Result) then
|
||||
exit;
|
||||
dec(i);
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TCustomLazDockingManager.CreateUniqueName(const AName: string;
|
||||
Ignore: TCustomLazControlDocker): string;
|
||||
begin
|
||||
@ -371,5 +532,86 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
function TCustomLazDockingManager.GetControlConfigName(AControl: TControl
|
||||
): string;
|
||||
var
|
||||
Docker: TCustomLazControlDocker;
|
||||
begin
|
||||
Docker:=FindDockerByControl(AControl,nil);
|
||||
if Docker<>nil then
|
||||
Result:=Docker.Name
|
||||
else
|
||||
Result:=''
|
||||
end;
|
||||
|
||||
{ TLazDockConfigNode }
|
||||
|
||||
function TLazDockConfigNode.GetSides(Side: TAnchorKind): TLazDockConfigNode;
|
||||
begin
|
||||
Result:=FSides[Side];
|
||||
end;
|
||||
|
||||
function TLazDockConfigNode.GetChildCount: Integer;
|
||||
begin
|
||||
Result:=FChilds.Count;
|
||||
end;
|
||||
|
||||
function TLazDockConfigNode.GetChilds(Index: integer): TLazDockConfigNode;
|
||||
begin
|
||||
Result:=TLazDockConfigNode(FChilds[Index]);
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.SetBounds(const AValue: TRect);
|
||||
begin
|
||||
if CompareRect(@FBounds,@AValue) then exit;
|
||||
FBounds:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.SetName(const AValue: string);
|
||||
begin
|
||||
if FName=AValue then exit;
|
||||
FName:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.SetParent(const AValue: TLazDockConfigNode);
|
||||
begin
|
||||
if FParent=AValue then exit;
|
||||
FParent:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.SetSides(Side: TAnchorKind;
|
||||
const AValue: TLazDockConfigNode);
|
||||
begin
|
||||
FSides[Side]:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.SetTheType(const AValue: TLDConfigNodeType);
|
||||
begin
|
||||
if FTheType=AValue then exit;
|
||||
FTheType:=AValue;
|
||||
end;
|
||||
|
||||
constructor TLazDockConfigNode.Create(const AName: string);
|
||||
begin
|
||||
FName:=AName;
|
||||
FChilds:=TFPList.Create;
|
||||
end;
|
||||
|
||||
destructor TLazDockConfigNode.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FChilds.Free;
|
||||
FChilds:=nil;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TLazDockConfigNode.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=ChildCount-1 downto 0 do Childs[i].Free;
|
||||
FChilds.Clear;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user