Ignore:
Timestamp:
Mar 11, 2011, 2:16:50 PM (14 years ago)
Author:
george
Message:
 
File:
1 edited

Legend:

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

    r194 r195  
    1515
    1616  TCDManagerRegionsItem = class(TCDManagerItem)
    17     Panel: TPanel;
     17    PanelHeader: TCDPanelHeader;
    1818    Splitter: TSplitter;
    19     ClientAreaPanel: TPanel;
    2019    constructor Create;
     20    destructor Destroy; override;
    2121  end;
    2222
     
    3131    //Panels: TObjectList; // TObjectList<TCDStyleRegionsPanel>
    3232    function FindControlInPanels(Control: TControl): TCDManagerItem; override;
     33    procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign);
    3334    procedure InsertControlPanel(Control: TControl; InsertAt: TAlign;
    3435      DropCtl: TControl); override;
     
    5455constructor TCDManagerRegionsItem.Create;
    5556begin
    56   Panel := TPanel.Create(nil);
    57 
    58   ClientAreaPanel := TPanel.Create(Panel);
    59   with ClientAreaPanel do begin
    60     Parent := Panel;
    61     Visible := True;
    62     DockSite := True;
    63     UseDockManager := True;
    64     Align := alClient;
    65     BevelInner := bvNone;
    66     BevelOuter := bvNone;
    67     //Color := clGreen;
    68   end;
    69   Splitter := TSplitter.Create(Panel);
     57  PanelHeader := TCDPanelHeader.Create(nil);
     58  PanelHeader.Header.ManagerItem := Self;
     59
     60  Splitter := TSplitter.Create(nil);
    7061  with Splitter do begin
    71     Parent := Panel;
     62    //Parent := Panel;
    7263    //Color := clRed;
    7364  end;
     65end;
     66
     67destructor TCDManagerRegionsItem.Destroy;
     68begin
     69  inherited Destroy;
    7470end;
    7571
     
    10096end;
    10197
     98procedure TCDManagerRegions.InsertControlNoUpdate(Control: TControl;
     99  InsertAt: TAlign);
     100var
     101  NewItem: TCDManagerRegionsItem;
     102begin
     103  NewItem := TCDManagerRegionsItem.Create;
     104  with NewItem do begin
     105    PanelHeader.Parent := Self.DockSite;
     106    Manager := Self;
     107    if DockStyle = dsList then Visible := True;
     108    PanelHeader.Header.PopupMenu := Self.PopupMenu;
     109  end;
     110  if (Control is TForm) and Assigned((Control as TForm).Icon) then
     111    NewItem.PanelHeader.Header.Icon.Picture.Assign((Control as TForm).Icon);
     112    NewItem.PanelHeader.Parent := DockSite;
     113
     114    NewItem.Control := Control;
     115    Control.AddHandlerOnVisibleChanged(NewItem.VisibleChange);
     116    Control.Parent := NewItem.PanelHeader.ControlPanel;
     117    Control.Align := alClient;
     118    if (InsertAt = alTop) or (InsertAt = alLeft) then
     119      DockItems.Insert(0, NewItem)
     120      else DockItems.Add(NewItem);
     121  end;
     122
    102123procedure TCDManagerRegions.InsertControlPanel(Control: TControl; InsertAt: TAlign;
    103124  DropCtl: TControl);
    104125var
    105   NewPanel: TCDManagerRegionsItem;
     126  NewItem: TCDManagerRegionsItem;
    106127  I: Integer;
    107128  NewDirection: TCDDirection;
     
    131152      end;
    132153    end;
    133 
    134     NewPanel := TCDManagerRegionsItem.Create;
    135     with NewPanel do begin
    136       Panel.Parent := Self.DockSite;
    137       Manager := Self;
    138       if DockStyle = dsList then Visible := True;
    139       Header.PopupMenu := Self.PopupMenu;
    140       //PopupMenu.Parent := Self.DockSite;
    141     end;
    142     if (Control is TForm) and Assigned((Control as TForm).Icon) then
    143       NewPanel.Header.Icon.Picture.Assign((Control as TForm).Icon);
    144 
    145     NewPanel.Control := Control;
    146     Control.AddHandlerOnVisibleChanged(NewPanel.VisibleChange);
    147     Control.Parent := NewPanel.ClientAreaPanel;
    148     Control.Align := alClient;
    149     if (InsertAt = alTop) or (InsertAt = alLeft) then
    150       DockItems.Insert(0, NewPanel)
    151       else DockItems.Add(NewPanel);
     154    InsertControlNoUpdate(Control, InsertAt);
    152155  end;
    153156  UpdateClientSize;
     
    156159procedure TCDManagerRegions.RemoveControl(Control: TControl);
    157160var
    158   ClientPanel: TCDManagerItem;
     161  ManagerItem: TCDManagerItem;
    159162  ClientCount: Integer;
    160163begin
    161   ClientPanel := FindControlInPanels(Control);
    162   Control.RemoveHandlerOnVisibleChanged(ClientPanel.VisibleChange);
    163 
    164   DockItems.Remove(ClientPanel);
     164  ManagerItem := FindControlInPanels(Control);
     165  if Assigned(ManagerItem) then
     166    Control.RemoveHandlerOnVisibleChanged(ManagerItem.VisibleChange);
     167
     168  DockItems.Remove(ManagerItem);
    165169  ClientCount := DockItems.Count;
    166170
     
    184188var
    185189  I: Integer;
     190  NewItem: TCDManagerRegionsItem;
    186191begin
    187192  inherited;
     
    189194  FDockItems := TObjectList.Create;
    190195
    191   for I := 0 to DockItems.Count - 1 do begin
    192     if Assigned(TCDManagerRegionsItem(DockItems[I]).Splitter) then
    193     with TCDManagerRegionsItem(DockItems[I]) do begin
    194       Splitter.Visible := True;
    195       Panel.Visible := True;
    196       ClientAreaPanel.Parent := TCDManagerRegionsItem(DockItems[I]).Panel;
    197       ClientAreaPanel.Visible := True;
    198       Control.Visible := True;
    199     end;
    200   end;
     196  for I := 0 to ADockSite.DockClientCount - 1 do
     197    InsertControlNoUpdate(ADockSite.DockClients[I], alLeft);
     198  UpdateClientSize;
    201199end;
    202200
     
    214212  for I := 0 to FDockItems.Count - 1 do
    215213    with TCDManagerRegionsItem(FDockItems[I]) do begin
    216       Panel.Invalidate;
     214      PanelHeader.Invalidate;
    217215    end;
    218216end;
     
    233231  for I := 0 to DockItems.Count - 1 do
    234232  with TCDManagerRegionsItem(DockItems[I]) do begin
    235     Panel.Left := SplitterLeft;
    236     Panel.Top := SplitterTop;
    237     Panel.Height := Self.DockSite.Height div
     233    PanelHeader.Left := SplitterLeft;
     234    PanelHeader.Top := SplitterTop;
     235    PanelHeader.Height := Self.DockSite.Height div
    238236      Self.DockSite.DockClientCount;
    239     Panel.Width := Self.DockSite.Width div
     237    PanelHeader.Width := Self.DockSite.Width div
    240238      Self.DockSite.DockClientCount;
    241239    //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    242     if I < (DockItems.Count - 1) then Panel.Align := BaseAlign
    243       else Panel.Align := alClient;
    244 
    245     Inc(SplitterLeft, Panel.Width);
    246     Inc(SplitterTop, Panel.Height);
     240    if I < (DockItems.Count - 1) then PanelHeader.Align := BaseAlign
     241      else PanelHeader.Align := alClient;
     242
     243    Inc(SplitterLeft, PanelHeader.Width);
     244    Inc(SplitterTop, PanelHeader.Height);
    247245    Splitter.Left := SplitterLeft;
    248246    Splitter.Top := SplitterTop;
     
    255253    Paint(Self);
    256254    if I < (DockItems.Count - 1) then begin
    257       if DockDirection = ddHorizontal then Panel.Align := alLeft
    258         else Panel.Align := alTop;
    259     end else Panel.Align := alClient;
     255      if DockDirection = ddHorizontal then PanelHeader.Align := alLeft
     256        else PanelHeader.Align := alTop;
     257    end else PanelHeader.Align := alClient;
    260258  end;
    261259end;
Note: See TracChangeset for help on using the changeset viewer.