Changeset 198 for Docking/CoolDocking/Managers
- Timestamp:
- Mar 16, 2011, 12:32:41 PM (14 years ago)
- Location:
- Docking/CoolDocking/Managers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/Managers/UCDManagerRegions.pas
r197 r198 17 17 PanelHeader: TCDPanelHeader; 18 18 Splitter: TSplitter; 19 procedure Paint(Sender: TObject); override; 19 20 constructor Create; 20 21 destructor Destroy; override; … … 26 27 private 27 28 FDockItems: TObjectList; // TList<TCDManagerRegionsItem> 29 function GetHeaderPos: THeaderPos; override; 30 procedure SetHeaderPos(const AValue: THeaderPos); override; 28 31 function GetDirection(InsertAt: TAlign): TCDDirection; 29 32 public … … 53 56 { TCDManagerRegionsItem } 54 57 58 procedure TCDManagerRegionsItem.Paint(Sender: TObject); 59 var 60 I: Integer; 61 R: TRect; 62 begin 63 inherited Paint(Sender); 64 with PanelHeader do 65 if not (csDesigning in ComponentState) then 66 if Assigned(Control) then begin 67 //R := Control.ClientRect; 68 //Canvas.FillRect(R); 69 Header.Visible := ShowHeader; 70 if ShowHeader then begin 71 if ControlPanel.DockClientCount = 0 then 72 Header.DrawGrabber(Canvas, Control) else 73 Header.DrawGrabber(Canvas, ControlPanel); 74 end; 75 end; 76 end; 77 55 78 constructor TCDManagerRegionsItem.Create; 56 79 begin … … 59 82 PanelHeader.Header.OnMouseDown := DockPanelMouseDown; 60 83 PanelHeader.Header.Title.OnMouseDown := DockPanelMouseDown; 84 PanelHeader.Header.Icon.OnMouseDown := DockPanelMouseDown; 61 85 62 86 Splitter := TSplitter.Create(nil); … … 81 105 82 106 { TCDManagerRegions } 107 108 function TCDManagerRegions.GetHeaderPos: THeaderPos; 109 begin 110 Result := inherited; 111 end; 112 113 procedure TCDManagerRegions.SetHeaderPos(const AValue: THeaderPos); 114 begin 115 inherited SetHeaderPos(AValue); 116 case AValue of 117 hpBottom, hpTop: FDockDirection := ddVertical; 118 hpLeft, hpRight: FDockDirection := ddHorizontal; 119 end; 120 end; 83 121 84 122 function TCDManagerRegions.GetDirection(InsertAt: TAlign): TCDDirection; … … 117 155 PanelHeader.Header.PopupMenu := Self.PopupMenu; 118 156 end; 119 if (Control is TForm) and Assigned((Control as TForm).Icon) then 157 if (Control is TForm) and Assigned((Control as TForm).Icon) then begin 120 158 NewItem.PanelHeader.Header.Icon.Picture.Assign((Control as TForm).Icon); 121 NewItem.PanelHeader.Parent := DockSite; 122 NewItem.PanelHeader.Header.Title.Caption := TForm(Control).Caption; 123 124 NewItem.Control := Control; 125 Control.AddHandlerOnVisibleChanged(NewItem.VisibleChange); 126 Control.Parent := NewItem.PanelHeader.ControlPanel; 127 Control.Align := alClient; 128 if (InsertAt = alTop) or (InsertAt = alLeft) then 129 DockItems.Insert(0, NewItem) 130 else DockItems.Add(NewItem); 131 end; 159 NewItem.PanelHeader.Header.Icon.Width := NewItem.PanelHeader.Header.Icon.Picture.Bitmap.Width; 160 NewItem.PanelHeader.Header.Icon.Height := NewItem.PanelHeader.Header.Icon.Picture.Bitmap.Height; 161 end; 162 163 NewItem.PanelHeader.Parent := DockSite; 164 NewItem.PanelHeader.Header.Title.Caption := TForm(Control).Caption; 165 166 NewItem.Control := Control; 167 Control.AddHandlerOnVisibleChanged(NewItem.VisibleChange); 168 Control.Parent := NewItem.PanelHeader.ControlPanel; 169 Control.Align := alClient; 170 if (InsertAt = alTop) or (InsertAt = alLeft) then 171 DockItems.Insert(0, NewItem) 172 else DockItems.Add(NewItem); 173 end; 132 174 133 175 procedure TCDManagerRegions.InsertControlPanel(Control: TControl; InsertAt: TAlign; … … 248 290 PanelHeader.Width := Self.DockSite.Width div 249 291 Self.DockSite.DockClientCount; 250 //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self);292 Paint(Self); 251 293 if I < (DockItems.Count - 1) then PanelHeader.Align := BaseAlign 252 294 else PanelHeader.Align := alClient; -
Docking/CoolDocking/Managers/UCDManagerTabs.pas
r195 r198 16 16 TCDManagerTabsItem = class(TCDManagerItem) 17 17 Icon: TImage; 18 constructor Create; 18 constructor Create; override; 19 19 destructor Destroy; override; 20 20 end; … … 23 23 24 24 TCDManagerTabs = class(TCDManager) 25 p ublic25 private 26 26 MouseDown: Boolean; 27 27 MouseButton: TMouseButton; 28 28 MouseDownSkip: Boolean; 29 PageControl: TPageControl;30 TabImageList: TImageList;31 29 FDockItems: TObjectList; // TList<TCDManagerRegionsItem> 32 30 procedure TabControlMouseLeave(Sender: TObject); 33 procedure TabControlChange(Sender: TObject);34 31 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton; 35 32 Shift: TShiftState; X, Y: Integer); … … 39 36 DropCtl: TControl); override; 40 37 procedure UpdateClientSize; override; 41 private42 FTabsPos: THeaderPos;43 38 function FindControlInPanels(Control: TControl): TCDManagerItem; override; 44 procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign);45 39 procedure RemoveControl(Control: TControl); override; 40 function GetHeaderPos: THeaderPos; override; 41 procedure SetHeaderPos(const AValue: THeaderPos); override; 46 42 public 47 constructor Create(ADockSite: TWinControl); 43 TabImageList: TImageList; 44 PageControl: TPageControl; 45 procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual; 46 procedure TabControlChange(Sender: TObject); virtual; 47 constructor Create(ADockSite: TWinControl); override; 48 48 destructor Destroy; override; 49 49 procedure PaintSite(DC: HDC); override; … … 51 51 procedure ChangeVisible(Control: TWinControl; Visible: Boolean); override; 52 52 procedure Switch(Index: Integer); override; 53 procedure SetTabsPos(const AValue: THeaderPos);54 53 procedure PopupMenuTabCloseClick(Sender: TObject); 55 property TabsPos: THeaderPos read FTabsPos write SetTabsPos;56 54 property DockItems: TObjectList read FDockItems write FDockItems; 57 55 end; … … 98 96 begin 99 97 if MouseDown then 100 if Assigned(PageControl.ActivePage) then begin98 if Assigned(PageControl.ActivePage) and not Locked then begin 101 99 //TCDManagerItem(DockItems[PageControl.TabIndex]).ClientAreaPanel.DockSite := False; 102 100 DragManager.DragStart(TCDManagerItem(DockItems[PageControl.TabIndex]).Control, False, 1); … … 188 186 TabImageList := TImageList.Create(ADockSite); //FDockSite); 189 187 with TabImageList do begin 190 Name := DockSite.Name + 'ImageList';188 Name := GetUniqueName(DockSite.Name + 'ImageList'); 191 189 end; 192 190 PageControl := TPageControl.Create(ADockSite); //FDockSite); 193 191 with PageControl do begin 194 192 Parent := ADockSite; 195 Name := Self.DockSite.Name + 'TabControl';193 Name := GetUniqueName(Self.DockSite.Name + 'TabControl'); 196 194 Visible := True; 197 195 //Align := alTop; … … 216 214 for I := 0 to ADockSite.DockClientCount - 1 do 217 215 InsertControlNoUpdate(ADockSite.DockClients[I], alNone); 218 TabControlChange(Self);216 //TabControlChange(Self); 219 217 //TCDManagerTabs(Self).TabControlChange(Self); 220 218 end; … … 287 285 begin 288 286 inherited RemoveControl(Control); 287 end; 288 289 function TCDManagerTabs.GetHeaderPos: THeaderPos; 290 begin 291 Result := inherited; 292 end; 293 294 procedure TCDManagerTabs.SetHeaderPos(const AValue: THeaderPos); 295 begin 296 inherited SetHeaderPos(AValue); 297 with PageControl do 298 case AValue of 299 hpAuto, hpTop: begin 300 //Align := alTop; 301 TabPosition := tpTop; 302 Height := GrabberSize; 303 end; 304 hpLeft: begin 305 //Align := alLeft; 306 TabPosition := tpLeft; 307 Width := GrabberSize; 308 end; 309 hpRight: begin 310 //Align := alRight; 311 TabPosition := tpRight; 312 Width := GrabberSize; 313 end; 314 hpBottom: begin 315 //Align := alBottom; 316 TabPosition := tpBottom; 317 Height := GrabberSize; 318 end; 319 end; 289 320 end; 290 321 … … 376 407 end; 377 408 378 procedure TCDManagerTabs.SetTabsPos(const AValue: THeaderPos);379 begin380 if FTabsPos = AValue then Exit;381 FTabsPos := AValue;382 with PageControl do383 case AValue of384 hpAuto, hpTop: begin385 Align := alTop;386 TabPosition := tpTop;387 Height := GrabberSize;388 end;389 hpLeft: begin390 Align := alLeft;391 TabPosition := tpLeft;392 Width := GrabberSize;393 end;394 hpRight: begin395 Align := alRight;396 TabPosition := tpRight;397 Width := GrabberSize;398 end;399 hpBottom: begin400 Align := alBottom;401 TabPosition := tpBottom;402 Height := GrabberSize;403 end;404 end;405 end;406 407 408 409 end. 409 410 -
Docking/CoolDocking/Managers/UCDManagerTabsPopup.pas
r197 r198 6 6 7 7 uses 8 Classes, Controls, SysUtils, ComCtrls, ExtCtrls, UCDCommon, 9 UCDManagerTabs ;8 Classes, Controls, SysUtils, ComCtrls, ExtCtrls, UCDCommon, UCDManager, 9 UCDManagerTabs, Forms; 10 10 11 11 type … … 40 40 { TCDManagerTabsPopupItem } 41 41 42 TCDManagerTabsPopupItem = class 43 constructor Create; 44 end; 45 46 { TCDStylePopupTabs } 47 48 TCDStylePopupTabs = class(TCDManagerTabs) 42 TCDManagerTabsPopupItem = class(TCDManagerTabsItem) 43 Hidden: Boolean; 44 constructor Create; override; 45 end; 46 47 { TCDManagerTabsPopup } 48 49 TCDManagerTabsPopup = class(TCDManagerTabs) 50 private 51 procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); override; 49 52 public 50 53 AutoHideEnabled: Boolean; 51 54 AutoHide: TCDAutoHide; 52 55 PopupPanel: TPanel; 53 constructor Create(ADockSite: TWinControl); 56 procedure SetHeaderPos(const AValue: THeaderPos); override; 57 procedure PinShowButtonClick(Sender: TObject); 58 procedure PinHideButtonClick(Sender: TObject); 59 procedure TabControlChange(Sender: TObject); override; 60 constructor Create(ADockSite: TWinControl); override; 54 61 destructor Destroy; override; 55 private56 62 end; 57 63 … … 60 66 61 67 uses 62 UCDClient ;68 UCDClient, UCDManagerRegions; 63 69 64 70 { TCDManagerTabsPopupItem } … … 66 72 constructor TCDManagerTabsPopupItem.Create; 67 73 begin 74 inherited; 68 75 end; 69 76 … … 121 128 begin 122 129 StartBounds := Control.BoundsRect; 130 Control.Show; 123 131 Control.Align := alCustom; 124 132 Direction := 1; … … 165 173 end; 166 174 167 { TCDStylePopupTabs } 168 169 170 constructor TCDStylePopupTabs.Create(ADockSite: TWinControl); 175 { TCDManagerTabsPopup } 176 177 procedure TCDManagerTabsPopup.PinShowButtonClick(Sender: TObject); 178 begin 179 180 end; 181 182 procedure TCDManagerTabsPopup.PinHideButtonClick(Sender: TObject); 183 begin 184 185 end; 186 187 procedure TCDManagerTabsPopup.TabControlChange(Sender: TObject); 188 begin 189 inherited TabControlChange(Sender); 190 if PopupPanel.ControlCount > 0 then 191 PopupPanel.Controls[0].Parent := nil; 192 AutoHide.Hide; 193 if PageControl.TabIndex >= 0 then begin 194 TCDManagerTabsPopupItem(DockItems[PageControl.TabIndex]).Control.Parent := PopupPanel; 195 AutoHide.Control.Align := alCustom; 196 with AutoHide.Control do 197 case AutoHide.TabPosition of 198 tpTop: SetBounds(PageControl.Left, PageControl.Top + PageControl.Height, 199 PageControl.Width, Height); 200 tpLeft: SetBounds(PageControl.Left + PageControl.Width, PageControl.Top, 201 Width, PageControl.Height); 202 tpBottom: SetBounds(PageControl.Left, PageControl.Top - Height, 203 PageControl.Width, Height); 204 tpRight: SetBounds(PageControl.Left - Width, PageControl.Top, 205 Width, PageControl.Height); 206 end; 207 AutoHide.Show; 208 end; 209 end; 210 211 constructor TCDManagerTabsPopup.Create(ADockSite: TWinControl); 171 212 var 172 213 I: Integer; … … 174 215 inherited; 175 216 FDockStyle := dsPopupTabs; 217 PopupPanel := TPanel.Create(nil); 218 PopupPanel.DockManager := TCDManagerRegions.Create(PopupPanel); 219 PopupPanel.Visible := True; 176 220 AutoHide := TCDAutoHide.Create; 177 PopupPanel := TPanel.Create(nil); 178 end; 179 180 destructor TCDStylePopupTabs.Destroy; 221 AutoHide.Control := PopupPanel; 222 223 for I := 0 to DockItems.Count - 1 do begin 224 // if TCDManagerTabsPopupItem(DockItems[I]).Hidden then 225 // if 226 end; 227 end; 228 229 destructor TCDManagerTabsPopup.Destroy; 181 230 begin 182 231 AutoHide.Free; … … 185 234 end; 186 235 236 procedure TCDManagerTabsPopup.InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); 237 var 238 NewTabSheet: TTabSheet; 239 NewItem: TCDManagerTabsItem; 240 begin 241 //inherited; 242 begin 243 NewItem := TCDManagerTabsPopupItem.Create; 244 with NewItem do begin 245 //Panel.Parent := Self.DockSite; 246 Manager := Self; 247 //if DockStyle = dsList then Visible := True; 248 //Align := alClient; 249 //Header.PopupMenu := Self.PopupMenu; 250 //PopupMenu.Parent := Self.DockSite; 251 end; 252 if (Control is TForm) and Assigned((Control as TForm).Icon) then 253 NewItem.Icon.Picture.Assign((Control as TForm).Icon); 254 255 NewItem.Control := Control; 256 Control.AddHandlerOnVisibleChanged(NewItem.VisibleChange); 257 //AControl.Parent := NewItem.ClientAreaPanel; 258 Control.Align := alClient; 259 if (InsertAt = alTop) or (InsertAt = alLeft) then 260 DockItems.Insert(0, NewItem) 261 else DockItems.Add(NewItem); 262 263 end; 264 265 NewTabSheet := TTabSheet.Create(PageControl); 266 NewTabSheet.PageControl := PageControl; 267 NewTabSheet.Caption := Control.Caption; 268 NewTabSheet.ImageIndex := TabImageList.Count; 269 NewTabSheet.TabVisible := Control.Visible; 270 Control.Parent := NewTabSheet; 271 TabImageList.Add(NewItem.Icon.Picture.Bitmap, nil); 272 // if Assigned(NewItem.Splitter) then 273 // NewItem.Splitter.Visible := False; 274 // NewItem.ClientAreaPanel.Visible := False; 275 // NewItem.Visible := False; 276 //NewItem.Parent := NewTabSheet; 277 end; 278 279 procedure TCDManagerTabsPopup.SetHeaderPos(const AValue: THeaderPos); 280 begin 281 inherited SetHeaderPos(AValue); 282 AutoHide.TabPosition := HeaderPosToTabPos(AValue); 283 end; 284 187 285 end. 188 286
Note:
See TracChangeset
for help on using the changeset viewer.