- Timestamp:
- May 26, 2011, 3:06:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/Managers/UCDManagerTabs.pas
r244 r248 16 16 TCDManagerTabsItem = class(TCDManagerItem) 17 17 IconImage: TImage; 18 TabSheet: TTabSheet; 18 19 constructor Create; override; 19 20 destructor Destroy; override; … … 38 39 function FindControlInPanels(Control: TControl): TCDManagerItem; override; 39 40 function GetHeaderPos: THeaderPos; override; 41 function FindTabSheet(TabSheet: TTabSheet): TCDManagerTabsItem; 40 42 public 41 43 MouseDownSkip: Boolean; … … 263 265 end; //else raise Exception.Create(Format('Control %s not found in DockItems', [Control.Name])); 264 266 267 ManagerItem.Control.Visible := False; 268 ManagerItem.Control.Parent := nil; 265 269 DockItems.Remove(ManagerItem); 266 270 ClientCount := DockItems.Count; … … 291 295 end; 292 296 297 function TCDManagerTabs.FindTabSheet(TabSheet: TTabSheet): TCDManagerTabsItem; 298 var 299 I: Integer; 300 begin 301 I := 0; 302 while (I < FDockItems.Count) and 303 (TCDManagerTabsItem(FDockItems[I]).TabSheet <> TabSheet) do Inc(I); 304 if I < FDockItems.Count then Result := TCDManagerTabsItem(FDockItems[I]) 305 else Result := nil; 306 end; 307 293 308 procedure TCDManagerTabs.SetHeaderPos(const AValue: THeaderPos); 294 309 begin … … 343 358 end; 344 359 345 while PageControl.PageList.Count > DockItems.Count do begin 360 // Remove old existed tabs which doesn't have item associated 361 for I := PageControl.PageList.Count - 1 downto 0 do begin 346 362 // TCDManagerTabsItem(DockItems[DockItems.Count - 1]).Control.Visible := False; 347 363 // TCDManagerTabsItem(DockItems[DockItems.Count - 1]).Control.Parent := nil; 348 364 349 PageControl.OnChange := nil; 350 DeletedPage := PageControl.Pages[PageControl.PageCount - 1]; 351 DeletedPage.Parent := nil; 352 PageControl.OnChange := TabControlChange; 353 DeletedPage.Free; 354 TabImageList.Delete(TabImageList.Count - 1); 355 end; 356 while PageControl.PageList.Count < DockItems.Count do begin 357 NewTabSheet := TTabSheet.Create(PageControl); 358 NewTabSheet.PageControl := PageControl; 359 TabImageList.Add(TCDManagerTabsItem(DockItems[PageControl.PageList.Count - 1]).IconImage.Picture.Bitmap, nil); 365 if FindTabSheet(TTabSheet(PageControl.PageList[I])) = nil then begin 366 PageControl.OnChange := nil; 367 DeletedPage := PageControl.Pages[I]; 368 DeletedPage.Parent := nil; 369 PageControl.OnChange := TabControlChange; 370 DeletedPage.Free; 371 TabImageList.Delete(I); 372 end; 373 end; 374 375 // Create tabs for new items 376 for I := 0 to DockItems.Count - 1 do 377 with TCDManagerTabsItem(DockItems[I]) do begin 378 if not Assigned(TabSheet) then begin 379 NewTabSheet := TTabSheet.Create(PageControl); 380 NewTabSheet.PageControl := PageControl; 381 TabSheet := NewTabSheet; 382 TabImageList.Add(IconImage.Picture.Bitmap, nil); 383 end; 360 384 end; 361 385
Note:
See TracChangeset
for help on using the changeset viewer.