Changeset 58 for Docking/CoolDocking/UCoolDocking.pas
- Timestamp:
- Sep 23, 2010, 11:41:59 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCoolDocking.pas
r57 r58 22 22 TCoolDockClientPanel = class; 23 23 TCoolDockCustomize = class; 24 TCoolDockClient = class; 24 25 25 26 { TCoolDockConjoinForm } … … 27 28 TCoolDockConjoinForm = class(TForm) 28 29 Panel: TPanel; 30 CoolDockClient: TCoolDockClient; 29 31 constructor Create(TheOwner: TComponent); override; 30 32 end; … … 86 88 FDockStyle: TDockStyle; 87 89 TabControl: TTabControl; 90 TabImageList: TImageList; 88 91 FDockDirection: TDockDirection; 89 92 FDockSite: TWinControl; … … 149 152 FCoolDockCustomize: TCoolDockCustomize; 150 153 FDefaultHeaderPos: THeaderPos; 154 FShowIcons: Boolean; 151 155 FTabsEnabled: Boolean; 156 FClients: TObjectList; 157 function GetClient(Index: Integer): TCoolDockClient; 152 158 procedure SetCustomize(const AValue: TCoolDockCustomize); 159 procedure SetShowIcons(const AValue: Boolean); 153 160 procedure SetTabsEnabled(const AValue: Boolean); 154 161 public … … 157 164 procedure SaveLayoutToFile(FileName: string); 158 165 procedure LoadLayoutFromFile(FileName: string); 166 constructor Create(AOwner: TComponent); override; 159 167 destructor Destroy; override; 168 procedure RegisterClient(Client: TCoolDockClient); 169 procedure UnRegisterClient(Client: TCoolDockClient); 170 property Clients[Index: Integer]: TCoolDockClient read GetClient; 160 171 published 161 172 property TabsEnabled: Boolean read FTabsEnabled write SetTabsEnabled; … … 164 175 property Customize: TCoolDockCustomize read FCoolDockCustomize 165 176 write SetCustomize; 177 property ShowIcons: Boolean read FShowIcons 178 write SetShowIcons; 179 end; 180 181 TCoolDockClient = class(TComponent) 182 private 183 FMaster: TCoolDockMaster; 184 FPanel: TPanel; 185 procedure SetMaster(const AValue: TCoolDockMaster); 186 constructor Create(AOwner: TComponent); override; 187 destructor Destroy; override; 188 procedure SetPanel(const AValue: TPanel); 189 published 190 property Master: TCoolDockMaster read FMaster 191 write SetMaster; 192 property Panel: TPanel read FPanel 193 write SetPanel; 166 194 end; 167 195 … … 210 238 SUndock = 'Undock'; 211 239 SCustomize = 'Customize...'; 240 SWrongOwner = 'Owner of TCoolDockClient have to be TForm'; 212 241 213 242 procedure Register; 214 243 begin 215 244 RegisterComponents('CoolDocking', [TCoolDockMaster]); 245 RegisterComponents('CoolDocking', [TCoolDockClient]); 216 246 RegisterComponents('CoolDocking', [TCoolDockCustomize]); 217 247 RegisterComponents('CoolDocking', [TCoolDockWindowList]); … … 380 410 PopupMenuHeader.Items.Add(NewMenuItem); 381 411 412 TabImageList := TImageList.Create(FDockSite); 413 with TabImageList do begin 414 end; 382 415 TabControl := TTabControl.Create(FDockSite); 383 416 with TabControl do begin … … 389 422 PopupMenu := PopupMenuTabs; 390 423 OnMouseDown := TabControlMouseDown; 424 Images := TabImageList; 391 425 end; 392 426 TabsPos := hpTop; … … 646 680 TabControl.Visible := True; 647 681 TabControl.Tabs.Clear; 682 TabImageList.Clear; 648 683 for I := 0 to FDockPanels.Count - 1 do begin 649 684 TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption); 685 TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil); 650 686 if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then 651 687 TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False; … … 846 882 procedure TCoolDockClientPanel.VisibleChange(Sender: TObject); 847 883 begin 848 (* if Assigned(Control) then begin 849 //OwnerDockManager.FDockPanels.Remove(Self); 884 if Assigned(Control) then begin 850 885 if Assigned(ClientAreaPanel) then 851 886 ClientAreaPanel.Visible := Control.Visible; … … 853 888 Splitter.Visible := Control.Visible; 854 889 OwnerDockManager.UpdateClientSize; 855 end; *)890 end; 856 891 end; 857 892 … … 963 998 // Color := clYellow; 964 999 end; 965 DragKind := dkDock; 966 DragMode := dmAutomatic; 1000 CoolDockClient := TCoolDockClient.Create(Self); 1001 with CoolDockClient do begin 1002 Panel := Self.Panel; 1003 end; 967 1004 end; 968 1005 … … 988 1025 OldCustomize.Master := nil; 989 1026 end; 1027 end; 1028 1029 function TCoolDockMaster.GetClient(Index: Integer): TCoolDockClient; 1030 begin 1031 Result := TCoolDockClient(FClients[Index]); 1032 end; 1033 1034 procedure TCoolDockMaster.SetShowIcons(const AValue: Boolean); 1035 begin 1036 if FShowIcons = AValue then Exit; 1037 FShowIcons := AValue; 990 1038 end; 991 1039 … … 1093 1141 end; 1094 1142 1143 constructor TCoolDockMaster.Create(AOwner: TComponent); 1144 begin 1145 inherited Create(AOwner); 1146 FClients := TObjectList.Create; 1147 FClients.OwnsObjects := False; 1148 end; 1149 1095 1150 destructor TCoolDockMaster.Destroy; 1096 1151 begin 1152 FClients.Free; 1097 1153 Customize := nil; 1098 1154 inherited Destroy; 1155 end; 1156 1157 procedure TCoolDockMaster.RegisterClient(Client: TCoolDockClient); 1158 begin 1159 if Assigned(Client) then 1160 if FClients.IndexOf(Client) <> -1 then begin 1161 FClients.Add(Client); 1162 Client.Master := Self; 1163 end; 1164 end; 1165 1166 procedure TCoolDockMaster.UnRegisterClient(Client: TCoolDockClient); 1167 begin 1168 if Assigned(Client) then begin 1169 Client.Master := nil; 1170 FClients.Remove(Client); 1171 end; 1099 1172 end; 1100 1173 … … 1140 1213 Parent := Self; 1141 1214 Left := 4; 1142 Top := 3;1215 Top := 2; 1143 1216 Visible := True; 1144 1217 end; … … 1223 1296 end; 1224 1297 1225 initialization 1226 DefaultDockManagerClass := TCoolDockManager; 1298 { TCoolDockClient } 1299 1300 procedure TCoolDockClient.SetMaster(const AValue: TCoolDockMaster); 1301 var 1302 FOldMaster: TCoolDockMaster; 1303 begin 1304 if FMaster = AValue then Exit; 1305 FOldMaster := FMaster; 1306 FMaster := AValue; 1307 if Assigned(FOldMaster) then 1308 FOldMaster.UnregisterClient(Self); 1309 if Assigned(FMaster) then 1310 FMaster.RegisterClient(Self); 1311 end; 1312 1313 constructor TCoolDockClient.Create(AOwner: TComponent); 1314 begin 1315 inherited Create(AOwner); 1316 if not (AOwner is TForm) then 1317 raise Exception.Create(SWrongOwner); 1318 with (AOwner as TForm) do begin 1319 if not (csDesigning in ComponentState) then begin 1320 DragKind := dkDock; 1321 DragMode := dmAutomatic; 1322 DockSite := True; 1323 UseDockManager := True; 1324 DockManager := TCoolDockManager.Create(TWinControl(AOwner)); 1325 end; 1326 end; 1327 end; 1328 1329 destructor TCoolDockClient.Destroy; 1330 begin 1331 inherited Destroy; 1332 Master := nil; 1333 end; 1334 1335 procedure TCoolDockClient.SetPanel(const AValue: TPanel); 1336 var 1337 OldPanel: TPanel; 1338 begin 1339 if FPanel = AValue then exit; 1340 OldPanel := FPanel; 1341 FPanel := AValue; 1342 if not (csDesigning in ComponentState) then begin 1343 if Assigned(FPanel) then 1344 with FPanel do begin 1345 DockSite := True; 1346 UseDockManager := True; 1347 DockManager := TCoolDockManager.Create(FPanel); 1348 end else begin 1349 OldPanel.DockSite := False; 1350 end; 1351 end; 1352 end; 1227 1353 1228 1354 end.
Note:
See TracChangeset
for help on using the changeset viewer.