mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 05:59:28 +02:00
dockmanager example: made floathostsite work for dockbooks
git-svn-id: trunk@25006 -
This commit is contained in:
parent
5567182a53
commit
45ecdbc420
@ -289,6 +289,7 @@ type
|
||||
FOnSave: TOnSaveControl;
|
||||
FOnRestore: TOnReloadControl;
|
||||
public //become class functions?
|
||||
function MakeDockable(AForm: TWinControl; fWrap: boolean = True; fVisible: boolean = False): TForm; virtual;
|
||||
function SaveControl(Control: TControl; Site: TWinControl): string; virtual;
|
||||
function ReloadControl(const AName: string; Site: TWinControl): TControl; virtual;
|
||||
property OnSave: TOnSaveControl read FOnSave write FOnSave;
|
||||
@ -327,7 +328,7 @@ var
|
||||
function ScreenRect(ACtrl: TControl): TRect;
|
||||
|
||||
//primarily for DockManager internal use
|
||||
function NoteBookCreate(AOwner: TWinControl): TCustomDockSite;
|
||||
function NoteBookCreate: TCustomDockSite;
|
||||
procedure NoteBookAdd(ABook: TCustomDockSite; AItem: TControl); //to be removed
|
||||
function TryRename(AComp: TComponent; const NewName: string): boolean;
|
||||
function CreateUniqueComponentName(const AClassName: string; OwnerComponent: TComponent): string;
|
||||
@ -378,7 +379,7 @@ const
|
||||
HeaderButtons = [zpCloseButton];
|
||||
{$ENDIF}
|
||||
|
||||
function NoteBookCreate(AOwner: TWinControl): TCustomDockSite;
|
||||
function NoteBookCreate: TCustomDockSite;
|
||||
begin
|
||||
(* Create default dockbook type.
|
||||
Dockable notebooks must not have an specific owner.
|
||||
@ -390,8 +391,9 @@ begin
|
||||
}
|
||||
//Result := TEasyDockBook.Create(AOwner);
|
||||
Result := TEasyDockBook.Create(Application);
|
||||
DockLoader.MakeDockable(Result, False, False); //do not make visible here!
|
||||
{ TODO : form style should become bsNone when docked - workaround here }
|
||||
Result.BorderStyle := bsNone;
|
||||
//Result.BorderStyle := bsNone;
|
||||
end;
|
||||
|
||||
procedure NoteBookAdd(ABook: TCustomDockSite; AItem: TControl);
|
||||
@ -676,7 +678,7 @@ begin
|
||||
NoteBook := TCustomDockSite(DropCtl);
|
||||
end else begin
|
||||
//create new book
|
||||
NoteBook := NoteBookCreate(FDockSite);
|
||||
NoteBook := NoteBookCreate;
|
||||
{$IFDEF replace}
|
||||
NoteBook.ReplaceDockedControl(DropZone.ChildControl, NoteBook, nil, alCustom);
|
||||
{$ELSE}
|
||||
@ -690,6 +692,7 @@ begin
|
||||
NoteBookAdd(NoteBook, DropCtl); //put the original control into the notebook
|
||||
NoteBook.BoundsRect := r;
|
||||
{$ENDIF}
|
||||
NoteBook.Show;
|
||||
end; //else use existing control
|
||||
NoteBookAdd(NoteBook, Control);
|
||||
FDockSite.Invalidate; //update notebook caption
|
||||
@ -697,9 +700,10 @@ begin
|
||||
{$IFDEF singleTab}
|
||||
end else if SingleTab and not (DropCtl is TEasyBook) then begin
|
||||
//empty root zone, create new notebook
|
||||
NoteBook := NoteBookCreate(FDockSite);
|
||||
NoteBook := NoteBookCreate;
|
||||
NoteBook.ManualDock(FDockSite, nil, alClient);
|
||||
NoteBookAdd(NoteBook, Control);
|
||||
NoteBook.Show;
|
||||
FDockSite.Invalidate; //update notebook caption
|
||||
exit;
|
||||
{$ELSE}
|
||||
@ -711,8 +715,6 @@ begin
|
||||
NewZone := TEasyZone.Create(self);
|
||||
NewZone.ChildControl := Control as TControl;
|
||||
Control.Align := alNone;
|
||||
//is this still required?
|
||||
//if Control is TCustomForm then TCustomForm(Control).BorderStyle := bsNone;
|
||||
|
||||
//special case: in root zone (empty dock site)
|
||||
|
||||
@ -2152,6 +2154,25 @@ begin
|
||||
Result := Control.Name; //definitely child.Name
|
||||
end;
|
||||
|
||||
function TCustomDockMaster.MakeDockable(AForm: TWinControl; fWrap: boolean;
|
||||
fVisible: boolean): TForm;
|
||||
var
|
||||
wctl: TWinControlAccess absolute AForm;
|
||||
begin
|
||||
(* Result is the floating site, if created (fWrap).
|
||||
fWrap here is ignored.
|
||||
To be overridden by final TDockMaster, for
|
||||
- wrapping
|
||||
- visibility
|
||||
*)
|
||||
//make it dockable
|
||||
wctl.DragKind := dkDock;
|
||||
wctl.DragMode := dmAutomatic;
|
||||
if fVisible then
|
||||
AForm.Show;
|
||||
Result := nil; //not wrapped
|
||||
end;
|
||||
|
||||
function TCustomDockMaster.ReloadControl(const AName: string;
|
||||
Site: TWinControl): TControl;
|
||||
var
|
||||
|
@ -12,7 +12,6 @@ inherited EasyDockBook: TEasyDockBook
|
||||
OnCreate = FormCreate
|
||||
OnDockDrop = FormDockDrop
|
||||
OnDockOver = FormDockOver
|
||||
OnEndDock = FormEndDock
|
||||
OnGetSiteInfo = FormGetSiteInfo
|
||||
OnUnDock = FormUnDock
|
||||
object pnlDock: TPanel[0]
|
||||
|
@ -54,7 +54,7 @@ HostDockSite.UpdateDockCaption (provide composed dock caption)
|
||||
|
||||
{.$DEFINE undockFix}
|
||||
{$DEFINE closeFix}
|
||||
{$DEFINE autoWrap} //request FloatingDockSiteClass
|
||||
{.$DEFINE autoWrap} //request FloatingDockSiteClass
|
||||
|
||||
interface
|
||||
|
||||
@ -89,7 +89,6 @@ type
|
||||
X, Y: Integer);
|
||||
procedure FormDockOver(Sender: TObject; Source: TDragDockObject;
|
||||
X, Y: Integer; State: TDragState; var Accept: Boolean);
|
||||
procedure FormEndDock(Sender, Target: TObject; X, Y: Integer);
|
||||
procedure FormGetSiteInfo(Sender: TObject; DockClient: TControl;
|
||||
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
|
||||
procedure FormUnDock(Sender: TObject; Client: TControl;
|
||||
@ -237,12 +236,6 @@ begin
|
||||
Source.DockRect := ScreenRect(pnlDock);
|
||||
end;
|
||||
|
||||
procedure TEasyDockBook.FormEndDock(Sender, Target: TObject; X, Y: Integer);
|
||||
begin
|
||||
(* wrap into an FloatHost
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure TEasyDockBook.FormGetSiteInfo(Sender: TObject; DockClient: TControl;
|
||||
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
|
||||
begin
|
||||
@ -378,13 +371,12 @@ end;
|
||||
|
||||
function TEasyDockBook.GetFloatingDockSiteClass: TWinControlClass;
|
||||
begin
|
||||
(* Try: request a floating site
|
||||
(* Try: request a floating site, if no OnEndDock handler is installed
|
||||
*)
|
||||
{$IFDEF autoWrap}
|
||||
Result:= TFloatingSite;
|
||||
{$ELSE}
|
||||
Result := inherited GetFloatingDockSiteClass;
|
||||
{$ENDIF}
|
||||
if assigned(OnEndDock) then
|
||||
Result := inherited GetFloatingDockSiteClass
|
||||
else
|
||||
Result:= TFloatingSite;
|
||||
end;
|
||||
|
||||
{$IFDEF new}
|
||||
@ -482,7 +474,6 @@ begin
|
||||
Try prevent undocking of NOT docked form.
|
||||
*)
|
||||
inherited MouseMove(Shift, X, Y);
|
||||
//if ssLeft in Shift then
|
||||
if (ssLeft in Shift) and (Parent.HostDockSite <> nil) then
|
||||
Parent.BeginDrag(False); //delayed docking of the container form
|
||||
end;
|
||||
@ -490,7 +481,6 @@ end;
|
||||
{$R *.lfm}
|
||||
|
||||
initialization
|
||||
{.$I fdockbook.lrs}
|
||||
RegisterClass(TEasyDockBook);
|
||||
end.
|
||||
|
||||
|
@ -89,7 +89,7 @@ type
|
||||
procedure AddElasticSites(AForm: TCustomForm; Sides: sDockSides);
|
||||
function CreateDockable(const AName: string;
|
||||
fMultiInst: boolean; fWrap: boolean = True; fVisible: boolean = False): TWinControl;
|
||||
function MakeDockable(AForm: TWinControl; fWrap: boolean = True; fVisible: boolean = False): TForm;
|
||||
function MakeDockable(AForm: TWinControl; fWrap: boolean = True; fVisible: boolean = False): TForm; override;
|
||||
procedure DumpSites;
|
||||
//persistence
|
||||
procedure LoadFromStream(Stream: TStream);
|
||||
@ -244,23 +244,23 @@ var
|
||||
Res: TWinControlAccess absolute AForm;
|
||||
begin
|
||||
Result := nil;
|
||||
//Result := inherited MakeDockable(AForm, fWrap, fVisible); - premature Visbile?
|
||||
//check already dockable
|
||||
{ TODO -cdocking : problems with IDE windows:
|
||||
wrapping results in exceptions - conflicts with OnEndDock? }
|
||||
//make it dockable
|
||||
Res.DragKind := dkDock;
|
||||
Res.DragMode := dmAutomatic;
|
||||
//always force FloatingDockSite
|
||||
{$IFDEF NeedHost}
|
||||
Res.FloatingDockSiteClass := TFloatingSite;
|
||||
{$ELSE}
|
||||
//if not ForIDE then //problems with the IDE?
|
||||
Res.OnEndDock := @FormEndDock; //float into default host site
|
||||
{$ENDIF}
|
||||
//wrap into floating site, if requested (not on restore Layout)
|
||||
if fWrap then begin
|
||||
{$IFDEF NeedHost}
|
||||
Res.FloatingDockSiteClass := TFloatingSite;
|
||||
{$ELSE}
|
||||
//if not ForIDE then //problems with the IDE?
|
||||
Res.OnEndDock := @FormEndDock; //float into default host site
|
||||
{$ENDIF}
|
||||
AForm.DisableAlign;
|
||||
Site := WrapDockable(AForm, fVisible);
|
||||
AForm.EnableAlign;
|
||||
end;
|
||||
//IDE?
|
||||
if ForIDE and fWrap and assigned(Site) and assigned(Site.DockManager) then begin
|
||||
@ -480,6 +480,7 @@ Notebooks?
|
||||
if site.DockManager = nil then
|
||||
TAppDockManager.Create(site);
|
||||
site.DockManager.LoadFromStream(Stream);
|
||||
site.Show;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
@ -705,6 +706,7 @@ function TDockMaster.WrapDockable(Client: TControl; fVisible: boolean): TFloatin
|
||||
var
|
||||
Site: TFloatingSite absolute Result;
|
||||
ctl: TControlAccess absolute Client;
|
||||
wctl: TWinControlAccess absolute Client;
|
||||
r: TRect;
|
||||
begin
|
||||
(* Wrap a control into a floating site.
|
||||
@ -729,11 +731,15 @@ begin
|
||||
Site.BoundsRect := r;
|
||||
//DebugLn('Before Wrap: ', DbgS(Site.BoundsRect));
|
||||
Client.Align := alNone;
|
||||
//retry make client auto-dockable
|
||||
{//retry make client auto-dockable?
|
||||
ctl.DragKind := dkDock;
|
||||
ctl.DragMode := dmAutomatic;
|
||||
ctl.DragMode := dmAutomatic;}
|
||||
if Client is TWinControl then
|
||||
wctl.DisableAlign;
|
||||
Client.ManualDock(Site);
|
||||
Client.Visible := True; //shown only if Site is visible
|
||||
Client.Visible := True; //shown only when Site becomes visible
|
||||
if Client is TWinControl then
|
||||
wctl.EnableAlign;
|
||||
//DebugLn('After Wrap: ', DbgS(Site.BoundsRect));
|
||||
|
||||
if ForIDE then begin
|
||||
@ -750,10 +756,6 @@ begin
|
||||
Site.Release;
|
||||
raise;
|
||||
end;
|
||||
{//retry make client auto-dockable
|
||||
ctl.DragKind := dkDock;
|
||||
ctl.DragMode := dmAutomatic;
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TDockMaster.DumpSites;
|
||||
|
Loading…
Reference in New Issue
Block a user