Changeset 194 for Docking/CoolDocking/Managers/UCDManagerRegions.pas
- Timestamp:
- Mar 11, 2011, 1:00:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/Managers/UCDManagerRegions.pas
r193 r194 7 7 uses 8 8 Classes, SysUtils, Controls, ExtCtrls, StdCtrls, Forms, 9 Graphics, Contnrs, Buttons, UCDClientPanel, UCDCommon, UCDManager; 9 Graphics, Contnrs, Buttons, UCDCommon, UCDManager, 10 LCLType, LMessages; 10 11 11 12 type 12 TCDStyleRegionsPanel = class(TPanel) 13 13 14 { TCDManagerRegionsItem } 15 16 TCDManagerRegionsItem = class(TCDManagerItem) 17 Panel: TPanel; 18 Splitter: TSplitter; 19 ClientAreaPanel: TPanel; 20 constructor Create; 14 21 end; 15 22 … … 18 25 TCDManagerRegions = class(TCDManager) 19 26 private 27 FDockItems: TObjectList; // TList<TCDManagerRegionsItem> 20 28 function GetDirection(InsertAt: TAlign): TCDDirection; 21 29 public 22 30 FDockDirection: TCDDirection; 23 31 //Panels: TObjectList; // TObjectList<TCDStyleRegionsPanel> 32 function FindControlInPanels(Control: TControl): TCDManagerItem; override; 24 33 procedure InsertControlPanel(Control: TControl; InsertAt: TAlign; 25 34 DropCtl: TControl); override; … … 27 36 constructor Create(ADockSite: TWinControl); 28 37 destructor Destroy; override; 38 procedure PaintSite(DC: HDC); override; 29 39 procedure UpdateClientSize; override; 30 40 procedure DoSetVisible(const AValue: Boolean); override; … … 32 42 property DockDirection: TCDDirection read FDockDirection 33 43 write FDockDirection; 44 property DockItems: TObjectList read FDockItems write FDockItems; 34 45 end; 35 46 … … 38 49 uses 39 50 UCDClient, UCDConjoinForm; 51 52 { TCDManagerRegionsItem } 53 54 constructor TCDManagerRegionsItem.Create; 55 begin 56 Panel := TPanel.Create(nil); 57 58 ClientAreaPanel := TPanel.Create(Panel); 59 with ClientAreaPanel do begin 60 Parent := Panel; 61 Visible := True; 62 DockSite := True; 63 UseDockManager := True; 64 Align := alClient; 65 BevelInner := bvNone; 66 BevelOuter := bvNone; 67 //Color := clGreen; 68 end; 69 Splitter := TSplitter.Create(Panel); 70 with Splitter do begin 71 Parent := Panel; 72 //Color := clRed; 73 end; 74 end; 40 75 41 76 … … 53 88 end; 54 89 90 function TCDManagerRegions.FindControlInPanels(Control: TControl 91 ): TCDManagerItem; 92 var 93 I: Integer; 94 begin 95 I := 0; 96 while (I < FDockItems.Count) and 97 (TCDManagerItem(FDockItems[I]).Control <> Control) do Inc(I); 98 if I < FDockItems.Count then Result := TCDManagerItem(FDockItems[I]) 99 else Result := nil; 100 end; 101 55 102 procedure TCDManagerRegions.InsertControlPanel(Control: TControl; InsertAt: TAlign; 56 103 DropCtl: TControl); 57 104 var 58 NewPanel: TCD ClientPanel;105 NewPanel: TCDManagerRegionsItem; 59 106 I: Integer; 60 107 NewDirection: TCDDirection; … … 85 132 end; 86 133 87 NewPanel := TCD ClientPanel.Create(nil);134 NewPanel := TCDManagerRegionsItem.Create; 88 135 with NewPanel do begin 89 Pa rent := Self.DockSite;90 OwnerDockManager := Self;136 Panel.Parent := Self.DockSite; 137 Manager := Self; 91 138 if DockStyle = dsList then Visible := True; 92 139 Header.PopupMenu := Self.PopupMenu; … … 101 148 Control.Align := alClient; 102 149 if (InsertAt = alTop) or (InsertAt = alLeft) then 103 Dock Panels.Insert(0, NewPanel)104 else Dock Panels.Add(NewPanel);150 DockItems.Insert(0, NewPanel) 151 else DockItems.Add(NewPanel); 105 152 end; 106 153 UpdateClientSize; … … 109 156 procedure TCDManagerRegions.RemoveControl(Control: TControl); 110 157 var 111 ClientPanel: TCD ClientPanel;158 ClientPanel: TCDManagerItem; 112 159 ClientCount: Integer; 113 160 begin … … 115 162 Control.RemoveHandlerOnVisibleChanged(ClientPanel.VisibleChange); 116 163 117 Dock Panels.Remove(ClientPanel);118 ClientCount := Dock Panels.Count;164 DockItems.Remove(ClientPanel); 165 ClientCount := DockItems.Count; 119 166 120 167 //if TCDManager(Manager).DockSite.DockClientCount = 2 then FDockDirection := ddNone; … … 124 171 with TCDConjoinForm(Self.DockSite) do begin 125 172 if Assigned(Parent) then begin 126 TCD ClientPanel(DockPanels[0]).Control.ManualDock(HostDockSite);127 end else TCD ClientPanel(DockPanels[0]).Control.ManualFloat(Rect(Left, Top, Left + Width, Top + Height));173 TCDManagerItem(DockItems[0]).Control.ManualDock(HostDockSite); 174 end else TCDManagerItem(DockItems[0]).Control.ManualFloat(Rect(Left, Top, Left + Width, Top + Height)); 128 175 ManualFloat(Rect(Left, Top, Left + Width, Top + Height)); 129 176 Free; … … 140 187 inherited; 141 188 FDockStyle := dsList; 142 //Panels := TObjectList.Create; 143 144 for I := 0 to DockPanels.Count - 1 do begin 145 if Assigned(TCDClientPanel(DockPanels[I]).Splitter) then 146 TCDClientPanel(DockPanels[I]).Splitter.Visible := True; 147 TCDClientPanel(DockPanels[I]).Visible := True; 148 TCDClientPanel(DockPanels[I]).ClientAreaPanel.Parent := TCDClientPanel(DockPanels[I]); 149 TCDClientPanel(DockPanels[I]).ClientAreaPanel.Visible := True; 150 TCDClientPanel(DockPanels[I]).Control.Visible := True; 189 FDockItems := TObjectList.Create; 190 191 for I := 0 to DockItems.Count - 1 do begin 192 if Assigned(TCDManagerRegionsItem(DockItems[I]).Splitter) then 193 with TCDManagerRegionsItem(DockItems[I]) do begin 194 Splitter.Visible := True; 195 Panel.Visible := True; 196 ClientAreaPanel.Parent := TCDManagerRegionsItem(DockItems[I]).Panel; 197 ClientAreaPanel.Visible := True; 198 Control.Visible := True; 199 end; 151 200 end; 152 201 end; … … 154 203 destructor TCDManagerRegions.Destroy; 155 204 begin 156 //Panels.Free;205 FDockItems.Free; 157 206 inherited Destroy; 207 end; 208 209 procedure TCDManagerRegions.PaintSite(DC: HDC); 210 var 211 I: Integer; 212 begin 213 inherited PaintSite(DC); 214 for I := 0 to FDockItems.Count - 1 do 215 with TCDManagerRegionsItem(FDockItems[I]) do begin 216 Panel.Invalidate; 217 end; 158 218 end; 159 219 … … 171 231 SplitterLeft := 0; 172 232 SplitterTop := 0; 173 for I := 0 to Dock Panels.Count - 1 do174 with TCD ClientPanel(DockPanels[I]) do begin175 Left := SplitterLeft;176 Top := SplitterTop;177 Height := Self.DockSite.Height div233 for I := 0 to DockItems.Count - 1 do 234 with TCDManagerRegionsItem(DockItems[I]) do begin 235 Panel.Left := SplitterLeft; 236 Panel.Top := SplitterTop; 237 Panel.Height := Self.DockSite.Height div 178 238 Self.DockSite.DockClientCount; 179 Width := Self.DockSite.Width div180 S Elf.DockSite.DockClientCount;239 Panel.Width := Self.DockSite.Width div 240 Self.DockSite.DockClientCount; 181 241 //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self); 182 if I < (Dock Panels.Count - 1) thenAlign := BaseAlign183 else Align := alClient;184 185 Inc(SplitterLeft, Width);186 Inc(SplitterTop, Height);242 if I < (DockItems.Count - 1) then Panel.Align := BaseAlign 243 else Panel.Align := alClient; 244 245 Inc(SplitterLeft, Panel.Width); 246 Inc(SplitterTop, Panel.Height); 187 247 Splitter.Left := SplitterLeft; 188 248 Splitter.Top := SplitterTop; 189 Splitter.Parent := S Elf.DockSite;249 Splitter.Parent := Self.DockSite; 190 250 Splitter.Align := BaseAlign; 191 Splitter.Visible := I < (Dock Panels.Count - 1);251 Splitter.Visible := I < (DockItems.Count - 1); 192 252 Inc(SplitterLeft, Splitter.Width); 193 253 Inc(SplitterTop, Splitter.Height); 194 254 195 DockPanelPaint(Self);196 if I < (Dock Panels.Count - 1) then begin197 if DockDirection = ddHorizontal then Align := alLeft198 else Align := alTop;199 end else Align := alClient;255 Paint(Self); 256 if I < (DockItems.Count - 1) then begin 257 if DockDirection = ddHorizontal then Panel.Align := alLeft 258 else Panel.Align := alTop; 259 end else Panel.Align := alClient; 200 260 end; 201 261 end; … … 206 266 begin 207 267 inherited; 208 for I := 0 to Dock Panels.Count - 1 do268 for I := 0 to DockItems.Count - 1 do 209 269 210 270 //Show; 211 271 //ShowMessage(IntToStr(Control.Tag)); 212 with TCD ClientPanel(DockPanels[I]) do begin272 with TCDManagerRegionsItem(DockItems[I]) do begin 213 273 if AValue and (not Control.Visible) and (Control.Tag = Integer(dhtTemporal)) then begin 214 274 Control.Show;
Note:
See TracChangeset
for help on using the changeset viewer.