From: <wp...@us...> - 2012-09-12 01:55:31
|
Revision: 13435 http://jvcl.svn.sourceforge.net/jvcl/?rev=13435&view=rev Author: wpostma Date: 2012-09-12 01:55:23 +0000 (Wed, 12 Sep 2012) Log Message: ----------- Fix demo examples\jvdocking\DockingInCode - some of the buttons in the demo were for features that never worked. Removed. Also, it turns out that using caFree as a CloseAction in a formClose event in the Document Form, is incompatible with the design of JvDocking. Fixed the docking demo so that we have a list of docked documents, which we undock when things are going to be messy, and we free in a controlled way AFTER all docking or undocking operations have completed. Modified Paths: -------------- trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.dfm trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.pas trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.dfm trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.pas Modified: trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.dfm =================================================================== --- trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.dfm 2012-09-11 07:37:34 UTC (rev 13434) +++ trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.dfm 2012-09-12 01:55:23 UTC (rev 13435) @@ -1,9 +1,9 @@ object DocForm: TDocForm Left = 456 Top = 476 - Width = 745 - Height = 513 Caption = 'Document Form' + ClientHeight = 474 + ClientWidth = 729 Color = clAqua DockSite = True DragKind = dkDock @@ -14,7 +14,6 @@ Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False - OnClose = FormClose OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnEndDock = FormEndDock @@ -35,7 +34,7 @@ Left = 0 Top = 33 Width = 729 - Height = 442 + Height = 441 Align = alClient Color = 16642009 ColCount = 20 Modified: trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.pas =================================================================== --- trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.pas 2012-09-11 07:37:34 UTC (rev 13434) +++ trunk/jvcl/examples/JvDocking/DockingInCode/DocFm.pas 2012-09-12 01:55:23 UTC (rev 13435) @@ -23,7 +23,6 @@ DockForm: TForm; DockServer: TJvDockServer; DockPanel: TJvDockPanel; var CanDock: Boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); - procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button1Click(Sender: TObject); procedure FormUnDock(Sender: TObject; Client: TControl; NewTarget: TWinControl; var Allow: Boolean); @@ -47,6 +46,7 @@ public { Public declarations } property OnTrace:TMsgEvent read FOnTrace write FOnTrace; + end; var @@ -171,9 +171,4 @@ end; -procedure TDocForm.FormClose(Sender: TObject; var Action: TCloseAction); -begin - Action := caFree; -end; - end. Modified: trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.dfm =================================================================== --- trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.dfm 2012-09-11 07:37:34 UTC (rev 13434) +++ trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.dfm 2012-09-12 01:55:23 UTC (rev 13435) @@ -1,9 +1,9 @@ object MainForm: TMainForm Left = 290 Top = 259 - Width = 965 - Height = 678 Caption = 'Controlling Docking from Code' + ClientHeight = 639 + ClientWidth = 949 Color = 14734247 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -17,17 +17,18 @@ TextHeight = 13 object JvSplitter1: TJvSplitter Left = 0 - Top = 473 + Top = 472 Width = 949 Height = 3 Cursor = crVSplit Align = alBottom + ExplicitTop = 473 end object Panel1: TPanel Left = 0 Top = 0 Width = 265 - Height = 473 + Height = 472 Align = alLeft Color = 15399897 TabOrder = 0 @@ -48,34 +49,6 @@ TabOrder = 0 OnClick = ButtonSibDockClick end - object Button2: TButton - Left = 6 - Top = 164 - Width = 99 - Height = 25 - Hint = 'Display number of windows docked in the Custom Docking Area.' - Caption = 'View Dock Tree' - TabOrder = 5 - OnClick = Button2Click - end - object Button3: TButton - Left = 6 - Top = 101 - Width = 99 - Height = 25 - Caption = 'Save Layout' - TabOrder = 3 - OnClick = Button3Click - end - object Button4: TButton - Left = 6 - Top = 132 - Width = 99 - Height = 25 - Caption = 'Load Layout' - TabOrder = 4 - OnClick = Button4Click - end object ButtonCreateTabDock: TButton Left = 6 Top = 72 @@ -103,7 +76,7 @@ Height = 22 MaxValue = 100 MinValue = 0 - TabOrder = 6 + TabOrder = 3 Value = 18 OnChange = SpinEdit1Change end @@ -113,7 +86,7 @@ Width = 233 Height = 17 Caption = 'Dock in tabs to right side (reproduce bug)' - TabOrder = 7 + TabOrder = 4 OnClick = tbDockRightSideClick end object cbWorkaround: TCheckBox @@ -124,7 +97,7 @@ Caption = 'Tab-Docking workaround mode' Checked = True State = cbChecked - TabOrder = 8 + TabOrder = 5 Visible = False end end @@ -132,21 +105,22 @@ Left = 265 Top = 0 Width = 684 - Height = 473 + Height = 472 Align = alClient Caption = 'Custom Docking Area' - Color = 4227200 + Color = clWhite Font.Charset = DEFAULT_CHARSET Font.Color = clWindow Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] + ParentBackground = False ParentFont = False TabOrder = 1 end object Panel3: TPanel Left = 0 - Top = 476 + Top = 475 Width = 949 Height = 164 Align = alBottom Modified: trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.pas =================================================================== --- trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.pas 2012-09-11 07:37:34 UTC (rev 13434) +++ trunk/jvcl/examples/JvDocking/DockingInCode/MainFm.pas 2012-09-12 01:55:23 UTC (rev 13435) @@ -132,25 +132,48 @@ } uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, JvComponent, JvDockControlForm, ExtCtrls, JvDockVIDVCStyle, - StdCtrls, JvDockVIDStyle, JvDockDelphiStyle, JvDockVSNetStyle, - JvAppStorage, JvAppIniStorage, DocFm, JvExExtCtrls, JvSplitter, Spin, - JvDockTree, JvComponentBase; + Windows, + Messages, + SysUtils, + Variants, + Classes, + Graphics, + Controls, + Forms, + Dialogs, + ExtCtrls, + StdCtrls, + Contnrs, + Spin, + DocFm, + + JvComponent, + JvDockControlForm, + JvDockVIDVCStyle, + JvDockVIDStyle, + JvDockDelphiStyle, + JvDockVSNetStyle, + JvAppStorage, + JvAppIniStorage, + JvExExtCtrls, + JvSplitter, + JvDockTree, + JvComponentBase; + + const - MinWidth=500; + MinWidth=500; type + TLastClickEnum = (lcNone,lcConjoin,lcSibling,lcTabbed); + TMainForm = class(TForm) Panel1: TPanel; Panel2: TPanel; dockServer: TJvDockServer; ButtonSibDock: TButton; JvDockVIDStyle1: TJvDockVIDStyle; - Button2: TButton; - Button3: TButton; DockIniStorage: TJvAppIniFileStorage; - Button4: TButton; ButtonCreateTabDock: TButton; ButtonCreateConjoin: TButton; Panel3: TPanel; @@ -179,11 +202,15 @@ FColors : Array of TColor; FIndex :Integer; FDocumentFormIndex:Integer; // Give each form a different caption. - + FDocs:TObjectList; + FLastClick:TLastClickEnum; procedure Trace(msg:String); function MakeNewDocFm:TDocForm; + procedure clearOldDocs; + + public { Public declarations } end; @@ -213,16 +240,19 @@ function TMainForm.MakeNewDocFm:TDocForm; begin result := TDocForm.Create(nil); + result.Visible := false; result.DockClient.DockStyle := DockServer.DockStyle; result.sg.Color := FColors[FIndex]; result.OnTrace := Trace; + Inc(FDocumentFormIndex); result.Caption := 'Document Form #'+IntToStr(FDocumentFormIndex); result.Name := 'DocumentForm'+IntToStr(FDocumentFormIndex); - Inc(FIndex); + FDocs.Add(result); + FIndex := FDocs.Count; if (FIndex>=Length(FColors)) then FIndex := 0; result.Top := result.Top + (FIndex * 10); @@ -230,6 +260,7 @@ end; + procedure TMainForm.ButtonSibDockClick(Sender: TObject); var newDocFm:TDocForm; @@ -239,14 +270,15 @@ ctrl:TWinControl; adef:TAlign; begin + if FLastClick<>lcSibling then + clearOldDocs; + + FLastClick := lcSibling; Assert(Assigned(DockServer.DockStyle)); newDocFm := MakeNewDocFm; - newDocFm.Show; - Assert(Assigned(DockServer.CustomDockPanel)); - { Simplest version just puts siblings side by side horizontally: } // newDocFm.ManualDock( DockServer.CustomDockPanel, nil, alNone ) @@ -289,11 +321,38 @@ newDocFm.ManualDock( ctrl, besideForm, alRight ); end; + newDocFm.Show; + TJvDockPanel(ctrl).DockManager.ResetBounds(true); end; +procedure TMainForm.clearOldDocs; +var + n:Integer; + R:TRect; + dockClient:TJvDockClient; + ctrl:TControl; +begin + R.Top := -800; + R.Left := -800; + for n := 0 to dockServer.CustomDockPanel.DockClientCount-1 do + begin + ctrl := dockServer.CustomDockPanel.DockClients[n]; + if ctrl is TForm then + begin + dockClient := FindDockClient(ctrl); + dockClient.FormUnDock(nil,nil); + end; + + //dockClient.FormUnDock(nil,nil); + end; + + // This Frees previously created forms. + FDocs.Clear; +end; + procedure TMainForm.FormCreate(Sender: TObject); begin SetLengtH( FColors, 5 ); @@ -305,6 +364,7 @@ DockIniStorage.FileName := ExtractFilePath(Application.ExeName)+'CustomTabbedDockingLayout.ini'; + FDocs := TObjectList.Create(true); end; @@ -431,6 +491,11 @@ tabHost: TJvDockTabHostForm; ctrl:TWinControl; begin + // clear previous contents + clearOldDocs; + FLastClick := lcTabbed; + + newDocFm1 := MakeNewDocFm; newDocFm2 := MakeNewDocFm; @@ -450,7 +515,9 @@ newDocFm2 := MakeNewDocFm; ManualTabDockAddPage( tabHost, newDocFm2 ); end; - + + newDocFm1.Show; + newDocFm2.Show; end; @@ -461,10 +528,16 @@ newDocFm1,newDocFm2:TDocForm; // conjoinHost:TJvDockConjoinHostForm; begin + if FLastClick <> lcConjoin then + clearOldDocs; + + FLastClick := lcConjoin; newDocFm1 := MakeNewDocFm; newDocFm2 := MakeNewDocFm; {conjoinHost := }ManualConjoinDock( DockServer.CustomDockPanel, newDocFm1, newDocFm2 ); + newDocFm1.Show; + newDocFm2.Show; // How to add a 3rd and a fourth page: // newDocFm2 := MakeNewDocFm; // ManualConjoinDockAdd( conjoinHost, newDocFm2 ); //TODO! IMPLEMENT THIS HELPER FUNCTION! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |