Changeset 43 for DockManager/Lazarus


Ignore:
Timestamp:
Sep 16, 2010, 1:52:48 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Přepracováno na uchování seznamu ukotvovacích klientů horizontálně nebo vertikálně.
Location:
DockManager/Lazarus
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • DockManager/Lazarus/Demo/Demo.lpi

    r41 r43  
    3232      </Item1>
    3333    </RequiredPackages>
    34     <Units Count="21">
     34    <Units Count="24">
    3535      <Unit0>
    3636        <Filename Value="Demo.lpr"/>
    3737        <IsPartOfProject Value="True"/>
    3838        <UnitName Value="Demo"/>
     39        <EditorIndex Value="4"/>
     40        <WindowIndex Value="0"/>
     41        <TopLine Value="1"/>
     42        <CursorPos X="1" Y="19"/>
    3943        <UsageCount Value="25"/>
     44        <Loaded Value="True"/>
    4045        <DefaultSyntaxHighlighter Value="Delphi"/>
    4146      </Unit0>
     
    4651        <ResourceBaseClass Value="Form"/>
    4752        <UnitName Value="UMainForm"/>
    48         <IsVisibleTab Value="True"/>
    4953        <EditorIndex Value="0"/>
    5054        <WindowIndex Value="0"/>
    51         <TopLine Value="37"/>
    52         <CursorPos X="3" Y="48"/>
     55        <TopLine Value="12"/>
     56        <CursorPos X="1" Y="25"/>
    5357        <UsageCount Value="25"/>
    5458        <Loaded Value="True"/>
     
    5963        <Filename Value="E:\Programy\Lazarus\lcl\controls.pp"/>
    6064        <UnitName Value="Controls"/>
    61         <EditorIndex Value="8"/>
    62         <WindowIndex Value="0"/>
    63         <TopLine Value="474"/>
    64         <CursorPos X="76" Y="487"/>
     65        <EditorIndex Value="12"/>
     66        <WindowIndex Value="0"/>
     67        <TopLine Value="1397"/>
     68        <CursorPos X="14" Y="1410"/>
    6569        <UsageCount Value="12"/>
    6670        <Loaded Value="True"/>
     
    7781      <Unit4>
    7882        <Filename Value="E:\Programy\Lazarus\lcl\include\control.inc"/>
    79         <EditorIndex Value="13"/>
    80         <WindowIndex Value="0"/>
    81         <TopLine Value="333"/>
    82         <CursorPos X="22" Y="340"/>
     83        <EditorIndex Value="18"/>
     84        <WindowIndex Value="0"/>
     85        <TopLine Value="4685"/>
     86        <CursorPos X="32" Y="4689"/>
    8387        <UsageCount Value="12"/>
    8488        <Loaded Value="True"/>
     
    8690      <Unit5>
    8791        <Filename Value="E:\Programy\Lazarus\lcl\include\wincontrol.inc"/>
    88         <EditorIndex Value="12"/>
    89         <WindowIndex Value="0"/>
    90         <TopLine Value="6220"/>
    91         <CursorPos X="1" Y="6233"/>
     92        <EditorIndex Value="16"/>
     93        <WindowIndex Value="0"/>
     94        <TopLine Value="3785"/>
     95        <CursorPos X="1" Y="3798"/>
    9296        <UsageCount Value="12"/>
    9397        <Loaded Value="True"/>
     
    96100        <Filename Value="E:\Programy\Lazarus\lcl\lclclasses.pp"/>
    97101        <UnitName Value="LCLClasses"/>
    98         <EditorIndex Value="10"/>
     102        <EditorIndex Value="14"/>
    99103        <WindowIndex Value="0"/>
    100104        <TopLine Value="28"/>
     
    105109      <Unit7>
    106110        <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\objpas\classes\classesh.inc"/>
    107         <EditorIndex Value="6"/>
     111        <EditorIndex Value="10"/>
    108112        <WindowIndex Value="0"/>
    109113        <TopLine Value="107"/>
     
    114118      <Unit8>
    115119        <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\inc\objpash.inc"/>
    116         <EditorIndex Value="11"/>
     120        <EditorIndex Value="15"/>
    117121        <WindowIndex Value="0"/>
    118122        <TopLine Value="206"/>
     
    154158        <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\win\sysutils.pp"/>
    155159        <UnitName Value="sysutils"/>
    156         <EditorIndex Value="7"/>
     160        <EditorIndex Value="11"/>
    157161        <WindowIndex Value="0"/>
    158162        <TopLine Value="280"/>
     
    163167      <Unit14>
    164168        <Filename Value="E:\Programy\Lazarus\lcl\include\docktree.inc"/>
    165         <EditorIndex Value="9"/>
     169        <EditorIndex Value="13"/>
    166170        <WindowIndex Value="0"/>
    167171        <TopLine Value="174"/>
     
    177181        <ResourceBaseClass Value="Form"/>
    178182        <UnitName Value="UDockForm"/>
    179         <EditorIndex Value="5"/>
     183        <EditorIndex Value="9"/>
    180184        <WindowIndex Value="0"/>
    181185        <TopLine Value="1"/>
     
    189193        <Filename Value="E:\Programy\Lazarus\lcl\graphics.pp"/>
    190194        <UnitName Value="Graphics"/>
    191         <EditorIndex Value="4"/>
     195        <EditorIndex Value="8"/>
    192196        <WindowIndex Value="0"/>
    193197        <TopLine Value="675"/>
     
    209213        <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    210214        <UnitName Value="AnchorDocking"/>
    211         <EditorIndex Value="3"/>
    212         <WindowIndex Value="0"/>
    213         <TopLine Value="1"/>
    214         <CursorPos X="58" Y="2"/>
     215        <EditorIndex Value="7"/>
     216        <WindowIndex Value="0"/>
     217        <TopLine Value="4754"/>
     218        <CursorPos X="14" Y="4763"/>
    215219        <UsageCount Value="11"/>
    216220        <Loaded Value="True"/>
     
    222226        <EditorIndex Value="1"/>
    223227        <WindowIndex Value="0"/>
    224         <TopLine Value="356"/>
     228        <TopLine Value="362"/>
    225229        <CursorPos X="21" Y="369"/>
    226230        <UsageCount Value="11"/>
     
    231235        <IsPartOfProject Value="True"/>
    232236        <UnitName Value="UCustomDockManager"/>
     237        <IsVisibleTab Value="True"/>
     238        <EditorIndex Value="3"/>
     239        <WindowIndex Value="0"/>
     240        <TopLine Value="156"/>
     241        <CursorPos X="3" Y="174"/>
    233242        <UsageCount Value="20"/>
     243        <Loaded Value="True"/>
    234244        <DefaultSyntaxHighlighter Value="Delphi"/>
    235245      </Unit20>
     246      <Unit21>
     247        <Filename Value="E:\Programy\Lazarus\lcl\extctrls.pp"/>
     248        <UnitName Value="ExtCtrls"/>
     249        <EditorIndex Value="6"/>
     250        <WindowIndex Value="0"/>
     251        <TopLine Value="1183"/>
     252        <CursorPos X="9" Y="1183"/>
     253        <UsageCount Value="10"/>
     254        <Loaded Value="True"/>
     255      </Unit21>
     256      <Unit22>
     257        <Filename Value="E:\Programy\Lazarus\lcl\interfaces\win32\win32wsbuttons.pp"/>
     258        <UnitName Value="Win32WSButtons"/>
     259        <EditorIndex Value="5"/>
     260        <WindowIndex Value="0"/>
     261        <TopLine Value="479"/>
     262        <CursorPos X="30" Y="488"/>
     263        <UsageCount Value="10"/>
     264        <Loaded Value="True"/>
     265      </Unit22>
     266      <Unit23>
     267        <Filename Value="E:\Programy\Lazarus\lcl\include\dragmanager.inc"/>
     268        <EditorIndex Value="17"/>
     269        <WindowIndex Value="0"/>
     270        <TopLine Value="455"/>
     271        <CursorPos X="1" Y="468"/>
     272        <UsageCount Value="10"/>
     273        <Loaded Value="True"/>
     274      </Unit23>
    236275    </Units>
    237     <JumpHistory Count="15" HistoryIndex="14">
     276    <JumpHistory Count="30" HistoryIndex="29">
    238277      <Position1>
    239         <Filename Value="UMainForm.pas"/>
    240         <Caret Line="50" Column="22" TopLine="50"/>
     278        <Filename Value="..\UCustomDockManager.pas"/>
     279        <Caret Line="239" Column="1" TopLine="226"/>
    241280      </Position1>
    242281      <Position2>
    243         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    244         <Caret Line="4506" Column="31" TopLine="4501"/>
     282        <Filename Value="..\UCustomDockManager.pas"/>
     283        <Caret Line="240" Column="1" TopLine="226"/>
    245284      </Position2>
    246285      <Position3>
    247         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    248         <Caret Line="121" Column="20" TopLine="110"/>
     286        <Filename Value="..\UCustomDockManager.pas"/>
     287        <Caret Line="239" Column="1" TopLine="226"/>
    249288      </Position3>
    250289      <Position4>
    251         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    252         <Caret Line="147" Column="54" TopLine="134"/>
     290        <Filename Value="..\UCustomDockManager.pas"/>
     291        <Caret Line="240" Column="1" TopLine="226"/>
    253292      </Position4>
    254293      <Position5>
    255         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    256         <Caret Line="225" Column="70" TopLine="212"/>
     294        <Filename Value="..\UCustomDockManager.pas"/>
     295        <Caret Line="239" Column="1" TopLine="226"/>
    257296      </Position5>
    258297      <Position6>
    259         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    260         <Caret Line="233" Column="31" TopLine="212"/>
     298        <Filename Value="..\UCustomDockManager.pas"/>
     299        <Caret Line="240" Column="1" TopLine="226"/>
    261300      </Position6>
    262301      <Position7>
    263         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    264         <Caret Line="271" Column="10" TopLine="263"/>
     302        <Filename Value="..\UCustomDockManager.pas"/>
     303        <Caret Line="239" Column="1" TopLine="226"/>
    265304      </Position7>
    266305      <Position8>
    267         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    268         <Caret Line="312" Column="39" TopLine="299"/>
     306        <Filename Value="..\UCustomDockManager.pas"/>
     307        <Caret Line="240" Column="1" TopLine="226"/>
    269308      </Position8>
    270309      <Position9>
    271         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    272         <Caret Line="391" Column="36" TopLine="378"/>
     310        <Filename Value="..\UCustomDockManager.pas"/>
     311        <Caret Line="239" Column="1" TopLine="226"/>
    273312      </Position9>
    274313      <Position10>
    275         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    276         <Caret Line="392" Column="12" TopLine="378"/>
     314        <Filename Value="..\UCustomDockManager.pas"/>
     315        <Caret Line="240" Column="1" TopLine="226"/>
    277316      </Position10>
    278317      <Position11>
    279         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    280         <Caret Line="404" Column="16" TopLine="391"/>
     318        <Filename Value="..\UCustomDockManager.pas"/>
     319        <Caret Line="239" Column="1" TopLine="226"/>
    281320      </Position11>
    282321      <Position12>
    283         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    284         <Caret Line="405" Column="16" TopLine="391"/>
     322        <Filename Value="..\UCustomDockManager.pas"/>
     323        <Caret Line="240" Column="1" TopLine="226"/>
    285324      </Position12>
    286325      <Position13>
    287         <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>
    288         <Caret Line="434" Column="32" TopLine="421"/>
     326        <Filename Value="..\UCustomDockManager.pas"/>
     327        <Caret Line="239" Column="1" TopLine="226"/>
    289328      </Position13>
    290329      <Position14>
    291         <Filename Value="E:\Programy\Lazarus\lcl\controls.pp"/>
    292         <Caret Line="1" Column="76" TopLine="1"/>
     330        <Filename Value="..\UCustomDockManager.pas"/>
     331        <Caret Line="240" Column="1" TopLine="226"/>
    293332      </Position14>
    294333      <Position15>
    295         <Filename Value="UMainForm.pas"/>
    296         <Caret Line="48" Column="3" TopLine="37"/>
     334        <Filename Value="..\UCustomDockManager.pas"/>
     335        <Caret Line="239" Column="1" TopLine="226"/>
    297336      </Position15>
     337      <Position16>
     338        <Filename Value="..\UCustomDockManager.pas"/>
     339        <Caret Line="240" Column="1" TopLine="226"/>
     340      </Position16>
     341      <Position17>
     342        <Filename Value="..\UCustomDockManager.pas"/>
     343        <Caret Line="239" Column="1" TopLine="226"/>
     344      </Position17>
     345      <Position18>
     346        <Filename Value="..\UCustomDockManager.pas"/>
     347        <Caret Line="244" Column="26" TopLine="226"/>
     348      </Position18>
     349      <Position19>
     350        <Filename Value="..\UCustomDockManager.pas"/>
     351        <Caret Line="239" Column="43" TopLine="226"/>
     352      </Position19>
     353      <Position20>
     354        <Filename Value="..\UCustomDockManager.pas"/>
     355        <Caret Line="240" Column="1" TopLine="226"/>
     356      </Position20>
     357      <Position21>
     358        <Filename Value="..\UCustomDockManager.pas"/>
     359        <Caret Line="241" Column="1" TopLine="226"/>
     360      </Position21>
     361      <Position22>
     362        <Filename Value="..\UCustomDockManager.pas"/>
     363        <Caret Line="240" Column="1" TopLine="226"/>
     364      </Position22>
     365      <Position23>
     366        <Filename Value="..\UCustomDockManager.pas"/>
     367        <Caret Line="241" Column="1" TopLine="226"/>
     368      </Position23>
     369      <Position24>
     370        <Filename Value="..\UCustomDockManager.pas"/>
     371        <Caret Line="240" Column="1" TopLine="226"/>
     372      </Position24>
     373      <Position25>
     374        <Filename Value="..\UCustomDockManager.pas"/>
     375        <Caret Line="241" Column="7" TopLine="226"/>
     376      </Position25>
     377      <Position26>
     378        <Filename Value="..\UCustomDockManager.pas"/>
     379        <Caret Line="240" Column="1" TopLine="226"/>
     380      </Position26>
     381      <Position27>
     382        <Filename Value="..\UCustomDockManager.pas"/>
     383        <Caret Line="242" Column="1" TopLine="226"/>
     384      </Position27>
     385      <Position28>
     386        <Filename Value="..\UCustomDockManager.pas"/>
     387        <Caret Line="243" Column="1" TopLine="226"/>
     388      </Position28>
     389      <Position29>
     390        <Filename Value="..\UCustomDockManager.pas"/>
     391        <Caret Line="244" Column="1" TopLine="226"/>
     392      </Position29>
     393      <Position30>
     394        <Filename Value="..\UCustomDockManager.pas"/>
     395        <Caret Line="246" Column="1" TopLine="226"/>
     396      </Position30>
    298397    </JumpHistory>
    299398  </ProjectOptions>
  • DockManager/Lazarus/Demo/UMainForm.pas

    r41 r43  
    4444
    4545procedure TMainForm.FormShow(Sender: TObject);
     46var
     47  DockForm1: TDockForm;
     48  DockForm2: TDockForm;
     49  DockForm3: TDockForm;
    4650begin
    4751  Button1Click(Self);
    48   LastDockForm.ManualDock(Panel1);
     52  DockForm1 := LastDockForm;
     53  DockForm1.ManualDock(Panel1);
     54
     55  Button1Click(Self);
     56  DockForm2 := LastDockForm;
     57  DockForm2.ManualDock(Panel1);
     58
     59  Button1Click(Self);
     60  DockForm3 := LastDockForm;
     61  DockForm3.ManualDock(DockForm2);
    4962end;
    5063
     
    7588  NewForm.DragKind := dkDock;
    7689  NewForm.DragMode := dmAutomatic;
     90  NewForm.DockSite := True;
     91  NewForm.UseDockManager := True;
    7792  Inc(FormIndex);
    7893  NewForm.Show;
  • DockManager/Lazarus/UCustomDockManager.pas

    r42 r43  
    77uses
    88  Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls,
    9   Buttons, ExtCtrls;
     9  Buttons, ExtCtrls, Contnrs, Forms;
    1010
    1111const
     
    1313
    1414type
    15 
    16   { TCustomDockManager }
    17 
    18   TCustomDockManager = class(TDockManager)
    19   private
    20     FDockSite: TWinControl;
    21     FDockPanel: TPanel;
     15  TDockDirection = (ddNone, ddHorizontal, ddVertical);
     16
     17  TCustomDockManager = class;
     18
     19  TConjoinDockForm = class(TForm)
     20
     21  end;
     22
     23  { TDockClientPanel }
     24
     25  TDockClientPanel = class(TPanel)
     26    OwnerDockManager: TCustomDockManager;
    2227    CloseButton: TSpeedButton;
    23     procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);
    24     procedure CloseButtonClick(Sender: TObject);
     28    Control: TControl;
     29    Splitter: TSplitter;
     30    constructor Create(TheOwner: TComponent); override;
     31    destructor Destroy; override;
    2532    procedure DockPanelPaint(Sender: TObject);
    2633    procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton;
    2734      Shift: TShiftState; X, Y: Integer);
     35    procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);
     36    procedure CloseButtonClick(Sender: TObject);
     37    procedure ResizeExecute(Sender: TObject);
     38  end;
     39
     40  { TCustomDockManager }
     41
     42  TCustomDockManager = class(TDockManager)
     43  private
     44    FDockDirection: TDockDirection;
     45    FDockSite: TWinControl;
     46    FDockPanels: TObjectList; // of TDockClientPanel
     47    function FindControlInPanels(Control: TControl): TDockClientPanel;
    2848  public
    2949    constructor Create(ADockSite: TWinControl); override;
     
    5474{ TCustomDockManager }
    5575
    56 procedure TCustomDockManager.DrawGrabber(Canvas: TCanvas; AControl: TControl);
    57 begin
    58   with Canvas do begin
    59     Brush.Color := clBtnFace;
    60     Pen.Color := clBlack;
    61     FillRect(0, 0, AControl.Width, GrabberSize);
    62     Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1);
    63     TextOut(6, 2, AControl.Caption);
    64 
    65     CloseButton.Left := AControl.Width - CloseButton.Width - 2;
    66     CloseButton.Top := 2;
    67   end;
    68 end;
    69 
    70 procedure TCustomDockManager.CloseButtonClick(Sender: TObject);
     76function TCustomDockManager.FindControlInPanels(Control: TControl
     77  ): TDockClientPanel;
     78var
     79  I: Integer;
     80begin
     81  I := 0;
     82  while (I < FDockPanels.Count) and
     83    (TDockClientPanel(FDockPanels[I]).Control <> Control) do Inc(I);
     84  if I < FDockPanels.Count then Result := TDockClientPanel(FDockPanels[I])
     85    else Result := nil;
     86end;
     87
     88constructor TCustomDockManager.Create(ADockSite: TWinControl);
     89begin
     90  FDockSite := ADockSite;
     91  FDockPanels := TObjectList.Create;
     92  inherited Create(ADockSite);
     93end;
     94
     95destructor TCustomDockManager.Destroy;
     96begin
     97  FDockPanels.Free;
     98  inherited Destroy;
     99end;
     100
     101procedure TCustomDockManager.BeginUpdate;
     102begin
     103  inherited BeginUpdate;
     104end;
     105
     106procedure TCustomDockManager.EndUpdate;
     107begin
     108  inherited EndUpdate;
     109end;
     110
     111procedure TCustomDockManager.GetControlBounds(Control: TControl; out
     112  AControlBounds: TRect);
     113begin
     114end;
     115
     116function TCustomDockManager.GetDockEdge(ADockObject: TDragDockObject): boolean;
     117begin
     118  Result := inherited GetDockEdge(ADockObject);
     119end;
     120
     121procedure TCustomDockManager.InsertControl(ADockObject: TDragDockObject);
     122begin
     123  inherited InsertControl(ADockObject);
     124end;
     125
     126procedure TCustomDockManager.InsertControl(Control: TControl; InsertAt: TAlign;
     127  DropCtl: TControl);
     128var
     129  NewSplitter: TSplitter;
     130  NewPanel: TDockClientPanel;
     131  I: Integer;
     132begin
     133  if FDockSite.DockClientCount = 2 then begin
     134    if (InsertAt = alTop) or (InsertAt = alBottom) then
     135      FDockDirection := ddVertical
     136    else
     137    if (InsertAt = alLeft) or (InsertAt = alRight) then
     138      FDockDirection := ddHorizontal
     139    else FDockDirection := ddHorizontal;
     140  end;
     141  if FDockSite.DockClientCount > 1 then begin
     142    NewSplitter := TSplitter.Create(nil);
     143    NewSplitter.Parent := FDockSite;
     144    NewSplitter.Visible := True;
     145    NewSplitter.Color := clRed;
     146    with NewSplitter do
     147    if FDockDirection = ddVertical then begin
     148      Align := alTop;
     149      Top := FDockSite.Height;
     150    end else
     151    if FDockDirection = ddHorizontal then begin
     152      Align := alLeft;
     153      Left := FDockSite.Width;
     154    end;
     155
     156    with TDockClientPanel(FDockPanels.Last) do
     157    if FDockDirection = ddVertical then
     158      Align := alTop
     159    else
     160    if FDockDirection = ddHorizontal then
     161      Align := alLeft;
     162  end;
     163  NewPanel := TDockClientPanel.Create(nil);
     164  with NewPanel do begin
     165    Splitter := NewSplitter;
     166    Parent := FDockSite;
     167    OwnerDockManager := Self;
     168    Visible := True;
     169    Align := alClient;
     170  end;
     171  NewPanel.Control := Control;
     172  Control.Parent := NewPanel;
     173  FDockPanels.Add(NewPanel);
     174
     175  for I := 0 to FDockPanels.Count - 1 do begin
     176    TDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div
     177      FDockSite.DockClientCount;
     178    TDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div
     179      FDockSite.DockClientCount;
     180  end;
     181
     182//  FDockPanel.Invalidate;
     183  inherited;
     184end;
     185
     186procedure TCustomDockManager.LoadFromStream(Stream: TStream);
     187begin
     188end;
     189
     190procedure TCustomDockManager.PaintSite(DC: HDC);
     191var
     192  Canvas: TControlCanvas;
     193  Control: TControl;
     194  I: Integer;
     195  R: TRect;
     196begin
     197  for I := 0 to FDockPanels.Count - 1 do
     198    with TDockClientPanel(FDockPanels[I]) do begin
     199      Invalidate;
     200    end;
     201end;
     202
     203procedure TCustomDockManager.MessageHandler(Sender: TControl;
     204  var Message: TLMessage);
     205begin
     206  inherited MessageHandler(Sender, Message);
     207end;
     208
     209procedure TCustomDockManager.PositionDockRect(ADockObject: TDragDockObject);
     210begin
     211  inherited PositionDockRect(ADockObject);
     212end;
     213
     214procedure TCustomDockManager.PositionDockRect(Client, DropCtl: TControl;
     215  DropAlign: TAlign; var DockRect: TRect);
     216begin
     217  case DropAlign of
     218    alNone: begin
     219      DockRect := Rect(0, 0, FDockSite.ClientWidth, FDockSite.ClientHeight);
     220    end;
     221    alRight: begin
     222      DockRect := Rect(FDockSite.ClientWidth div 2, 0, FDockSite.ClientWidth, FDockSite.ClientHeight);
     223    end;
     224    alLeft: begin
     225      DockRect := Rect(0, 0, FDockSite.ClientWidth div 2, FDockSite.ClientHeight);
     226    end;
     227    alTop: begin
     228      DockRect := Rect(0, 0, FDockSite.ClientWidth, FDockSite.ClientHeight div 2);
     229    end;
     230    alBottom: begin
     231      DockRect := Rect(0, FDockSite.ClientHeight div 2, FDockSite.ClientWidth, FDockSite.ClientHeight);
     232    end;
     233  end;
     234  DockRect.TopLeft := FDockSite.ClientToScreen(DockRect.TopLeft);
     235  DockRect.BottomRight := FDockSite.ClientToScreen(DockRect.BottomRight);
     236end;
     237
     238procedure TCustomDockManager.RemoveControl(Control: TControl);
     239var
     240  ClientPanel: TDockClientPanel;
     241begin
     242  inherited;
     243  if Control.HostDockSite = Self.FDockSite then begin
     244    ClientPanel := FindControlInPanels(Control);
     245    //ClientPanel.Splitter.Free;
     246    FDockPanels.Remove(ClientPanel);
     247    if FDockSite.DockClientCount = 2 then FDockDirection := ddNone;
     248    //FDockSite.Invalidate;
     249  end;
     250end;
     251
     252procedure TCustomDockManager.ResetBounds(Force: Boolean);
    71253var
    72254  I: Integer;
     
    74256  R: TRect;
    75257begin
    76   for I := 0 to FDockSite.ControlCount - 1 do
    77     begin
    78       Control := FDockSite.Controls[I];
    79       if Control.Visible and (Control.HostDockSite = FDockSite) then
    80       begin
    81         Control.Hide;
    82       end;
    83     end;
    84   FDockPanel.Hide;
    85 end;
    86 
    87 procedure TCustomDockManager.DockPanelPaint(Sender: TObject);
    88 var
    89   I: Integer;
    90   Control: TControl;
    91   R: TRect;
    92 begin
    93   CloseButton.Visible := FDockSite.DockClientCount > 0;
    94   for I := 0 to FDockSite.DockClientCount - 1 do begin
    95     Control := FDockSite.DockClients[I];
    96     if Control.Visible and (Control.HostDockSite = FDockSite) then
    97     begin
    98       R := Control.BoundsRect;
    99       //Control.SetBounds(0, GrabberSize, FDockSite.Width - Control.Left,
    100       //  FDockSite.Height - Control.Top);
    101       //Canvas.FillRect(R);
    102       DrawGrabber(FDockPanel.Canvas, Control);
    103     end;
    104   end;
    105 end;
    106 
    107 procedure TCustomDockManager.DockPanelMouseDown(Sender: TObject;
    108   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    109 begin
    110   if (Button=mbLeft) and (FDockSite.DockClientCount > 0) then
    111     DragManager.DragStart(FDockSite.DockClients[0], False, 1);
    112 end;
    113 
    114 constructor TCustomDockManager.Create(ADockSite: TWinControl);
    115 begin
    116   FDockSite := ADockSite;
    117   FDockPanel := TPanel.Create(nil);
    118   with FDockPanel do begin
    119     Parent := ADockSite;
    120     Align := alClient;
    121     Visible := True;
    122     OnPaint := DockPanelPaint;
    123     OnMouseDown := DockPanelMouseDown();
    124     BevelInner := bvNone;
    125     BevelOuter := bvNone;
    126   end;
    127 
    128   CloseButton := TSpeedButton.Create(FDockPanel);
     258end;
     259
     260procedure TCustomDockManager.SaveToStream(Stream: TStream);
     261begin
     262end;
     263
     264procedure TCustomDockManager.SetReplacingControl(Control: TControl);
     265begin
     266  inherited SetReplacingControl(Control);
     267end;
     268
     269function TCustomDockManager.AutoFreeByControl: Boolean;
     270begin
     271  Result := inherited AutoFreeByControl;
     272end;
     273
     274{ TDockClientPanel }
     275
     276constructor TDockClientPanel.Create(TheOwner: TComponent);
     277begin
     278  inherited;
     279  CloseButton := TSpeedButton.Create(Self);
    129280  with CloseButton do begin
    130     Parent := FDockPanel;
     281    Parent := Self;
    131282    Caption := 'X';
    132283    Font.Size := 6;
     
    136287    OnClick := CloseButtonClick;
    137288  end;
    138   inherited Create(ADockSite);
    139 end;
    140 
    141 destructor TCustomDockManager.Destroy;
    142 begin
    143   FDockPanel.Free;
     289  OnPaint := DockPanelPaint;
     290  OnMouseDown := DockPanelMouseDown;
     291  OnResize := ResizeExecute;
     292  BevelInner := bvNone;
     293  BevelOuter := bvNone;
     294end;
     295
     296destructor TDockClientPanel.Destroy;
     297begin
    144298  inherited Destroy;
    145299end;
    146300
    147 procedure TCustomDockManager.BeginUpdate;
    148 begin
    149   inherited BeginUpdate;
    150 end;
    151 
    152 procedure TCustomDockManager.EndUpdate;
    153 begin
    154   inherited EndUpdate;
    155 end;
    156 
    157 procedure TCustomDockManager.GetControlBounds(Control: TControl; out
    158   AControlBounds: TRect);
    159 begin
    160 end;
    161 
    162 function TCustomDockManager.GetDockEdge(ADockObject: TDragDockObject): boolean;
    163 begin
    164   Result := inherited GetDockEdge(ADockObject);
    165 end;
    166 
    167 procedure TCustomDockManager.InsertControl(ADockObject: TDragDockObject);
    168 begin
    169   inherited InsertControl(ADockObject);
    170   FDockPanel.Repaint;
    171 end;
    172 
    173 procedure TCustomDockManager.InsertControl(Control: TControl; InsertAt: TAlign;
    174   DropCtl: TControl);
    175 begin
    176   inherited;
    177 end;
    178 
    179 procedure TCustomDockManager.LoadFromStream(Stream: TStream);
    180 begin
    181 end;
    182 
    183 procedure TCustomDockManager.PaintSite(DC: HDC);
    184 var
    185   Canvas: TControlCanvas;
    186   Control: TControl;
     301procedure TDockClientPanel.DrawGrabber(Canvas: TCanvas; AControl: TControl);
     302begin
     303  with Canvas do begin
     304    Brush.Color := clBtnFace;
     305    Pen.Color := clBlack;
     306    FillRect(0, 0, AControl.Width, GrabberSize);
     307
     308    if (AControl as TWinControl).Focused then
     309      Font.Style := Font.Style + [fsBold]
     310      else Font.Style := Font.Style - [fsBold];
     311    Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1);
     312    TextOut(6, 2, AControl.Caption);
     313
     314    CloseButton.Left := AControl.Width - CloseButton.Width - 2;
     315    CloseButton.Top := 2;
     316  end;
     317end;
     318
     319procedure TDockClientPanel.CloseButtonClick(Sender: TObject);
     320begin
     321  Control.Hide;
     322end;
     323
     324procedure TDockClientPanel.ResizeExecute(Sender: TObject);
     325begin
     326  Control.Top := GrabberSize;
     327  Control.Left := 0;
     328  Control.Width := Width;
     329  Control.Height := Height - GrabberSize;
     330  //Control.SetBounds(0, GrabberSize, Width - Control.Left,
     331  //  Height - Control.Top);
     332end;
     333
     334procedure TDockClientPanel.DockPanelPaint(Sender: TObject);
     335var
    187336  I: Integer;
    188337  R: TRect;
    189338begin
    190   Canvas := TControlCanvas.Create;
    191   try
    192     //Canvas.Control := FDockSite;
    193     Canvas.Control := FDockPanel;
    194     Canvas.Lock;
    195     try
    196       Canvas.Handle := DC;
    197       try
    198         for I := 0 to FDockSite.ControlCount - 1 do
    199         begin
    200           Control := FDockSite.Controls[I];
    201           if Control.Visible and (Control.HostDockSite = FDockSite) then
    202           begin
    203             R := Control.BoundsRect;
    204             Control.SetBounds(0, GrabberSize, FDockSite.Width - Control.Left,
    205               FDockSite.Height - Control.Top);
    206             Canvas.FillRect(R);
    207             DrawGrabber(Canvas, Control);
    208           end;
    209         end;
    210       finally
    211         Canvas.Handle := 0;
    212       end;
    213     finally
    214       Canvas.Unlock;
    215     end;
    216   finally
    217     Canvas.Free;
    218   end;
    219   FDockPanel.Repaint;
    220 end;
    221 
    222 procedure TCustomDockManager.MessageHandler(Sender: TControl;
    223   var Message: TLMessage);
    224 begin
    225   inherited MessageHandler(Sender, Message);
    226 end;
    227 
    228 procedure TCustomDockManager.PositionDockRect(ADockObject: TDragDockObject);
    229 begin
    230   inherited PositionDockRect(ADockObject);
    231 end;
    232 
    233 procedure TCustomDockManager.PositionDockRect(Client, DropCtl: TControl;
    234   DropAlign: TAlign; var DockRect: TRect);
    235 begin
    236   DockRect := Rect(0, 0, FDockSite.ClientWidth, FDockSite.ClientHeight);
    237   DockRect.TopLeft := FDockSite.ClientToScreen(DockRect.TopLeft);
    238   DockRect.BottomRight := FDockSite.ClientToScreen(DockRect.BottomRight);
    239 end;
    240 
    241 procedure TCustomDockManager.RemoveControl(Control: TControl);
    242 begin
    243   inherited;
    244   //FDockPanel.Invalidate;
    245   FDockSite.Invalidate;
    246 end;
    247 
    248 procedure TCustomDockManager.ResetBounds(Force: Boolean);
    249 var
    250   I: Integer;
    251   Control: TControl;
    252   R: TRect;
    253 begin
    254   for I := 0 to FDockSite.ControlCount - 1 do
    255     begin
    256       Control := FDockSite.Controls[I];
    257       if Control.Visible and (Control.HostDockSite = FDockSite) then
    258       begin
    259         R := Control.BoundsRect;
    260         Control.SetBounds(0, GrabberSize, FDockSite.Width - Control.Left,
    261           FDockSite.Height - Control.Top);
    262       end;
    263     end;
    264 end;
    265 
    266 procedure TCustomDockManager.SaveToStream(Stream: TStream);
    267 begin
    268 end;
    269 
    270 procedure TCustomDockManager.SetReplacingControl(Control: TControl);
    271 begin
    272   inherited SetReplacingControl(Control);
    273 end;
    274 
    275 function TCustomDockManager.AutoFreeByControl: Boolean;
    276 begin
    277   Result := inherited AutoFreeByControl;
     339  R := Control.ClientRect;
     340  Canvas.FillRect(R);
     341  DrawGrabber(Canvas, Control);
     342end;
     343
     344procedure TDockClientPanel.DockPanelMouseDown(Sender: TObject;
     345  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     346begin
     347  if (Button=mbLeft) then begin
     348    DragManager.DragStart(Control, False, 1);
     349  end;
    278350end;
    279351
Note: See TracChangeset for help on using the changeset viewer.