Ignore:
Timestamp:
Sep 23, 2010, 11:41:59 AM (14 years ago)
Author:
george
Message:
  • Upraveno: Systém inicializace ukotvení přepracován z ručního na automatický pomocí použití komponenty TCoolDockClient. Zrušeno nastavení globální třídy výchozího správce ukotvení.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r57 r58  
    2222  TCoolDockClientPanel = class;
    2323  TCoolDockCustomize = class;
     24  TCoolDockClient = class;
    2425
    2526  { TCoolDockConjoinForm }
     
    2728  TCoolDockConjoinForm = class(TForm)
    2829    Panel: TPanel;
     30    CoolDockClient: TCoolDockClient;
    2931    constructor Create(TheOwner: TComponent); override;
    3032  end;
     
    8688    FDockStyle: TDockStyle;
    8789    TabControl: TTabControl;
     90    TabImageList: TImageList;
    8891    FDockDirection: TDockDirection;
    8992    FDockSite: TWinControl;
     
    149152    FCoolDockCustomize: TCoolDockCustomize;
    150153    FDefaultHeaderPos: THeaderPos;
     154    FShowIcons: Boolean;
    151155    FTabsEnabled: Boolean;
     156    FClients: TObjectList;
     157    function GetClient(Index: Integer): TCoolDockClient;
    152158    procedure SetCustomize(const AValue: TCoolDockCustomize);
     159    procedure SetShowIcons(const AValue: Boolean);
    153160    procedure SetTabsEnabled(const AValue: Boolean);
    154161  public
     
    157164    procedure SaveLayoutToFile(FileName: string);
    158165    procedure LoadLayoutFromFile(FileName: string);
     166    constructor Create(AOwner: TComponent); override;
    159167    destructor Destroy; override;
     168    procedure RegisterClient(Client: TCoolDockClient);
     169    procedure UnRegisterClient(Client: TCoolDockClient);
     170    property Clients[Index: Integer]: TCoolDockClient read GetClient;
    160171  published
    161172    property TabsEnabled: Boolean read FTabsEnabled write SetTabsEnabled;
     
    164175    property Customize: TCoolDockCustomize read FCoolDockCustomize
    165176      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;
    166194  end;
    167195
     
    210238  SUndock = 'Undock';
    211239  SCustomize = 'Customize...';
     240  SWrongOwner = 'Owner of TCoolDockClient have to be TForm';
    212241
    213242procedure Register;
    214243begin
    215244  RegisterComponents('CoolDocking', [TCoolDockMaster]);
     245  RegisterComponents('CoolDocking', [TCoolDockClient]);
    216246  RegisterComponents('CoolDocking', [TCoolDockCustomize]);
    217247  RegisterComponents('CoolDocking', [TCoolDockWindowList]);
     
    380410  PopupMenuHeader.Items.Add(NewMenuItem);
    381411
     412  TabImageList := TImageList.Create(FDockSite);
     413  with TabImageList do begin
     414  end;
    382415  TabControl := TTabControl.Create(FDockSite);
    383416  with TabControl do begin
     
    389422    PopupMenu := PopupMenuTabs;
    390423    OnMouseDown := TabControlMouseDown;
     424    Images := TabImageList;
    391425  end;
    392426  TabsPos := hpTop;
     
    646680    TabControl.Visible := True;
    647681    TabControl.Tabs.Clear;
     682    TabImageList.Clear;
    648683    for I := 0 to FDockPanels.Count - 1 do begin
    649684      TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption);
     685      TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil);
    650686      if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then
    651687        TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False;
     
    846882procedure TCoolDockClientPanel.VisibleChange(Sender: TObject);
    847883begin
    848 (*  if Assigned(Control) then begin
    849     //OwnerDockManager.FDockPanels.Remove(Self);
     884  if Assigned(Control) then begin
    850885    if Assigned(ClientAreaPanel) then
    851886      ClientAreaPanel.Visible := Control.Visible;
     
    853888      Splitter.Visible := Control.Visible;
    854889    OwnerDockManager.UpdateClientSize;
    855   end;*)
     890  end;
    856891end;
    857892
     
    963998  //  Color := clYellow;
    964999  end;
    965   DragKind := dkDock;
    966   DragMode := dmAutomatic;
     1000  CoolDockClient := TCoolDockClient.Create(Self);
     1001  with CoolDockClient do begin
     1002    Panel := Self.Panel;
     1003  end;
    9671004end;
    9681005
     
    9881025    OldCustomize.Master := nil;
    9891026  end;
     1027end;
     1028
     1029function TCoolDockMaster.GetClient(Index: Integer): TCoolDockClient;
     1030begin
     1031  Result := TCoolDockClient(FClients[Index]);
     1032end;
     1033
     1034procedure TCoolDockMaster.SetShowIcons(const AValue: Boolean);
     1035begin
     1036  if FShowIcons = AValue then Exit;
     1037  FShowIcons := AValue;
    9901038end;
    9911039
     
    10931141end;
    10941142
     1143constructor TCoolDockMaster.Create(AOwner: TComponent);
     1144begin
     1145  inherited Create(AOwner);
     1146  FClients := TObjectList.Create;
     1147  FClients.OwnsObjects := False;
     1148end;
     1149
    10951150destructor TCoolDockMaster.Destroy;
    10961151begin
     1152  FClients.Free;
    10971153  Customize := nil;
    10981154  inherited Destroy;
     1155end;
     1156
     1157procedure TCoolDockMaster.RegisterClient(Client: TCoolDockClient);
     1158begin
     1159  if Assigned(Client) then
     1160    if FClients.IndexOf(Client) <> -1 then begin
     1161      FClients.Add(Client);
     1162      Client.Master := Self;
     1163    end;
     1164end;
     1165
     1166procedure TCoolDockMaster.UnRegisterClient(Client: TCoolDockClient);
     1167begin
     1168  if Assigned(Client) then begin
     1169    Client.Master := nil;
     1170    FClients.Remove(Client);
     1171  end;
    10991172end;
    11001173
     
    11401213    Parent := Self;
    11411214    Left := 4;
    1142     Top := 3;
     1215    Top := 2;
    11431216    Visible := True;
    11441217  end;
     
    12231296end;
    12241297
    1225 initialization
    1226   DefaultDockManagerClass := TCoolDockManager;
     1298{ TCoolDockClient }
     1299
     1300procedure TCoolDockClient.SetMaster(const AValue: TCoolDockMaster);
     1301var
     1302  FOldMaster: TCoolDockMaster;
     1303begin
     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);
     1311end;
     1312
     1313constructor TCoolDockClient.Create(AOwner: TComponent);
     1314begin
     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;
     1327end;
     1328
     1329destructor TCoolDockClient.Destroy;
     1330begin
     1331  inherited Destroy;
     1332  Master := nil;
     1333end;
     1334
     1335procedure TCoolDockClient.SetPanel(const AValue: TPanel);
     1336var
     1337  OldPanel: TPanel;
     1338begin
     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;
     1352end;
    12271353
    12281354end.
Note: See TracChangeset for help on using the changeset viewer.