Ignore:
Timestamp:
Mar 23, 2011, 12:22:26 PM (13 years ago)
Author:
george
Message:
  • Fixed: Parent manager tabs switching.
File:
1 edited

Legend:

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

    r217 r218  
    4949    procedure TabControlChange(Sender: TObject); virtual;
    5050    procedure PaintSite(DC: HDC); override;
    51     procedure DoSetVisible(const AValue: Boolean); override;
    52     procedure ChangeVisible(Control: TWinControl; Visible: Boolean); override;
    5351    procedure Switch(Index: Integer); override;
    5452    procedure PopupMenuTabCloseClick(Sender: TObject);
     53    procedure SetVisible(const AValue: Boolean); override;
    5554    property DockItems: TObjectList read FDockItems write FDockItems;
    5655  end;
     
    8281  with TCDManagerTabs(Manager) do begin
    8382    if TControl(Sender).Visible then begin
     83      UpdateClientSize;
    8484      Switch(DockItems.IndexOf(FindControlInPanels(TControl(Sender))));
    85       TCDManagerTabsItem(DockItems[DockItems.IndexOf(FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
    86     end;
    87     UpdateClientSize;
     85      TCDManagerTabsItem(DockItems[DockItems.IndexOf(
     86        FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
     87    end else UpdateClientSize;
    8888  end;
    8989
    9090  // Show current dock clients in parent dock sites
    9191  if TControl(Sender).Visible then
    92     if Assigned(TControl(Sender).HostDockSite) then
     92    if Assigned(TControl(Sender).HostDockSite) then begin
     93      //TControl(Sender).HostDockSite.DockManager.;
    9394      TControl(Sender).HostDockSite.Visible := True;
    94 
    95   {Temp := TControl(Sender);
    96   if Assigned(Control) then
    97   begin
    98     ControlVisible := TControl(Sender).Visible;
    99     (*if Assigned(ClientAreaPanel) then
    100       ClientAreaPanel.Visible := ControlVisible;
    101     if Assigned(Splitter) then
    102       Splitter.Visible := ControlVisible;
    103       *)
    104 //    if Assigned(TCDManager(OwnerDockManager).DockStyleHandler) then
    105     if Assigned(Manager) then
    106     with TCDManagerTabs(Manager) do
    107     begin
    108       //UpdateClientSize;
    109       if ControlVisible then
    110         Switch(FDockItems.IndexOf(FindControlInPanels(TControl(Sender))));
    111       if not (Control is TWinControl) then raise Exception.Create('Not TWinControl');
    112       if not Assigned(Control) then raise Exception.Create('Control not assigned');
    113       ChangeVisible(TWinControl(Control), ControlVisible);
    114       // Show parent control
    115       Temp := TControl(Sender).HostDockSite;
    116 
    117       if ControlVisible then
    118         TControl(Sender).HostDockSite.Visible := ControlVisible;
    119     end;
    120     if csDestroying in Control.ComponentState then Control := nil;
    121   end;
    122   }
     95    end;
    12396end;
    12497
     
    141114  if Assigned(PageControl.ActivePage) then
    142115    TCDManagerItem(DockItems[PageControl.TabIndex]).Control.Hide;
     116end;
     117
     118procedure TCDManagerTabs.SetVisible(const AValue: Boolean);
     119begin
     120  inherited;
     121  if (PageControl.TabIndex >= 0) and (PageControl.TabIndex < DockItems.Count) then
     122    with TCDManagerItem(DockItems[PageControl.TabIndex]) do begin
     123      if AValue and (not Control.Visible) and (Control.Tag = Integer(dhtTemporal)) then begin
     124        Control.Show;
     125        Control.Tag := Integer(dhtPermanent);
     126      end;
     127    end;
    143128end;
    144129
     
    255240
    256241    NewItem.Control := TWinControl(Control);
     242    //NewItem.HideType := dhtTemporal;
    257243    Control.AddHandlerOnVisibleChanged(NewItem.VisibleChange);
     244    Control.AddHandlerOnVisibleChanging(NewItem.VisibleChanging);
    258245    //AControl.Parent := NewItem.ClientAreaPanel;
    259246    Control.Align := alClient;
     
    272259  if Assigned(ManagerItem) then begin
    273260    Control.RemoveHandlerOnVisibleChanged(ManagerItem.VisibleChange);
     261    Control.RemoveHandlerOnVisibleChanging(ManagerItem.VisibleChanging);
    274262  end; //else raise Exception.Create(Format('Control %s not found in DockItems', [Control.Name]));
    275263
     
    388376end;
    389377
    390 procedure TCDManagerTabs.DoSetVisible(const AValue: Boolean);
    391 begin
    392   inherited;
    393     if (PageControl.TabIndex >= 0) and (PageControl.TabIndex < DockItems.Count) then
    394       with TCDManagerItem(DockItems[PageControl.TabIndex]) do begin
    395         //Show;
    396         //ShowMessage(IntToStr(Control.Tag));
    397         if AValue and (not Control.Visible) and (Control.Tag = Integer(dhtTemporal))  then begin
    398           Control.Show;
    399           Control.Tag := Integer(dhtPermanent);
    400         end;
    401         //TabControl.Show;
    402         //ClientAreaPanel.Show;
    403       end;
    404 end;
    405 
    406 procedure TCDManagerTabs.ChangeVisible(Control: TWinControl; Visible: Boolean);
    407 var
    408   I: Integer;
    409 begin
    410   inherited;
    411   if not Visible then begin
    412     //if Assigned(TWinControl(Control).DockManager) then
    413     //with TCDManager(TWinControl(Control).DockManager) do
    414     begin
    415 //    ShowMessage(IntToStr(TabControl.TabIndex) + ' ' + IntToStr(DockPanels.Count));
    416 //    TabControl.Tabs[0].;
    417 //    if (TabControl.TabIndex >= 0) and (TabControl.TabIndex < DockPanels.Count) then begin
    418 //      TCDClientPanel(DockPanels[TabControl.TabIndex]).Show;
    419 //      TCDClientPanel(DockPanels[TabControl.TabIndex]).Control.Show;
    420 //    end;
    421     //    ShowMessage(IntToStr(DockPanels.Count));
    422         //TabImageList.Delete(PageControl.Tabs.IndexOf(Control.Caption));
    423 
    424         I := DockItems.IndexOf(FindControlInPanels(Control));
    425         if Control.Tag = Integer(dhtPermanent) then
    426         if (I <> -1) and (I < PageControl.PageCount) then
    427   //        Control.Hide;
    428           PageControl.Page[I].TabVisible := False;
    429         //Control.Tag := 0;
    430 //      end;
    431     end;
    432   end else
    433   begin
    434 //    if Assigned(TWinControl(Control).DockManager) then
    435 //    with TCDManager(TWinControl(Control).DockManager) do
    436     begin
    437 //      if Control.Tag = 0 then begin
    438         I := DockItems.IndexOf(FindControlInPanels(Control));
    439         //if  then
    440         if I <> -1 then
    441           PageControl.Page[I].TabVisible := True;
    442 //      TabImageList.Add(TCDClientPanel(TCDManager(Manager).FindControlInPanels(Control)).Header.Icon.Picture.Bitmap, nil);
    443 //      TabControl.Tabs.Add(Control.Caption);
    444 
    445 //      end;
    446     end;
    447   end;
    448 end;
    449 
    450378end.
    451379
Note: See TracChangeset for help on using the changeset viewer.