Ignore:
Timestamp:
Mar 10, 2011, 7:55:48 AM (14 years ago)
Author:
george
Message:
  • Fixed: Insertion in regions on left and top side.
  • Added: If inserted control side is defferent than already placed controls then create conjoined subform.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDockStyleRegions.pas

    r182 r183  
    66
    77uses
    8   Classes, SysUtils, Controls, ExtCtrls, StdCtrls, UCoolDockStyle,
     8  Classes, SysUtils, Controls, ExtCtrls, StdCtrls, UCoolDockStyle, Forms,
    99  Graphics, Contnrs, Buttons, UCoolDockClientPanel, UCoolDockCommon;
    1010
     
    1818  TCoolDockStyleRegions = class(TCoolDockStyle)
    1919  private
     20    function GetDirection(InsertAt: TAlign): TDockDirection;
    2021  public
    21     Panels: TObjectList; // TObjectList<TCoolDockStyleRegionsPanel>
     22    FDockDirection: TDockDirection;
     23    //Panels: TObjectList; // TObjectList<TCoolDockStyleRegionsPanel>
     24    procedure InsertControl(AControl: TControl; InsertAt: TAlign); override;
     25    procedure RemoveControl(Control: TControl); override;
    2226    function GetHeaderPos: THeaderPos; override;
    2327    procedure SetHeaderPos(const AValue: THeaderPos); override;
     
    2731    procedure SetVisible(const AValue: Boolean); override;
    2832    procedure ChangeVisible(Control: TWinControl; Visible: Boolean); override;
     33    property DockDirection: TDockDirection read FDockDirection
     34      write FDockDirection;
    2935  end;
    3036
     
    3743{ TCoolDockStyleRegions }
    3844
     45function TCoolDockStyleRegions.GetDirection(InsertAt: TAlign): TDockDirection;
     46begin
     47  Result := ddHorizontal;
     48  if (InsertAt = alTop) or (InsertAt = alBottom) then
     49    Result := ddVertical
     50  else
     51  if (InsertAt = alLeft) or (InsertAt = alRight) then
     52    Result := ddHorizontal
     53  else;
     54end;
     55
     56procedure TCoolDockStyleRegions.InsertControl(AControl: TControl; InsertAt: TAlign);
     57var
     58  NewPanel: TCoolDockClientPanel;
     59  I: Integer;
     60  NewDirection: TDockDirection;
     61  NewConjoinDockForm: TCoolDockConjoinForm;
     62  NewDockSite: TWinControl;
     63begin
     64  inherited;
     65  with TCoolDockManager(Manager) do begin
     66    if DockSite.DockClientCount <= 2 then FDockDirection := GetDirection(InsertAt)
     67    else
     68    if (DockSite.DockClientCount > 2) then begin
     69      NewDirection := GetDirection(InsertAt);
     70      if (NewDirection <> FDockDirection) then begin
     71        // Direction change, create conjoin form
     72        NewConjoinDockForm := CreateContainer(InsertAt);
     73        NewDockSite := DockSite.HostDockSite;
     74        // FDockSite.ManualFloat(FDockSite.BoundsRect);
     75        NewConjoinDockForm.ManualDock(NewDockSite);
     76        DockSite.ManualDock(NewConjoinDockForm.Panel);
     77        AControl.ManualDock(NewConjoinDockForm.Panel, nil, InsertAt);
     78        Exit;
     79      end;
     80    end;
     81
     82    NewPanel := TCoolDockClientPanel.Create(nil);
     83    with NewPanel do begin
     84      Parent := TCoolDockManager(Manager).DockSite;
     85      OwnerDockManager := Self;
     86      if DockStyle = dsList then Visible := True;
     87      Header.PopupMenu := TCoolDockManager(Manager).PopupMenu;
     88      //PopupMenu.Parent := Self.DockSite;
     89    end;
     90    if (AControl is TForm) and Assigned((AControl as TForm).Icon) then
     91      NewPanel.Header.Icon.Picture.Assign((AControl as TForm).Icon);
     92
     93    NewPanel.Control := AControl;
     94    AControl.AddHandlerOnVisibleChanged(NewPanel.VisibleChange);
     95    AControl.Parent := NewPanel.ClientAreaPanel;
     96    AControl.Align := alClient;
     97    if (InsertAt = alTop) or (InsertAt = alLeft) then
     98      DockPanels.Insert(0, NewPanel)
     99      else DockPanels.Add(NewPanel);
     100  end;
     101  UpdateClientSize;
     102end;
     103
     104procedure TCoolDockStyleRegions.RemoveControl(Control: TControl);
     105begin
     106  if TCoolDockManager(Manager).DockSite.DockClientCount = 2 then FDockDirection := ddNone;
     107  inherited RemoveControl(Control);
     108end;
     109
    39110function TCoolDockStyleRegions.GetHeaderPos: THeaderPos;
    40111begin
     
    52123begin
    53124  inherited;
    54   Panels := TObjectList.Create;
     125  //Panels := TObjectList.Create;
    55126
    56127  with TCoolDockManager(AManager) do
     
    67138destructor TCoolDockStyleRegions.Destroy;
    68139begin
    69   Panels.Free;
     140  //Panels.Free;
    70141  inherited Destroy;
    71142end;
     
    74145var
    75146  I: Integer;
     147  SplitterLeft: Integer;
     148  SplitterTop: Integer;
     149  BaseAlign: TAlign;
    76150begin
    77151  inherited UpdateClientSize;
     152  if FDockDirection = ddHorizontal then
     153    BaseAlign := alLeft else BaseAlign := alTop;
     154
     155  SplitterLeft := 0;
     156  SplitterTop := 0;
    78157  with TCoolDockManager(Manager) do
    79158  for I := 0 to DockPanels.Count - 1 do
    80159  with TCoolDockClientPanel(DockPanels[I]) do begin
     160    Left := SplitterLeft;
     161    Top := SplitterTop;
    81162    Height := TCoolDockManager(Manager).DockSite.Height div
    82163      TCoolDockManager(Manager).DockSite.DockClientCount;
     
    84165      TCoolDockManager(Manager).DockSite.DockClientCount;
    85166    //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
     167    if I < (DockPanels.Count - 1) then Align := BaseAlign
     168      else Align := alClient;
     169
     170    Splitter.Left := SplitterLeft;
     171    Splitter.Top := SplitterTop;
     172    Inc(SplitterLeft, Width);
     173    Inc(SplitterTop, Height);
     174    Splitter.Parent := TCoolDockManager(Manager).DockSite;
     175    Splitter.Align := BaseAlign;
     176    Splitter.Visible := True;
     177
     178
    86179    DockPanelPaint(Self);
    87180    if I < (DockPanels.Count - 1) then begin
    88       if TCoolDockManager(Manager).DockDirection = ddHorizontal then Align := alLeft
     181      if DockDirection = ddHorizontal then Align := alLeft
    89182        else Align := alTop;
    90183    end else Align := alClient;
Note: See TracChangeset for help on using the changeset viewer.