Changeset 97 for Docking/CoolDocking/UCoolDockStylePopupTabs.pas
- Timestamp:
- Dec 9, 2010, 2:15:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDockStylePopupTabs.pas
r89 r97 1 unit UCoolDockStylePopupTabs; 2 3 {$mode objfpc}{$H+}1 unit UCoolDockStylePopupTabs; 2 3 {$mode Delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils; 8 Classes, Controls, SysUtils, ComCtrls, ExtCtrls, 9 UCoolDockStyleTabs, UCoolDockStyle; 10 11 type 12 { TCoolDockAutoHide } 13 14 TCoolDockAutoHide = class 15 private 16 FDuration: Real; 17 FStepCount: Integer; 18 StartBounds: TRect; 19 procedure SetDuration(const AValue: Real); 20 procedure SetStepCount(const AValue: Integer); 21 procedure UpdateBounds; 22 procedure UpdateTimerInterval; 23 public 24 Position: Real; 25 Direction: Integer; 26 TabPosition: TTabPosition; 27 Enable: Boolean; 28 Timer: TTimer; 29 Control: TControl; 30 ControlVisible: Boolean; 31 procedure Hide; 32 procedure Show; 33 constructor Create; 34 destructor Destroy; override; 35 procedure TimerExecute(Sender: TObject); 36 property Duration: Real read FDuration write SetDuration; 37 property StepCount: Integer read FStepCount write SetStepCount; 38 end; 39 40 { TCoolDockStylePopupTabs } 41 42 TCoolDockStylePopupTabs = class(TCoolDockStyleTabs) 43 TabControl: TTabControl; 44 TabImageList: TImageList; 45 AutoHide: TCoolDockAutoHide; 46 procedure TabControlMouseLeave(Sender: TObject); 47 procedure TabControlChange(Sender: TObject); 48 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton; 49 Shift: TShiftState; X, Y: Integer); 50 procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton; 51 Shift: TShiftState; X, Y: Integer); 52 constructor Create(AManager: TObject); 53 destructor Destroy; override; 54 end; 55 9 56 10 57 implementation 11 58 59 uses 60 UCoolDocking; 61 62 { TCoolDockAutoHide } 63 64 procedure TCoolDockAutoHide.UpdateBounds; 65 begin 66 case TabPosition of 67 tpBottom: begin 68 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position); 69 Control.Top := StartBounds.Bottom - Control.Height; 70 end; 71 tpTop: begin 72 Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position); 73 end; 74 tpRight: begin 75 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position); 76 end; 77 tpLeft: begin 78 Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position); 79 Control.Left := StartBounds.Right - Control.Width; 80 end; 81 end; 82 end; 83 84 procedure TCoolDockAutoHide.UpdateTimerInterval; 85 begin 86 Timer.Interval := Round(FDuration * 1000 / FStepCount); 87 end; 88 89 procedure TCoolDockAutoHide.SetDuration(const AValue: Real); 90 begin 91 if FDuration = AValue then Exit; 92 FDuration := AValue; 93 UpdateTimerInterval; 94 end; 95 96 procedure TCoolDockAutoHide.SetStepCount(const AValue: Integer); 97 begin 98 if FStepCount = AValue then Exit; 99 FStepCount := AValue; 100 UpdateTimerInterval; 101 end; 102 103 procedure TCoolDockAutoHide.Hide; 104 begin 105 StartBounds := Control.BoundsRect; 106 Direction := -1; 107 Position := 1; 108 Timer.Enabled := True; 109 UpdateBounds; 110 end; 111 112 procedure TCoolDockAutoHide.Show; 113 begin 114 StartBounds := Control.BoundsRect; 115 Control.Align := alCustom; 116 Direction := 1; 117 Position := 0; 118 Timer.Enabled := True; 119 UpdateBounds; 120 end; 121 122 constructor TCoolDockAutoHide.Create; 123 begin 124 Timer := TTimer.Create(nil); 125 Timer.Enabled := False; 126 Timer.OnTimer := TimerExecute; 127 StepCount := 10; 128 Duration := 0.5; 129 end; 130 131 destructor TCoolDockAutoHide.Destroy; 132 begin 133 Timer.Free; 134 inherited Destroy; 135 end; 136 137 procedure TCoolDockAutoHide.TimerExecute(Sender: TObject); 138 begin 139 if Direction = 1 then begin 140 Position := Position + 1 / StepCount; 141 if Position > 1 then begin 142 Position := 1; 143 Timer.Enabled := False; 144 ControlVisible := True; 145 end; 146 end else 147 if Direction = -1 then begin 148 Position := Position - 1 / StepCount; 149 if Position < 1 then begin 150 Position := 0; 151 Timer.Enabled := False; 152 ControlVisible := False; 153 end; 154 end; 155 UpdateBounds; 156 end; 157 158 { TCoolDockStylePopupTabs } 159 160 procedure TCoolDockStylePopupTabs.TabControlMouseLeave(Sender: TObject); 161 begin 162 163 end; 164 165 procedure TCoolDockStylePopupTabs.TabControlChange(Sender: TObject); 166 begin 167 168 end; 169 170 procedure TCoolDockStylePopupTabs.TabControlMouseDown(Sender: TObject; 171 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 172 begin 173 174 end; 175 176 procedure TCoolDockStylePopupTabs.TabControlMouseUp(Sender: TObject; 177 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 178 begin 179 180 end; 181 182 constructor TCoolDockStylePopupTabs.Create(AManager: TObject); 183 begin 184 AutoHide := TCoolDockAutoHide.Create; 185 TabImageList := TImageList.Create(TCoolDockManager(AManager).DockSite); 186 with TabImageList do begin 187 end; 188 TabControl := TTabControl.Create(TCoolDockManager(AManager).DockSite); 189 with TabControl do begin 190 Parent := TCoolDockManager(AManager).DockSite; 191 Visible := False; 192 Align := alTop; 193 Height := 24; 194 OnChange := TabControlChange; 195 PopupMenu := PopupMenuTabs; 196 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave; 197 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown; 198 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp; 199 OnMouseUp := TabControlMouseUp; 200 Images := TabImageList; 201 end; 202 end; 203 204 destructor TCoolDockStylePopupTabs.Destroy; 205 begin 206 AutoHide.Free; 207 inherited Destroy; 208 end; 209 12 210 end. 13 211
Note:
See TracChangeset
for help on using the changeset viewer.