Changeset 97 for Docking/CoolDocking/UCoolDocking.pas
- Timestamp:
- Dec 9, 2010, 2:15:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDocking.pas
r96 r97 11 11 Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil, 12 12 UCoolDockCustomize, DOM, XMLWrite, XMLRead, UCoolDockWindowList, 13 DateUtils; 13 DateUtils, UCoolDockStyleTabs, UCoolDockStyleRegions, UCoolDockStylePopupTabs, 14 UCoolDockStylePopupRegions, UCoolDockStyle, UCoolDockClientPanel; 14 15 15 16 const 16 17 GrabberSize = 22; 17 AutoHideStepCount = 20;18 18 19 19 type 20 20 TDockDirection = (ddNone, ddHorizontal, ddVertical); 21 THeaderPos = (hpAuto, hpLeft, hpTop, hpRight, hpBottom);22 21 23 22 TCoolDockManager = class; 24 TCoolDockClientPanel = class;25 23 TCoolDockCustomize = class; 26 24 TCoolDockClient = class; … … 36 34 end; 37 35 38 TDockStyle = (dsList, dsTabs); 39 40 { TCoolDockHeader } 41 42 TCoolDockHeader = class(TPanel) 43 private 44 procedure CloseButtonClick(Sender: TObject); 45 procedure DrawGrabber(Canvas: TCanvas; AControl: TControl); 46 public 47 CloseButton: TSpeedButton; 48 Title: TLabel; 49 Icon: TImage; 50 ParentClientPanel: TCoolDockClientPanel; 51 Shape: TShape; 52 constructor Create(TheOwner: TComponent); override; 53 destructor Destroy; override; 54 end; 55 56 TCoolDockStyle = class 57 end; 58 59 { TCoolDockClientPanel } 60 61 TCoolDockClientPanel = class(TPanel) 62 private 63 FAutoHide: Boolean; 64 FHeaderPos: THeaderPos; 65 FShowHeader: Boolean; 66 function GetAutoHideEnabled: Boolean; 67 procedure SetAutoHide(const AValue: Boolean); 68 procedure SetAutoHideEnabled(const AValue: Boolean); 69 procedure SetHeaderPos(const AValue: THeaderPos); 70 procedure SetShowHeader(const AValue: Boolean); 71 procedure VisibleChange(Sender: TObject); 72 public 73 Header: TCoolDockHeader; 74 OwnerDockManager: TCoolDockManager; 75 Control: TControl; 76 Splitter: TSplitter; 77 ClientAreaPanel: TPanel; 78 constructor Create(TheOwner: TComponent); override; 79 destructor Destroy; override; 80 procedure DockPanelPaint(Sender: TObject); 81 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton; 82 Shift: TShiftState; X, Y: Integer); 83 procedure ResizeExecute(Sender: TObject); 84 property ShowHeader: Boolean read FShowHeader write SetShowHeader; 85 property AutoHideEnabled: Boolean read GetAutoHideEnabled 86 write SetAutoHideEnabled; 87 property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos; 88 end; 89 90 { TCoolDockAutoHide } 91 92 TCoolDockAutoHide = class 93 private 94 FDuration: Real; 95 FStepCount: Integer; 96 StartBounds: TRect; 97 procedure SetDuration(const AValue: Real); 98 procedure SetStepCount(const AValue: Integer); 99 procedure UpdateBounds; 100 procedure UpdateTimerInterval; 101 public 102 Position: Real; 103 Direction: Integer; 104 TabPosition: TTabPosition; 105 Enable: Boolean; 106 Timer: TTimer; 107 Control: TControl; 108 ControlVisible: Boolean; 109 procedure Hide; 110 procedure Show; 111 constructor Create; 112 destructor Destroy; override; 113 procedure TimerExecute(Sender: TObject); 114 property Duration: Real read FDuration write SetDuration; 115 property StepCount: Integer read FStepCount write SetStepCount; 116 end; 36 TDockStyle = (dsList, dsTabs, dsPopupTabs, dsPopupList); 117 37 118 38 { TCoolDockManager } … … 120 40 TCoolDockManager = class(TDockManager) 121 41 private 122 MouseDown: Boolean;123 MouseButton: TMouseButton;124 MouseDownSkip: Boolean;125 42 FMaster: TCoolDockMaster; 126 FTabsPos: THeaderPos; 127 PopupMenuTabs: TPopupMenu; 43 DockStyleHandler: TCoolDockStyle; 128 44 PopupMenuHeader: TPopupMenu; 129 45 FDockStyle: TDockStyle; 130 TabControl: TTabControl;131 TabImageList: TImageList;132 46 FDockDirection: TDockDirection; 133 47 FDockSite: TWinControl; 134 48 FDockPanels: TObjectList; // TObjectList<TCoolDockClientPanel> 135 AutoHide: TCoolDockAutoHide;136 49 function FindControlInPanels(Control: TControl): TCoolDockClientPanel; 137 50 function GetDockSite: TWinControl; … … 139 52 procedure InsertControlPanel(Control: TControl; InsertAt: TAlign; 140 53 DropCtl: TControl); 141 procedure PopupMenuTabCloseClick(Sender: TObject);142 54 procedure SetDockStyle(const AValue: TDockStyle); 143 55 procedure SetMaster(const AValue: TCoolDockMaster); 144 56 procedure SetMoveDuration(const AValue: Integer); 145 procedure SetTabsPos(const AValue: THeaderPos);146 procedure TabControlMouseLeave(Sender: TObject);147 procedure TabControlChange(Sender: TObject);148 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;149 Shift: TShiftState; X, Y: Integer);150 procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton;151 Shift: TShiftState; X, Y: Integer);152 57 procedure UpdateClientSize; 153 58 procedure PopupMenuListClick(Sender: TObject); … … 188 93 189 94 function CreateContainer(InsertAt: TAlign): TCoolDockConjoinForm; 95 property DockPanels: TObjectList read FDockPanels write FDockPanels; 190 96 property DockStyle: TDockStyle read FDockStyle write SetDockStyle; 191 97 property MoveDuration: Integer read GetMoveDuration write SetMoveDuration; 192 property TabsPos: THeaderPos read FTabsPos write SetTabsPos;193 98 property Master: TCoolDockMaster read FMaster write SetMaster; 194 99 property DockSite: TWinControl read GetDockSite; … … 286 191 procedure Register; 287 192 288 implementation289 290 uses291 UCoolDockStyleTabs;292 293 193 resourcestring 294 194 SDockStyle = 'Style'; … … 309 209 SRenameWindow = 'Rename window'; 310 210 211 212 implementation 213 311 214 procedure Register; 312 215 begin … … 342 245 end; 343 246 344 procedure TCoolDockManager.TabControlMouseLeave(Sender: TObject);345 begin346 if MouseDown then347 if (TabControl.TabIndex <> -1) then begin348 TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel.DockSite := False;349 DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1);350 end;351 MouseDown := False;352 end;353 354 247 constructor TCoolDockManager.Create(ADockSite: TWinControl); 355 248 var … … 361 254 FDockPanels := TObjectList.Create; 362 255 363 AutoHide := TCoolDockAutoHide.Create; 364 365 // Tabs popup 256 FDockStyle := dsTabs; // To initialize style value have to be different 257 DockStyle := dsList; 258 259 (* // Tabs popup 366 260 367 261 PopupMenuTabs := TPopupMenu.Create(FDockSite); … … 498 392 NewMenuItem.OnClick := PopupMenuCustomizeClick; 499 393 PopupMenuHeader.Items.Add(NewMenuItem); 500 501 TabImageList := TImageList.Create(FDockSite); 502 with TabImageList do begin 503 Name := ADockSite.Name + '_' + 'ImageList'; 504 end; 505 TabControl := TTabControl.Create(FDockSite); 506 with TabControl do begin 507 Parent := FDockSite; 508 Name := ADockSite.Name + '_' + 'TabControl'; 509 Visible := False; 510 Align := alTop; 511 Height := 24; 512 OnChange := TabControlChange; 513 PopupMenu := PopupMenuTabs; 514 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave; 515 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown; 516 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp; 517 OnMouseUp := TabControlMouseUp; 518 Images := TabImageList; 519 end; 520 TabsPos := hpTop; 521 MoveDuration := 1000; // ms 394 *) 522 395 end; 523 396 … … 601 474 NewPanel.Header.Icon.Picture.Assign((Control as TForm).Icon); 602 475 603 if DockStyle = dsTabs then begin 604 TabControl.Tabs.Add(Control.Caption); 605 TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil); 606 if Assigned(NewPanel.Splitter) then 607 NewPanel.Splitter.Visible := False; 608 NewPanel.ClientAreaPanel.Visible := False; 609 NewPanel.Visible := False; 610 TabControlChange(Self); 611 end; 476 DockStyleHandler.InsertControl(NewPanel, Control, InsertAt); 477 612 478 NewPanel.Control := Control; 613 479 Control.AddHandlerOnVisibleChanged(NewPanel.VisibleChange); … … 765 631 if FDockStyle <> AValue then begin 766 632 FDockStyle := AValue; 633 DockStyleHandler.Free; 767 634 if AValue = dsTabs then begin 768 TabControl.Visible := True; 769 TabControl.Tabs.Clear; 770 TabImageList.Clear; 771 for I := 0 to FDockPanels.Count - 1 do begin 772 TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption); 773 TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil); 774 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 775 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False; 776 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False; 777 TCoolDockClientPanel(FDockPanels[I]).Visible := False; 778 end; 779 TabControlChange(Self); 635 DockStyleHandler := TCoolDockStyleTabs.Create(Self); 780 636 end else 781 637 if AValue = dsList then begin 782 TabControl.Visible := False; 783 TabControl.Tabs.Clear; 784 for I := 0 to FDockPanels.Count - 1 do begin 785 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 786 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := True; 787 TCoolDockClientPanel(FDockPanels[I]).Visible := True; 788 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := TCoolDockClientPanel(FDockPanels[I]); 789 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := True; 790 TCoolDockClientPanel(FDockPanels[I]).Control.Visible := True; 791 end; 638 DockStyleHandler := TCoolDockStyleRegions.Create(Self); 639 end else 640 if AValue = dsPopupList then begin 641 DockStyleHandler := TCoolDockStylePopupRegions.Create(Self); 642 end else 643 if AValue = dsPopupTabs then begin 644 DockStyleHandler := TCoolDockStylePopupTabs.Create(Self); 792 645 end; 793 646 end; … … 799 652 if FMaster = AValue then Exit; 800 653 FMaster := AValue; 801 TabsPos := AValue.DefaultTabsPos;802 654 end; 803 655 … … 806 658 end; 807 659 808 procedure TCoolDockManager.SetTabsPos(const AValue: THeaderPos);809 begin810 if FTabsPos = AValue then Exit;811 FTabsPos := AValue;812 with TabControl do813 case AValue of814 hpAuto, hpTop: begin815 Align := alTop;816 TabPosition := tpTop;817 Height := GrabberSize;818 end;819 hpLeft: begin820 Align := alLeft;821 TabPosition := tpLeft;822 Width := GrabberSize;823 end;824 hpRight: begin825 Align := alRight;826 TabPosition := tpRight;827 Width := GrabberSize;828 end;829 hpBottom: begin830 Align := alBottom;831 TabPosition := tpBottom;832 Height := GrabberSize;833 end;834 end;835 end;836 837 660 procedure TCoolDockManager.UpdateClientSize; 838 var 839 I: Integer; 840 begin 841 if DockStyle = dsList then begin 842 for I := 0 to FDockPanels.Count - 1 do begin 843 TCoolDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div 844 FDockSite.DockClientCount; 845 TCoolDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div 846 FDockSite.DockClientCount; 847 //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 848 TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 849 end; 850 end else 851 if DockStyle = dsTabs then begin 852 for I := 0 to FDockPanels.Count - 1 do begin 853 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Width := FDockSite.Width; 854 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Height := FDockSite.Height - TabControl.Height; 855 //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 856 end; 857 end; 858 end; 859 860 procedure TCoolDockManager.TabControlChange(Sender: TObject); 861 var 862 I: Integer; 863 begin 864 // Hide all clients 865 for I := 0 to FDockPanels.Count - 1 do begin 866 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False; 867 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := FDockSite; 868 TCoolDockClientPanel(FDockPanels[I]).Control.Align := alClient; 869 TCoolDockClientPanel(FDockPanels[I]).Control.Visible := False; 870 871 // Workaround for "Cannot focus" error 872 TForm(TCoolDockClientPanel(FDockPanels[I]).Control).ActiveControl := nil; 873 end; 874 if (TabControl.TabIndex <> -1) and (FDockPanels.Count > TabControl.TabIndex) then begin 875 with TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]), ClientAreaPanel do begin 876 Control.Show; 877 AutoHide.Enable := True; 878 if AutoHide.Enable then begin 879 //Parent := nil; 880 Visible := True; 881 if AutoHide.ControlVisible then begin 882 AutoHide.Hide; 883 end; 884 AutoHide.Control := Control; 885 AutoHide.Show; 886 end else begin 887 Parent := FDockSite; 888 Visible := True; 889 UpdateClientSize; 890 end; 891 end; 892 //TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True; 893 end; 894 MouseDownSkip := True; 661 begin 662 DockStyleHandler.UpdateClientSize; 895 663 end; 896 664 … … 910 678 end; 911 679 912 procedure TCoolDockManager.PopupMenuTabCloseClick(Sender: TObject);913 begin914 if TabControl.TabIndex <> -1 then915 TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control.Hide;916 end;917 918 680 procedure TCoolDockManager.PopupMenuRenameClick(Sender: TObject); 919 681 var … … 927 689 procedure TCoolDockManager.PopupMenuPositionAutoClick(Sender: TObject); 928 690 begin 929 TabsPos := hpAuto;691 //TabsPos := hpAuto; 930 692 end; 931 693 932 694 procedure TCoolDockManager.PopupMenuPositionLeftClick(Sender: TObject); 933 695 begin 934 TabsPos := hpLeft;696 //TabsPos := hpLeft; 935 697 end; 936 698 937 699 procedure TCoolDockManager.PopupMenuPositionRightClick(Sender: TObject); 938 700 begin 939 TabsPos := hpRight;701 //TabsPos := hpRight; 940 702 end; 941 703 942 704 procedure TCoolDockManager.PopupMenuPositionTopClick(Sender: TObject); 943 705 begin 944 TabsPos := hpTop;706 //TabsPos := hpTop; 945 707 end; 946 708 947 709 procedure TCoolDockManager.PopupMenuPositionBottomClick(Sender: TObject); 948 710 begin 949 TabsPos := hpBottom;711 //TabsPos := hpBottom; 950 712 end; 951 713 … … 965 727 end; 966 728 967 procedure TCoolDockManager.TabControlMouseDown(Sender: TObject; Button: TMouseButton;968 Shift: TShiftState; X, Y: Integer);969 begin970 if not MouseDownSkip then begin971 MouseDown := True;972 MouseButton := Button;973 end;974 MouseDownSkip := False;975 end;976 977 procedure TCoolDockManager.TabControlMouseUp(Sender: TObject;978 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);979 begin980 MouseDown := False;981 end;982 983 729 procedure TCoolDockManager.PopupMenuListClick(Sender: TObject); 984 730 begin … … 986 732 end; 987 733 988 { TCoolDockClientPanel }989 990 procedure TCoolDockClientPanel.SetShowHeader(const AValue: Boolean);991 begin992 if FShowHeader = AValue then Exit;993 FShowHeader := AValue;994 DockPanelPaint(Self);995 end;996 997 procedure TCoolDockClientPanel.VisibleChange(Sender: TObject);998 var999 Visible: Boolean;1000 begin1001 (*if Assigned(Control) then begin1002 Visible := Control.Visible;1003 if Assigned(ClientAreaPanel) then1004 ClientAreaPanel.Visible := Visible;1005 if Assigned(Splitter) then1006 Splitter.Visible := Visible;1007 OwnerDockManager.UpdateClientSize;1008 end;*)1009 end;1010 1011 procedure TCoolDockClientPanel.SetAutoHide(const AValue: Boolean);1012 begin1013 if FAutoHide = AValue then Exit;1014 FAutoHide := AValue;1015 end;1016 1017 function TCoolDockClientPanel.GetAutoHideEnabled: Boolean;1018 begin1019 end;1020 1021 procedure TCoolDockClientPanel.SetAutoHideEnabled(const AValue: Boolean);1022 begin1023 1024 end;1025 1026 procedure TCoolDockClientPanel.SetHeaderPos(const AValue: THeaderPos);1027 begin1028 if FHeaderPos=AValue then exit;1029 FHeaderPos:=AValue;1030 end;1031 1032 constructor TCoolDockClientPanel.Create(TheOwner: TComponent);1033 begin1034 inherited;1035 ShowHeader := True;1036 Header := TCoolDockHeader.Create(Self);1037 with Header do begin1038 Parent := Self;1039 Visible := ShowHeader;1040 Align := alTop;1041 Height := GrabberSize;1042 ParentClientPanel := Self;1043 end;1044 ClientAreaPanel := TPanel.Create(Self);1045 with ClientAreaPanel do begin1046 Parent := Self;1047 Visible := True;1048 DockSite := True;1049 UseDockManager := True;1050 Align := alClient;1051 BevelInner := bvNone;1052 BevelOuter := bvNone;1053 //Color := clGreen;1054 end;1055 Splitter := TSplitter.Create(Self);1056 with Splitter do begin1057 //Color := clRed;1058 end;1059 OnPaint := DockPanelPaint;1060 Header.Shape.OnMouseDown := DockPanelMouseDown;1061 OnResize := ResizeExecute;1062 BevelInner := bvNone;1063 BevelOuter := bvNone;1064 AutoHideEnabled := True;1065 HeaderPos := hpTop;1066 end;1067 1068 destructor TCoolDockClientPanel.Destroy;1069 begin1070 inherited Destroy;1071 end;1072 1073 procedure TCoolDockClientPanel.ResizeExecute(Sender: TObject);1074 begin1075 Control.Top := GrabberSize;1076 Control.Left := 0;1077 Control.Width := Width;1078 Control.Height := Height - GrabberSize;1079 //Control.SetBounds(0, GrabberSize, Width - Control.Left,1080 // Height - Control.Top);1081 end;1082 1083 procedure TCoolDockClientPanel.DockPanelPaint(Sender: TObject);1084 var1085 I: Integer;1086 R: TRect;1087 begin1088 if not (csDesigning in ComponentState) then1089 if Assigned(Control) then begin1090 R := Control.ClientRect;1091 Canvas.FillRect(R);1092 Header.Visible := ShowHeader;1093 if ShowHeader then begin1094 if ClientAreaPanel.DockClientCount = 0 then1095 Header.DrawGrabber(Canvas, Control) else1096 Header.DrawGrabber(Canvas, ClientAreaPanel);1097 end;1098 end;1099 end;1100 1101 procedure TCoolDockClientPanel.DockPanelMouseDown(Sender: TObject;1102 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);1103 begin1104 if Control is TForm then begin1105 //TForm(Control).SetFocus;1106 DockPanelPaint(Self);1107 end;1108 if (Button = mbLeft) then begin1109 //(Control as TWinControl).DockSite := False;1110 ClientAreaPanel.DockSite := False;1111 (Control as TWinControl).BeginDrag(False, 10);1112 //DragManager.DragStart(Control, False, 1);1113 end;1114 end;1115 734 1116 735 { TCoolDockConjoinForm } … … 1314 933 FClients.Remove(Client); 1315 934 end; 1316 end;1317 1318 { TCoolDockHeader }1319 1320 constructor TCoolDockHeader.Create(TheOwner: TComponent);1321 begin1322 inherited Create(TheOwner);1323 Shape := TShape.Create(Self);1324 with Shape do begin1325 Parent := Self;1326 Anchors := [akRight, akBottom, akLeft, akTop];1327 Left := 1;1328 Top := 1;1329 Width := Self.Width - 2;1330 Height := Self.Height - 2;1331 Brush.Style := bsClear;1332 end;1333 CloseButton := TSpeedButton.Create(Self);1334 with CloseButton do begin1335 Parent := Self;1336 Caption := 'X';1337 Font.Size := 6;1338 Width := GrabberSize - 8;1339 Height := GrabberSize - 8;1340 Anchors := [akRight, akTop];1341 Left := Self.Width - Width - 4;1342 Top := 4;1343 Visible := True;1344 OnClick := CloseButtonClick;1345 end;1346 Title := TLabel.Create(Self);1347 with Title do begin1348 Parent := Self;1349 Visible := True;1350 Top := 4;1351 Left := 6;1352 BevelInner := bvNone;1353 BevelOuter := bvNone;1354 end;1355 Icon := TImage.Create(Self);1356 with Icon do begin1357 Parent := Self;1358 Left := 4;1359 Top := 2;1360 Visible := True;1361 end;1362 end;1363 1364 destructor TCoolDockHeader.Destroy;1365 begin1366 inherited Destroy;1367 end;1368 1369 procedure TCoolDockHeader.DrawGrabber(Canvas: TCanvas; AControl: TControl);1370 begin1371 with Canvas do begin1372 Brush.Color := clBtnFace;1373 Pen.Color := clBlack;1374 //FillRect(0, 0, AControl.Width, GrabberSize);1375 1376 if (AControl as TWinControl).Focused then1377 Title.Font.Style := Font.Style + [fsBold]1378 else Title.Font.Style := Font.Style - [fsBold];1379 Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1);1380 if Icon.Picture.Width > 0 then Title.Left := 8 + Icon.Picture.Width1381 else Title.Left := 6;1382 Title.Caption := AControl.Caption;1383 end;1384 end;1385 1386 procedure TCoolDockHeader.CloseButtonClick(Sender: TObject);1387 begin1388 ParentClientPanel.Control.Hide;1389 935 end; 1390 936 … … 1539 1085 end; 1540 1086 1541 { TCoolDockAutoHide }1542 1543 procedure TCoolDockAutoHide.UpdateBounds;1544 begin1545 case TabPosition of1546 tpBottom: begin1547 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);1548 Control.Top := StartBounds.Bottom - Control.Height;1549 end;1550 tpTop: begin1551 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);1552 end;1553 tpRight: begin1554 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);1555 end;1556 tpLeft: begin1557 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);1558 Control.Left := StartBounds.Right - Control.Width;1559 end;1560 end;1561 end;1562 1563 procedure TCoolDockAutoHide.UpdateTimerInterval;1564 begin1565 Timer.Interval := Round(FDuration * 1000 / FStepCount);1566 end;1567 1568 procedure TCoolDockAutoHide.SetDuration(const AValue: Real);1569 begin1570 if FDuration = AValue then Exit;1571 FDuration := AValue;1572 UpdateTimerInterval;1573 end;1574 1575 procedure TCoolDockAutoHide.SetStepCount(const AValue: Integer);1576 begin1577 if FStepCount = AValue then Exit;1578 FStepCount := AValue;1579 UpdateTimerInterval;1580 end;1581 1582 procedure TCoolDockAutoHide.Hide;1583 begin1584 StartBounds := Control.BoundsRect;1585 Direction := -1;1586 Position := 1;1587 Timer.Enabled := True;1588 UpdateBounds;1589 end;1590 1591 procedure TCoolDockAutoHide.Show;1592 begin1593 StartBounds := Control.BoundsRect;1594 Control.Align := alCustom;1595 Direction := 1;1596 Position := 0;1597 Timer.Enabled := True;1598 UpdateBounds;1599 end;1600 1601 constructor TCoolDockAutoHide.Create;1602 begin1603 Timer := TTimer.Create(nil);1604 Timer.Enabled := False;1605 Timer.OnTimer := TimerExecute;1606 StepCount := AutoHideStepCount;1607 Duration := 0.5;1608 end;1609 1610 destructor TCoolDockAutoHide.Destroy;1611 begin1612 Timer.Free;1613 inherited Destroy;1614 end;1615 1616 procedure TCoolDockAutoHide.TimerExecute(Sender: TObject);1617 begin1618 if Direction = 1 then begin1619 Position := Position + 1 / StepCount;1620 if Position > 1 then begin1621 Position := 1;1622 Timer.Enabled := False;1623 ControlVisible := True;1624 end;1625 end else1626 if Direction = -1 then begin1627 Position := Position - 1 / StepCount;1628 if Position < 1 then begin1629 Position := 0;1630 Timer.Enabled := False;1631 ControlVisible := False;1632 end;1633 end;1634 UpdateBounds;1635 end;1636 1087 1637 1088 end.
Note:
See TracChangeset
for help on using the changeset viewer.