Changeset 183 for Docking/CoolDocking/UCoolDockStyleRegions.pas
- Timestamp:
- Mar 10, 2011, 7:55:48 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDockStyleRegions.pas
r182 r183 6 6 7 7 uses 8 Classes, SysUtils, Controls, ExtCtrls, StdCtrls, UCoolDockStyle, 8 Classes, SysUtils, Controls, ExtCtrls, StdCtrls, UCoolDockStyle, Forms, 9 9 Graphics, Contnrs, Buttons, UCoolDockClientPanel, UCoolDockCommon; 10 10 … … 18 18 TCoolDockStyleRegions = class(TCoolDockStyle) 19 19 private 20 function GetDirection(InsertAt: TAlign): TDockDirection; 20 21 public 21 Panels: TObjectList; // TObjectList<TCoolDockStyleRegionsPanel> 22 FDockDirection: TDockDirection; 23 //Panels: TObjectList; // TObjectList<TCoolDockStyleRegionsPanel> 24 procedure InsertControl(AControl: TControl; InsertAt: TAlign); override; 25 procedure RemoveControl(Control: TControl); override; 22 26 function GetHeaderPos: THeaderPos; override; 23 27 procedure SetHeaderPos(const AValue: THeaderPos); override; … … 27 31 procedure SetVisible(const AValue: Boolean); override; 28 32 procedure ChangeVisible(Control: TWinControl; Visible: Boolean); override; 33 property DockDirection: TDockDirection read FDockDirection 34 write FDockDirection; 29 35 end; 30 36 … … 37 43 { TCoolDockStyleRegions } 38 44 45 function TCoolDockStyleRegions.GetDirection(InsertAt: TAlign): TDockDirection; 46 begin 47 Result := ddHorizontal; 48 if (InsertAt = alTop) or (InsertAt = alBottom) then 49 Result := ddVertical 50 else 51 if (InsertAt = alLeft) or (InsertAt = alRight) then 52 Result := ddHorizontal 53 else; 54 end; 55 56 procedure TCoolDockStyleRegions.InsertControl(AControl: TControl; InsertAt: TAlign); 57 var 58 NewPanel: TCoolDockClientPanel; 59 I: Integer; 60 NewDirection: TDockDirection; 61 NewConjoinDockForm: TCoolDockConjoinForm; 62 NewDockSite: TWinControl; 63 begin 64 inherited; 65 with TCoolDockManager(Manager) do begin 66 if DockSite.DockClientCount <= 2 then FDockDirection := GetDirection(InsertAt) 67 else 68 if (DockSite.DockClientCount > 2) then begin 69 NewDirection := GetDirection(InsertAt); 70 if (NewDirection <> FDockDirection) then begin 71 // Direction change, create conjoin form 72 NewConjoinDockForm := CreateContainer(InsertAt); 73 NewDockSite := DockSite.HostDockSite; 74 // FDockSite.ManualFloat(FDockSite.BoundsRect); 75 NewConjoinDockForm.ManualDock(NewDockSite); 76 DockSite.ManualDock(NewConjoinDockForm.Panel); 77 AControl.ManualDock(NewConjoinDockForm.Panel, nil, InsertAt); 78 Exit; 79 end; 80 end; 81 82 NewPanel := TCoolDockClientPanel.Create(nil); 83 with NewPanel do begin 84 Parent := TCoolDockManager(Manager).DockSite; 85 OwnerDockManager := Self; 86 if DockStyle = dsList then Visible := True; 87 Header.PopupMenu := TCoolDockManager(Manager).PopupMenu; 88 //PopupMenu.Parent := Self.DockSite; 89 end; 90 if (AControl is TForm) and Assigned((AControl as TForm).Icon) then 91 NewPanel.Header.Icon.Picture.Assign((AControl as TForm).Icon); 92 93 NewPanel.Control := AControl; 94 AControl.AddHandlerOnVisibleChanged(NewPanel.VisibleChange); 95 AControl.Parent := NewPanel.ClientAreaPanel; 96 AControl.Align := alClient; 97 if (InsertAt = alTop) or (InsertAt = alLeft) then 98 DockPanels.Insert(0, NewPanel) 99 else DockPanels.Add(NewPanel); 100 end; 101 UpdateClientSize; 102 end; 103 104 procedure TCoolDockStyleRegions.RemoveControl(Control: TControl); 105 begin 106 if TCoolDockManager(Manager).DockSite.DockClientCount = 2 then FDockDirection := ddNone; 107 inherited RemoveControl(Control); 108 end; 109 39 110 function TCoolDockStyleRegions.GetHeaderPos: THeaderPos; 40 111 begin … … 52 123 begin 53 124 inherited; 54 Panels := TObjectList.Create;125 //Panels := TObjectList.Create; 55 126 56 127 with TCoolDockManager(AManager) do … … 67 138 destructor TCoolDockStyleRegions.Destroy; 68 139 begin 69 Panels.Free;140 //Panels.Free; 70 141 inherited Destroy; 71 142 end; … … 74 145 var 75 146 I: Integer; 147 SplitterLeft: Integer; 148 SplitterTop: Integer; 149 BaseAlign: TAlign; 76 150 begin 77 151 inherited UpdateClientSize; 152 if FDockDirection = ddHorizontal then 153 BaseAlign := alLeft else BaseAlign := alTop; 154 155 SplitterLeft := 0; 156 SplitterTop := 0; 78 157 with TCoolDockManager(Manager) do 79 158 for I := 0 to DockPanels.Count - 1 do 80 159 with TCoolDockClientPanel(DockPanels[I]) do begin 160 Left := SplitterLeft; 161 Top := SplitterTop; 81 162 Height := TCoolDockManager(Manager).DockSite.Height div 82 163 TCoolDockManager(Manager).DockSite.DockClientCount; … … 84 165 TCoolDockManager(Manager).DockSite.DockClientCount; 85 166 //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 167 if I < (DockPanels.Count - 1) then Align := BaseAlign 168 else Align := alClient; 169 170 Splitter.Left := SplitterLeft; 171 Splitter.Top := SplitterTop; 172 Inc(SplitterLeft, Width); 173 Inc(SplitterTop, Height); 174 Splitter.Parent := TCoolDockManager(Manager).DockSite; 175 Splitter.Align := BaseAlign; 176 Splitter.Visible := True; 177 178 86 179 DockPanelPaint(Self); 87 180 if I < (DockPanels.Count - 1) then begin 88 if TCoolDockManager(Manager).DockDirection = ddHorizontal then Align := alLeft181 if DockDirection = ddHorizontal then Align := alLeft 89 182 else Align := alTop; 90 183 end else Align := alClient;
Note:
See TracChangeset
for help on using the changeset viewer.