Changeset 89 for Docking/CoolDocking/UCoolDocking.pas
- Timestamp:
- Nov 4, 2010, 7:14:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDocking.pas
r64 r89 15 15 const 16 16 GrabberSize = 22; 17 AutoHideStepCount = 20; 17 18 18 19 type … … 52 53 end; 53 54 55 TCoolDockStyle = class 56 end; 57 54 58 { TCoolDockClientPanel } 55 59 … … 59 63 FHeaderPos: THeaderPos; 60 64 FShowHeader: Boolean; 65 function GetAutoHideEnabled: Boolean; 61 66 procedure SetAutoHide(const AValue: Boolean); 67 procedure SetAutoHideEnabled(const AValue: Boolean); 62 68 procedure SetHeaderPos(const AValue: THeaderPos); 63 69 procedure SetShowHeader(const AValue: Boolean); … … 76 82 procedure ResizeExecute(Sender: TObject); 77 83 property ShowHeader: Boolean read FShowHeader write SetShowHeader; 78 property AutoHide: Boolean read FAutoHide write SetAutoHide; 84 property AutoHideEnabled: Boolean read GetAutoHideEnabled 85 write SetAutoHideEnabled; 79 86 property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos; 87 end; 88 89 { TCoolDockAutoHide } 90 91 TCoolDockAutoHide = class 92 private 93 FDuration: Real; 94 FStepCount: Integer; 95 StartBounds: TRect; 96 procedure SetDuration(const AValue: Real); 97 procedure SetStepCount(const AValue: Integer); 98 procedure UpdateBounds; 99 procedure UpdateTimerInterval; 100 public 101 Position: Real; 102 Direction: Integer; 103 TabPosition: TTabPosition; 104 Enable: Boolean; 105 Timer: TTimer; 106 Control: TControl; 107 ControlVisible: Boolean; 108 procedure Hide; 109 procedure Show; 110 constructor Create; 111 destructor Destroy; override; 112 procedure TimerExecute(Sender: TObject); 113 property Duration: Real read FDuration write SetDuration; 114 property StepCount: Integer read FStepCount write SetStepCount; 80 115 end; 81 116 … … 88 123 MouseDownSkip: Boolean; 89 124 FMaster: TCoolDockMaster; 90 FMoveDuration: Integer;91 125 FTabsPos: THeaderPos; 92 Timer1: TTimer;93 126 PopupMenuTabs: TPopupMenu; 94 127 PopupMenuHeader: TPopupMenu; … … 98 131 FDockDirection: TDockDirection; 99 132 FDockSite: TWinControl; 100 FDockPanels: TObjectList; // of TCoolDockClientPanel 133 FDockPanels: TObjectList; // TObjectList<TCoolDockClientPanel> 134 AutoHide: TCoolDockAutoHide; 101 135 function FindControlInPanels(Control: TControl): TCoolDockClientPanel; 102 136 function GetDockSite: TWinControl; 137 function GetMoveDuration: Integer; 103 138 procedure InsertControlPanel(Control: TControl; InsertAt: TAlign; 104 139 DropCtl: TControl); … … 126 161 procedure PopupMenuUndockClick(Sender: TObject); 127 162 procedure PopupMenuCustomizeClick(Sender: TObject); 128 procedure Timer1Timer(Sender: TObject);129 163 public 130 164 constructor Create(ADockSite: TWinControl); override; … … 154 188 function CreateContainer(InsertAt: TAlign): TCoolDockConjoinForm; 155 189 property DockStyle: TDockStyle read FDockStyle write SetDockStyle; 156 property MoveDuration: Integer read FMoveDuration write SetMoveDuration;190 property MoveDuration: Integer read GetMoveDuration write SetMoveDuration; 157 191 property TabsPos: THeaderPos read FTabsPos write SetTabsPos; 158 192 property Master: TCoolDockMaster read FMaster write SetMaster; … … 166 200 FCoolDockCustomize: TCoolDockCustomize; 167 201 FDefaultHeaderPos: THeaderPos; 202 FDefaultMoveSpeed: Integer; 168 203 FDefaultTabsPos: THeaderPos; 169 204 FShowIcons: Boolean; … … 190 225 property DefaultHeaderPos: THeaderPos read FDefaultHeaderPos 191 226 write FDefaultHeaderPos; 227 property DefaultMoveSpeed: Integer read FDefaultMoveSpeed 228 write FDefaultMoveSpeed; 192 229 property Customize: TCoolDockCustomize read FCoolDockCustomize 193 230 write SetCustomize; … … 250 287 implementation 251 288 289 uses 290 UCoolDockStyleTabs; 291 252 292 resourcestring 253 293 SDockStyle = 'Style'; … … 296 336 end; 297 337 338 function TCoolDockManager.GetMoveDuration: Integer; 339 begin 340 341 end; 342 298 343 procedure TCoolDockManager.TabControlMouseLeave(Sender: TObject); 299 344 begin … … 315 360 FDockPanels := TObjectList.Create; 316 361 317 Timer1 := TTimer.Create(nil); 318 Timer1.Enabled := False; 319 Timer1.OnTimer := Timer1Timer; 362 AutoHide := TCoolDockAutoHide.Create; 320 363 321 364 // Tabs popup … … 476 519 destructor TCoolDockManager.Destroy; 477 520 begin 478 Timer1.Free;479 521 FDockPanels.Free; 480 522 inherited Destroy; … … 716 758 I: Integer; 717 759 begin 718 FDockStyle := AValue; 719 if AValue = dsTabs then begin 720 TabControl.Visible := True; 721 TabControl.Tabs.Clear; 722 TabImageList.Clear; 723 for I := 0 to FDockPanels.Count - 1 do begin 724 TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption); 725 TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil); 726 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 727 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False; 728 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False; 729 TCoolDockClientPanel(FDockPanels[I]).Visible := False; 730 end; 731 TabControlChange(Self); 732 end else 733 if AValue = dsList then begin 734 TabControl.Visible := False; 735 TabControl.Tabs.Clear; 736 for I := 0 to FDockPanels.Count - 1 do begin 737 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 760 if FDockStyle <> AValue then begin 761 FDockStyle := AValue; 762 if AValue = dsTabs then begin 763 TabControl.Visible := True; 764 TabControl.Tabs.Clear; 765 TabImageList.Clear; 766 for I := 0 to FDockPanels.Count - 1 do begin 767 TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption); 768 TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil); 769 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 770 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False; 771 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False; 772 TCoolDockClientPanel(FDockPanels[I]).Visible := False; 773 end; 774 TabControlChange(Self); 775 end else 776 if AValue = dsList then begin 777 TabControl.Visible := False; 778 TabControl.Tabs.Clear; 779 for I := 0 to FDockPanels.Count - 1 do begin 780 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 738 781 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := True; 739 TCoolDockClientPanel(FDockPanels[I]).Visible := True; 740 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := TCoolDockClientPanel(FDockPanels[I]); 741 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := True; 742 TCoolDockClientPanel(FDockPanels[I]).Control.Visible := True; 782 TCoolDockClientPanel(FDockPanels[I]).Visible := True; 783 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := TCoolDockClientPanel(FDockPanels[I]); 784 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := True; 785 TCoolDockClientPanel(FDockPanels[I]).Control.Visible := True; 786 end; 743 787 end; 744 788 end; … … 755 799 procedure TCoolDockManager.SetMoveDuration(const AValue: Integer); 756 800 begin 757 if FMoveDuration=AValue then exit;758 FMoveDuration := AValue;759 //Timer1.Interval := AValue;760 801 end; 761 802 762 803 procedure TCoolDockManager.SetTabsPos(const AValue: THeaderPos); 763 804 begin 764 if FTabsPos =AValue then exit;805 if FTabsPos = AValue then Exit; 765 806 FTabsPos := AValue; 766 807 with TabControl do … … 816 857 I: Integer; 817 858 begin 859 // Hide all clients 818 860 for I := 0 to FDockPanels.Count - 1 do begin 819 861 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False; 862 TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := FDockSite; 863 TCoolDockClientPanel(FDockPanels[I]).Control.Align := alClient; 820 864 TCoolDockClientPanel(FDockPanels[I]).Control.Visible := False; 821 865 end; … … 823 867 with TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]), ClientAreaPanel do begin 824 868 Control.Show; 825 if AutoHide then begin 826 Parent := nil; 869 AutoHide.Enable := True; 870 if AutoHide.Enable then begin 871 //Parent := nil; 827 872 Visible := True; 828 Width := 0;829 //TimerMoveForm :=830 //TimerIncrement := 1;831 Timer1.Interval := MoveDuration div 10;832 Timer1.Enabled := True;873 if AutoHide.ControlVisible then begin 874 AutoHide.Hide; 875 end; 876 AutoHide.Control := Control; 877 AutoHide.Show; 833 878 end else begin 834 879 Parent := FDockSite; … … 912 957 end; 913 958 914 procedure TCoolDockManager.Timer1Timer(Sender: TObject);915 begin916 // TimerMoveForm.Width := TimerMoveForm.Width917 end;918 919 959 procedure TCoolDockManager.TabControlMouseDown(Sender: TObject; Button: TMouseButton; 920 960 Shift: TShiftState; X, Y: Integer); … … 942 982 procedure TCoolDockClientPanel.SetShowHeader(const AValue: Boolean); 943 983 begin 944 if FShowHeader =AValue then exit;984 if FShowHeader = AValue then Exit; 945 985 FShowHeader := AValue; 946 986 DockPanelPaint(Self); … … 963 1003 procedure TCoolDockClientPanel.SetAutoHide(const AValue: Boolean); 964 1004 begin 965 if FAutoHide=AValue then exit; 966 FAutoHide:=AValue; 1005 if FAutoHide = AValue then Exit; 1006 FAutoHide := AValue; 1007 end; 1008 1009 function TCoolDockClientPanel.GetAutoHideEnabled: Boolean; 1010 begin 1011 end; 1012 1013 procedure TCoolDockClientPanel.SetAutoHideEnabled(const AValue: Boolean); 1014 begin 1015 967 1016 end; 968 1017 … … 1005 1054 BevelInner := bvNone; 1006 1055 BevelOuter := bvNone; 1007 AutoHide := False;1056 AutoHideEnabled := True; 1008 1057 HeaderPos := hpTop; 1009 1058 end; … … 1082 1131 procedure TCoolDockMaster.SetTabsEnabled(const AValue: Boolean); 1083 1132 begin 1084 if FTabsEnabled =AValue then exit;1085 FTabsEnabled :=AValue;1133 if FTabsEnabled = AValue then Exit; 1134 FTabsEnabled := AValue; 1086 1135 end; 1087 1136 … … 1343 1392 begin 1344 1393 Form := TCoolDockCustomizeForm.Create(Self); 1394 if Assigned(Master) then begin 1395 Form.SpinEdit1.Value := Master.DefaultMoveSpeed; 1396 Form.ComboBox1.ItemIndex := Integer(Master.DefaultTabsPos); 1397 Form.ComboBox2.ItemIndex := Integer(Master.DefaultHeaderPos); 1398 end; 1345 1399 Form.ShowModal; 1400 if Assigned(Master) then begin 1401 Master.DefaultMoveSpeed := Form.SpinEdit1.Value; 1402 Master.DefaultTabsPos := THeaderPos(Form.ComboBox1.ItemIndex); 1403 Master.DefaultHeaderPos := THeaderPos(Form.ComboBox2.ItemIndex); 1404 end; 1346 1405 Form.Free; 1347 1406 Result := True; … … 1464 1523 end; 1465 1524 1525 { TCoolDockAutoHide } 1526 1527 procedure TCoolDockAutoHide.UpdateBounds; 1528 begin 1529 case TabPosition of 1530 tpBottom: begin 1531 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position); 1532 Control.Top := StartBounds.Bottom - Control.Height; 1533 end; 1534 tpTop: begin 1535 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position); 1536 end; 1537 tpRight: begin 1538 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position); 1539 end; 1540 tpLeft: begin 1541 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position); 1542 Control.Left := StartBounds.Right - Control.Width; 1543 end; 1544 end; 1545 end; 1546 1547 procedure TCoolDockAutoHide.UpdateTimerInterval; 1548 begin 1549 Timer.Interval := Round(FDuration * 1000 / FStepCount); 1550 end; 1551 1552 procedure TCoolDockAutoHide.SetDuration(const AValue: Real); 1553 begin 1554 if FDuration = AValue then Exit; 1555 FDuration := AValue; 1556 UpdateTimerInterval; 1557 end; 1558 1559 procedure TCoolDockAutoHide.SetStepCount(const AValue: Integer); 1560 begin 1561 if FStepCount = AValue then Exit; 1562 FStepCount := AValue; 1563 UpdateTimerInterval; 1564 end; 1565 1566 procedure TCoolDockAutoHide.Hide; 1567 begin 1568 StartBounds := Control.BoundsRect; 1569 Direction := -1; 1570 Position := 1; 1571 Timer.Enabled := True; 1572 UpdateBounds; 1573 end; 1574 1575 procedure TCoolDockAutoHide.Show; 1576 begin 1577 StartBounds := Control.BoundsRect; 1578 Control.Align := alCustom; 1579 Direction := 1; 1580 Position := 0; 1581 Timer.Enabled := True; 1582 UpdateBounds; 1583 end; 1584 1585 constructor TCoolDockAutoHide.Create; 1586 begin 1587 Timer := TTimer.Create(nil); 1588 Timer.Enabled := False; 1589 Timer.OnTimer := TimerExecute; 1590 StepCount := AutoHideStepCount; 1591 Duration := 0.5; 1592 end; 1593 1594 destructor TCoolDockAutoHide.Destroy; 1595 begin 1596 Timer.Free; 1597 inherited Destroy; 1598 end; 1599 1600 procedure TCoolDockAutoHide.TimerExecute(Sender: TObject); 1601 begin 1602 if Direction = 1 then begin 1603 Position := Position + 1 / StepCount; 1604 if Position > 1 then begin 1605 Position := 1; 1606 Timer.Enabled := False; 1607 ControlVisible := True; 1608 end; 1609 end else 1610 if Direction = -1 then begin 1611 Position := Position - 1 / StepCount; 1612 if Position < 1 then begin 1613 Position := 0; 1614 Timer.Enabled := False; 1615 ControlVisible := False; 1616 end; 1617 end; 1618 UpdateBounds; 1619 end; 1620 1466 1621 end. 1467 1622
Note:
See TracChangeset
for help on using the changeset viewer.