Changeset 49 for DockManager/Lazarus/UCustomDockManager.pas
- Timestamp:
- Sep 17, 2010, 4:16:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DockManager/Lazarus/UCustomDockManager.pas
r48 r49 33 33 TDockClientPanel = class(TPanel) 34 34 private 35 FAutoHide: Boolean; 36 FHeaderPos: THeaderPos; 35 37 FShowHeader: Boolean; 38 procedure SetAutoHide(const AValue: Boolean); 39 procedure SetHeaderPos(const AValue: THeaderPos); 36 40 procedure SetShowHeader(const AValue: Boolean); 37 41 public … … 50 54 procedure ResizeExecute(Sender: TObject); 51 55 property ShowHeader: Boolean read FShowHeader write SetShowHeader; 56 property AutoHide: Boolean read FAutoHide write SetAutoHide; 57 property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos; 52 58 end; 53 59 … … 56 62 TCustomDockManager = class(TDockManager) 57 63 private 64 FMoveDuration: Integer; 65 FTabsPos: THeaderPos; 66 Timer1: TTimer; 58 67 PopupMenu1: TPopupMenu; 59 68 FDockStyle: TDockStyle; … … 66 75 DropCtl: TControl); 67 76 procedure SetDockStyle(const AValue: TDockStyle); 77 procedure SetMoveDuration(const AValue: Integer); 78 procedure SetTabsPos(const AValue: THeaderPos); 68 79 procedure UpdateClientSize; 69 80 procedure TabControlChange(Sender: TObject); 70 81 procedure PopupMenuListClick(Sender: TObject); 71 82 procedure PopupMenuTabsClick(Sender: TObject); 83 procedure PopupMenuCloseClick(Sender: TObject); 84 procedure PopupMenuRenameClick(Sender: TObject); 85 procedure Timer1Timer(Sender: TObject); 72 86 public 73 87 constructor Create(ADockSite: TWinControl); override; … … 95 109 function CreateContainer(InsertAt: TAlign): TConjoinDockForm; 96 110 property DockStyle: TDockStyle read FDockStyle write SetDockStyle; 111 property MoveDuration: Integer read FMoveDuration write SetMoveDuration; 112 property TabsPos: THeaderPos read FTabsPos write SetTabsPos; 97 113 end; 98 114 … … 119 135 implementation 120 136 137 resourcestring 138 SDockStyle = 'Style'; 139 SDockList = 'List'; 140 SDockTabs = 'Tabs'; 141 SCloseForm = 'Close'; 142 SRenameForm = 'Rename'; 143 144 121 145 procedure Register; 122 146 begin … … 142 166 var 143 167 NewMenuItem: TMenuItem; 168 NewMenuItem2: TMenuItem; 144 169 begin 145 170 inherited Create(ADockSite); … … 147 172 FDockPanels := TObjectList.Create; 148 173 PopupMenu1 := TPopupMenu.Create(FDockSite); 174 175 Timer1 := TTimer.Create(nil); 176 Timer1.Enabled := False; 177 Timer1.OnTimer := Timer1Timer; 178 149 179 NewMenuItem := TMenuItem.Create(PopupMenu1); 150 NewMenuItem.Caption := 'List';180 NewMenuItem.Caption := SDockStyle; 151 181 PopupMenu1.Items.Add(NewMenuItem); 152 NewMenuItem.OnClick := PopupMenuListClick; 182 183 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 184 NewMenuItem2.Caption := SDockList; 185 NewMenuItem2.OnClick := PopupMenuListClick; 186 NewMenuItem.Add(NewMenuItem2); 187 188 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 189 NewMenuItem2.Caption := SDockTabs; 190 NewMenuItem2.OnClick := PopupMenuTabsClick; 191 NewMenuItem.Add(NewMenuItem2); 192 153 193 NewMenuItem := TMenuItem.Create(PopupMenu1); 154 NewMenuItem.Caption := 'Tabs';155 NewMenuItem.OnClick := PopupMenu TabsClick;194 NewMenuItem.Caption := SCloseForm; 195 NewMenuItem.OnClick := PopupMenuCloseClick; 156 196 PopupMenu1.Items.Add(NewMenuItem); 197 198 NewMenuItem := TMenuItem.Create(PopupMenu1); 199 NewMenuItem.Caption := SRenameForm; 200 NewMenuItem.OnClick := PopupMenuRenameClick; 201 PopupMenu1.Items.Add(NewMenuItem); 202 157 203 TabControl := TTabControl.Create(FDockSite); 158 204 with TabControl do begin … … 164 210 PopupMenu := PopupMenu1; 165 211 end; 212 TabsPos := hpTop; 213 MoveDuration := 1000; // ms 166 214 end; 167 215 168 216 destructor TCustomDockManager.Destroy; 169 217 begin 218 Timer1.Free; 170 219 FDockPanels.Free; 171 220 inherited Destroy; … … 431 480 end; 432 481 482 procedure TCustomDockManager.SetMoveDuration(const AValue: Integer); 483 begin 484 if FMoveDuration=AValue then exit; 485 FMoveDuration := AValue; 486 //Timer1.Interval := AValue; 487 end; 488 489 procedure TCustomDockManager.SetTabsPos(const AValue: THeaderPos); 490 begin 491 if FTabsPos=AValue then exit; 492 FTabsPos := AValue; 493 with TabControl do 494 case AValue of 495 hpAuto, hpTop: begin 496 Align := alTop; 497 TabPosition := tpTop; 498 Height := GrabberSize; 499 end; 500 hpLeft: begin 501 Align := alLeft; 502 TabPosition := tpLeft; 503 Width := GrabberSize; 504 end; 505 hpRight: begin 506 Align := alRight; 507 TabPosition := tpRight; 508 Width := GrabberSize; 509 end; 510 hpBottom: begin 511 Align := alBottom; 512 TabPosition := tpBottom; 513 Height := GrabberSize; 514 end; 515 end; 516 end; 517 433 518 procedure TCustomDockManager.UpdateClientSize; 434 519 var … … 461 546 end; 462 547 if (TabControl.TabIndex <> -1) and (FDockPanels.Count > TabControl.TabIndex) then begin 463 with TDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel do begin 464 Parent := FDockSite; 465 Visible := True; 466 UpdateClientSize; 548 with TDockClientPanel(FDockPanels[TabControl.TabIndex]), ClientAreaPanel do begin 549 if AutoHide then begin 550 Parent := nil; 551 Visible := True; 552 Width := 0; 553 //TimerMoveForm := 554 //TimerIncrement := 1; 555 Timer1.Interval := MoveDuration div 10; 556 Timer1.Enabled := True; 557 end else begin 558 Parent := FDockSite; 559 Visible := True; 560 UpdateClientSize; 561 end; 467 562 end; 468 563 // TDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True; … … 473 568 begin 474 569 DockStyle := dsTabs; 570 end; 571 572 procedure TCustomDockManager.PopupMenuCloseClick(Sender: TObject); 573 begin 574 // TForm(TCustomDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close; 575 end; 576 577 procedure TCustomDockManager.PopupMenuRenameClick(Sender: TObject); 578 begin 579 580 end; 581 582 procedure TCustomDockManager.Timer1Timer(Sender: TObject); 583 begin 584 // TimerMoveForm.Width := TimerMoveForm.Width 475 585 end; 476 586 … … 487 597 FShowHeader := AValue; 488 598 DockPanelPaint(Self); 599 end; 600 601 procedure TDockClientPanel.SetAutoHide(const AValue: Boolean); 602 begin 603 if FAutoHide=AValue then exit; 604 FAutoHide:=AValue; 605 end; 606 607 procedure TDockClientPanel.SetHeaderPos(const AValue: THeaderPos); 608 begin 609 if FHeaderPos=AValue then exit; 610 FHeaderPos:=AValue; 489 611 end; 490 612 … … 527 649 BevelOuter := bvNone; 528 650 ShowHeader := True; 651 AutoHide := False; 652 HeaderPos := hpTop; 529 653 end; 530 654
Note:
See TracChangeset
for help on using the changeset viewer.