Changeset 208 for Docking/CoolDocking/Managers/UCDManagerTabs.pas
- Timestamp:
- Mar 18, 2011, 1:24:37 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/Managers/UCDManagerTabs.pas
r205 r208 7 7 uses 8 8 Classes, Controls, ExtCtrls, ComCtrls, SysUtils, Dialogs, Contnrs, 9 Menus, Forms, UCDCommon, UCDManager, 9 Menus, Forms, UCDCommon, UCDManager, UCDConjoinForm, 10 10 LCLType, LMessages, Graphics; 11 11 … … 15 15 16 16 TCDManagerTabsItem = class(TCDManagerItem) 17 Icon : TImage;17 IconImage: TImage; 18 18 constructor Create; override; 19 19 destructor Destroy; override; … … 36 36 procedure UpdateClientSize; override; 37 37 function FindControlInPanels(Control: TControl): TCDManagerItem; override; 38 procedure RemoveControl(Control: TControl); override;39 38 function GetHeaderPos: THeaderPos; override; 40 39 public … … 44 43 procedure SetHeaderPos(const AValue: THeaderPos); override; 45 44 procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual; 46 procedure TabControlChange(Sender: TObject); virtual;45 procedure RemoveControl(Control: TControl); override; 47 46 constructor Create(ADockSite: TWinControl); override; 48 47 destructor Destroy; override; 48 procedure TabControlChange(Sender: TObject); virtual; 49 49 procedure PaintSite(DC: HDC); override; 50 50 procedure DoSetVisible(const AValue: Boolean); override; … … 64 64 constructor TCDManagerTabsItem.Create; 65 65 begin 66 Icon := TImage.Create(nil);66 IconImage := TImage.Create(nil); 67 67 end; 68 68 69 69 destructor TCDManagerTabsItem.Destroy; 70 70 begin 71 Icon .Free;71 IconImage.Free; 72 72 inherited Destroy; 73 73 end; … … 107 107 I: Integer; 108 108 begin 109 UpdateClientSize;109 //UpdateClientSize; 110 110 { // Hide all clients 111 111 for I := 0 to DockItems.Count - 1 do … … 249 249 NewItem := TCDManagerTabsItem.Create; 250 250 with NewItem do begin 251 //Panel.Parent := Self.DockSite;252 251 Manager := Self; 253 //if DockStyle = dsList then Visible := True;254 //Align := alClient;255 //Header.PopupMenu := Self.PopupMenu;256 //PopupMenu.Parent := Self.DockSite;257 252 end; 258 253 if (Control is TForm) and Assigned((Control as TForm).Icon) then 259 NewItem.Icon .Picture.Assign((Control as TForm).Icon);254 NewItem.IconImage.Picture.Assign((Control as TForm).Icon); 260 255 261 256 NewItem.Control := Control; … … 266 261 DockItems.Insert(0, NewItem) 267 262 else DockItems.Add(NewItem); 268 269 end; 270 271 NewTabSheet := TTabSheet.Create(PageControl); 272 NewTabSheet.PageControl := PageControl; 273 NewTabSheet.Caption := Control.Caption; 274 NewTabSheet.ImageIndex := TabImageList.Count; 275 NewTabSheet.TabVisible := Control.Visible; 276 Control.Parent := NewTabSheet; 277 TabImageList.Add(NewItem.Icon.Picture.Bitmap, nil); 278 // if Assigned(NewItem.Splitter) then 279 // NewItem.Splitter.Visible := False; 280 // NewItem.ClientAreaPanel.Visible := False; 281 // NewItem.Visible := False; 282 //NewItem.Parent := NewTabSheet; 263 end; 283 264 end; 284 265 285 266 procedure TCDManagerTabs.RemoveControl(Control: TControl); 286 begin 267 var 268 ManagerItem: TCDManagerItem; 269 ClientCount: Integer; 270 begin 271 ManagerItem := FindControlInPanels(Control); 272 if Assigned(ManagerItem) then begin 273 Control.RemoveHandlerOnVisibleChanged(ManagerItem.VisibleChange); 274 end; 275 276 DockItems.Remove(ManagerItem); 277 ClientCount := DockItems.Count; 278 279 //if TCDManager(Manager).DockSite.DockClientCount = 2 then FDockDirection := ddNone; 280 if ClientCount = 1 then begin 281 // Last removed control => Free parent if it is TCDConjoinForm 282 if Self.DockSite is TCDConjoinForm then 283 with TCDConjoinForm(Self.DockSite) do begin 284 if Assigned(Parent) then begin 285 TCDManagerItem(DockItems[0]).Control.ManualDock(HostDockSite); 286 end else TCDManagerItem(DockItems[0]).Control.ManualFloat(Rect(Left, Top, Left + Width, Top + Height)); 287 ManualFloat(Rect(Left, Top, Left + Width, Top + Height)); 288 Free; 289 end; 290 end; 287 291 inherited RemoveControl(Control); 292 if ClientCount > 1 then UpdateClientSize; 288 293 end; 289 294 … … 328 333 inherited; 329 334 InsertControlNoUpdate(AControl, InsertAt); 330 TabControlChange(Self);335 UpdateClientSize; 331 336 end; 332 337 … … 336 341 NewTabSheet: TTabSheet; 337 342 begin 338 inherited UpdateClientSize;339 343 for I := 0 to DockItems.Count - 1 do 340 344 with TCDManagerTabsItem(DockItems[I]) do begin 345 Control.Visible := False; 346 Control.Parent := nil; 347 end; 348 349 while PageControl.PageList.Count > DockItems.Count do begin 350 PageControl.Pages[PageControl.PageCount - 1].Parent := nil; 351 PageControl.Pages[PageControl.PageCount - 1].Free; 352 TabImageList.Delete(TabImageList.Count - 1); 353 end; 354 while PageControl.PageList.Count < DockItems.Count do begin 355 NewTabSheet := TTabSheet.Create(PageControl); 356 NewTabSheet.PageControl := PageControl; 357 TabImageList.Add(TCDManagerTabsItem(DockItems[PageControl.PageList.Count - 1]).IconImage.Picture.Bitmap, nil); 358 end; 359 360 for I := 0 to DockItems.Count - 1 do 361 with TCDManagerTabsItem(DockItems[I]) do begin 362 PageControl.Pages[I].Caption := Control.Caption; 363 PageControl.Pages[I].ImageIndex := TabImageList.Count; 364 TabImageList.Replace(I, IconImage.Picture.Bitmap, nil); 341 365 Control.Parent := PageControl.Pages[I]; 342 366 Control.Align := alClient; 343 367 Control.Visible := True; 368 PageControl.Pages[I].TabVisible := Control.Visible; 344 369 //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width; 345 370 //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - PageControl.Height; 346 371 //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self); 347 372 end; 373 inherited UpdateClientSize; 348 374 end; 349 375
Note:
See TracChangeset
for help on using the changeset viewer.