Having spent much of this week delving into the depths of docking I now
know of something else I'd like on the wish list. TDockTree does what
it does well, but is limited. Incidently, the docking demo project
DockEx has (at least) two bugs in it: for the record they are:
1/. positions of forms are not correct when undocking from a
TConjoinHost or a TTabHost. To fix, change the TConjoinHost.DoFloat
procedure to the following:
procedure TConjoinDockHost.DoFloat(AControl: TControl);
begin
//float the control with its original size.
AControl.ManualFloat(Rect(Left, Top, Left + AControl.UndockWidth,
Top + AControl.UnDockHeight));
end;
and change the TTabHost.FormClose procedure to the following:
procedure TTabDockHost.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if PageControl1.DockClientCount = 1 then begin
PageControl1.DockClients[0].ManualFloat(Rect(Left, Top, Left +
PageControl1.DockClients[0].UndockWidth, Top +
PageControl1.DockClients[0].UndockHeight));
Action := caFree;
end
else Action := caHide;
end;
2/. When docking a form in a TTabHost to its own PageControl ugly things
happen (try it). Here is a better way to deal with this. Replace
TTabDockHost.PageControl1UnDock with the following:
procedure TTabDockHost.PageControl1UnDock(Sender: TObject;
Client: TControl; NewTarget: TWinControl; var Allow: Boolean);
var LTabSheet: TTabSheet;
begin
if NewTarget = PageControl1 then begin
Allow := False;
// Rotate tabsheets instead - the dragged one becomes last
LTabSheet := Client.Parent as TTabSheet;
LTabSheet.PageControl := nil;
LTabSheet.PageControl := PageControl1;
PageControl1.ActivePage := LTabSheet;
end
//only 2 dock clients means the host must be destroyed and
//the remaining window undocked to its old position and size.
else if (PageControl1.DockClientCount = 2) and (NewTarget <> Self)
then begin
PostMessage(Self.Handle, WM_CLOSE, 0, 0);
end;
end;
Anyway, that was the easy bit. Delving into the depths of TDockTree to
enhance it, things became very hairy indeed! The main problem I have
with TDockTree as a docking manager is that I can't easily persuade its
zones to size themselves sensibly to cope with the docking of
constrained forms - or indeed, do it at all. Also, while it copes well
with docking forms together, it doesn't understand very well if you try
to explain that what you want is all these panels to be treated just as
if they're forms _already docked_ to a container form. And I can't
quite justify spending the time to create a new dock manager all of my
very own. Having said that, it's probably warranted - I just won't be
the one who gets to do it.
So here's my wish for today. :)
In an ideal world, I want to have three new components: a
TContainerForm, which contains a TDockArea, and TDockPanels within that.
The latter act like forms that start off docked to their container -
they're always aligned (not alNone) or in PageControls, which are not
explicit components but group properties of themselves. They have
properties that specify whether or not they have a grabber, which side
it's on, and whether or not they have a close button, among others. The
TDockArea is just a container for a TDockTree, that allows you to see
everything docked in place at design time (sorely required IMO, and
that's the main problem with the IDockManager interface), except that it
also dynamically creates and removes PageControls in its zones,
depending how and where you dock.
A TContainerForm is a form that contains these. Whenever you undock a
TDockPanel from a TDockArea, another TContainerForm is created to hold
it (unless it's the last one you're trying to undock - that's called
moving your window) and whenever one container form docks with another,
one is removed. Oh, while I'm wishing I'd also like menus specific to
each TDockPanel, so that they merge, in an MDI sort of way, when docked.
Any components not in the TDockArea that are specific to the
TContainerForm, also including menus, are duplicated to exist on every
container form created. They become the "menu container" if you will.
I mention menus, but it would be useful to have this flexibility with
toolbars as well. Lastly, container forms dock only with others of the
same type, and with TDockPanels from others of the same type.
This functionality would be very powerful. With an extremely small
amount of preparatory design you could enable users to tear your large
form into little formlets, each from a TabSheet or TDockPanel, and dock
the pieces they wanted together again any which way they chose. Oh, and
an option to save preferences wouldn't go amiss either. Sound
attractive? Or am I living in a dreamworld again? :)
> Carl Reynolds Ph: +64-9-4154790
> CJN Technologies Ltd. Fax: +64-9-4154791
> [EMAIL PROTECTED] DDI: +64-9-4154795
> PO Box 302-278, North Harbour, Auckland, New Zealand
> 12 Piermark Drive, North Harbour Estate, Auckland, NZ
> Visit our website at http://www.cjntech.co.nz/
>
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Offtopic List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
application/ms-tnef