Ignore:
Timestamp:
Nov 19, 2012, 2:34:58 PM (12 years ago)
Author:
chronos
Message:
  • Fixed: Better switching tabbed controls.
File:
1 edited

Legend:

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

    r430 r437  
    88  Classes, Controls, ExtCtrls, ComCtrls, SysUtils, Dialogs, Contnrs,
    99  Menus, Forms, UCDCommon, UCDManager, UCDConjoinForm,
    10   LCLType, LMessages, Graphics;
     10  LCLType, Graphics;
    1111
    1212type
     
    3535    procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton;
    3636      Shift: TShiftState; X, Y: Integer);
     37    procedure PageControlContextPopup(Sender: TObject; MousePos: TPoint;
     38      var Handled: Boolean);
     39    function FindTabSheet(TabSheet: TTabSheet): TCDManagerTabsItem;
     40  protected
     41    function GetHeaderPos: THeaderPos; override;
     42    function FindControlInPanels(Control: TControl): TCDManagerItem; override;
    3743    procedure InsertControlPanel(AControl: TControl; InsertAt: TAlign;
    3844      DropCtl: TControl); override;
    39     function FindControlInPanels(Control: TControl): TCDManagerItem; override;
    40     function GetHeaderPos: THeaderPos; override;
    41     function FindTabSheet(TabSheet: TTabSheet): TCDManagerTabsItem;
    42     procedure PageControlContextPopup(Sender: TObject; MousePos: TPoint;
    43       var Handled: Boolean);
     45    procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual;
     46    procedure TabControlChange(Sender: TObject); virtual;
    4447  public
    4548    MouseDownSkip: Boolean;
     
    4952    procedure Update; override;
    5053    procedure SetHeaderPos(const AValue: THeaderPos); override;
    51     procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual;
    5254    procedure RemoveControl(Control: TControl); override;
    5355    constructor Create(ADockSite: TWinControl); override;
    5456    destructor Destroy; override;
    55     procedure TabControlChange(Sender: TObject); virtual;
    5657    procedure PaintSite(DC: HDC); override;
    5758    procedure Switch(Index: Integer); override;
     
    8485  Temp: TControl;
    8586  Temp2: TControl;
     87  PI: Integer;
    8688begin
    8789  DebugLog('TCDManagerTabsItem.VisibleChange');
     
    9294      //TCDManagerTabsItem(DockItems[DockItems.IndexOf(
    9395      //  FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
    94     end else Update;
     96    end else begin
     97      TabSheet.TabVisible := False;
     98
     99      // Workaround for not showing current tab agter other tab is hidden
     100      PI := PageControl.PageIndex;
     101      PageControl.PageIndex := -1;
     102      PageControl.PageIndex := PI;
     103
     104      Update;
     105    end;
    95106  end;
    96107
     
    379390  LastIndex: Integer;
    380391begin
    381   LastIndex := PageControl.TabIndex;
     392  LastIndex := PageControl.PageIndex;
    382393  if FUpdateCount = 0 then begin
    383394  DebugLog('TCDManagerTabs.Update');
     
    426437    if PageControl.PageIndex = I then begin
    427438      TCDManager(Control.DockManager).DockSiteVisible := True;
    428       if not Control.Visible then Control.Show;
     439      if not Control.Visible then
     440        Control.Show;
    429441      //PageControl.TabIndex := I;
    430442    end else begin
     
    437449    //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    438450  end;
    439   end;
    440   inherited;
    441   //ShowMessage(IntToStr(PageControl.TabIndex));
    442   PageControl.TabIndex := LastIndex;
     451  //PageControl.TabIndex := LastIndex;
     452  //if PageControl.PageIndex = PI then
     453  //  PageControl.PageIndex := -1; // Workaround for bug in LCL TPageControl.TabVisible not updating PageIndex properly
     454  end;
     455  inherited;
    443456end;
    444457
Note: See TracChangeset for help on using the changeset viewer.