Ignore:
Timestamp:
Apr 27, 2012, 8:34:10 AM (13 years ago)
Author:
chronos
Message:
  • Modified: Change concept of dock manager items logical visibility vs TControl real visibility. Not visible controls are hidden by manager using TCDManager.DockSiteVisible property. TCDManager provide events OnDockSiteHide and OnDockSiteShow for handling logical visibility.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCDManager.pas

    r354 r355  
    6868  private
    6969    FControl: TWinControl;
    70     function GetHideType: TCDHideType;
    7170    procedure ResizeExecute(Sender: TObject);
    72     procedure SetHideType(const AValue: TCDHideType);
    7371  public
    7472    Manager: TCDManager;
     
    8179    constructor Create; virtual;
    8280    destructor Destroy; override;
    83     property HideType: TCDHideType read GetHideType write SetHideType;
    8481    property Control: TWinControl read FControl write SetControl;
    8582  end;
     
    9087  protected
    9188    FUpdateCount: Integer;
     89    FDockStyle: TCDStyleType;
    9290  private
    9391    FDockSite: TWinControl;
     92    FDockSiteVisible: Boolean;
    9493    FHeaderPos: THeaderPos;
    9594    FHeaderVisible: Boolean;
     95    FOnDockSiteHide: TNotifyEvent;
     96    FOnDockSiteShow: TNotifyEvent;
    9697    function GetDockSite: TWinControl;
    9798    function GetMoveDuration: Integer;
     99    procedure SetDockSiteVisible(AValue: Boolean); virtual;
    98100    procedure SetDockStyle(const AValue: TCDStyleType);
    99101    procedure SetHeaderVisible(const AValue: Boolean);
    100102    procedure SetMoveDuration(const AValue: Integer);
     103    procedure CloseHandler(Sender: TObject; var CloseAction: TCloseAction);
    101104  public
    102105    Locked: Boolean;
    103106    PopupMenu: TCDPopupMenu;
    104     FDockStyle: TCDStyleType;
    105107    FreeParentIfEmpty: Boolean; // Free or not parent conjoin forms
    106108    procedure SetVisible(const AValue: Boolean); virtual;
     
    146148    property HeaderVisible: Boolean read FHeaderVisible write SetHeaderVisible;
    147149    property Visible: Boolean write SetVisible;
     150    property DockSiteVisible: Boolean read FDockSiteVisible write SetDockSiteVisible;
     151    property OnDockSiteHide: TNotifyEvent read FOnDockSiteHide write FOnDockSiteHide;
     152    property OnDockSiteShow: TNotifyEvent read FOnDockSiteShow write FOnDockSiteShow;
    148153  end;
    149154
     
    273278end;
    274279
    275 function TCDManagerItem.GetHideType: TCDHideType;
    276 begin
    277   Result := TCDHideType(Control.Tag);
    278 end;
    279 
    280280procedure TCDManagerItem.ResizeExecute(Sender: TObject);
    281281begin
     
    296296end;
    297297
    298 procedure TCDManagerItem.SetHideType(const AValue: TCDHideType);
    299 begin
    300   Control.Tag := Integer(AValue);
    301 end;
    302 
    303298procedure TCDManagerItem.DockPanelMouseDown(Sender: TObject;
    304299  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     
    357352end;
    358353
     354procedure TCDManager.SetDockSiteVisible(AValue: Boolean);
     355begin
     356  if FDockSiteVisible = AValue then Exit;
     357  FDockSiteVisible := AValue;
     358  SetVisible(FDockSiteVisible);
     359  if Assigned(FOnDockSiteHide) and not AValue then
     360    FOnDockSiteHide(Self);
     361  if Assigned(FOnDockSiteShow) and AValue then
     362    FOnDockSiteShow(Self);
     363end;
     364
    359365constructor TCDManager.Create(ADockSite: TWinControl);
    360366var
     
    372378  PopupMenu := TCDPopupMenu.Create(Self);
    373379  PopupMenu.Parent := ADockSite;
     380  if ADockSite is TForm then
     381    TForm(ADockSite).AddHandlerClose(CloseHandler);
    374382end;
    375383
    376384destructor TCDManager.Destroy;
    377385begin
     386  if FDockSite is TForm then
     387    TForm(FDockSite).RemoveHandlerClose(CloseHandler);
    378388  PopupMenu.Free;
    379389  inherited Destroy;
     
    594604procedure TCDManager.SetMoveDuration(const AValue: Integer);
    595605begin
     606end;
     607
     608procedure TCDManager.CloseHandler(Sender: TObject; var CloseAction: TCloseAction
     609  );
     610begin
     611  //DockSite.Visible := False;
     612  //SetVisible(FDockSite.Visible);
    596613end;
    597614
Note: See TracChangeset for help on using the changeset viewer.