mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-23 08:59:14 +02:00
dockmanager example: some cleanup, dockbook is working now
git-svn-id: trunk@20332 -
This commit is contained in:
parent
c06f404a56
commit
a045057513
@ -19,7 +19,6 @@ begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TEasyDockMain, EasyDockMain);
|
||||
Application.CreateForm(TDumpBox, DumpBox);
|
||||
Application.CreateForm(TEasyDockBook, EasyDockBook);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
@ -53,6 +53,8 @@ done? (unclear whether this is really fixed in the trunk)
|
||||
{.$DEFINE NoDrop} //patched dragobject?
|
||||
{.$DEFINE visibility} //handling of invisible clients deserves dock manager notification!
|
||||
{.$DEFINE restore} //restore button?
|
||||
{.$DEFINE singleTab} //allow to create notebooks with 1 tab (in the topzone)?
|
||||
//doesn't look nice, with both a header AND a button list
|
||||
{$DEFINE bookform} //using notebook within form? Seems to work ONLY if defined
|
||||
|
||||
interface
|
||||
@ -195,7 +197,9 @@ type
|
||||
public
|
||||
procedure MessageHandler(Sender: TControl; var Message: TLMessage); override;
|
||||
public
|
||||
{$IFDEF singleTab}
|
||||
SingleTab: boolean; //always create notebook for alCustom?
|
||||
{$ENDIF}
|
||||
constructor Create(ADockSite: TWinControl);
|
||||
destructor Destroy; override;
|
||||
procedure AdjustDockRect(Control: TControl; var ARect: TRect);
|
||||
@ -290,8 +294,10 @@ begin
|
||||
DockSite.DockManager := self;
|
||||
//init node class - impossible due to visibility restrictions!
|
||||
inherited Create; //(DockSite);
|
||||
{$IFDEF singleTab}
|
||||
//test: notebook with 1 tab in root zone
|
||||
SingleTab := True;
|
||||
{$ENDIF}
|
||||
//init top zone
|
||||
FSiteRect := DockSite.ClientRect;
|
||||
FTopZone := TEasyZone.Create(self);
|
||||
@ -466,6 +472,7 @@ begin
|
||||
NoteBookAdd(NoteBook, Control);
|
||||
FDockSite.Invalidate; //update notebook caption
|
||||
exit;
|
||||
{$IFDEF singleTab}
|
||||
end else if SingleTab and not (DropCtl is TEasyBook) then begin
|
||||
//empty root zone, create new notebook
|
||||
NoteBook := NoteBookCreate(FDockSite);
|
||||
@ -473,6 +480,8 @@ begin
|
||||
NoteBookAdd(NoteBook, Control);
|
||||
FDockSite.Invalidate; //update notebook caption
|
||||
exit;
|
||||
{$ELSE}
|
||||
{$ENDIF}
|
||||
end; // else //continue docking of the notebook
|
||||
InsertAt := alNone; //force automatic orientation
|
||||
end;
|
||||
@ -617,9 +626,11 @@ Signal results:
|
||||
DropOnControl := zone.ChildControl;
|
||||
DropAlign := DetectAlign(ADockRect, DragTargetPos);
|
||||
if DropOnControl = nil then begin
|
||||
{$IFDEF singleTab}
|
||||
if SingleTab and (DropAlign = alCustom) then begin
|
||||
//notebook in top zone
|
||||
end else
|
||||
{$ENDIF}
|
||||
DropAlign := alClient; //first element in entire site
|
||||
end; //else //determine the alignment within the zone.
|
||||
//to screen coords
|
||||
@ -631,8 +642,9 @@ Signal results:
|
||||
//force DockRect update by DockTrackNoTarget
|
||||
DropOnControl := Control; //prevent drop - signal drop onto self
|
||||
{$IFDEF NoDrop}
|
||||
NoDrop := True;
|
||||
NoDrop := True; //signal that nothing will happen on a drop
|
||||
{$ELSE}
|
||||
//all these are lousy features, do not allow to signal an invalid drop
|
||||
DragTarget := nil;
|
||||
//Control.DockTrackNoTarget
|
||||
//DragTarget := FDockSite; //prevent floating - doesn't work :-(
|
||||
@ -657,7 +669,7 @@ begin
|
||||
//debug!
|
||||
DropOn := DropCtl;
|
||||
|
||||
if (DropCtl = nil) and not SingleTab then
|
||||
if (DropCtl = nil) {$IFDEF singleTab} and not SingleTab {$ENDIF} then
|
||||
exit; //empty dock site
|
||||
|
||||
case DropAlign of
|
||||
|
@ -30,14 +30,6 @@ object EasyDockBook: TEasyDockBook
|
||||
ParentFont = False
|
||||
ShowCaptions = True
|
||||
TabOrder = 0
|
||||
object ToolButton1: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
AutoSize = True
|
||||
Caption = 'ToolButton1'
|
||||
Style = tbsCheck
|
||||
Visible = False
|
||||
end
|
||||
end
|
||||
object pnlDock: TPanel
|
||||
Left = 0
|
||||
|
@ -10,10 +10,8 @@ LazarusResources.Add('TEasyDockBook','FORMDATA',[
|
||||
+'orizontalSpacing'#2#2#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBo'
|
||||
+'ttom'#5'Color'#7#9'clBtnFace'#11'EdgeBorders'#11#5'ebTop'#8'ebBottom'#0#4'F'
|
||||
+'lat'#8#10'Font.Style'#11#6'fsBold'#0#4'List'#9#11'ParentColor'#8#10'ParentF'
|
||||
+'ont'#8#12'ShowCaptions'#9#8'TabOrder'#2#0#0#11'TToolButton'#11'ToolButton1'
|
||||
+#4'Left'#2#0#3'Top'#2#0#8'AutoSize'#9#7'Caption'#6#11'ToolButton1'#5'Style'#7
|
||||
+#8'tbsCheck'#7'Visible'#8#0#0#0#6'TPanel'#7'pnlDock'#4'Left'#2#0#6'Height'#3
|
||||
+#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClient'#7'Caption'#6#7'pnl'
|
||||
+'Dock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15'pnlDockDockDrop'#8
|
||||
+'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
||||
+'ont'#8#12'ShowCaptions'#9#8'TabOrder'#2#0#0#0#6'TPanel'#7'pnlDock'#4'Left'#2
|
||||
+#0#6'Height'#3#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClient'#7'Ca'
|
||||
+'ption'#6#7'pnlDock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15'pnlDo'
|
||||
+'ckDockDrop'#8'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
||||
]);
|
||||
|
@ -31,7 +31,6 @@ type
|
||||
TEasyDockBook = class(TForm)
|
||||
pnlDock: TPanel;
|
||||
Tabs: TToolBar;
|
||||
ToolButton1: TToolButton;
|
||||
procedure pnlDockDockDrop(Sender: TObject; Source: TDragDockObject;
|
||||
X, Y: Integer);
|
||||
procedure pnlDockUnDock(Sender: TObject; Client: TControl;
|
||||
@ -130,7 +129,7 @@ begin
|
||||
if CurTab = nil then begin //current button removed
|
||||
//find next tab to show
|
||||
if i >= Tabs.ButtonCount then
|
||||
dec(i);
|
||||
i := Pred(Tabs.ButtonCount); // dec(i);
|
||||
//activate new tab
|
||||
CurTab := Tabs.Buttons[i] as TTabButton;
|
||||
CurTab.Down := True;
|
||||
|
@ -1,7 +1,7 @@
|
||||
object EasyDockMain: TEasyDockMain
|
||||
Left = 680
|
||||
Left = 280
|
||||
Height = 285
|
||||
Top = 125
|
||||
Top = 123
|
||||
Width = 461
|
||||
ActiveControl = buDump
|
||||
Caption = 'EasyDockMain'
|
||||
@ -80,7 +80,7 @@ object EasyDockMain: TEasyDockMain
|
||||
end
|
||||
object edDock: TEdit
|
||||
Left = 249
|
||||
Height = 22
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 80
|
||||
DragKind = dkDock
|
||||
|
@ -1,18 +1,18 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TEasyDockMain','FORMDATA',[
|
||||
'TPF0'#13'TEasyDockMain'#12'EasyDockMain'#4'Left'#3#168#2#6'Height'#3#29#1#3
|
||||
+'Top'#2'}'#5'Width'#3#205#1#13'ActiveControl'#7#6'buDump'#7'Caption'#6#12'Ea'
|
||||
+'syDockMain'#12'ClientHeight'#3#29#1#11'ClientWidth'#3#205#1#11'Font.Height'
|
||||
+#2#245#9'Font.Name'#6#13'MS Sans Serif'#8'OnCreate'#7#10'FormCreate'#10'LCLV'
|
||||
+'ersion'#6#6'0.9.27'#0#10'TStatusBar'#2'sb'#4'Left'#2#0#6'Height'#2#20#3'Top'
|
||||
+#3#9#1#5'Width'#3#205#1#6'Panels'#14#0#0#0#8'TToolBar'#8'ToolBar1'#4'Left'#2
|
||||
+#0#6'Height'#2#29#3'Top'#2#0#5'Width'#3#205#1#7'Caption'#6#8'ToolBar1'#8'Tab'
|
||||
+'Order'#2#1#0#6'TShape'#6'Shape1'#4'Left'#2#1#6'Height'#2#22#3'Top'#2#2#5'Wi'
|
||||
+'dth'#2#21#11'Brush.Color'#7#5'clRed'#9'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6
|
||||
+'TShape'#6'Shape2'#4'Left'#2#22#6'Height'#2#22#3'Top'#2#2#5'Width'#2#24#11'B'
|
||||
+'rush.Color'#7#6'clLime'#9'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6'TShape'#6'Sh'
|
||||
+'ape4'#4'Left'#2'.'#6'Height'#2#22#3'Top'#2#2#5'Width'#2#24#11'Brush.Color'#7
|
||||
'TPF0'#13'TEasyDockMain'#12'EasyDockMain'#4'Left'#3#24#1#6'Height'#3#29#1#3'T'
|
||||
+'op'#2'{'#5'Width'#3#205#1#13'ActiveControl'#7#6'buDump'#7'Caption'#6#12'Eas'
|
||||
+'yDockMain'#12'ClientHeight'#3#29#1#11'ClientWidth'#3#205#1#11'Font.Height'#2
|
||||
+#245#9'Font.Name'#6#13'MS Sans Serif'#8'OnCreate'#7#10'FormCreate'#10'LCLVer'
|
||||
+'sion'#6#6'0.9.27'#0#10'TStatusBar'#2'sb'#4'Left'#2#0#6'Height'#2#20#3'Top'#3
|
||||
+#9#1#5'Width'#3#205#1#6'Panels'#14#0#0#0#8'TToolBar'#8'ToolBar1'#4'Left'#2#0
|
||||
+#6'Height'#2#29#3'Top'#2#0#5'Width'#3#205#1#7'Caption'#6#8'ToolBar1'#8'TabOr'
|
||||
+'der'#2#1#0#6'TShape'#6'Shape1'#4'Left'#2#1#6'Height'#2#22#3'Top'#2#2#5'Widt'
|
||||
+'h'#2#21#11'Brush.Color'#7#5'clRed'#9'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6'T'
|
||||
+'Shape'#6'Shape2'#4'Left'#2#22#6'Height'#2#22#3'Top'#2#2#5'Width'#2#24#11'Br'
|
||||
+'ush.Color'#7#6'clLime'#9'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6'TShape'#6'Sha'
|
||||
+'pe4'#4'Left'#2'.'#6'Height'#2#22#3'Top'#2#2#5'Width'#2#24#11'Brush.Color'#7
|
||||
+#8'clYellow'#9'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6'TShape'#6'Shape3'#4'Left'
|
||||
+#2'F'#6'Height'#2#22#3'Top'#2#2#5'Width'#2#24#11'Brush.Color'#7#6'clBlue'#9
|
||||
+'OnMouseUp'#7#13'Shape1MouseUp'#0#0#6'TLabel'#6'lbDock'#4'Left'#3#152#0#6'He'
|
||||
@ -20,7 +20,7 @@ LazarusResources.Add('TEasyDockMain','FORMDATA',[
|
||||
+#7'Caption'#6#8'Drag Me!'#8'DragKind'#7#6'dkDock'#8'DragMode'#7#11'dmAutomat'
|
||||
+'ic'#11'ParentColor'#8#0#0#7'TButton'#6'buDump'#4'Left'#2'^'#6'Height'#2#22#3
|
||||
+'Top'#2#2#5'Width'#2':'#7'Caption'#6#4'Dump'#7'OnClick'#7#11'buDumpClick'#8
|
||||
+'TabOrder'#2#0#0#0#5'TEdit'#6'edDock'#4'Left'#3#249#0#6'Height'#2#22#3'Top'#2
|
||||
+'TabOrder'#2#0#0#0#5'TEdit'#6'edDock'#4'Left'#3#249#0#6'Height'#2#23#3'Top'#2
|
||||
+#2#5'Width'#2'P'#8'DragKind'#7#6'dkDock'#8'TabOrder'#2#1#4'Text'#6#8'Drag Me'
|
||||
+'!'#0#0#7'TButton'#9'buManDock'#4'Left'#3'I'#1#6'Height'#2#22#3'Top'#2#2#5'W'
|
||||
+'idth'#2'K'#7'Caption'#6#9'buManDock'#7'OnClick'#7#14'buManDockClick'#8'TabO'
|
||||
|
@ -1,6 +1,9 @@
|
||||
unit fMain;
|
||||
(* EasyDockSite dock test form by DoDi.
|
||||
Demonstrates docking of various controls, and related bugs in the LCL.
|
||||
|
||||
Beware: writing to e.g. the StatusBar from dock event handlers
|
||||
can cause relicts of a docking rectangle in the changed text.
|
||||
*)
|
||||
|
||||
(* A dock site should contain no other (not docked) controls.
|
||||
@ -8,8 +11,6 @@ unit fMain;
|
||||
This does not (yet) work with the LCL :-(
|
||||
When a docking manager is replaced, the controls should be undocked again?
|
||||
(depends on the lists, where docked and undocked controls reside in the dock site)
|
||||
|
||||
LCL does not notify the docking manager of a resized dock site?
|
||||
*)
|
||||
|
||||
//some defines, to demonstrate LCL flaws
|
||||
@ -61,11 +62,6 @@ type
|
||||
Y: Integer; State: TDragState; var Accept: Boolean);
|
||||
procedure buDumpClick(Sender: TObject);
|
||||
private
|
||||
{$IFDEF docker}
|
||||
//Docker: TPanel;
|
||||
{$ELSE}
|
||||
//Docker: TForm;
|
||||
{$ENDIF}
|
||||
Docker: TWinControl;
|
||||
ShapeCount: integer;
|
||||
public
|
||||
@ -97,6 +93,8 @@ var
|
||||
ctl: TShape;
|
||||
r: TRect;
|
||||
begin
|
||||
(* Clone the clicked shape and make it floating.
|
||||
*)
|
||||
if sender is TShape then begin
|
||||
shp := Sender as TShape;
|
||||
{$IFDEF dragForm}
|
||||
@ -106,7 +104,6 @@ begin
|
||||
sb.SimpleText := df.Name;
|
||||
c := shp.Brush.Color;
|
||||
//df.Color := c; - not all widgetsets support TForm.Color!?
|
||||
//c := df.Color;
|
||||
df.Shape1.Brush.Color := c;
|
||||
|
||||
{ TODO -cdocking : form is not dockable with some widgetsets? }
|
||||
@ -130,13 +127,12 @@ begin
|
||||
ctl.Brush.Color := shp.Brush.Color;
|
||||
ctl.DragMode := dmAutomatic;
|
||||
ctl.DragKind := dkDock;
|
||||
//position the floating control near the clicked shape
|
||||
r.TopLeft := self.BoundsRect.TopLeft;
|
||||
//r.Left := x; r.Top := y;
|
||||
r.Right := r.Left + 100;
|
||||
r.Bottom := r.Top + 100;
|
||||
ctl.ManualFloat(r); //(ctl.BoundsRect);
|
||||
ctl.ManualFloat(r);
|
||||
{$ENDIF}
|
||||
//df.Name := shp.Name;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user