Changeset 50 for DockManager/Lazarus/UCustomDockManager.pas
- Timestamp:
- Sep 20, 2010, 8:07:01 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DockManager/Lazarus/UCustomDockManager.pas
r49 r50 19 19 20 20 TCustomDockManager = class; 21 TDockClientPanel = class; 21 22 22 23 { TConjoinDockForm } … … 28 29 29 30 TDockStyle = (dsList, dsTabs); 31 32 { TDockHeader } 33 34 TDockHeader = class(TPanel) 35 CloseButton: TSpeedButton; 36 Title: TLabel; 37 Icon: TIcon; 38 ParentClientPanel: TDockClientPanel; 39 Shape: TShape; 40 constructor Create(TheOwner: TComponent); override; 41 destructor Destroy; override; 42 private 43 procedure CloseButtonClick(Sender: TObject); 44 procedure DrawGrabber(Canvas: TCanvas; AControl: TControl); 45 end; 30 46 31 47 { TDockClientPanel } … … 40 56 procedure SetShowHeader(const AValue: Boolean); 41 57 public 58 Header: TDockHeader; 42 59 OwnerDockManager: TCustomDockManager; 43 CloseButton: TSpeedButton;44 60 Control: TControl; 45 61 Splitter: TSplitter; … … 50 66 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton; 51 67 Shift: TShiftState; X, Y: Integer); 52 procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);53 procedure CloseButtonClick(Sender: TObject);54 68 procedure ResizeExecute(Sender: TObject); 55 69 property ShowHeader: Boolean read FShowHeader write SetShowHeader; … … 83 97 procedure PopupMenuCloseClick(Sender: TObject); 84 98 procedure PopupMenuRenameClick(Sender: TObject); 99 procedure PopupMenuPositionAutoClick(Sender: TObject); 100 procedure PopupMenuPositionLeftClick(Sender: TObject); 101 procedure PopupMenuPositionRightClick(Sender: TObject); 102 procedure PopupMenuPositionTopClick(Sender: TObject); 103 procedure PopupMenuPositionBottomClick(Sender: TObject); 85 104 procedure Timer1Timer(Sender: TObject); 86 105 public 87 106 constructor Create(ADockSite: TWinControl); override; 88 107 destructor Destroy; override; 108 109 // Inherited from TDockManager 89 110 procedure BeginUpdate; override; 90 111 procedure EndUpdate; override; … … 141 162 SCloseForm = 'Close'; 142 163 SRenameForm = 'Rename'; 143 164 SPosition = 'Position'; 165 SPositionAuto = 'Auto'; 166 SPositionTop = 'Top'; 167 SPositionLeft = 'Left'; 168 SPositionRight = 'Right'; 169 SPositionBottom = 'Bottom'; 144 170 145 171 procedure Register; … … 189 215 NewMenuItem2.Caption := SDockTabs; 190 216 NewMenuItem2.OnClick := PopupMenuTabsClick; 217 NewMenuItem.Add(NewMenuItem2); 218 219 NewMenuItem := TMenuItem.Create(PopupMenu1); 220 NewMenuItem.Caption := SPosition; 221 PopupMenu1.Items.Add(NewMenuItem); 222 223 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 224 NewMenuItem2.Caption := SPositionAuto; 225 NewMenuItem2.OnClick := PopupMenuPositionAutoClick; 226 NewMenuItem.Add(NewMenuItem2); 227 228 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 229 NewMenuItem2.Caption := SPositionTop; 230 NewMenuItem2.OnClick := PopupMenuPositionTopClick; 231 NewMenuItem.Add(NewMenuItem2); 232 233 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 234 NewMenuItem2.Caption := SPositionLeft; 235 NewMenuItem2.OnClick := PopupMenuPositionLeftClick; 236 NewMenuItem.Add(NewMenuItem2); 237 238 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 239 NewMenuItem2.Caption := SPositionBottom; 240 NewMenuItem2.OnClick := PopupMenuPositionBottomClick; 241 NewMenuItem.Add(NewMenuItem2); 242 243 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 244 NewMenuItem2.Caption := SPositionRight; 245 NewMenuItem2.OnClick := PopupMenuPositionRightClick; 191 246 NewMenuItem.Add(NewMenuItem2); 192 247 … … 580 635 end; 581 636 637 procedure TCustomDockManager.PopupMenuPositionAutoClick(Sender: TObject); 638 begin 639 TabsPos := hpAuto; 640 end; 641 642 procedure TCustomDockManager.PopupMenuPositionLeftClick(Sender: TObject); 643 begin 644 TabsPos := hpLeft; 645 end; 646 647 procedure TCustomDockManager.PopupMenuPositionRightClick(Sender: TObject); 648 begin 649 TabsPos := hpRight; 650 end; 651 652 procedure TCustomDockManager.PopupMenuPositionTopClick(Sender: TObject); 653 begin 654 TabsPos := hpTop; 655 end; 656 657 procedure TCustomDockManager.PopupMenuPositionBottomClick(Sender: TObject); 658 begin 659 TabsPos := hpBottom; 660 end; 661 582 662 procedure TCustomDockManager.Timer1Timer(Sender: TObject); 583 663 begin … … 614 694 begin 615 695 inherited; 616 CloseButton := TSpeedButton.Create(Self);617 with CloseButtondo begin696 Header := TDockHeader.Create(Self); 697 with Header do begin 618 698 Parent := Self; 619 Caption := 'X'; 620 Font.Size := 6; 621 Width := GrabberSize - 4; 622 Height := GrabberSize - 4; 623 Visible := False; 624 OnClick := CloseButtonClick; 699 Visible := ShowHeader; 700 Align := alTop; 701 Height := GrabberSize; 625 702 end; 626 703 ClientAreaPanel := TPanel.Create(Self); … … 630 707 DockSite := True; 631 708 UseDockManager := True; 632 Left := 0; 633 Top := GrabberSize; 634 Width := Self.Width; 635 Height := Self.Height - GrabberSize; 636 Anchors := [akTop, akBottom, akLeft, akRight]; 709 Align := alClient; 637 710 BevelInner := bvNone; 638 711 BevelOuter := bvNone; … … 658 731 end; 659 732 660 procedure TDockClientPanel.DrawGrabber(Canvas: TCanvas; AControl: TControl);661 begin662 with Canvas do begin663 Brush.Color := clBtnFace;664 Pen.Color := clBlack;665 FillRect(0, 0, AControl.Width, GrabberSize);666 667 if (AControl as TWinControl).Focused then668 Font.Style := Font.Style + [fsBold]669 else Font.Style := Font.Style - [fsBold];670 Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1);671 TextOut(6, 4, AControl.Caption);672 673 CloseButton.Left := AControl.Width - CloseButton.Width - 2;674 CloseButton.Top := 2;675 end;676 end;677 678 procedure TDockClientPanel.CloseButtonClick(Sender: TObject);679 begin680 Control.Hide;681 end;682 683 733 procedure TDockClientPanel.ResizeExecute(Sender: TObject); 684 734 begin … … 699 749 R := Control.ClientRect; 700 750 Canvas.FillRect(R); 701 CloseButton.Visible := ShowHeader;751 Header.Visible := ShowHeader; 702 752 if ShowHeader then begin 703 753 if ClientAreaPanel.DockClientCount = 0 then 704 DrawGrabber(Canvas, Control) else705 DrawGrabber(Canvas, ClientAreaPanel);754 Header.DrawGrabber(Canvas, Control) else 755 Header.DrawGrabber(Canvas, ClientAreaPanel); 706 756 end; 707 757 end; … … 731 781 UseDockManager := True; 732 782 Align := alClient; 783 BevelOuter := bvNone; 784 BevelInner := bvNone; 733 785 // Color := clYellow; 734 786 end; … … 781 833 end; 782 834 835 { TDockHeader } 836 837 constructor TDockHeader.Create(TheOwner: TComponent); 838 begin 839 inherited Create(TheOwner); 840 Shape := TShape.Create(Self); 841 with Shape do begin 842 Parent := Self; 843 Anchors := [akRight, akBottom, akLeft, akTop]; 844 Left := 1; 845 Top := 1; 846 Width := Self.Width - 2; 847 Height := Self.Height - 2; 848 Brush.Style := bsClear; 849 end; 850 CloseButton := TSpeedButton.Create(Self); 851 with CloseButton do begin 852 Parent := Self; 853 Caption := 'X'; 854 Font.Size := 6; 855 Width := GrabberSize - 8; 856 Height := GrabberSize - 8; 857 Anchors := [akRight, akTop]; 858 Left := Self.Width - Width - 4; 859 Top := 4; 860 Visible := True; 861 OnClick := CloseButtonClick; 862 end; 863 Title := TLabel.Create(Self); 864 with Title do begin 865 Parent := Self; 866 Visible := True; 867 Top := 4; 868 Left := 6; 869 BevelInner := bvNone; 870 BevelOuter := bvNone; 871 end; 872 end; 873 874 destructor TDockHeader.Destroy; 875 begin 876 inherited Destroy; 877 end; 878 879 procedure TDockHeader.DrawGrabber(Canvas: TCanvas; AControl: TControl); 880 begin 881 with Canvas do begin 882 Brush.Color := clBtnFace; 883 Pen.Color := clBlack; 884 //FillRect(0, 0, AControl.Width, GrabberSize); 885 886 if (AControl as TWinControl).Focused then 887 Title.Font.Style := Font.Style + [fsBold] 888 else Title.Font.Style := Font.Style - [fsBold]; 889 Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1); 890 Title.Caption := AControl.Caption; 891 end; 892 end; 893 894 procedure TDockHeader.CloseButtonClick(Sender: TObject); 895 begin 896 // Control.Hide; 897 end; 898 783 899 initialization 784 900 DefaultDockManagerClass := TCustomDockManager;
Note:
See TracChangeset
for help on using the changeset viewer.