Ignore:
Timestamp:
Mar 16, 2011, 12:32:41 PM (14 years ago)
Author:
george
Message:
  • Fixed: Popup submenus style and position item selection.
  • Added: Locking dock managers.
  • Modified: Enhanced auto popup tabs handling. Not yet finished.
  • Modified: Dock manager position united for all dock manager descendands.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCDManager.pas

    r197 r198  
    1414
    1515type
    16   THeaderPos = (hpAuto, hpLeft, hpTop, hpRight, hpBottom);
    17 
    1816  TCDManager = class;
    1917  TCDManagerItem = class;
     
    2321  TCDHeaderButton = class
    2422    Icon: TImage;
     23    Visible: Boolean;
    2524    constructor Create;
    2625    destructor Destroy; override;
     
    3231  private
    3332    procedure CloseButtonClick(Sender: TObject);
    34     procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);
    3533    procedure PaintExecute(Sender: TObject);
    3634    procedure RearrangeButtons;
     
    4038    Icon: TImage;
    4139    ManagerItem: TCDManagerItem;
     40    procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);
    4241    constructor Create(TheOwner: TComponent); override;
    4342    destructor Destroy; override;
     
    7271    procedure Paint(Sender: TObject); virtual;
    7372    procedure VisibleChange(Sender: TObject); virtual;
    74     constructor Create;
     73    constructor Create; virtual;
    7574    destructor Destroy; override;
    7675  end;
     
    8180  private
    8281    FDockSite: TWinControl;
     82    FHeaderPos: THeaderPos;
    8383    function GetDockSite: TWinControl;
    84     function GetHeaderPos: THeaderPos;
    8584    function GetMoveDuration: Integer;
    8685    procedure SetDockStyle(const AValue: TCDStyleType);
    87     procedure SetHeaderPos(const AValue: THeaderPos);
    8886    procedure SetMoveDuration(const AValue: Integer);
    8987    procedure SetVisible(const AValue: Boolean);
    9088  public
     89    Locked: Boolean;
     90    PopupMenu: TCDPopupMenu;
    9191    FDockStyle: TCDStyleType;
    92     PopupMenu: TCDPopupMenu;
    9392    constructor Create(ADockSite: TWinControl); override;
    9493    destructor Destroy; override;
     
    10099      DropCtl: TControl); virtual;
    101100    procedure DoSetVisible(const AValue: Boolean); virtual;
     101    procedure SetHeaderPos(const AValue: THeaderPos); virtual;
     102    function GetHeaderPos: THeaderPos; virtual;
    102103
    103104    // Inherited from TDockManager
     
    131132  end;
    132133
     134function HeaderPosToTabPos(HeaderPos: THeaderPos): TTabPosition;
     135
    133136
    134137implementation
     
    137140  UCDManagerRegions, UCDManagerTabs, UCDManagerRegionsPopup, UCDManagerTabsPopup,
    138141  UCDResource;
     142
     143function HeaderPosToTabPos(HeaderPos: THeaderPos): TTabPosition;
     144begin
     145  case HeaderPos of
     146    hpBottom: Result := tpBottom;
     147    hpLeft: Result := tpLeft;
     148    hpTop: Result := tpTop;
     149    hpRight: Result := tpRight;
     150    hpAuto: Result := tpLeft;
     151  end;
     152end;
    139153
    140154{ TCDHeaderButton }
     
    204218
    205219procedure TCDManagerItem.Paint(Sender: TObject);
    206 var
    207   I: Integer;
    208   R: TRect;
    209 begin
    210 (*  if not (csDesigning in ComponentState) then
    211   if Assigned(Control) then begin
    212     R := Control.ClientRect;
    213     Canvas.FillRect(R);
    214     Header.Visible := ShowHeader;
    215     if ShowHeader then begin
    216       if ClientAreaPanel.DockClientCount = 0 then
    217         Header.DrawGrabber(Canvas, Control) else
    218       Header.DrawGrabber(Canvas, ClientAreaPanel);
    219     end;
    220   end;*)
     220begin
    221221end;
    222222
     
    248248    //(Control as TWinControl).DockSite := False;
    249249    //ClientAreaPanel.DockSite := False;
    250     (Control as TWinControl).BeginDrag(False, 10);
    251     DragManager.DragStart(Control, False, 1);
     250    if not Manager.Locked then begin
     251      (Control as TWinControl).BeginDrag(False, 10);
     252      DragManager.DragStart(Control, False, 1);
     253    end;
    252254  end;
    253255end;
     
    310312function TCDManager.GetHeaderPos: THeaderPos;
    311313begin
    312 
     314  Result := FHeaderPos;
    313315end;
    314316
     
    527529    end else
    528530    if AValue = dsPopupTabs then begin
    529       NewManager := TCDStylePopupTabs.Create(FDockSite);
     531      NewManager := TCDManagerTabsPopup.Create(FDockSite);
    530532    end;
    531533    if DockSite.DockManager is TCDManager then
     
    538540procedure TCDManager.SetHeaderPos(const AValue: THeaderPos);
    539541begin
    540 
     542  FHeaderPos := AValue;
    541543end;
    542544
     
    600602    Icon.Parent := Self;
    601603    Icon.OnClick := CloseButtonClick;
     604    Visible := True;
    602605  end;
    603606  Buttons.Add(NewButton);
     
    606609    DataModule2.ImageList1.GetBitmap(1, Icon.Picture.Bitmap);
    607610    Icon.Parent := Self;
    608     Icon.OnClick := CloseButtonClick;
     611    Icon.OnClick := nil;
     612    Visible := False;
     613  end;
     614  Buttons.Add(NewButton);
     615  NewButton := TCDHeaderButton.Create;
     616  with NewButton do begin
     617    DataModule2.ImageList1.GetBitmap(2, Icon.Picture.Bitmap);
     618    Icon.Parent := Self;
     619    Icon.OnClick := nil;
     620    Visible := False;
    609621  end;
    610622  Buttons.Add(NewButton);
     
    640652      else Title.Left := 6;
    641653    Title.Caption := AControl.Caption;
     654    RearrangeButtons;
    642655  end;
    643656end;
     
    702715  LeftPos := Self.Width;
    703716  for I := 0 to Buttons.Count - 1 do
    704   with TCDHeaderButton(Buttons[I]), Icon do begin
    705     Anchors := [akRight, akTop];
     717  with TCDHeaderButton(Buttons[I]) do
     718  if Visible then begin
     719    Icon.Anchors := [akRight, akTop];
    706720    //Icon.Picture.Bitmap.SetSize(16, 16);
    707721    Icon.Width := Icon.Picture.Bitmap.Width;
     
    712726
    713727    //ShowMessage(IntToStr(Icon.Width) + ' ' +  InttoStr(Icon.Height));
    714     Visible := True;
    715   end;
     728    Icon.Visible := True;
     729  end else Icon.Visible := False;
    716730end;
    717731
Note: See TracChangeset for help on using the changeset viewer.