Changeset 97 for Docking/CoolDocking/UCoolDockStyleTabs.pas
- Timestamp:
- Dec 9, 2010, 2:15:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDockStyleTabs.pas
r89 r97 1 1 unit UCoolDockStyleTabs; 2 2 3 {$mode objfpc}{$H+}3 {$mode Delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, UCoolDocking; 8 Classes, Controls, ExtCtrls, ComCtrls, SysUtils, 9 Menus, UCoolDockStyle, Forms, UCoolDockClientPanel; 9 10 10 11 type 12 13 { TCoolDockStyleTabs } 14 11 15 TCoolDockStyleTabs = class(TCoolDockStyle) 12 16 MouseDown: Boolean; 17 MouseButton: TMouseButton; 18 MouseDownSkip: Boolean; 19 TabControl: TTabControl; 20 TabImageList: TImageList; 21 PopupMenuTabs: TPopupMenu; 22 procedure TabControlMouseLeave(Sender: TObject); 23 procedure TabControlChange(Sender: TObject); 24 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton; 25 Shift: TShiftState; X, Y: Integer); 26 procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton; 27 Shift: TShiftState; X, Y: Integer); 28 constructor Create(AManager: TObject); 29 destructor Destroy; override; 30 procedure InsertControl(NewPanel: TCoolDockClientPanel; 31 AControl: TControl; InsertAt: TAlign); override; 32 procedure UpdateClientSize; override; 33 private 34 FTabsPos: THeaderPos; 35 public 36 procedure SetTabsPos(const AValue: THeaderPos); 37 procedure PopupMenuTabCloseClick(Sender: TObject); 38 property TabsPos: THeaderPos read FTabsPos write SetTabsPos; 13 39 end; 14 40 15 41 implementation 16 42 43 uses 44 UCoolDocking; 45 46 { TCoolDockStyleTabs } 47 48 procedure TCoolDockStyleTabs.PopupMenuTabCloseClick(Sender: TObject); 49 begin 50 if TabControl.TabIndex <> -1 then 51 TCoolDockClientPanel(TCoolDockManager(Manager).DockPanels[TabControl.TabIndex]).Control.Hide; 52 end; 53 54 procedure TCoolDockStyleTabs.TabControlMouseLeave(Sender: TObject); 55 begin 56 (* if MouseDown then 57 if (TabControl.TabIndex <> -1) then begin 58 TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel.DockSite := False; 59 DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1); 60 end; 61 MouseDown := False; 62 *) 63 end; 64 65 procedure TCoolDockStyleTabs.TabControlChange(Sender: TObject); 66 var 67 I: Integer; 68 begin 69 // Hide all clients 70 with TCoolDockManager(Manager) do 71 for I := 0 to DockPanels.Count - 1 do begin 72 TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Visible := False; 73 TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite; 74 TCoolDockClientPanel(DockPanels[I]).Control.Align := alClient; 75 TCoolDockClientPanel(DockPanels[I]).Control.Visible := False; 76 77 // Workaround for "Cannot focus" error 78 TForm(TCoolDockClientPanel(DockPanels[I]).Control).ActiveControl := nil; 79 end; 80 with TCoolDockManager(Manager) do 81 if (TabControl.TabIndex <> -1) and (DockPanels.Count > TabControl.TabIndex) then begin 82 with TCoolDockClientPanel(DockPanels[TabControl.TabIndex]), ClientAreaPanel do begin 83 Control.Show; 84 (*AutoHide.Enable := True; 85 if AutoHide.Enable then begin 86 //Parent := nil; 87 Visible := True; 88 if AutoHide.ControlVisible then begin 89 AutoHide.Hide; 90 end; 91 AutoHide.Control := Control; 92 AutoHide.Show; 93 end else begin 94 *) 95 //Parent := DockSite; 96 Visible := True; 97 UpdateClientSize; 98 // end; 99 end; 100 //TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True; 101 end; 102 MouseDownSkip := True; 103 end; 104 105 procedure TCoolDockStyleTabs.TabControlMouseDown(Sender: TObject; 106 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 107 begin 108 if not MouseDownSkip then begin 109 MouseDown := True; 110 MouseButton := Button; 111 end; 112 MouseDownSkip := False; 113 end; 114 115 procedure TCoolDockStyleTabs.TabControlMouseUp(Sender: TObject; 116 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 117 begin 118 MouseDown := False; 119 end; 120 121 constructor TCoolDockStyleTabs.Create(AManager: TObject); 122 var 123 NewMenuItem: TMenuItem; 124 NewMenuItem2: TMenuItem; 125 I: Integer; 126 begin 127 inherited; 128 129 (*// Tabs popup 130 131 PopupMenuTabs := TPopupMenu.Create(Manager.DockSite); 132 133 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 134 NewMenuItem.Caption := SDockStyle; 135 PopupMenuTabs.Items.Add(NewMenuItem); 136 137 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 138 NewMenuItem2.Caption := SDockList; 139 NewMenuItem2.OnClick := PopupMenuListClick; 140 NewMenuItem.Add(NewMenuItem2); 141 142 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 143 NewMenuItem2.Caption := SDockTabs; 144 NewMenuItem2.OnClick := PopupMenuTabsClick; 145 NewMenuItem.Add(NewMenuItem2); 146 147 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 148 NewMenuItem.Caption := SPosition; 149 PopupMenuTabs.Items.Add(NewMenuItem); 150 151 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 152 NewMenuItem2.Caption := SPositionAuto; 153 NewMenuItem2.OnClick := PopupMenuPositionAutoClick; 154 NewMenuItem.Add(NewMenuItem2); 155 156 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 157 NewMenuItem2.Caption := SPositionTop; 158 NewMenuItem2.OnClick := PopupMenuPositionTopClick; 159 NewMenuItem.Add(NewMenuItem2); 160 161 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 162 NewMenuItem2.Caption := SPositionLeft; 163 NewMenuItem2.OnClick := PopupMenuPositionLeftClick; 164 NewMenuItem.Add(NewMenuItem2); 165 166 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 167 NewMenuItem2.Caption := SPositionBottom; 168 NewMenuItem2.OnClick := PopupMenuPositionBottomClick; 169 NewMenuItem.Add(NewMenuItem2); 170 171 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 172 NewMenuItem2.Caption := SPositionRight; 173 NewMenuItem2.OnClick := PopupMenuPositionRightClick; 174 NewMenuItem.Add(NewMenuItem2); 175 176 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 177 NewMenuItem.Caption := SCloseForm; 178 NewMenuItem.OnClick := PopupMenuCloseClick; 179 PopupMenuTabs.Items.Add(NewMenuItem); 180 181 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 182 NewMenuItem.Caption := SRenameForm; 183 NewMenuItem.OnClick := PopupMenuRenameClick; 184 PopupMenuTabs.Items.Add(NewMenuItem); 185 186 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 187 NewMenuItem.Caption := SUndock; 188 NewMenuItem.OnClick := PopupMenuUndockClick; 189 PopupMenuTabs.Items.Add(NewMenuItem); 190 191 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 192 NewMenuItem.Caption := SCustomize; 193 NewMenuItem.OnClick := PopupMenuCustomizeClick; 194 PopupMenuTabs.Items.Add(NewMenuItem); *) 195 196 TabImageList := TImageList.Create(TCoolDockManager(AManager).DockSite); //FDockSite); 197 with TabImageList do begin 198 Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'ImageList'; 199 end; 200 TabControl := TTabControl.Create(TCoolDockManager(AManager).DockSite); //FDockSite); 201 with TabControl do begin 202 Parent := TCoolDockManager(Manager).DockSite; 203 Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'TabControl'; 204 Visible := False; 205 Align := alTop; 206 Height := 24; 207 OnChange := TabControlChange; 208 PopupMenu := PopupMenuTabs; 209 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave; 210 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown; 211 TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp; 212 OnMouseUp := TabControlMouseUp; 213 Images := TabImageList; 214 end; 215 //TabsPos := hpTop; 216 //MoveDuration := 1000; // ms 217 218 TabControl.Visible := True; 219 TabControl.Tabs.Clear; 220 TabImageList.Clear; 221 with TCoolDockManager(Manager) do 222 for I := 0 to DockPanels.Count - 1 do begin 223 TabControl.Tabs.Add(TCoolDockClientPanel(DockPanels[I]).Control.Caption); 224 TabImageList.Add(TCoolDockClientPanel(DockPanels[I]).Header.Icon.Picture.Bitmap, nil); 225 if Assigned(TCoolDockClientPanel(DockPanels[I]).Splitter) then 226 TCoolDockClientPanel(DockPanels[I]).Splitter.Visible := False; 227 TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Visible := False; 228 TCoolDockClientPanel(DockPanels[I]).Visible := False; 229 end; 230 TabControlChange(Self); 231 end; 232 233 destructor TCoolDockStyleTabs.Destroy; 234 begin 235 TabControl.Visible := False; 236 TabControl.Tabs.Clear; 237 inherited Destroy; 238 end; 239 240 procedure TCoolDockStyleTabs.InsertControl(NewPanel: TCoolDockClientPanel; 241 AControl: TControl; InsertAt: TAlign); 242 begin 243 inherited; 244 TabControl.Tabs.Add(AControl.Caption); 245 TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil); 246 if Assigned(NewPanel.Splitter) then 247 NewPanel.Splitter.Visible := False; 248 NewPanel.ClientAreaPanel.Visible := False; 249 NewPanel.Visible := False; 250 TabControlChange(Self); 251 end; 252 253 procedure TCoolDockStyleTabs.UpdateClientSize; 254 var 255 I: Integer; 256 begin 257 inherited UpdateClientSize; 258 with TCoolDockManager(Manager) do 259 for I := 0 to DockPanels.Count - 1 do begin 260 TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width; 261 TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - TabControl.Height; 262 //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 263 end; 264 end; 265 266 procedure TCoolDockStyleTabs.SetTabsPos(const AValue: THeaderPos); 267 begin 268 (*if FTabsPos = AValue then Exit; 269 FTabsPos := AValue; 270 with TabControl do 271 case AValue of 272 hpAuto, hpTop: begin 273 Align := alTop; 274 TabPosition := tpTop; 275 Height := GrabberSize; 276 end; 277 hpLeft: begin 278 Align := alLeft; 279 TabPosition := tpLeft; 280 Width := GrabberSize; 281 end; 282 hpRight: begin 283 Align := alRight; 284 TabPosition := tpRight; 285 Width := GrabberSize; 286 end; 287 hpBottom: begin 288 Align := alBottom; 289 TabPosition := tpBottom; 290 Height := GrabberSize; 291 end; 292 end; *) 293 end; 294 295 17 296 end. 18 297
Note:
See TracChangeset
for help on using the changeset viewer.