dockmanager example: added Visible flag to DockMaster methods

git-svn-id: trunk@24904 -
This commit is contained in:
dodi 2010-04-25 09:55:26 +00:00
parent 374d65d68c
commit 554e1663e9
9 changed files with 24 additions and 107 deletions

3
.gitattributes vendored
View File

@ -2880,13 +2880,10 @@ examples/dockmanager/package/easydockmgr.lpk svneol=native#text/plain
examples/dockmanager/package/easydockmgr.pas svneol=native#text/pascal examples/dockmanager/package/easydockmgr.pas svneol=native#text/pascal
examples/dockmanager/package/easydocksite.pas svneol=native#text/plain examples/dockmanager/package/easydocksite.pas svneol=native#text/plain
examples/dockmanager/package/fdockbook.lfm svneol=native#text/plain examples/dockmanager/package/fdockbook.lfm svneol=native#text/plain
examples/dockmanager/package/fdockbook.lrs svneol=native#text/pascal
examples/dockmanager/package/fdockbook.pas svneol=native#text/pascal examples/dockmanager/package/fdockbook.pas svneol=native#text/pascal
examples/dockmanager/package/felasticsite.lfm svneol=native#text/plain examples/dockmanager/package/felasticsite.lfm svneol=native#text/plain
examples/dockmanager/package/felasticsite.lrs svneol=native#text/plain
examples/dockmanager/package/felasticsite.pas svneol=native#text/pascal examples/dockmanager/package/felasticsite.pas svneol=native#text/pascal
examples/dockmanager/package/ffloatingsite.lfm svneol=native#text/plain examples/dockmanager/package/ffloatingsite.lfm svneol=native#text/plain
examples/dockmanager/package/ffloatingsite.lrs svneol=native#text/plain
examples/dockmanager/package/ffloatingsite.pas svneol=native#text/pascal examples/dockmanager/package/ffloatingsite.pas svneol=native#text/pascal
examples/dockmanager/package/umakesite.pas svneol=native#text/pascal examples/dockmanager/package/umakesite.pas svneol=native#text/pascal
examples/dockmanager/package/uminirestore.pas svneol=native#text/pascal examples/dockmanager/package/uminirestore.pas svneol=native#text/pascal

View File

@ -73,10 +73,11 @@ var
begin begin
DockMaster := TDockMaster.Create(self); //(Application)? DockMaster := TDockMaster.Create(self); //(Application)?
DockMaster.AddElasticSites(self, [alBottom]); DockMaster.AddElasticSites(self, [alBottom]);
f := DockMaster.CreateDockable('', True); f := DockMaster.CreateDockable('', True, False);
if f.HostDockSite <> nil then if f.HostDockSite <> nil then
f := f.HostDockSite; f := f.HostDockSite;
f.Top := 300; f.Top := 300;
f.Show;
{$IFDEF TestUnwrapped} {$IFDEF TestUnwrapped}
f := DockMaster.CreateDockable('', True, False); f := DockMaster.CreateDockable('', True, False);
if f.Name = '' then //name it - for unique caption if f.Name = '' then //name it - for unique caption
@ -87,6 +88,7 @@ begin
f := f.HostDockSite; f := f.HostDockSite;
f.Top := 600; f.Top := 600;
{$ENDIF} {$ENDIF}
f.Show;
end; end;
initialization initialization

View File

@ -20,26 +20,4 @@ object ViewWindow: TViewWindow
Caption = 'Label1' Caption = 'Label1'
ParentColor = False ParentColor = False
end end
object Image1: TImage
Left = 384
Height = 16
Top = 0
Width = 16
Anchors = [akTop, akRight]
AutoSize = True
OnMouseMove = Image1MouseMove
Picture.Data = {
055449636F6E3E01000000000100010010101000000000002801000016000000
2800000010000000200000000100040000000000C00000000000000000000000
0000000000000000000000000000800000800000008080008000000080008000
8080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00
FFFF0000FFFFFF00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000990000000000009999990000000000999999000000000999999990
0000000999999990000000009999990000000000999999000000000000990000
00000000000000007FFF0000BFFF0000DFFF0000EFFF0000F7FF0000FBFF0000
FDCF0000FE030000FE010000FE010000FC000000FC000000FE010000FE010000
FF030000FFCF0000
}
end
end end

View File

@ -18,7 +18,6 @@ uses
type type
TViewWindow = class(TForm) TViewWindow = class(TForm)
Image1: TImage;
Label1: TLabel; Label1: TLabel;
procedure FormEndDock(Sender, Target: TObject; X, Y: Integer); procedure FormEndDock(Sender, Target: TObject; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; procedure Image1MouseMove(Sender: TObject; Shift: TShiftState;

View File

@ -1,12 +0,0 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TEasyDockBook','FORMDATA',[
'TPF0'#241#13'TEasyDockBook'#12'EasyDockBook'#4'Left'#3#7#1#6'Height'#3','#1#3
+'Top'#3#146#0#5'Width'#3#144#1#7'Caption'#6#12'EasyDockBook'#12'ClientHeight'
+#3','#1#11'ClientWidth'#3#144#1#8'DockSite'#9#8'DragKind'#7#6'dkDock'#7'OnCl'
+'ose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#10'OnDockDrop'#7#12'FormDo'
+'ckDrop'#10'OnDockOver'#7#12'FormDockOver'#9'OnEndDock'#7#11'FormEndDock'#13
+'OnGetSiteInfo'#7#15'FormGetSiteInfo'#8'OnUnDock'#7#10'FormUnDock'#0#242#2#0
+#6'TPanel'#7'pnlDock'#4'Left'#2#0#6'Height'#3','#1#3'Top'#2#0#5'Width'#3#144
+#1#5'Align'#7#8'alClient'#8'TabOrder'#2#0#14'UseDockManager'#8#0#0#0
]);

View File

@ -1,28 +0,0 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TDockingSite','FORMDATA',[
'TPF0'#12'TDockingSite'#11'DockingSite'#4'Left'#3#253#1#6'Height'#3#163#0#3'T'
+'op'#3#12#1#5'Width'#3#255#0#8'AutoSize'#9#7'Caption'#6#9'Dock Site'#12'Clie'
+'ntHeight'#3#163#0#11'ClientWidth'#3#255#0#10'LCLVersion'#6#6'0.9.29'#7'Visi'
+'ble'#9#0#6'TPanel'#7'pnlLeft'#4'Left'#2#0#6'Height'#3#138#0#3'Top'#2#0#5'Wi'
+'dth'#2#0#5'Align'#7#6'alLeft'#7'Caption'#6#7'pnlLeft'#5'Color'#7#7'clWhite'
+#8'DockSite'#9#11'ParentColor'#8#8'TabOrder'#2#0#10'OnDockDrop'#7#15'pnlLeft'
+'DockDrop'#10'OnDockOver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7#18'pnlLe'
+'ftGetSiteInfo'#8'OnUnDock'#7#13'pnlLeftUnDock'#0#0#9'TSplitter'#9'splitLeft'
+#4'Left'#2#0#6'Height'#3#138#0#3'Top'#2#0#5'Width'#2#4#0#0#6'TPanel'#8'pnlRi'
+'ght'#4'Left'#3#255#0#6'Height'#3#138#0#3'Top'#2#0#5'Width'#2#0#5'Align'#7#7
+'alRight'#7'Caption'#6#8'pnlRight'#5'Color'#7#6'clAqua'#8'DockSite'#9#11'Par'
+'entColor'#8#8'TabOrder'#2#2#10'OnDockDrop'#7#15'pnlLeftDockDrop'#10'OnDockO'
+'ver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7#18'pnlLeftGetSiteInfo'#8'OnU'
+'nDock'#7#13'pnlLeftUnDock'#0#0#6'TPanel'#9'pnlBottom'#4'Left'#2#0#6'Height'
+#2#1#3'Top'#3#142#0#5'Width'#3#255#0#5'Align'#7#8'alBottom'#7'Caption'#6#9'p'
+'nlBottom'#8'DockSite'#9#8'TabOrder'#2#3#10'OnDockDrop'#7#15'pnlLeftDockDrop'
+#10'OnDockOver'#7#15'pnlLeftDockOver'#13'OnGetSiteInfo'#7#18'pnlLeftGetSiteI'
+'nfo'#8'OnUnDock'#7#13'pnlLeftUnDock'#0#0#9'TSplitter'#10'splitRight'#4'Left'
+#3#251#0#6'Height'#3#138#0#3'Top'#2#0#5'Width'#2#4#5'Align'#7#7'alRight'#12
+'ResizeAnchor'#7#7'akRight'#0#0#10'TStatusBar'#10'StatusBar1'#4'Left'#2#0#6
+'Height'#2#20#3'Top'#3#143#0#5'Width'#3#255#0#6'Panels'#14#0#0#0#9'TSplitter'
+#11'splitBottom'#6'Cursor'#7#8'crVSplit'#4'Left'#2#0#6'Height'#2#4#3'Top'#3
+#138#0#5'Width'#3#255#0#5'Align'#7#8'alBottom'#12'ResizeAnchor'#7#8'akBottom'
+#0#0#0
]);

View File

@ -1,8 +0,0 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TFloatingSite','FORMDATA',[
'TPF0'#13'TFloatingSite'#12'FloatingSite'#4'Left'#3#175#1#6'Height'#3#9#1#3'T'
+'op'#3#242#1#5'Width'#3'y'#1#7'Caption'#6#12'FloatingSite'#8'DockSite'#9#7'O'
+'nClose'#7#9'FormClose'#10'OnDockDrop'#7#12'FormDockDrop'#8'OnUnDock'#7#10'F'
+'ormUnDock'#14'UseDockManager'#9#10'LCLVersion'#6#6'0.9.29'#0#0
]);

View File

@ -188,7 +188,7 @@ end;
{$ENDIF} {$ENDIF}
initialization initialization
{$I ffloatingsite.lrs} {.$I ffloatingsite.lrs}
end. end.

View File

@ -72,8 +72,8 @@ type
protected //event handlers protected //event handlers
procedure FormEndDock(Sender, Target: TObject; X, Y: Integer); procedure FormEndDock(Sender, Target: TObject; X, Y: Integer);
protected //utilities protected //utilities
function ReloadForm(const AName: string; fMultiInst: boolean): TWinControl; virtual; function ReloadForm(const AName: string; fMultiInst: boolean; fVisible: boolean): TWinControl; virtual;
function WrapDockable(Client: TControl): TFloatingSite; function WrapDockable(Client: TControl; fVisible: boolean): TFloatingSite;
private private
LastPanel: TDockPanel; //last elastic panel created LastPanel: TDockPanel; //last elastic panel created
{$IFDEF ownPanels} {$IFDEF ownPanels}
@ -88,8 +88,8 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure AddElasticSites(AForm: TCustomForm; Sides: sDockSides); procedure AddElasticSites(AForm: TCustomForm; Sides: sDockSides);
function CreateDockable(const AName: string; function CreateDockable(const AName: string;
fMultiInst: boolean; fWrap: boolean = True): TWinControl; fMultiInst: boolean; fWrap: boolean = True; fVisible: boolean = False): TWinControl;
function MakeDockable(AForm: TWinControl; fWrap: boolean = True): TForm; function MakeDockable(AForm: TWinControl; fWrap: boolean = True; fVisible: boolean = False): TForm;
procedure DumpSites; procedure DumpSites;
//persistence //persistence
procedure LoadFromStream(Stream: TStream); procedure LoadFromStream(Stream: TStream);
@ -220,7 +220,7 @@ begin
end; end;
function TDockMaster.CreateDockable(const AName: string; function TDockMaster.CreateDockable(const AName: string;
fMultiInst: boolean; fWrap: boolean): TWinControl; fMultiInst: boolean; fWrap: boolean; fVisible: boolean): TWinControl;
begin begin
(* Create a dockable form, based on its name. (* Create a dockable form, based on its name.
Used also to restore a layout. Used also to restore a layout.
@ -230,15 +230,15 @@ Options (to come or to be removed)
otherwise an already existing instance is returned. (really returned?) otherwise an already existing instance is returned. (really returned?)
*) *)
//get the form //get the form
Result := ReloadForm(AName, fMultiInst); Result := ReloadForm(AName, fMultiInst, False);
if Result = nil then if Result = nil then
exit; exit;
MakeDockable(Result, fWrap); MakeDockable(Result, fWrap, fVisible);
//problem with first show? //problem with first show?
//Result.Invalidate; - doesn't help //Result.Invalidate; - doesn't help
end; end;
function TDockMaster.MakeDockable(AForm: TWinControl; fWrap: boolean): TForm; function TDockMaster.MakeDockable(AForm: TWinControl; fWrap, fVisible: boolean): TForm;
var var
Site: TFloatingSite absolute Result; Site: TFloatingSite absolute Result;
Res: TWinControlAccess absolute AForm; Res: TWinControlAccess absolute AForm;
@ -259,7 +259,7 @@ begin
Res.OnEndDock := @FormEndDock; //float into default host site Res.OnEndDock := @FormEndDock; //float into default host site
{$ENDIF} {$ENDIF}
AForm.DisableAlign; AForm.DisableAlign;
Site := WrapDockable(AForm); Site := WrapDockable(AForm, fVisible);
AForm.EnableAlign; AForm.EnableAlign;
end; end;
//IDE? //IDE?
@ -293,7 +293,7 @@ begin
//not found //not found
Result := inherited ReloadControl(AName, Site); Result := inherited ReloadControl(AName, Site);
if Result = nil then if Result = nil then
Result := ReloadForm(AName, True); Result := ReloadForm(AName, False, True);
end; end;
procedure TDockMaster.FormEndDock(Sender, Target: TObject; X, Y: Integer); procedure TDockMaster.FormEndDock(Sender, Target: TObject; X, Y: Integer);
@ -318,7 +318,7 @@ begin
ctl := Sender as TControl; ctl := Sender as TControl;
//if not (csDestroying in ctl.ComponentState) and (ctl.HostDockSite = nil) then begin //if not (csDestroying in ctl.ComponentState) and (ctl.HostDockSite = nil) then begin
//if (ctl.HostDockSite = nil) then //if (ctl.HostDockSite = nil) then
WrapDockable(ctl); WrapDockable(ctl, True);
end; end;
procedure TDockMaster.LoadFromFile(const AName: string); procedure TDockMaster.LoadFromFile(const AName: string);
@ -395,7 +395,7 @@ var
begin begin
(* AName is <align><form> (* AName is <align><form>
*) *)
hcomp := self.ReloadForm(FormName, True); //try multi-instance first hcomp := self.ReloadForm(FormName, True, False); //try multi-instance first
if host <> nil then begin if host <> nil then begin
AddElasticSites(host, [aln]); AddElasticSites(host, [aln]);
Result := LastPanel; //found or created Result := LastPanel; //found or created
@ -403,6 +403,7 @@ var
Result.BoundsRect := SiteRec.Extent; Result.BoundsRect := SiteRec.Extent;
Result.AutoExpand := SiteRec.AutoExpand; Result.AutoExpand := SiteRec.AutoExpand;
Result.EnableAlign; Result.EnableAlign;
Result.Visible := True;
exit; exit;
end; end;
//failed //failed
@ -598,7 +599,7 @@ begin
end; end;
function TDockMaster.ReloadForm(const AName: string; function TDockMaster.ReloadForm(const AName: string;
fMultiInst: boolean): TWinControl; fMultiInst: boolean; fVisible: boolean): TWinControl;
var var
//instname: string //instname: string
basename: string; basename: string;
@ -681,13 +682,7 @@ begin
//search/create ourselves //search/create ourselves
fo := Owner; //our owner also owns the forms fo := Owner; //our owner also owns the forms
if AName = '' then begin if AName = '' then begin
{$IFDEF new}
Result := TForm(TForm.NewInstance);
//Result.DisableAlign;
Result.Create(fo); //named Form1, Form2... - not now???
{$ELSE}
Result := TForm.Create(fo); //named Form1, Form2... - not now??? Result := TForm.Create(fo); //named Form1, Form2... - not now???
{$ENDIF}
end else begin end else begin
//create new instance //create new instance
//DebugLn('!!! create new: ', AName); //DebugLn('!!! create new: ', AName);
@ -697,21 +692,16 @@ begin
DebugLn(basename , ' is not a registered class'); DebugLn(basename , ' is not a registered class');
exit(nil); //bad form name exit(nil); //bad form name
end; end;
{$IFDEF new}
Result := TWinControl(fc.NewInstance);
Result.DisableAlign;
Result.Create(fo);
{$ELSE}
Result := TWinControl(fc.Create(fo)); Result := TWinControl(fc.Create(fo));
{$ENDIF}
if (AName <> '') and (Result.Name <> AName) then if (AName <> '') and (Result.Name <> AName) then
TryRename(Result, AName); TryRename(Result, AName);
end; end;
//if not DisableUpdate then Result.EnableAlign; //if not DisableUpdate then Result.EnableAlign;
//Result.Visible := True; //required for docking if fVisible then
Result.Visible := True;
end; end;
function TDockMaster.WrapDockable(Client: TControl): TFloatingSite; function TDockMaster.WrapDockable(Client: TControl; fVisible: boolean): TFloatingSite;
var var
Site: TFloatingSite absolute Result; Site: TFloatingSite absolute Result;
ctl: TControlAccess absolute Client; ctl: TControlAccess absolute Client;
@ -742,10 +732,8 @@ begin
//retry make client auto-dockable //retry make client auto-dockable
ctl.DragKind := dkDock; ctl.DragKind := dkDock;
ctl.DragMode := dmAutomatic; ctl.DragMode := dmAutomatic;
{$IFDEF ForceVisible}
Client.Visible := True;
{$ENDIF}
Client.ManualDock(Site); Client.ManualDock(Site);
Client.Visible := True; //shown only if Site is visible
//DebugLn('After Wrap: ', DbgS(Site.BoundsRect)); //DebugLn('After Wrap: ', DbgS(Site.BoundsRect));
if ForIDE then begin if ForIDE then begin
@ -754,6 +742,7 @@ begin
//Client.Left := 0; //Client.Left := 0;
Site.DockManager.ResetBounds(True); Site.DockManager.ResetBounds(True);
end; end;
if fVisible then;
Site.Visible := True; Site.Visible := True;
except except
DebugLn('error WrapDockable: ' + Client.Name); DebugLn('error WrapDockable: ' + Client.Name);