Changeset 55 for Docking/CoolDocking/UCoolDocking.pas
- Timestamp:
- Sep 20, 2010, 1:15:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDocking.pas
r54 r55 9 9 uses 10 10 Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls, 11 Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil; 11 Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil, 12 UCoolDockCustomize, DOM, XMLWrite, XMLRead; 12 13 13 14 const … … 88 89 procedure InsertControlPanel(Control: TControl; InsertAt: TAlign; 89 90 DropCtl: TControl); 91 procedure PopupMenuTabCloseClick(Sender: TObject); 90 92 procedure SetDockStyle(const AValue: TDockStyle); 91 93 procedure SetMoveDuration(const AValue: Integer); … … 102 104 procedure PopupMenuPositionTopClick(Sender: TObject); 103 105 procedure PopupMenuPositionBottomClick(Sender: TObject); 106 procedure PopupMenuUndockClick(Sender: TObject); 104 107 procedure Timer1Timer(Sender: TObject); 108 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton; 109 Shift: TShiftState; X, Y: Integer); 105 110 public 106 111 constructor Create(ADockSite: TWinControl); override; … … 168 173 SPositionRight = 'Right'; 169 174 SPositionBottom = 'Bottom'; 175 SUndock = 'Undock'; 170 176 171 177 procedure Register; 172 178 begin 173 179 RegisterComponents('CoolDocking', [TCoolDockMaster]); 180 RegisterComponents('CoolDocking', [TCoolDockCustomize]); 174 181 end; 175 182 … … 254 261 NewMenuItem.Caption := SRenameForm; 255 262 NewMenuItem.OnClick := PopupMenuRenameClick; 263 PopupMenu1.Items.Add(NewMenuItem); 264 265 NewMenuItem := TMenuItem.Create(PopupMenu1); 266 NewMenuItem.Caption := SUndock; 267 NewMenuItem.OnClick := PopupMenuUndockClick; 256 268 PopupMenu1.Items.Add(NewMenuItem); 257 269 … … 264 276 OnChange := TabControlChange; 265 277 PopupMenu := PopupMenu1; 278 OnMouseDown := TabControlMouseDown; 266 279 end; 267 280 TabsPos := hpTop; … … 344 357 if DockStyle = dsList then Visible := True; 345 358 Align := alClient; 346 PopupMenu := PopupMenu1;347 359 end; 348 360 … … 376 388 if (not Assigned(FDockSite.Parent)) then begin 377 389 // Create conjointed form 378 NewConjoinDockForm := TCoolDockConjoinForm.Create( nil);390 NewConjoinDockForm := TCoolDockConjoinForm.Create(Application); 379 391 NewConjoinDockForm.Visible := True; 380 392 NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect; … … 382 394 Control.ManualDock(NewConjoinDockForm.Panel, nil, InsertAt); 383 395 end else begin 384 NewConjoinDockForm := TCoolDockConjoinForm.Create( nil);396 NewConjoinDockForm := TCoolDockConjoinForm.Create(Application); 385 397 NewConjoinDockForm.Visible := True; 386 398 NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect; … … 464 476 FDockPanels.Remove(ClientPanel); 465 477 if FDockSite.DockClientCount = 2 then FDockDirection := ddNone; 478 UpdateClientSize; 466 479 //FDockSite.Invalidate; 467 480 //if (FDockSite is TCoolDockConjoinForm) and (FDockSite.DockClientCount = 1) then … … 498 511 NewConjoinDockForm: TCoolDockConjoinForm; 499 512 begin 500 NewConjoinDockForm := TCoolDockConjoinForm.Create( nil);513 NewConjoinDockForm := TCoolDockConjoinForm.Create(Application); 501 514 NewConjoinDockForm.Visible := True; 502 515 NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect; … … 632 645 procedure TCoolDockManager.PopupMenuCloseClick(Sender: TObject); 633 646 begin 634 // TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close; 647 TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close; 648 end; 649 650 procedure TCoolDockManager.PopupMenuTabCloseClick(Sender: TObject); 651 begin 652 if TabControl.TabIndex <> -1 then 653 TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control.Hide; 635 654 end; 636 655 … … 665 684 end; 666 685 686 procedure TCoolDockManager.PopupMenuUndockClick(Sender: TObject); 687 begin 688 689 end; 690 667 691 procedure TCoolDockManager.Timer1Timer(Sender: TObject); 668 692 begin 669 693 // TimerMoveForm.Width := TimerMoveForm.Width 694 end; 695 696 procedure TCoolDockManager.TabControlMouseDown(Sender: TObject; Button: TMouseButton; 697 Shift: TShiftState; X, Y: Integer); 698 begin 699 if (Button = mbLeft) and (TabControl.TabIndex <> -1) then begin 700 DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1); 701 end; 670 702 end; 671 703 … … 803 835 804 836 procedure TCoolDockMaster.SaveLayoutToStream(Stream: TStream); 805 begin 806 837 var 838 Doc: TXMLDocument; 839 RootNode: TDOMNode; 840 NewNode: TDOMNode; 841 NewNode2: TDOMNode; 842 I: Integer; 843 begin 844 Doc := TXMLDocument.Create; 845 with Doc do try 846 RootNode := CreateElement('DockLayout'); 847 AppendChild(RootNode); 848 with RootNode do begin 849 for I := 0 to Application.ComponentCount - 1 do begin 850 if Application.Components[I] is TForm then 851 with Application.Components[I] as TForm do 852 if Assigned(HostDockSite) then 853 begin 854 NewNode := OwnerDocument.CreateElement('Form'); 855 856 if HostDockSite.Parent is TForm then begin 857 NewNode2 := OwnerDocument.CreateElement('ParentFormName'); 858 NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.Name); 859 NewNode.AppendChild(NewNode2); 860 861 NewNode2 := OwnerDocument.CreateElement('ParentFormClassName'); 862 NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.ClassName); 863 NewNode.AppendChild(NewNode2); 864 end; 865 866 NewNode2 := OwnerDocument.CreateElement('Name'); 867 NewNode2.TextContent := UTF8Decode(Name); 868 NewNode.AppendChild(NewNode2); 869 870 NewNode2 := OwnerDocument.CreateElement('Caption'); 871 NewNode2.TextContent := UTF8Decode(Caption); 872 NewNode.AppendChild(NewNode2); 873 874 NewNode2 := OwnerDocument.CreateElement('Width'); 875 NewNode2.TextContent := IntToStr(Width); 876 NewNode.AppendChild(NewNode2); 877 878 NewNode2 := OwnerDocument.CreateElement('Height'); 879 NewNode2.TextContent := IntToStr(Height); 880 NewNode.AppendChild(NewNode2); 881 882 NewNode2 := OwnerDocument.CreateElement('UndockWidth'); 883 NewNode2.TextContent := IntToStr(UndockWidth); 884 NewNode.AppendChild(NewNode2); 885 886 NewNode2 := OwnerDocument.CreateElement('UndockHeight'); 887 NewNode2.TextContent := IntToStr(UndockHeight); 888 NewNode.AppendChild(NewNode2); 889 890 NewNode2 := OwnerDocument.CreateElement('FormState'); 891 NewNode2.TextContent := IntToStr(Integer(FormState)); 892 NewNode.AppendChild(NewNode2); 893 894 NewNode2 := OwnerDocument.CreateElement('Visible'); 895 NewNode2.TextContent := IntToStr(Integer(Visible)); 896 NewNode.AppendChild(NewNode2); 897 898 AppendChild(NewNode); 899 end; 900 end; 901 end; 902 WriteXMLFile(Doc, Stream); 903 finally 904 Free; 905 end; 807 906 end; 808 907
Note:
See TracChangeset
for help on using the changeset viewer.