Changeset 43
- Timestamp:
- Sep 16, 2010, 1:52:48 PM (14 years ago)
- Location:
- DockManager/Lazarus
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DockManager/Lazarus/Demo/Demo.lpi
r41 r43 32 32 </Item1> 33 33 </RequiredPackages> 34 <Units Count="2 1">34 <Units Count="24"> 35 35 <Unit0> 36 36 <Filename Value="Demo.lpr"/> 37 37 <IsPartOfProject Value="True"/> 38 38 <UnitName Value="Demo"/> 39 <EditorIndex Value="4"/> 40 <WindowIndex Value="0"/> 41 <TopLine Value="1"/> 42 <CursorPos X="1" Y="19"/> 39 43 <UsageCount Value="25"/> 44 <Loaded Value="True"/> 40 45 <DefaultSyntaxHighlighter Value="Delphi"/> 41 46 </Unit0> … … 46 51 <ResourceBaseClass Value="Form"/> 47 52 <UnitName Value="UMainForm"/> 48 <IsVisibleTab Value="True"/>49 53 <EditorIndex Value="0"/> 50 54 <WindowIndex Value="0"/> 51 <TopLine Value=" 37"/>52 <CursorPos X=" 3" Y="48"/>55 <TopLine Value="12"/> 56 <CursorPos X="1" Y="25"/> 53 57 <UsageCount Value="25"/> 54 58 <Loaded Value="True"/> … … 59 63 <Filename Value="E:\Programy\Lazarus\lcl\controls.pp"/> 60 64 <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"/> 65 69 <UsageCount Value="12"/> 66 70 <Loaded Value="True"/> … … 77 81 <Unit4> 78 82 <Filename Value="E:\Programy\Lazarus\lcl\include\control.inc"/> 79 <EditorIndex Value="1 3"/>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"/> 83 87 <UsageCount Value="12"/> 84 88 <Loaded Value="True"/> … … 86 90 <Unit5> 87 91 <Filename Value="E:\Programy\Lazarus\lcl\include\wincontrol.inc"/> 88 <EditorIndex Value="1 2"/>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"/> 92 96 <UsageCount Value="12"/> 93 97 <Loaded Value="True"/> … … 96 100 <Filename Value="E:\Programy\Lazarus\lcl\lclclasses.pp"/> 97 101 <UnitName Value="LCLClasses"/> 98 <EditorIndex Value="1 0"/>102 <EditorIndex Value="14"/> 99 103 <WindowIndex Value="0"/> 100 104 <TopLine Value="28"/> … … 105 109 <Unit7> 106 110 <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\objpas\classes\classesh.inc"/> 107 <EditorIndex Value=" 6"/>111 <EditorIndex Value="10"/> 108 112 <WindowIndex Value="0"/> 109 113 <TopLine Value="107"/> … … 114 118 <Unit8> 115 119 <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\inc\objpash.inc"/> 116 <EditorIndex Value="1 1"/>120 <EditorIndex Value="15"/> 117 121 <WindowIndex Value="0"/> 118 122 <TopLine Value="206"/> … … 154 158 <Filename Value="E:\Programy\Lazarus\fpc\2.4.0\source\rtl\win\sysutils.pp"/> 155 159 <UnitName Value="sysutils"/> 156 <EditorIndex Value=" 7"/>160 <EditorIndex Value="11"/> 157 161 <WindowIndex Value="0"/> 158 162 <TopLine Value="280"/> … … 163 167 <Unit14> 164 168 <Filename Value="E:\Programy\Lazarus\lcl\include\docktree.inc"/> 165 <EditorIndex Value=" 9"/>169 <EditorIndex Value="13"/> 166 170 <WindowIndex Value="0"/> 167 171 <TopLine Value="174"/> … … 177 181 <ResourceBaseClass Value="Form"/> 178 182 <UnitName Value="UDockForm"/> 179 <EditorIndex Value=" 5"/>183 <EditorIndex Value="9"/> 180 184 <WindowIndex Value="0"/> 181 185 <TopLine Value="1"/> … … 189 193 <Filename Value="E:\Programy\Lazarus\lcl\graphics.pp"/> 190 194 <UnitName Value="Graphics"/> 191 <EditorIndex Value=" 4"/>195 <EditorIndex Value="8"/> 192 196 <WindowIndex Value="0"/> 193 197 <TopLine Value="675"/> … … 209 213 <Filename Value="E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/> 210 214 <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"/> 215 219 <UsageCount Value="11"/> 216 220 <Loaded Value="True"/> … … 222 226 <EditorIndex Value="1"/> 223 227 <WindowIndex Value="0"/> 224 <TopLine Value="3 56"/>228 <TopLine Value="362"/> 225 229 <CursorPos X="21" Y="369"/> 226 230 <UsageCount Value="11"/> … … 231 235 <IsPartOfProject Value="True"/> 232 236 <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"/> 233 242 <UsageCount Value="20"/> 243 <Loaded Value="True"/> 234 244 <DefaultSyntaxHighlighter Value="Delphi"/> 235 245 </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> 236 275 </Units> 237 <JumpHistory Count=" 15" HistoryIndex="14">276 <JumpHistory Count="30" HistoryIndex="29"> 238 277 <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"/> 241 280 </Position1> 242 281 <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"/> 245 284 </Position2> 246 285 <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"/> 249 288 </Position3> 250 289 <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"/> 253 292 </Position4> 254 293 <Position5> 255 <Filename Value=" E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>256 <Caret Line="2 25" Column="70" TopLine="212"/>294 <Filename Value="..\UCustomDockManager.pas"/> 295 <Caret Line="239" Column="1" TopLine="226"/> 257 296 </Position5> 258 297 <Position6> 259 <Filename Value=" E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>260 <Caret Line="2 33" Column="31" TopLine="212"/>298 <Filename Value="..\UCustomDockManager.pas"/> 299 <Caret Line="240" Column="1" TopLine="226"/> 261 300 </Position6> 262 301 <Position7> 263 <Filename Value=" E:\Projekty jine\Lazarus\examples\anchordocking\anchordocking.pas"/>264 <Caret Line="2 71" Column="10" TopLine="263"/>302 <Filename Value="..\UCustomDockManager.pas"/> 303 <Caret Line="239" Column="1" TopLine="226"/> 265 304 </Position7> 266 305 <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"/> 269 308 </Position8> 270 309 <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"/> 273 312 </Position9> 274 313 <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"/> 277 316 </Position10> 278 317 <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"/> 281 320 </Position11> 282 321 <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"/> 285 324 </Position12> 286 325 <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"/> 289 328 </Position13> 290 329 <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"/> 293 332 </Position14> 294 333 <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"/> 297 336 </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> 298 397 </JumpHistory> 299 398 </ProjectOptions> -
DockManager/Lazarus/Demo/UMainForm.pas
r41 r43 44 44 45 45 procedure TMainForm.FormShow(Sender: TObject); 46 var 47 DockForm1: TDockForm; 48 DockForm2: TDockForm; 49 DockForm3: TDockForm; 46 50 begin 47 51 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); 49 62 end; 50 63 … … 75 88 NewForm.DragKind := dkDock; 76 89 NewForm.DragMode := dmAutomatic; 90 NewForm.DockSite := True; 91 NewForm.UseDockManager := True; 77 92 Inc(FormIndex); 78 93 NewForm.Show; -
DockManager/Lazarus/UCustomDockManager.pas
r42 r43 7 7 uses 8 8 Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls, 9 Buttons, ExtCtrls ;9 Buttons, ExtCtrls, Contnrs, Forms; 10 10 11 11 const … … 13 13 14 14 type 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; 22 27 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; 25 32 procedure DockPanelPaint(Sender: TObject); 26 33 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton; 27 34 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; 28 48 public 29 49 constructor Create(ADockSite: TWinControl); override; … … 54 74 { TCustomDockManager } 55 75 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); 76 function TCustomDockManager.FindControlInPanels(Control: TControl 77 ): TDockClientPanel; 78 var 79 I: Integer; 80 begin 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; 86 end; 87 88 constructor TCustomDockManager.Create(ADockSite: TWinControl); 89 begin 90 FDockSite := ADockSite; 91 FDockPanels := TObjectList.Create; 92 inherited Create(ADockSite); 93 end; 94 95 destructor TCustomDockManager.Destroy; 96 begin 97 FDockPanels.Free; 98 inherited Destroy; 99 end; 100 101 procedure TCustomDockManager.BeginUpdate; 102 begin 103 inherited BeginUpdate; 104 end; 105 106 procedure TCustomDockManager.EndUpdate; 107 begin 108 inherited EndUpdate; 109 end; 110 111 procedure TCustomDockManager.GetControlBounds(Control: TControl; out 112 AControlBounds: TRect); 113 begin 114 end; 115 116 function TCustomDockManager.GetDockEdge(ADockObject: TDragDockObject): boolean; 117 begin 118 Result := inherited GetDockEdge(ADockObject); 119 end; 120 121 procedure TCustomDockManager.InsertControl(ADockObject: TDragDockObject); 122 begin 123 inherited InsertControl(ADockObject); 124 end; 125 126 procedure TCustomDockManager.InsertControl(Control: TControl; InsertAt: TAlign; 127 DropCtl: TControl); 128 var 129 NewSplitter: TSplitter; 130 NewPanel: TDockClientPanel; 131 I: Integer; 132 begin 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; 184 end; 185 186 procedure TCustomDockManager.LoadFromStream(Stream: TStream); 187 begin 188 end; 189 190 procedure TCustomDockManager.PaintSite(DC: HDC); 191 var 192 Canvas: TControlCanvas; 193 Control: TControl; 194 I: Integer; 195 R: TRect; 196 begin 197 for I := 0 to FDockPanels.Count - 1 do 198 with TDockClientPanel(FDockPanels[I]) do begin 199 Invalidate; 200 end; 201 end; 202 203 procedure TCustomDockManager.MessageHandler(Sender: TControl; 204 var Message: TLMessage); 205 begin 206 inherited MessageHandler(Sender, Message); 207 end; 208 209 procedure TCustomDockManager.PositionDockRect(ADockObject: TDragDockObject); 210 begin 211 inherited PositionDockRect(ADockObject); 212 end; 213 214 procedure TCustomDockManager.PositionDockRect(Client, DropCtl: TControl; 215 DropAlign: TAlign; var DockRect: TRect); 216 begin 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); 236 end; 237 238 procedure TCustomDockManager.RemoveControl(Control: TControl); 239 var 240 ClientPanel: TDockClientPanel; 241 begin 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; 250 end; 251 252 procedure TCustomDockManager.ResetBounds(Force: Boolean); 71 253 var 72 254 I: Integer; … … 74 256 R: TRect; 75 257 begin 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); 258 end; 259 260 procedure TCustomDockManager.SaveToStream(Stream: TStream); 261 begin 262 end; 263 264 procedure TCustomDockManager.SetReplacingControl(Control: TControl); 265 begin 266 inherited SetReplacingControl(Control); 267 end; 268 269 function TCustomDockManager.AutoFreeByControl: Boolean; 270 begin 271 Result := inherited AutoFreeByControl; 272 end; 273 274 { TDockClientPanel } 275 276 constructor TDockClientPanel.Create(TheOwner: TComponent); 277 begin 278 inherited; 279 CloseButton := TSpeedButton.Create(Self); 129 280 with CloseButton do begin 130 Parent := FDockPanel;281 Parent := Self; 131 282 Caption := 'X'; 132 283 Font.Size := 6; … … 136 287 OnClick := CloseButtonClick; 137 288 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; 294 end; 295 296 destructor TDockClientPanel.Destroy; 297 begin 144 298 inherited Destroy; 145 299 end; 146 300 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; 301 procedure TDockClientPanel.DrawGrabber(Canvas: TCanvas; AControl: TControl); 302 begin 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; 317 end; 318 319 procedure TDockClientPanel.CloseButtonClick(Sender: TObject); 320 begin 321 Control.Hide; 322 end; 323 324 procedure TDockClientPanel.ResizeExecute(Sender: TObject); 325 begin 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); 332 end; 333 334 procedure TDockClientPanel.DockPanelPaint(Sender: TObject); 335 var 187 336 I: Integer; 188 337 R: TRect; 189 338 begin 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); 342 end; 343 344 procedure TDockClientPanel.DockPanelMouseDown(Sender: TObject; 345 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 346 begin 347 if (Button=mbLeft) then begin 348 DragManager.DragStart(Control, False, 1); 349 end; 278 350 end; 279 351
Note:
See TracChangeset
for help on using the changeset viewer.