mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 09:39:31 +02:00
dockmanager example: fixed resize bug in reload layout
git-svn-id: trunk@25326 -
This commit is contained in:
parent
e2bde5f2a6
commit
7684d0756d
@ -55,8 +55,10 @@ end;
|
||||
|
||||
procedure TMasterSite.buRestoreClick(Sender: TObject);
|
||||
begin
|
||||
if ms <> nil then
|
||||
if ms <> nil then begin
|
||||
ms.Position := 0; //rewind
|
||||
DockMaster.LoadFromStream(ms);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMasterSite.buSaveClick(Sender: TObject);
|
||||
|
@ -123,7 +123,8 @@ type
|
||||
FTree: TEasyTree;
|
||||
FFirstChild,
|
||||
FNextSibling, FPrevSibling, FParent: TEasyZone;
|
||||
FOrientation: TDockOrientation;
|
||||
FZoneOrientation, //true orientation
|
||||
FOrientation: TDockOrientation; //Delphi compatible (doNone when containing a control)
|
||||
procedure SetControl(Control: TControl);
|
||||
procedure SetOrientation(NewOrientation: TDockOrientation);
|
||||
function GetLeft: Integer;
|
||||
@ -139,8 +140,10 @@ type
|
||||
procedure SetBounds(TLBR: TRect);
|
||||
|
||||
function GetHandle: HWND;
|
||||
{$IFDEF visibility} //to be redesigned
|
||||
function GetVisible: boolean;
|
||||
function GetVisibleControl: TControl;
|
||||
{$ENDIF}
|
||||
function GetPartRect(APart: TEasyZonePart): TRect;
|
||||
function GetStyle: TEasyHeaderStyle;
|
||||
public
|
||||
@ -163,7 +166,7 @@ type
|
||||
property Parent: TEasyZone read FParent write SetParent;
|
||||
property Orientation: TDockOrientation read FOrientation write SetOrientation;
|
||||
property Style: TEasyHeaderStyle read GetStyle;
|
||||
property Visible: boolean read GetVisible;
|
||||
//property Visible: boolean read GetVisible;
|
||||
|
||||
property Bottom: integer read BR.Y;
|
||||
property Left: integer read GetLeft;
|
||||
@ -982,10 +985,18 @@ begin
|
||||
Control.Visible := False;
|
||||
DockSite.Invalidate;
|
||||
{$ELSE}
|
||||
Control.ManualDock(nil, nil, alNone); //do float
|
||||
(* Definitely close a form, but other controls???
|
||||
*)
|
||||
if Control is TCustomForm then begin
|
||||
TCustomForm(Control).Close;
|
||||
Control.ManualDock(nil, nil, alNone); //do float
|
||||
TWinControlAccess(Control).DoEndDock(nil, Control.Left, Control.Top);
|
||||
end else begin
|
||||
{ TODO -cLCL : OnEndDock not called by ManualDock? }
|
||||
//TWinControlAccess(Control).DoEndDock(nil, Control.Left, Control.Top);
|
||||
Control.Visible := False;
|
||||
Control.ManualDock(nil, nil, alNone); //do float
|
||||
TWinControlAccess(Control).DoEndDock(nil, Control.Left, Control.Top);
|
||||
Control.Visible := False;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
@ -1196,6 +1207,7 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
|
||||
PrevZone, NewZone: TEasyZone;
|
||||
PrevLvl, NewLvl: byte;
|
||||
NewCtl: TControl;
|
||||
r: TRect;
|
||||
begin
|
||||
PrevZone := FTopZone;
|
||||
PrevLvl := 1;
|
||||
@ -1218,9 +1230,13 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
|
||||
NewZone.ChildControl := NewCtl;
|
||||
SetReplacingControl(NewCtl); //prevent DockManager actions
|
||||
NewCtl.ManualDock(DockSite);
|
||||
NewCtl.Width := ZoneRec.BottomRight.x;
|
||||
NewCtl.Height := ZoneRec.BottomRight.y;
|
||||
//NewCtl.DisableAutoSizing; //forever?
|
||||
r := NewZone.GetPartRect(zpClient);
|
||||
NewCtl.BoundsRect := r;
|
||||
DebugLn('?NewCtl w=%d=%d h=%d=%d', [NewCtl.Width, ZoneRec.BottomRight.x,NewCtl.Height, ZoneRec.BottomRight.y]);
|
||||
NewCtl.Visible := True;
|
||||
//NewCtl.EnableAutoSizing;
|
||||
DebugLn('!NewCtl w=%d=%d h=%d=%d', [NewCtl.Width, ZoneRec.BottomRight.x,NewCtl.Height, ZoneRec.BottomRight.y]);
|
||||
end;
|
||||
{$IFDEF oldOrient}
|
||||
{$ELSE}
|
||||
@ -1243,19 +1259,23 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
|
||||
end;
|
||||
|
||||
begin
|
||||
(* Problem: what if site doesn't match zone extent?
|
||||
*)
|
||||
//remove all docked controls
|
||||
ClearSite;
|
||||
//read record
|
||||
if GetRec > 0 then begin
|
||||
FSiteRect.BottomRight := ZoneRec.BottomRight; //stored extent, not current one!
|
||||
FTopZone.BR := ZoneRec.BottomRight;
|
||||
FTopZone.Orientation := ZoneRec.Orientation;
|
||||
MakeZones;
|
||||
//now make the zone fit the current extent, and position all child controls
|
||||
//DebugLn('fit zone ', DbgS(FTopZone.BR), ' into site ', DbgS(FDockSite.ClientRect.BottomRight));
|
||||
ResetBounds(True); //always position controls!
|
||||
//finish?
|
||||
//remove all leafs without a child control?
|
||||
end;
|
||||
//finish?
|
||||
//remove all leafs without a child control?
|
||||
//refresh the site
|
||||
ResetBounds(True);
|
||||
//assure everything is visible
|
||||
//assure everything is visible (recursive, until topmost parent)
|
||||
MakeVisible(FDockSite);
|
||||
end;
|
||||
|
||||
@ -1574,6 +1594,8 @@ begin
|
||||
Result := FTree.FDockSite;
|
||||
end;
|
||||
|
||||
|
||||
{$IFDEF visibility}
|
||||
function TEasyZone.GetVisible: boolean;
|
||||
begin
|
||||
Result := GetVisibleControl <> nil;
|
||||
@ -1598,6 +1620,7 @@ begin
|
||||
zone := zone.NextSibling;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function TEasyZone.GetPartRect(APart: TEasyZonePart): TRect;
|
||||
begin
|
||||
@ -1810,6 +1833,7 @@ end;
|
||||
|
||||
procedure TEasyZone.SetOrientation(NewOrientation: TDockOrientation);
|
||||
begin
|
||||
FZoneOrientation := NewOrientation; //independent from ChildControl
|
||||
if ChildControl = nil then
|
||||
FOrientation := NewOrientation
|
||||
else
|
||||
@ -1830,7 +1854,12 @@ begin
|
||||
if (fTop = (zone.Parent.Orientation = doVertical)) then begin
|
||||
prev := zone.PrevSibling;
|
||||
while prev <> nil do begin
|
||||
if prev.Visible then begin
|
||||
{$IFDEF visibility}
|
||||
if prev.Visible then
|
||||
{$ELSE}
|
||||
//zones are always visible
|
||||
{$ENDIF}
|
||||
begin
|
||||
if fTop then
|
||||
Result := prev.Bottom
|
||||
else
|
||||
|
@ -3,6 +3,8 @@ object FloatingSite: TFloatingSite
|
||||
Height = 265
|
||||
Top = 498
|
||||
Width = 377
|
||||
HorzScrollBar.Visible = False
|
||||
VertScrollBar.Visible = False
|
||||
Caption = 'FloatingSite'
|
||||
DockSite = True
|
||||
OnClose = FormClose
|
||||
|
@ -147,6 +147,7 @@ Fix: disallow TControls to become floating.
|
||||
*)
|
||||
//try to distinguish between TControl and TWinControl (TCustomForm?)
|
||||
Allow := (NewTarget <> nil) or (Client is TWinControl); //seems to be safe
|
||||
DebugLn('TFloatingSite undodock, allow ', DbgS(Allow));
|
||||
if not Allow then
|
||||
exit; //all done
|
||||
|
||||
|
@ -463,7 +463,9 @@ Notebooks?
|
||||
//adjust host form
|
||||
if site.DockManager = nil then
|
||||
TAppDockManager.Create(site);
|
||||
site.DisableAutoSizing;
|
||||
site.DockManager.LoadFromStream(Stream);
|
||||
site.EnableAutoSizing;
|
||||
site.Show;
|
||||
end;
|
||||
end;
|
||||
@ -739,6 +741,7 @@ const
|
||||
hds: boolean;
|
||||
Site: TWinControl;
|
||||
j: integer;
|
||||
r: TRect;
|
||||
begin
|
||||
ctl := ASite;
|
||||
s := Format('Site=%s (%d,%d)[%d,%d]', [SiteName(ctl),
|
||||
@ -747,8 +750,13 @@ const
|
||||
hds := ctl.HostDockSite <> nil;
|
||||
if hds then begin
|
||||
Site := ctl.HostDockSite;
|
||||
if Site <> nil then
|
||||
if Site <> nil then begin
|
||||
n := ' in ' + SiteName(Site) + '@' + OrientString[ctl.DockOrientation];
|
||||
if assigned(Site.DockManager) then begin
|
||||
Site.DockManager.GetControlBounds(ctl, r);
|
||||
n := n + Format(' in [%d,%d]', [r.Right, r.Bottom]);
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
Site := ctl.Parent;
|
||||
if Site <> nil then
|
||||
@ -767,6 +775,12 @@ const
|
||||
s := OrientString[ctl.DockOrientation];
|
||||
DebugLn(' %s.Client=%s.%s@%s (%d,%d)[%d,%d]', [SiteName(ASite), ctl.Owner.Name, SiteName(ctl), s,
|
||||
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
|
||||
if assigned(Site.DockManager) then begin
|
||||
Site.DockManager.GetControlBounds(ctl, r);
|
||||
//n := Format(' in [%d,%d]', [r.Right, r.Bottom]);
|
||||
//DebugLn(n);
|
||||
DebugLn(' in ', DbgS(r));
|
||||
end;
|
||||
//if ctl is TFloatingSite then
|
||||
if (ctl is TWinControl) and wc.DockSite then
|
||||
DumpSite(wc);
|
||||
@ -778,6 +792,8 @@ var
|
||||
cmp: TComponent;
|
||||
wc: TWinControl absolute cmp;
|
||||
ctl: TControl absolute cmp;
|
||||
//zone: TEasyZone;
|
||||
r: TRect;
|
||||
begin
|
||||
(* Dump registered docking sites.
|
||||
Elastic panels have no name.
|
||||
@ -795,8 +811,10 @@ begin
|
||||
if (cmp is TWinControl) and wc.DockSite then
|
||||
DumpSite(wc)
|
||||
else if ctl is TControl then begin
|
||||
DebugLn('Client=%s in %s (%d,%d)[%d,%d]', [SiteName(ctl), SiteName(ctl.HostDockSite),
|
||||
ctl.Left, ctl.Top, ctl.Width, ctl.Height]);
|
||||
wc.DockManager.GetControlBounds(ctl, r);
|
||||
DebugLn('Client=%s in %s (%d,%d)[%d,%d] in [%d,%d]', [SiteName(ctl), SiteName(ctl.HostDockSite),
|
||||
ctl.Left, ctl.Top, ctl.Width, ctl.Height,
|
||||
r.Right, r.Bottom]);
|
||||
end;
|
||||
end;
|
||||
DebugLn('--- dump forms ---');
|
||||
|
Loading…
Reference in New Issue
Block a user