Changeset 56 for Docking/CoolDocking/UCoolDocking.pas
- Timestamp:
- Sep 21, 2010, 8:03:17 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDocking.pas
r55 r56 10 10 Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls, 11 11 Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil, 12 UCoolDockCustomize, DOM, XMLWrite, XMLRead ;12 UCoolDockCustomize, DOM, XMLWrite, XMLRead, UCoolDockWindowList; 13 13 14 14 const … … 21 21 TCoolDockManager = class; 22 22 TCoolDockClientPanel = class; 23 TCoolDockCustomize = class; 23 24 24 25 { TCoolDockConjoinForm } … … 56 57 procedure SetHeaderPos(const AValue: THeaderPos); 57 58 procedure SetShowHeader(const AValue: Boolean); 59 procedure VisibleChange(Sender: TObject); 58 60 public 59 61 Header: TCoolDockHeader; … … 80 82 FTabsPos: THeaderPos; 81 83 Timer1: TTimer; 82 PopupMenu1: TPopupMenu; 84 PopupMenuTabs: TPopupMenu; 85 PopupMenuHeader: TPopupMenu; 83 86 FDockStyle: TDockStyle; 84 87 TabControl: TTabControl; … … 105 108 procedure PopupMenuPositionBottomClick(Sender: TObject); 106 109 procedure PopupMenuUndockClick(Sender: TObject); 110 procedure PopupMenuCustomizeClick(Sender: TObject); 107 111 procedure Timer1Timer(Sender: TObject); 108 112 procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton; … … 143 147 TCoolDockMaster = class(TComponent) 144 148 private 149 FCoolDockCustomize: TCoolDockCustomize; 145 150 FDefaultHeaderPos: THeaderPos; 146 151 FTabsEnabled: Boolean; 152 procedure SetCustomize(const AValue: TCoolDockCustomize); 147 153 procedure SetTabsEnabled(const AValue: Boolean); 148 154 public … … 155 161 property DefaultHeaderPos: THeaderPos read FDefaultHeaderPos 156 162 write FDefaultHeaderPos; 163 property Customize: TCoolDockCustomize read FCoolDockCustomize 164 write SetCustomize; 165 end; 166 167 { TCoolDockCustomize } 168 169 TCoolDockCustomize = class(TComponent) 170 private 171 FManager: TCoolDockMaster; 172 procedure SetManager(const AValue: TCoolDockMaster); 173 public 174 Form: TCoolDockCustomizeForm; 175 function Execute: Boolean; 176 constructor Create(AOwner: TComponent); override; 177 published 178 property Manager: TCoolDockMaster read FManager write SetManager; 179 end; 180 181 { TCoolDockWindowList } 182 183 TCoolDockWindowList = class(TComponent) 184 private 185 public 186 Form: TCoolDockWindowListForm; 187 function Execute: Boolean; 188 constructor Create(AOwner: TComponent); override; 189 published 157 190 end; 158 191 … … 174 207 SPositionBottom = 'Bottom'; 175 208 SUndock = 'Undock'; 209 SCustomize = 'Customize...'; 176 210 177 211 procedure Register; … … 179 213 RegisterComponents('CoolDocking', [TCoolDockMaster]); 180 214 RegisterComponents('CoolDocking', [TCoolDockCustomize]); 215 RegisterComponents('CoolDocking', [TCoolDockWindowList]); 181 216 end; 182 217 … … 204 239 FDockSite := ADockSite; 205 240 FDockPanels := TObjectList.Create; 206 PopupMenu1 := TPopupMenu.Create(FDockSite);207 241 208 242 Timer1 := TTimer.Create(nil); … … 210 244 Timer1.OnTimer := Timer1Timer; 211 245 212 NewMenuItem := TMenuItem.Create(PopupMenu1); 246 // Tabs popup 247 248 PopupMenuTabs := TPopupMenu.Create(FDockSite); 249 250 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 213 251 NewMenuItem.Caption := SDockStyle; 214 PopupMenu 1.Items.Add(NewMenuItem);252 PopupMenuTabs.Items.Add(NewMenuItem); 215 253 216 254 NewMenuItem2 := TMenuItem.Create(NewMenuItem); … … 224 262 NewMenuItem.Add(NewMenuItem2); 225 263 226 NewMenuItem := TMenuItem.Create(PopupMenu 1);264 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 227 265 NewMenuItem.Caption := SPosition; 228 PopupMenu 1.Items.Add(NewMenuItem);266 PopupMenuTabs.Items.Add(NewMenuItem); 229 267 230 268 NewMenuItem2 := TMenuItem.Create(NewMenuItem); … … 253 291 NewMenuItem.Add(NewMenuItem2); 254 292 255 NewMenuItem := TMenuItem.Create(PopupMenu 1);293 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 256 294 NewMenuItem.Caption := SCloseForm; 257 295 NewMenuItem.OnClick := PopupMenuCloseClick; 258 PopupMenu 1.Items.Add(NewMenuItem);259 260 NewMenuItem := TMenuItem.Create(PopupMenu 1);296 PopupMenuTabs.Items.Add(NewMenuItem); 297 298 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 261 299 NewMenuItem.Caption := SRenameForm; 262 300 NewMenuItem.OnClick := PopupMenuRenameClick; 263 PopupMenu 1.Items.Add(NewMenuItem);264 265 NewMenuItem := TMenuItem.Create(PopupMenu 1);301 PopupMenuTabs.Items.Add(NewMenuItem); 302 303 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 266 304 NewMenuItem.Caption := SUndock; 267 305 NewMenuItem.OnClick := PopupMenuUndockClick; 268 PopupMenu1.Items.Add(NewMenuItem); 306 PopupMenuTabs.Items.Add(NewMenuItem); 307 308 NewMenuItem := TMenuItem.Create(PopupMenuTabs); 309 NewMenuItem.Caption := SCustomize; 310 NewMenuItem.OnClick := PopupMenuCustomizeClick; 311 PopupMenuTabs.Items.Add(NewMenuItem); 312 313 // Header popup 314 315 PopupMenuHeader := TPopupMenu.Create(FDockSite); 316 317 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 318 NewMenuItem.Caption := SDockStyle; 319 PopupMenuHeader.Items.Add(NewMenuItem); 320 321 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 322 NewMenuItem2.Caption := SDockList; 323 NewMenuItem2.OnClick := PopupMenuListClick; 324 NewMenuItem.Add(NewMenuItem2); 325 326 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 327 NewMenuItem2.Caption := SDockTabs; 328 NewMenuItem2.OnClick := PopupMenuTabsClick; 329 NewMenuItem.Add(NewMenuItem2); 330 331 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 332 NewMenuItem.Caption := SPosition; 333 PopupMenuHeader.Items.Add(NewMenuItem); 334 335 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 336 NewMenuItem2.Caption := SPositionAuto; 337 NewMenuItem2.OnClick := PopupMenuPositionAutoClick; 338 NewMenuItem.Add(NewMenuItem2); 339 340 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 341 NewMenuItem2.Caption := SPositionTop; 342 NewMenuItem2.OnClick := PopupMenuPositionTopClick; 343 NewMenuItem.Add(NewMenuItem2); 344 345 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 346 NewMenuItem2.Caption := SPositionLeft; 347 NewMenuItem2.OnClick := PopupMenuPositionLeftClick; 348 NewMenuItem.Add(NewMenuItem2); 349 350 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 351 NewMenuItem2.Caption := SPositionBottom; 352 NewMenuItem2.OnClick := PopupMenuPositionBottomClick; 353 NewMenuItem.Add(NewMenuItem2); 354 355 NewMenuItem2 := TMenuItem.Create(NewMenuItem); 356 NewMenuItem2.Caption := SPositionRight; 357 NewMenuItem2.OnClick := PopupMenuPositionRightClick; 358 NewMenuItem.Add(NewMenuItem2); 359 360 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 361 NewMenuItem.Caption := SCloseForm; 362 NewMenuItem.OnClick := PopupMenuCloseClick; 363 PopupMenuHeader.Items.Add(NewMenuItem); 364 365 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 366 NewMenuItem.Caption := SRenameForm; 367 NewMenuItem.OnClick := PopupMenuRenameClick; 368 PopupMenuHeader.Items.Add(NewMenuItem); 369 370 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 371 NewMenuItem.Caption := SUndock; 372 NewMenuItem.OnClick := PopupMenuUndockClick; 373 PopupMenuHeader.Items.Add(NewMenuItem); 374 375 NewMenuItem := TMenuItem.Create(PopupMenuHeader); 376 NewMenuItem.Caption := SCustomize; 377 NewMenuItem.OnClick := PopupMenuCustomizeClick; 378 PopupMenuHeader.Items.Add(NewMenuItem); 269 379 270 380 TabControl := TTabControl.Create(FDockSite); … … 275 385 Height := 24; 276 386 OnChange := TabControlChange; 277 PopupMenu := PopupMenu 1;387 PopupMenu := PopupMenuTabs; 278 388 OnMouseDown := TabControlMouseDown; 279 389 end; … … 357 467 if DockStyle = dsList then Visible := True; 358 468 Align := alClient; 469 Header.PopupMenu := PopupMenuHeader; 359 470 end; 360 471 … … 368 479 end; 369 480 NewPanel.Control := Control; 481 Control.AddHandlerOnVisibleChanged(NewPanel.VisibleChange); 370 482 Control.Parent := NewPanel.ClientAreaPanel; 371 483 Control.Align := alClient; … … 596 708 for I := 0 to FDockPanels.Count - 1 do begin 597 709 TCoolDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div 598 FDockSite. DockClientCount;710 FDockSite.VisibleDockClientCount; 599 711 TCoolDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div 600 FDockSite. DockClientCount;712 FDockSite.VisibleDockClientCount; 601 713 //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self); 602 714 end; … … 644 756 645 757 procedure TCoolDockManager.PopupMenuCloseClick(Sender: TObject); 646 begin 647 TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close; 758 var 759 Control: TControl; 760 begin 761 Control := FindLCLControl(Mouse.CursorPos); 762 if Assigned(Control) then 763 ShowMessage(Control.ClassName); 764 // DockSiteTForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close; 648 765 end; 649 766 … … 687 804 begin 688 805 806 end; 807 808 procedure TCoolDockManager.PopupMenuCustomizeClick(Sender: TObject); 809 begin 810 // if Assigned(DockMaster.Customize) then 811 // DockMaster.Customize.Execute; 689 812 end; 690 813 … … 714 837 FShowHeader := AValue; 715 838 DockPanelPaint(Self); 839 end; 840 841 procedure TCoolDockClientPanel.VisibleChange(Sender: TObject); 842 begin 843 //OwnerDockManager.FDockPanels.Remove(Self); 844 ClientAreaPanel.Visible := Control.Visible; 845 Splitter.Visible := Control.Visible; 846 OwnerDockManager.UpdateClientSize; 716 847 end; 717 848 … … 737 868 Align := alTop; 738 869 Height := GrabberSize; 870 ParentClientPanel := Self; 739 871 end; 740 872 ClientAreaPanel := TPanel.Create(Self); … … 832 964 if FTabsEnabled=AValue then exit; 833 965 FTabsEnabled:=AValue; 966 end; 967 968 procedure TCoolDockMaster.SetCustomize(const AValue: TCoolDockCustomize 969 ); 970 begin 971 if FCoolDockCustomize=AValue then exit; 972 FCoolDockCustomize:=AValue; 973 if Assigned(AValue) then 974 if not Assigned(AValue.Manager) then 975 AValue.Manager := Self; 834 976 end; 835 977 … … 998 1140 procedure TCoolDockHeader.CloseButtonClick(Sender: TObject); 999 1141 begin 1000 // Control.Hide; 1142 ParentClientPanel.Control.Hide; 1143 end; 1144 1145 { TCoolDockCustomize } 1146 1147 procedure TCoolDockCustomize.SetManager(const AValue: TCoolDockMaster); 1148 begin 1149 if FManager = AValue then exit; 1150 FManager := AValue; 1151 if Assigned(AValue) then 1152 if not Assigned(AValue.Customize) then 1153 AValue.Customize := Self; 1154 end; 1155 1156 function TCoolDockCustomize.Execute: Boolean; 1157 begin 1158 Form.ShowModal; 1159 Result := True; 1160 end; 1161 1162 constructor TCoolDockCustomize.Create(AOwner: TComponent); 1163 begin 1164 inherited Create(AOwner); 1165 Form := TCoolDockCustomizeForm.Create(Self); 1166 end; 1167 1168 1169 { TCoolDockWindowList } 1170 1171 function TCoolDockWindowList.Execute: Boolean; 1172 begin 1173 Form.ShowModal; 1174 Result := True; 1175 end; 1176 1177 constructor TCoolDockWindowList.Create(AOwner: TComponent); 1178 begin 1179 inherited Create(AOwner); 1180 Form := TCoolDockWindowListForm.Create(Self); 1001 1181 end; 1002 1182
Note:
See TracChangeset
for help on using the changeset viewer.