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/UCDManager.pas

    r217 r218  
    1616  TCDManager = class;
    1717  TCDManagerItem = class;
     18
     19  TCDPanelForm = class(TForm)
     20    Panel: TPanel;
     21  end;
    1822
    1923  { TCDHeaderButton }
     
    3741    Buttons: TObjectList; // TList<TCDHeaderButton>
    3842    Icon: TImage;
    39     ManagerItem: TCDManagerItem;
     43    Control: TControl;
    4044    constructor Create(TheOwner: TComponent); override;
    4145    destructor Destroy; override;
     
    6367  TCDManagerItem = class
    6468  private
     69    FControl: TWinControl;
    6570    function GetHideType: TCDHideType;
    6671    procedure ResizeExecute(Sender: TObject);
    6772    procedure SetHideType(const AValue: TCDHideType);
    6873  public
    69     Control: TWinControl;
    7074    Manager: TCDManager;
     75    procedure SetControl(const AValue: TWinControl); virtual;
    7176    procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton;
    7277      Shift: TShiftState; X, Y: Integer);
    7378    procedure Paint(Sender: TObject); virtual;
    7479    procedure VisibleChange(Sender: TObject); virtual;
     80    procedure VisibleChanging(Sender: TObject); virtual;
    7581    constructor Create; virtual;
    7682    destructor Destroy; override;
    7783    property HideType: TCDHideType read GetHideType write SetHideType;
     84    property Control: TWinControl read FControl write SetControl;
    7885  end;
    7986
     
    9097    procedure SetHeaderVisible(const AValue: Boolean);
    9198    procedure SetMoveDuration(const AValue: Integer);
    92     procedure SetVisible(const AValue: Boolean);
    9399  public
    94100    Locked: Boolean;
     
    96102    FDockStyle: TCDStyleType;
    97103    FreeParentIfEmpty: Boolean; // Free or not parent conjoin forms
     104    procedure SetVisible(const AValue: Boolean); virtual;
    98105    constructor Create(ADockSite: TWinControl); override;
    99106    destructor Destroy; override;
     
    104111    procedure InsertControlPanel(Control: TControl; InsertAt: TAlign;
    105112      DropCtl: TControl); virtual;
    106     procedure DoSetVisible(const AValue: Boolean); virtual;
    107113    procedure SetHeaderPos(const AValue: THeaderPos); virtual;
    108114    function GetHeaderPos: THeaderPos; virtual;
     
    130136
    131137    function FindControlInPanels(Control: TControl): TCDManagerItem; virtual;
    132     function CreateContainer(InsertAt: TAlign): TCDConjoinForm;
     138    function CreateConjoinForm: TCDConjoinForm;
     139    function CreateDockableForm: TCDPanelForm;
    133140    property DockStyle: TCDStyleType read FDockStyle write SetDockStyle;
    134141    property MoveDuration: Integer read GetMoveDuration write SetMoveDuration;
     
    144151uses
    145152  UCDManagerRegions, UCDManagerTabs, UCDManagerRegionsPopup, UCDManagerTabsPopup,
    146   UCDResource;
     153  UCDResource, UCDClient;
    147154
    148155function CreateRotatedFont(F: TFont; Angle: Integer): Integer;
     
    281288end;
    282289
     290procedure TCDManagerItem.SetControl(const AValue: TWinControl);
     291begin
     292  if FControl = AValue then Exit;
     293  FControl := AValue;
     294end;
     295
    283296procedure TCDManagerItem.SetHideType(const AValue: TCDHideType);
    284297begin
     
    314327end;
    315328
     329procedure TCDManagerItem.VisibleChanging(Sender: TObject);
     330begin
     331
     332end;
     333
    316334{ TCDManager }
    317335
     
    388406  DropCtl: TControl);
    389407begin
    390 end;
    391 
    392 procedure TCDManager.DoSetVisible(const AValue: Boolean);
    393 begin
    394 
    395408end;
    396409
     
    409422    if (not Assigned(FDockSite.Parent)) then begin
    410423      // Create conjointed form
    411       NewConjoinDockForm := CreateContainer(InsertAt);
     424      NewConjoinDockForm := CreateConjoinForm;
    412425      FDockSite.ManualDock(NewConjoinDockForm);
    413426      Control.ManualDock(NewConjoinDockForm, nil, InsertAt);
    414427      NewConjoinDockForm.UpdateCaption;
    415428    end else begin
    416       NewConjoinDockForm := CreateContainer(InsertAt);
     429      NewConjoinDockForm := CreateConjoinForm;
    417430      NewDockSite := FDockSite.HostDockSite;
    418431//      FDockSite.ManualFloat(FDockSite.BoundsRect);
     
    504517end;
    505518
    506 function TCDManager.CreateContainer(InsertAt: TAlign): TCDConjoinForm;
     519function TCDManager.CreateConjoinForm: TCDConjoinForm;
    507520var
    508521  NewDockSite: TWinControl;
     
    511524  NewConjoinDockForm := TCDConjoinForm.Create(Application);
    512525  NewConjoinDockForm.Name := GetUniqueName('ConjoinForm');
    513   NewConjoinDockForm.Visible := True;
     526  //NewConjoinDockForm.Visible := True;
    514527  NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect;
    515528  NewConjoinDockForm.CoolDockClient.Master := Self.Master;
     
    518531  //NewConjoinDockForm.ManualDock(NewDockSite, nil, InsertAt);
    519532  Result := NewConjoinDockForm;
     533end;
     534
     535function TCDManager.CreateDockableForm: TCDPanelForm;
     536var
     537  NewClient: TCDClient;
     538begin
     539  Application.CreateForm(TCDPanelForm, Result);
     540  Result.Name := GetUniqueName('DockForm');
     541  NewClient := TCDClient.Create(Result);
     542  Result.Panel := TPanel.Create(Result);
     543  Result.Panel.Parent := Result;
     544  //Result.Panel.Visible := True;
     545  Result.Panel.BevelInner := bvNone;
     546  Result.Panel.BevelOuter := bvNone;
     547  NewClient.Panel := Result.Panel;
     548  NewClient.Master := Self.Master;
     549  NewClient.Dockable := False;
    520550end;
    521551
     
    564594
    565595procedure TCDManager.SetVisible(const AValue: Boolean);
    566 var
    567   I: Integer;
    568 begin
    569   DoSetVisible(AValue);
    570   //Visible := AValue;
    571 //  for I := 0 to DockPanels.Count - 1 do
    572 //    TCDClientPanel(DockPanels[I]).Visible := AValue;
     596begin
    573597end;
    574598
     
    638662    Visible := True;
    639663  end;
     664
     665  BevelInner := bvNone;
     666  BevelOuter := bvNone;
    640667end;
    641668
     
    662689  R: TRect;
    663690begin
    664   with TCDManager(TWinControl(ManagerItem.Control).DockManager) do
     691  if Assigned(Control) then
     692  with TCDManager(TWinControl(Control).DockManager) do
    665693  case HeaderPos of
    666694    hpLeft: begin
     
    682710  end;
    683711
    684   if (ManagerItem.Control as TWinControl).Focused then
    685   Canvas.Font.Style := Canvas.Font.Style + [fsBold]
    686   else Canvas.Font.Style := Canvas.Font.Style - [fsBold];
     712  if Assigned(Control) then
     713    if (Control as TWinControl).Focused then
     714      Canvas.Font.Style := Canvas.Font.Style + [fsBold]
     715        else Canvas.Font.Style := Canvas.Font.Style - [fsBold];
    687716
    688717  RearrangeButtons;
     
    737766
    738767    //SelectObject(Canvas.Handle, MyFont);
    739     Title := ManagerItem.Control.Caption;
     768    if Assigned(Control) then
     769      Title := Control.Caption else Title := '';
    740770    if (TextWidth(Title) > TitleMaxWidth) then begin
    741771      while (Length(Title) > 0) and (TextWidth(Title + '...') > TitleMaxWidth) do begin
     
    776806procedure TCDHeader.CloseButtonClick(Sender: TObject);
    777807begin
    778   ManagerItem.Control.Hide;
    779 end;
    780 
    781 
     808  if Assigned(Control) then
     809    Control.Hide;
     810end;
    782811
    783812end.
Note: See TracChangeset for help on using the changeset viewer.