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.
Location:
Docking/CoolDocking/Managers
Files:
2 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
  • Docking/CoolDocking/Managers/UCDManagerTabsPopup.pas

    r207 r208  
    6565    procedure UpdatePopupFormBounds;
    6666    procedure TabControlChange(Sender: TObject); override;
     67    procedure PopupFormMouseLeave(Sender: TObject);
    6768  public
    6869    AutoHideEnabled: Boolean;
     
    7172    HeaderPanel: TCDPanelHeader;
    7273    Splitter: TPanel;
     74    procedure RemoveControl(Control: TControl); override;
    7375    procedure SetHeaderPos(const AValue: THeaderPos); override;
    7476    procedure PinShowButtonClick(Sender: TObject);
     
    253255end;
    254256
     257procedure TCDManagerTabsPopup.PopupFormMouseLeave(Sender: TObject);
     258begin
     259  if PopupForm.Visible then AutoHide.Hide;
     260end;
     261
     262procedure TCDManagerTabsPopup.RemoveControl(Control: TControl);
     263begin
     264  if DockItems.Count <= 2 then
     265    PageControl.OnResize := nil;
     266  inherited;
     267end;
     268
    255269constructor TCDManagerTabsPopup.Create(ADockSite: TWinControl);
    256270var
     
    263277  PopupForm.Visible := True;
    264278  PopupForm.BorderStyle := bsNone;
     279  PopupForm.OnMouseLeave := PopupFormMouseLeave;
    265280  HeaderPanel := TCDPanelHeader.Create(nil);
    266281  HeaderPanel.Parent := PopupForm;
     
    276291  AutoHide.Control := PopupForm;
    277292  PageControl.OnResize := PageControlResize;
     293  HeaderVisible := False;
    278294
    279295  for I := 0 to DockItems.Count - 1 do begin
     
    288304  AutoHide.Free;
    289305  PopupForm.Free;
     306  Splitter.Free;
    290307  HeaderPanel.Free;
    291308  inherited Destroy;
     
    306323    NewItem := TCDManagerTabsPopupItem.Create;
    307324    with NewItem do begin
    308       //Panel.Parent := Self.DockSite;
    309325      Manager := Self;
    310       //if DockStyle = dsList then Visible := True;
    311       //Align := alClient;
    312       //Header.PopupMenu := Self.PopupMenu;
    313       //PopupMenu.Parent := Self.DockSite;
    314326    end;
    315327    if (Control is TForm) and Assigned((Control as TForm).Icon) then
    316       NewItem.Icon.Picture.Assign((Control as TForm).Icon);
     328      NewItem.IconImage.Picture.Assign((Control as TForm).Icon);
    317329
    318330    NewItem.Control := Control;
     
    323335      DockItems.Insert(0, NewItem)
    324336      else DockItems.Add(NewItem);
    325 
    326   end;
    327 
    328     NewTabSheet := TTabSheet.Create(PageControl);
    329     NewTabSheet.PageControl := PageControl;
    330     NewTabSheet.Caption := Control.Caption;
    331     NewTabSheet.ImageIndex := TabImageList.Count;
    332     NewTabSheet.TabVisible := Control.Visible;
    333     Control.Parent := NewTabSheet;
    334     TabImageList.Add(NewItem.Icon.Picture.Bitmap, nil);
    335 //    if Assigned(NewItem.Splitter) then
    336 //      NewItem.Splitter.Visible := False;
    337 //    NewItem.ClientAreaPanel.Visible := False;
    338 //    NewItem.Visible := False;
    339     //NewItem.Parent := NewTabSheet;
     337  end;
    340338end;
    341339
Note: See TracChangeset for help on using the changeset viewer.