Ignore:
Timestamp:
Mar 18, 2011, 1:24:37 PM (14 years ago)
Author:
george
Message:
  • Fixed: Controls docked in Popup Tabs Manager was not removed due wrong RemoveControl method inheritance.
  • Fixed: Tabs in Tabs manager was not update properly.
  • Added: HeaderPos stored in Layout.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/Managers/UCDManagerTabs.pas

    r205 r208  
    77uses
    88  Classes, Controls, ExtCtrls, ComCtrls, SysUtils, Dialogs, Contnrs,
    9   Menus, Forms, UCDCommon, UCDManager,
     9  Menus, Forms, UCDCommon, UCDManager, UCDConjoinForm,
    1010  LCLType, LMessages, Graphics;
    1111
     
    1515
    1616  TCDManagerTabsItem = class(TCDManagerItem)
    17     Icon: TImage;
     17    IconImage: TImage;
    1818    constructor Create; override;
    1919    destructor Destroy; override;
     
    3636    procedure UpdateClientSize; override;
    3737    function FindControlInPanels(Control: TControl): TCDManagerItem; override;
    38     procedure RemoveControl(Control: TControl); override;
    3938    function GetHeaderPos: THeaderPos; override;
    4039  public
     
    4443    procedure SetHeaderPos(const AValue: THeaderPos); override;
    4544    procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual;
    46     procedure TabControlChange(Sender: TObject); virtual;
     45    procedure RemoveControl(Control: TControl); override;
    4746    constructor Create(ADockSite: TWinControl); override;
    4847    destructor Destroy; override;
     48    procedure TabControlChange(Sender: TObject); virtual;
    4949    procedure PaintSite(DC: HDC); override;
    5050    procedure DoSetVisible(const AValue: Boolean); override;
     
    6464constructor TCDManagerTabsItem.Create;
    6565begin
    66   Icon := TImage.Create(nil);
     66  IconImage := TImage.Create(nil);
    6767end;
    6868
    6969destructor TCDManagerTabsItem.Destroy;
    7070begin
    71   Icon.Free;
     71  IconImage.Free;
    7272  inherited Destroy;
    7373end;
     
    107107  I: Integer;
    108108begin
    109   UpdateClientSize;
     109  //UpdateClientSize;
    110110{  // Hide all clients
    111111  for I := 0 to DockItems.Count - 1 do
     
    249249    NewItem := TCDManagerTabsItem.Create;
    250250    with NewItem do begin
    251       //Panel.Parent := Self.DockSite;
    252251      Manager := Self;
    253       //if DockStyle = dsList then Visible := True;
    254       //Align := alClient;
    255       //Header.PopupMenu := Self.PopupMenu;
    256       //PopupMenu.Parent := Self.DockSite;
    257252    end;
    258253    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);
    260255
    261256    NewItem.Control := Control;
     
    266261      DockItems.Insert(0, NewItem)
    267262      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;
    283264end;
    284265
    285266procedure TCDManagerTabs.RemoveControl(Control: TControl);
    286 begin
     267var
     268  ManagerItem: TCDManagerItem;
     269  ClientCount: Integer;
     270begin
     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;
    287291  inherited RemoveControl(Control);
     292  if ClientCount > 1 then UpdateClientSize;
    288293end;
    289294
     
    328333  inherited;
    329334  InsertControlNoUpdate(AControl, InsertAt);
    330   TabControlChange(Self);
     335  UpdateClientSize;
    331336end;
    332337
     
    336341  NewTabSheet: TTabSheet;
    337342begin
    338   inherited UpdateClientSize;
    339343  for I := 0 to DockItems.Count - 1 do
    340344  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);
    341365    Control.Parent := PageControl.Pages[I];
    342366    Control.Align := alClient;
    343 
     367    Control.Visible := True;
     368    PageControl.Pages[I].TabVisible := Control.Visible;
    344369    //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width;
    345370    //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - PageControl.Height;
    346371    //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    347372  end;
     373  inherited UpdateClientSize;
    348374end;
    349375
Note: See TracChangeset for help on using the changeset viewer.