Changeset 187 for Docking/CoolDocking/UCoolDockCommon.pas
- Timestamp:
- Mar 11, 2011, 8:41:52 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDockCommon.pas
r183 r187 6 6 7 7 uses 8 Classes, SysUtils, Forms, Controls ;8 Classes, SysUtils, Forms, Controls, Contnrs, StdCtrls, ExtCtrls, ComCtrls; 9 9 10 10 type … … 14 14 15 15 TCoolDockMasterBase = class; 16 TCoolDockClientBase = class; 17 18 { TCoolDockManagerBase } 16 19 17 20 TCoolDockManagerBase = class(TDockManager) 21 private 22 FMaster: TCoolDockMasterBase; 23 procedure SetMaster(const AValue: TCoolDockMasterBase); 24 public 25 property Master: TCoolDockMasterBase read FMaster write SetMaster; 18 26 end; 19 27 … … 30 38 end; 31 39 40 { TCoolDockMasterBase } 41 32 42 TCoolDockMasterBase = class(TComponent) 33 43 private 34 44 FCoolDockCustomize: TCoolDockCustomizeBase; 45 FClients: TObjectList; // TList<TCoolDockClientBase> 46 function GetClient(Index: Integer): TCoolDockClientBase; 35 47 procedure SetCustomize(const AValue: TCoolDockCustomizeBase); 48 public 49 constructor Create(AOwner: TComponent); override; 50 destructor Destroy; override; 51 procedure RegisterClient(Client: TCoolDockClientBase); 52 procedure UnRegisterClient(Client: TCoolDockClientBase); 53 property Clients[Index: Integer]: TCoolDockClientBase read GetClient; 36 54 published 37 55 property Customize: TCoolDockCustomizeBase read FCoolDockCustomize … … 39 57 end; 40 58 59 { TCoolDockClientBase } 60 61 TCoolDockClientBase = class(TComponent) 62 private 63 FMaster: TCoolDockMasterBase; 64 FPanel: TPanel; 65 procedure SetMaster(const AValue: TCoolDockMasterBase); 66 procedure SetPanel(const AValue: TPanel); 67 published 68 property Master: TCoolDockMasterBase read FMaster 69 write SetMaster; 70 property Panel: TPanel read FPanel 71 write SetPanel; 72 end; 73 74 function GetUniqueName(BaseName: string): string; 75 41 76 implementation 77 78 function GetUniqueName(BaseName: string): string; 79 var 80 I: Integer; 81 begin 82 I := 1; 83 while Assigned(FindGlobalComponent(BaseName + IntToStr(I))) do Inc(I); 84 Result := BaseName + IntToStr(I); 85 end; 86 87 88 { TCoolDockManagerBase } 89 90 procedure TCoolDockManagerBase.SetMaster(const AValue: TCoolDockMasterBase); 91 begin 92 if FMaster = AValue then Exit; 93 FMaster := AValue; 94 end; 95 96 { TCoolDockClientBase } 97 98 procedure TCoolDockClientBase.SetMaster(const AValue: TCoolDockMasterBase); 99 var 100 FOldMaster: TCoolDockMasterBase; 101 begin 102 if FMaster = AValue then Exit; 103 FOldMaster := FMaster; 104 FMaster := AValue; 105 if Assigned(FOldMaster) then 106 FOldMaster.UnregisterClient(Self); 107 if Assigned(FMaster) then begin 108 FMaster.RegisterClient(Self); 109 if not (csDesigning in ComponentState) then begin 110 if Assigned(TWinControl(Owner).DockManager) then 111 TCoolDockManagerBase(TWinControl(Owner).DockManager).Master := FMaster; 112 if Assigned(FPanel) then 113 TCoolDockManagerBase(FPanel.DockManager).Master := FMaster; 114 end; 115 end; 116 end; 117 118 procedure TCoolDockClientBase.SetPanel(const AValue: TPanel); 119 var 120 OldPanel: TPanel; 121 begin 122 if FPanel = AValue then exit; 123 OldPanel := FPanel; 124 FPanel := AValue; 125 if not (csDesigning in ComponentState) then begin 126 if Assigned(FPanel) then 127 with FPanel do begin 128 DockSite := True; 129 UseDockManager := True; 130 //DockManager := TCoolDockManager.Create(FPanel); 131 end else begin 132 OldPanel.DockSite := False; 133 end; 134 end; 135 end; 42 136 43 137 { TCoolDockConjoinFormBase } … … 77 171 end; 78 172 173 constructor TCoolDockMasterBase.Create(AOwner: TComponent); 174 begin 175 inherited; 176 FClients := TObjectList.Create; 177 FClients.OwnsObjects := False; 178 end; 179 180 destructor TCoolDockMasterBase.Destroy; 181 var 182 I: Integer; 183 begin 184 for I := FClients.Count - 1 downto 0 do 185 TCoolDockClientBase(FClients[I]).Master := nil; 186 FClients.Free; 187 inherited Destroy; 188 end; 189 190 procedure TCoolDockMasterBase.RegisterClient(Client: TCoolDockClientBase); 191 begin 192 if Assigned(Client) then 193 if FClients.IndexOf(Client) = -1 then begin 194 FClients.Add(Client); 195 Client.Master := Self; 196 end; 197 end; 198 199 procedure TCoolDockMasterBase.UnRegisterClient(Client: TCoolDockClientBase); 200 begin 201 if Assigned(Client) then begin 202 Client.Master := nil; 203 FClients.Remove(Client); 204 end; 205 end; 206 207 function TCoolDockMasterBase.GetClient(Index: Integer): TCoolDockClientBase; 208 begin 209 Result := TCoolDockClientBase(FClients[Index]); 210 end; 211 212 213 79 214 80 215 end.
Note:
See TracChangeset
for help on using the changeset viewer.