Changeset 194 for Docking/CoolDocking/Managers/UCDManagerTabs.pas
- Timestamp:
- Mar 11, 2011, 1:00:06 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/Managers/UCDManagerTabs.pas
r193 r194 6 6 7 7 uses 8 Classes, Controls, ExtCtrls, ComCtrls, SysUtils, Dialogs, 9 Menus, Forms, UCDClientPanel, UCDCommon, UCDManager; 8 Classes, Controls, ExtCtrls, ComCtrls, SysUtils, Dialogs, Contnrs, 9 Menus, Forms, UCDCommon, UCDManager, 10 LCLType, LMessages, Graphics; 10 11 11 12 type 13 TCDManagerTabsITem = class(TCDManagerItem) 14 15 end; 12 16 13 17 { TCDManagerTabs } … … 20 24 PageControl: TPageControl; 21 25 TabImageList: TImageList; 26 FDockItems: TObjectList; // TList<TCDManagerRegionsItem> 22 27 procedure TabControlMouseLeave(Sender: TObject); 23 28 procedure TabControlChange(Sender: TObject); … … 31 36 private 32 37 FTabsPos: THeaderPos; 38 function FindControlInPanels(Control: TControl): TCDManagerItem; override; 33 39 procedure InsertControlNoUpdate(AControl: TControl; InsertAt: TAlign); 34 40 procedure RemoveControl(Control: TControl); override; 35 41 public 36 42 constructor Create(ADockSite: TWinControl); 43 destructor Destroy; override; 44 procedure PaintSite(DC: HDC); override; 37 45 procedure DoSetVisible(const AValue: Boolean); override; 38 destructor Destroy; override;39 46 procedure ChangeVisible(Control: TWinControl; Visible: Boolean); override; 40 47 procedure Switch(Index: Integer); override; … … 42 49 procedure PopupMenuTabCloseClick(Sender: TObject); 43 50 property TabsPos: THeaderPos read FTabsPos write SetTabsPos; 51 property DockItems: TObjectList read FDockItems write FDockItems; 44 52 end; 45 53 … … 51 59 { TCDManagerTabs } 52 60 61 function TCDManagerTabs.FindControlInPanels(Control: TControl 62 ): TCDManagerItem; 63 var 64 I: Integer; 65 begin 66 I := 0; 67 while (I < FDockItems.Count) and 68 (TCDManagerItem(FDockItems[I]).Control <> Control) do Inc(I); 69 if I < FDockItems.Count then Result := TCDManagerItem(FDockItems[I]) 70 else Result := nil; 71 end; 72 53 73 procedure TCDManagerTabs.PopupMenuTabCloseClick(Sender: TObject); 54 74 begin 55 75 if Assigned(PageControl.ActivePage) then 56 TCD ClientPanel(DockPanels[PageControl.TabIndex]).Control.Hide;76 TCDManagerItem(DockItems[PageControl.TabIndex]).Control.Hide; 57 77 end; 58 78 … … 61 81 if MouseDown then 62 82 if Assigned(PageControl.ActivePage) then begin 63 TCDClientPanel(DockPanels[PageControl.TabIndex]).ClientAreaPanel.DockSite := False;64 DragManager.DragStart(TCD ClientPanel(DockPanels[PageControl.TabIndex]).Control, False, 1);83 //TCDManagerItem(DockItems[PageControl.TabIndex]).ClientAreaPanel.DockSite := False; 84 DragManager.DragStart(TCDManagerItem(DockItems[PageControl.TabIndex]).Control, False, 1); 65 85 end; 66 86 MouseDown := False; … … 72 92 begin 73 93 // Hide all clients 74 for I := 0 to Dock Panels.Count - 1 do75 if TCD ClientPanel(DockPanels[I]).Control.Visible94 for I := 0 to DockItems.Count - 1 do 95 if TCDManagerItem(DockItems[I]).Control.Visible 76 96 //and (PageControl.TabIndex <> I) 77 97 then 78 98 begin 79 TCD ClientPanel(DockPanels[I]).Control.Tag := Integer(dhtTemporal);80 TCD ClientPanel(DockPanels[I]).Control.Hide;81 TCDClientPanel(DockPanels[I]).ClientAreaPanel.Hide;82 TCDClientPanel(DockPanels[I]).ClientAreaPanel.Parent := PageControl.Pages[I];99 TCDManagerItem(DockItems[I]).Control.Tag := Integer(dhtTemporal); 100 TCDManagerItem(DockItems[I]).Control.Hide; 101 //TCDClientPanel(DockItems[I]).ClientAreaPanel.Hide; 102 //TCDClientPanel(DockItems[I]).ClientAreaPanel.Parent := PageControl.Pages[I]; 83 103 //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite; 84 TCD ClientPanel(DockPanels[I]).Control.Align := alClient;104 TCDManagerItem(DockItems[I]).Control.Align := alClient; 85 105 //TCDClientPanel(DockPanels[I]).Control.Parent := 86 106 // TCDClientPanel(DockPanels[I]).ClientAreaPanel; 87 107 //ShowMessage(TCDClientPanel(DockPanels[I]).Control.ClassName); 88 Application.ProcessMessages;108 //Application.ProcessMessages; 89 109 90 110 // Workaround for "Cannot focus" error 91 TForm(TCD ClientPanel(DockPanels[I]).Control).ActiveControl := nil;111 TForm(TCDManagerItem(DockItems[I]).Control).ActiveControl := nil; 92 112 end; 93 113 94 114 // Show selected 95 if (PageControl.TabIndex <> -1) and (Dock Panels.Count > PageControl.TabIndex)115 if (PageControl.TabIndex <> -1) and (DockItems.Count > PageControl.TabIndex) 96 116 // and not TCDClientPanel(DockPanels[PageControl.TabIndex]).Control.Visible 97 117 then begin 98 with TCD ClientPanel(DockPanels[PageControl.TabIndex]), ClientAreaPaneldo begin118 with TCDManagerItem(DockItems[PageControl.TabIndex]) do begin 99 119 Control.Show; 100 120 (*AutoHide.Enable := True; … … 145 165 inherited; 146 166 FDockStyle := dsTabs; 167 FDockItems := TObjectList.Create; 168 147 169 TabImageList := TImageList.Create(ADockSite); //FDockSite); 148 170 with TabImageList do begin … … 173 195 PageControl.Visible := True; 174 196 //TabImageList.Clear; 175 for I := 0 to Dock Panels.Count - 1 do176 Self.InsertControlNoUpdate(TCD ClientPanel(DockPanels[I]).Control, alNone);197 for I := 0 to DockItems.Count - 1 do 198 Self.InsertControlNoUpdate(TCDManagerItem(DockItems[I]).Control, alNone); 177 199 TabControlChange(Self); 178 200 end; … … 180 202 destructor TCDManagerTabs.Destroy; 181 203 begin 204 FDockItems.Free; 182 205 PageControl.Free; 183 206 TabImageList.Free; … … 185 208 end; 186 209 210 procedure TCDManagerTabs.PaintSite(DC: HDC); 211 var 212 I: Integer; 213 begin 214 inherited PaintSite(DC); 215 PageControl.Invalidate; 216 end; 217 187 218 procedure TCDManagerTabs.Switch(Index: Integer); 188 219 begin … … 193 224 var 194 225 NewTabSheet: TTabSheet; 195 NewPanel: TCD ClientPanel;226 NewPanel: TCDManagerTabsItem; 196 227 begin 197 228 inherited; 198 229 begin 199 NewPanel := TCD ClientPanel.Create(nil);230 NewPanel := TCDManagerTabsItem.Create; 200 231 with NewPanel do begin 201 Parent := Self.DockSite;202 OwnerDockManager := Self;232 //Panel.Parent := Self.DockSite; 233 Manager := Self; 203 234 if DockStyle = dsList then Visible := True; 204 Align := alClient;235 //Align := alClient; 205 236 Header.PopupMenu := Self.PopupMenu; 206 237 //PopupMenu.Parent := Self.DockSite; … … 211 242 NewPanel.Control := AControl; 212 243 AControl.AddHandlerOnVisibleChanged(NewPanel.VisibleChange); 213 AControl.Parent := NewPanel.ClientAreaPanel;244 //AControl.Parent := NewPanel.ClientAreaPanel; 214 245 AControl.Align := alClient; 215 246 if (InsertAt = alTop) or (InsertAt = alLeft) then 216 Dock Panels.Insert(0, NewPanel)217 else Dock Panels.Add(NewPanel);247 DockItems.Insert(0, NewPanel) 248 else DockItems.Add(NewPanel); 218 249 219 250 end; … … 225 256 NewTabSheet.ImageIndex := TabImageList.Count; 226 257 TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil); 227 if Assigned(NewPanel.Splitter) then228 NewPanel.Splitter.Visible := False;229 NewPanel.ClientAreaPanel.Visible := False;230 NewPanel.Visible := False;258 // if Assigned(NewPanel.Splitter) then 259 // NewPanel.Splitter.Visible := False; 260 // NewPanel.ClientAreaPanel.Visible := False; 261 // NewPanel.Visible := False; 231 262 //NewPanel.Parent := NewTabSheet; 232 263 end; … … 253 284 begin 254 285 inherited UpdateClientSize; 255 for I := 0 to Dock Panels.Count - 1 do begin286 for I := 0 to DockItems.Count - 1 do begin 256 287 //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width; 257 288 //TCDClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - PageControl.Height; … … 263 294 begin 264 295 inherited; 265 if (PageControl.TabIndex >= 0) and (PageControl.TabIndex < Dock Panels.Count) then266 with TCD ClientPanel(DockPanels[PageControl.TabIndex]) do begin296 if (PageControl.TabIndex >= 0) and (PageControl.TabIndex < DockItems.Count) then 297 with TCDManagerItem(DockItems[PageControl.TabIndex]) do begin 267 298 //Show; 268 299 //ShowMessage(IntToStr(Control.Tag)); … … 294 325 //TabImageList.Delete(PageControl.Tabs.IndexOf(Control.Caption)); 295 326 296 I := Dock Panels.IndexOf(FindControlInPanels(Control));327 I := DockItems.IndexOf(FindControlInPanels(Control)); 297 328 if Control.Tag = Integer(dhtPermanent) then 298 329 if I <> -1 then … … 308 339 begin 309 340 // if Control.Tag = 0 then begin 310 I := Dock Panels.IndexOf(FindControlInPanels(Control));341 I := DockItems.IndexOf(FindControlInPanels(Control)); 311 342 //if then 312 343 if I <> -1 then
Note:
See TracChangeset
for help on using the changeset viewer.