Ignore:
Timestamp:
Mar 22, 2011, 8:20:18 AM (13 years ago)
Author:
george
Message:
  • Fixed: Tabs in TCDManagerTabs PageControl visibility update. If Control is hided it will not be visibled as tab but stay docked for later showing.
File:
1 edited

Legend:

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

    r213 r215  
    1818    constructor Create; override;
    1919    destructor Destroy; override;
     20    procedure VisibleChange(Sender: TObject); override;
    2021  end;
    2122
     
    7374end;
    7475
     76procedure TCDManagerTabsItem.VisibleChange(Sender: TObject);
     77var
     78  ControlVisible: Boolean;
     79  Temp: TControl;
     80  Temp2: TControl;
     81begin
     82  with TCDManagerTabs(Manager) do begin
     83    if TControl(Sender).Visible then begin
     84      Switch(DockItems.IndexOf(FindControlInPanels(TControl(Sender))));
     85      TCDManagerTabsItem(DockItems[DockItems.IndexOf(FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
     86    end;
     87    UpdateClientSize;
     88  end;
     89
     90  // Show current dock clients in parent dock sites
     91  if TControl(Sender).Visible then
     92    TControl(Sender).HostDockSite.Visible := True;
     93
     94  {Temp := TControl(Sender);
     95  if Assigned(Control) then
     96  begin
     97    ControlVisible := TControl(Sender).Visible;
     98    (*if Assigned(ClientAreaPanel) then
     99      ClientAreaPanel.Visible := ControlVisible;
     100    if Assigned(Splitter) then
     101      Splitter.Visible := ControlVisible;
     102      *)
     103//    if Assigned(TCDManager(OwnerDockManager).DockStyleHandler) then
     104    if Assigned(Manager) then
     105    with TCDManagerTabs(Manager) do
     106    begin
     107      //UpdateClientSize;
     108      if ControlVisible then
     109        Switch(FDockItems.IndexOf(FindControlInPanels(TControl(Sender))));
     110      if not (Control is TWinControl) then raise Exception.Create('Not TWinControl');
     111      if not Assigned(Control) then raise Exception.Create('Control not assigned');
     112      ChangeVisible(TWinControl(Control), ControlVisible);
     113      // Show parent control
     114      Temp := TControl(Sender).HostDockSite;
     115
     116      if ControlVisible then
     117        TControl(Sender).HostDockSite.Visible := ControlVisible;
     118    end;
     119    if csDestroying in Control.ComponentState then Control := nil;
     120  end;
     121  }
     122end;
     123
    75124{ TCDManagerTabs }
    76125
     
    104153
    105154procedure TCDManagerTabs.TabControlChange(Sender: TObject);
    106 var
    107   I: Integer;
    108 begin
    109   //UpdateClientSize;
    110 {  // Hide all clients
    111   for I := 0 to DockItems.Count - 1 do
    112     if TCDManagerItem(DockItems[I]).Control.Visible
    113     //and (PageControl.TabIndex <> I)
    114     then
    115     begin
    116       TCDManagerItem(DockItems[I]).Control.Tag := Integer(dhtTemporal);
    117       TCDManagerItem(DockItems[I]).Control.Hide;
    118       //TCDClientPanel(DockItems[I]).ClientAreaPanel.Hide;
    119       //TCDClientPanel(DockItems[I]).ClientAreaPanel.Parent := PageControl.Pages[I];
    120       //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite;
    121       TCDManagerItem(DockItems[I]).Control.Align := alClient;
    122       //TCDClientPanel(DockPanels[I]).Control.Parent :=
    123       //  TCDClientPanel(DockPanels[I]).ClientAreaPanel;
    124       //ShowMessage(TCDClientPanel(DockPanels[I]).Control.ClassName);
    125       //Application.ProcessMessages;
    126 
    127       // Workaround for "Cannot focus" error
    128       TForm(TCDManagerItem(DockItems[I]).Control).ActiveControl := nil;
    129     end;
    130 
    131   // Show selected
    132   if (PageControl.TabIndex <> -1) and (DockItems.Count > PageControl.TabIndex)
    133 //  and not TCDClientPanel(DockPanels[PageControl.TabIndex]).Control.Visible
    134   then begin
    135     with TCDManagerItem(DockItems[PageControl.TabIndex]) do begin
    136       Control.Show;
    137       (*AutoHide.Enable := True;
    138       if AutoHide.Enable then begin
    139         //Parent := nil;
    140         Visible := True;
    141         if AutoHide.ControlVisible then begin
    142           AutoHide.Hide;
    143         end;
    144         AutoHide.Control := Control;
    145         AutoHide.Show;
    146       end else begin
    147       *)
    148         //Parent := DockSite;
    149         //Show;
    150         Visible := True;
    151         UpdateClientSize;
    152 //      end;
    153     end;
    154   //TCDClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True;
    155   end;
    156   MouseDownSkip := True;        }
     155begin
     156  UpdateClientSize;
     157  MouseDownSkip := True;
    157158end;
    158159
     
    208209    Images := TabImageList;
    209210  end;
    210   //TabsPos := hpTop;
    211   //MoveDuration := 1000; // ms
    212211
    213212  //PageControl.Visible := True;
     
    342341  for I := 0 to DockItems.Count - 1 do
    343342  with TCDManagerTabsItem(DockItems[I]) do begin
    344     Control.Visible := False;
    345     Control.Parent := nil;
     343    //Control.Visible := False;
     344    //Control.Parent := nil;
    346345  end;
    347346
    348347  while PageControl.PageList.Count > DockItems.Count do begin
    349     //PageControl.Pages[PageControl.PageCount - 1].Parent := nil;
     348    TCDManagerTabsItem(DockItems[I]).Control.Parent := nil;
     349    PageControl.Pages[PageControl.PageCount - 1].Parent := nil;
    350350    PageControl.Pages[PageControl.PageCount - 1].Free;
    351351    TabImageList.Delete(TabImageList.Count - 1);
     
    364364    Control.Parent := PageControl.Pages[I];
    365365    Control.Align := alClient;
    366     Control.Visible := True;
    367     PageControl.Pages[I].TabVisible := Control.Visible;
     366    if PageControl.PageIndex = I then begin
     367      if (not Control.Visible) and (HideType = dhtTemporal) then
     368        Control.Visible := True;
     369    end else begin
     370      if Control.Visible then begin
     371        HideType := dhtTemporal;
     372        Control.Visible := False;
     373      end;
     374    end;
     375    PageControl.Pages[I].TabVisible := Control.Visible or (HideType = dhtTemporal);
    368376    //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width;
    369377    //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - PageControl.Height;
     
    409417        I := DockItems.IndexOf(FindControlInPanels(Control));
    410418        if Control.Tag = Integer(dhtPermanent) then
    411         if I <> -1 then
     419        if (I <> -1) and (I < PageControl.PageCount) then
    412420  //        Control.Hide;
    413421          PageControl.Page[I].TabVisible := False;
Note: See TracChangeset for help on using the changeset viewer.