Ignore:
Timestamp:
Mar 11, 2011, 10:07:38 AM (14 years ago)
Author:
george
Message:
  • Modified: Classes which iherits from TCDStyle changed to inherit from TCDManager. Now all styles will be different dock managers. Field DockStyleHanler of TCDManager removed and DockStyle property changes TCDManager descendends.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCDLayout.pas

    r189 r191  
    2121    HostDockSiteName: string;
    2222    Caption: string;
    23     Visible: Boolean;
     23    Visible: boolean;
    2424    Rect: TRectangle;
    2525    RestoredRect: TRectangle;
     
    2727    UndockSize: TPoint;
    2828    DockStyle: TCDStyleType;
    29     Processed: Boolean;
     29    Processed: boolean;
    3030    procedure SaveToNode(Node: TDOMNode);
    3131    procedure LoadFromNode(Node: TDOMNode);
     
    7979function FindGlobalComponentDeep(Name: string): TComponent;
    8080var
    81   I: Integer;
    82 begin
    83   for I := 0 to Application.ComponentCount - 1 do begin
     81  I: integer;
     82begin
     83  for I := 0 to Application.ComponentCount - 1 do
     84  begin
    8485    Result := Application.Components[I];
    85     if Result.Name = Name then Exit
    86       else begin
    87         Result := Result.FindComponent(Name);
    88         if Assigned(Result) and (Result.Name = Name) then Exit;
    89       end;
     86    if Result.Name = Name then
     87      Exit
     88    else
     89    begin
     90      Result := Result.FindComponent(Name);
     91      if Assigned(Result) and (Result.Name = Name) then
     92        Exit;
     93    end;
    9094  end;
    9195end;
     
    116120    ReadXMLFile(Doc, Stream);
    117121    Items.Clear;
    118     with Doc.DocumentElement do begin
     122    with Doc.DocumentElement do
     123    begin
    119124      NewNode := FindNode('Items');
    120125      if Assigned(NewNode) then
    121       with NewNode do begin
    122         Child := FirstChild;
    123         while Assigned(Child) do begin
    124           NewItem := TCDLayout.Create;
    125           NewItem.LoadFromNode(Child);
    126           Items.Add(NewItem);
    127           Child := Child.NextSibling;
     126        with NewNode do
     127        begin
     128          Child := FirstChild;
     129          while Assigned(Child) do
     130          begin
     131            NewItem := TCDLayout.Create;
     132            NewItem.LoadFromNode(Child);
     133            Items.Add(NewItem);
     134            Child := Child.NextSibling;
     135          end;
    128136        end;
    129       end;
    130137    end;
    131138  finally
     
    138145  Doc: TXMLDocument;
    139146  RootNode: TDOMNode;
    140   I: Integer;
     147  I: integer;
    141148  NewNode: TDOMNode;
    142149  NewNode2: TDOMNode;
     
    144151  try
    145152    Doc := TXMLDocument.Create;
    146     with Doc do begin
     153    with Doc do
     154    begin
    147155      RootNode := CreateElement('CoolDockLayout');
    148156      AppendChild(RootNode);
    149       with RootNode do begin
     157      with RootNode do
     158      begin
    150159        NewNode := OwnerDocument.CreateElement('Items');
    151160        with NewNode do
    152         for I := 0 to Items.Count - 1 do begin
    153           NewNode2 := OwnerDocument.CreateElement('Layout');
    154           TCDLayout(Items[I]).SaveToNode(NewNode2);
    155           AppendChild(NewNode2);
    156          end;
     161          for I := 0 to Items.Count - 1 do
     162          begin
     163            NewNode2 := OwnerDocument.CreateElement('Layout');
     164            TCDLayout(Items[I]).SaveToNode(NewNode2);
     165            AppendChild(NewNode2);
     166          end;
    157167        AppendChild(NewNode);
    158168      end;
     
    181191begin
    182192  try
    183     if FileExistsUTF8(FileName) then Stream := TFileStream.Create(FileName, fmOpenReadWrite)
    184       else Stream := TFileStream.Create(FileName, fmCreate);
     193    if FileExistsUTF8(FileName) then
     194      Stream := TFileStream.Create(FileName, fmOpenReadWrite)
     195    else
     196      Stream := TFileStream.Create(FileName, fmCreate);
    185197    Stream.Size := 0;
    186198    SaveToStream(Stream);
     
    192204procedure TCDLayoutList.PopulateStringList(List: TStrings);
    193205var
    194   I: Integer;
     206  I: integer;
    195207begin
    196208  List.Clear;
     
    201213function TCDLayoutList.FindByName(Name: string): TCDLayout;
    202214var
    203   I: Integer;
     215  I: integer;
    204216begin
    205217  I := 0;
    206   while (I < Items.Count) and (TCDLayout(Items[I]).Name <> Name) do Inc(I);
    207   if I < Items.Count then Result := TCDLayout(Items[I])
    208     else Result := nil;
     218  while (I < Items.Count) and (TCDLayout(Items[I]).Name <> Name) do
     219    Inc(I);
     220  if I < Items.Count then
     221    Result := TCDLayout(Items[I])
     222  else
     223    Result := nil;
    209224end;
    210225
     
    215230  NewNode: TDOMNode;
    216231begin
    217   with Node do begin
     232  with Node do
     233  begin
    218234    NewNode := OwnerDocument.CreateElement('Name');
    219235    NewNode.TextContent := UTF8Decode(Name);
     
    232248    AppendChild(NewNode);
    233249    NewNode := OwnerDocument.CreateElement('WindowState');
    234     NewNode.TextContent := IntToStr(Integer(WindowState));
     250    NewNode.TextContent := IntToStr(integer(WindowState));
    235251    AppendChild(NewNode);
    236252    NewNode := OwnerDocument.CreateElement('UndockWidth');
     
    256272    AppendChild(NewNode);
    257273    NewNode := OwnerDocument.CreateElement('DockStyle');
    258     NewNode.TextContent := IntToStr(Integer(DockStyle));
     274    NewNode.TextContent := IntToStr(integer(DockStyle));
    259275    AppendChild(NewNode);
    260276    NewNode := OwnerDocument.CreateElement('RestoredWidth');
     
    277293  NewNode: TDOMNode;
    278294begin
    279   with TDOMElement(Node) do begin
     295  with TDOMElement(Node) do
     296  begin
    280297    NewNode := FindNode('Name');
    281298    if Assigned(NewNode) then
     
    349366  Rect.Width := Form.Width;
    350367  Rect.Height := Form.Height;
    351   if Form is TForm then begin
     368  if Form is TForm then
     369  begin
    352370    RestoredRect.Left := TForm(Form).RestoredLeft;
    353371    RestoredRect.Top := TForm(Form).RestoredTop;
     
    358376  if Assigned(Form.Parent) then
    359377    ParentName := Form.Parent.Name
    360     else ParentName := '';
    361   if Assigned(Form.HostDockSite) then begin
     378  else
     379    ParentName := '';
     380  if Assigned(Form.HostDockSite) then
     381  begin
    362382    if Assigned(Form.HostDockSite) then
    363383    begin
    364384      HostDockSiteName := Form.HostDockSite.Name;
    365       if not Assigned(Parent.FindByName(HostDockSiteName)) then begin
     385      if not Assigned(Parent.FindByName(HostDockSiteName)) then
     386      begin
    366387        NewItem := TCDLayoutItem.Create;
    367388        NewItem.Parent := Parent;
     
    371392      end;
    372393    end;
    373   end else HostDockSiteName := '';
     394  end
     395  else
     396    HostDockSiteName := '';
    374397end;
    375398
     
    381404begin
    382405  if Form is TForm then
    383   if WindowState = wsMaximized then begin
    384     TForm(Form).SetRestoredBounds(RestoredRect.Left, RestoredRect.Top,
    385       RestoredRect.Width, RestoredRect.Height);
    386     TForm(Form).WindowState := WindowState;
    387   end else begin
    388     TForm(Form).WindowState := WindowState;
    389     TForm(Form).SetRestoredBounds(RestoredRect.Left, RestoredRect.Top,
    390       RestoredRect.Width, RestoredRect.Height);
    391   end;
     406    if WindowState = wsMaximized then
     407    begin
     408      TForm(Form).SetRestoredBounds(RestoredRect.Left, RestoredRect.Top,
     409        RestoredRect.Width, RestoredRect.Height);
     410      TForm(Form).WindowState := WindowState;
     411    end
     412    else
     413    begin
     414      TForm(Form).WindowState := WindowState;
     415      TForm(Form).SetRestoredBounds(RestoredRect.Left, RestoredRect.Top,
     416        RestoredRect.Width, RestoredRect.Height);
     417    end;
    392418  Form.Name := Name;
    393419  Form.Caption := Caption;
     
    396422  Form.UndockHeight := UndockSize.Y;
    397423  Form.Visible := Visible;
    398   if HostDockSiteName <> '' then begin
     424  if HostDockSiteName <> '' then
     425  begin
    399426    ParentComponent := FindGlobalComponentDeep(HostDockSiteName);
    400     if not Assigned(ParentComponent) then begin
     427    if not Assigned(ParentComponent) then
     428    begin
    401429      ParentLayoutItem := Parent.FindByName(HostDockSiteName);
    402       if Assigned(ParentLayoutItem) then begin
    403         if ParentLayoutItem.StoredClassName <> '' then begin
     430      if Assigned(ParentLayoutItem) then
     431      begin
     432        if ParentLayoutItem.StoredClassName <> '' then
     433        begin
    404434          //ParentComponent := TComponent(FindClass(ParentLayoutItem.StoredClassName).Create);
    405           if (ParentLayoutItem.StoredClassName = 'TCoolDockConjoinForm') then begin
    406             FormClass := TFormClass(FindClass('TCoolDockConjoinForm'));
    407             if FormClass = TCDConjoinForm then begin
     435          if (ParentLayoutItem.StoredClassName = 'TCDConjoinForm') then
     436          begin
     437            FormClass := TFormClass(FindClass('TCDConjoinForm'));
     438            if FormClass = TCDConjoinForm then
     439            begin
    408440              ParentComponent := TCDManager(Form.DockManager).CreateContainer(alNone);
    409               TCDManager(TCDConjoinForm(ParentComponent).DockManager).DockStyle := ParentLayoutItem.DockStyle;
     441              TCDManager(TCDConjoinForm(ParentComponent).DockManager).DockStyle :=
     442                ParentLayoutItem.DockStyle;
    410443              ParentLayoutItem.Restore(TWinControl(ParentComponent));
    411444            end;
     
    439472  NewNode: TDOMNode;
    440473  NewNode2: TDOMNode;
    441   I: Integer;
    442 begin
    443   with Node do begin
     474  I: integer;
     475begin
     476  with Node do
     477  begin
    444478    NewNode := OwnerDocument.CreateElement('Name');
    445479    NewNode.TextContent := UTF8Decode(Name);
     
    447481    NewNode := OwnerDocument.CreateElement('Items');
    448482    with NewNode do
    449     for I := 0 to Items.Count - 1 do begin
    450       NewNode2 := OwnerDocument.CreateElement('Form');
    451       TCDLayoutItem(Items[I]).SaveToNode(NewNode2);
    452       AppendChild(NewNode2);
    453     end;
     483      for I := 0 to Items.Count - 1 do
     484      begin
     485        NewNode2 := OwnerDocument.CreateElement('Form');
     486        TCDLayoutItem(Items[I]).SaveToNode(NewNode2);
     487        AppendChild(NewNode2);
     488      end;
    454489    AppendChild(NewNode);
    455490  end;
     
    462497  NewItem: TCDLayoutItem;
    463498begin
    464   with Node do begin
     499  with Node do
     500  begin
    465501    NewNode := FindNode('Name');
    466502    if Assigned(NewNode) then
     
    468504    NewNode := FindNode('Items');
    469505    if Assigned(NewNode) then
    470     with NewNode do begin
    471       Child := FirstChild;
    472       while Assigned(Child) do begin
    473         NewItem := TCDLayoutItem.Create;
    474         NewItem.Parent := Self;
    475         NewItem.LoadFromNode(Child);
    476         Items.Add(NewItem);
    477         Child := Child.NextSibling;
     506      with NewNode do
     507      begin
     508        Child := FirstChild;
     509        while Assigned(Child) do
     510        begin
     511          NewItem := TCDLayoutItem.Create;
     512          NewItem.Parent := Self;
     513          NewItem.LoadFromNode(Child);
     514          Items.Add(NewItem);
     515          Child := Child.NextSibling;
     516        end;
    478517      end;
    479     end;
    480518  end;
    481519end;
     
    483521function TCDLayout.FindByName(Name: string): TCDLayoutItem;
    484522var
    485   I: Integer;
     523  I: integer;
    486524begin
    487525  I := 0;
    488   while (I < Items.Count) and (TCDLayoutItem(Items[I]).Name <> Name) do Inc(I);
    489   if I < Items.Count then Result := TCDLayoutItem(Items[I])
    490     else Result := nil;
     526  while (I < Items.Count) and (TCDLayoutItem(Items[I]).Name <> Name) do
     527    Inc(I);
     528  if I < Items.Count then
     529    Result := TCDLayoutItem(Items[I])
     530  else
     531    Result := nil;
    491532end;
    492533
     
    504545procedure TCDLayout.Store;
    505546var
    506   I: Integer;
     547  I: integer;
    507548  Form: TForm;
    508549  NewItem: TCDLayoutItem;
     
    510551  Items.Clear;
    511552  for I := 0 to Application.ComponentCount - 1 do
    512   if (Application.Components[I] is TForm) then begin
    513     Form := (Application.Components[I] as TForm);
    514     NewItem := TCDLayoutItem.Create;
    515     NewItem.Parent := Self;
    516     NewItem.Store(Form);
    517     Items.Add(NewItem);
    518   end;
     553    if (Application.Components[I] is TForm) then
     554    begin
     555      Form := (Application.Components[I] as TForm);
     556      NewItem := TCDLayoutItem.Create;
     557      NewItem.Parent := Self;
     558      NewItem.Store(Form);
     559      Items.Add(NewItem);
     560    end;
    519561end;
    520562
     
    522564var
    523565  Form: TForm;
    524   I: Integer;
     566  I: integer;
    525567begin
    526568  // Undock all forms
    527569  I := 0;
    528   while (I < Application.ComponentCount) do begin
    529     if (Application.Components[I] is TForm) then begin
     570  while (I < Application.ComponentCount) do
     571  begin
     572    if (Application.Components[I] is TForm) then
     573    begin
    530574      Form := (Application.Components[I] as TForm);
    531575      if Assigned(Form.HostDockSite) then
    532         Form.ManualFloat(Rect(Form.Left, Form.Top, Form.Left + Form.Width, Form.Top + Form.Height));
     576        Form.ManualFloat(Rect(Form.Left, Form.Top, Form.Left +
     577          Form.Width, Form.Top + Form.Height));
    533578    end;
    534579    Inc(I);
     
    536581
    537582  for I := 0 to Items.Count - 1 do
    538   with TCDLayoutItem(Items[I]) do
    539     Processed := False;
     583    with TCDLayoutItem(Items[I]) do
     584      Processed := False;
    540585
    541586  for I := 0 to Items.Count - 1 do
    542   with TCDLayoutItem(Items[I]) do begin
    543     Form := TForm(Application.FindComponent(Name));
    544     if Assigned(Form) and (not Assigned(Form.HostDockSite)) and (not Processed) then Restore(Form);
    545   end;
     587    with TCDLayoutItem(Items[I]) do
     588    begin
     589      Form := TForm(Application.FindComponent(Name));
     590      if Assigned(Form) and (not Assigned(Form.HostDockSite)) and (not Processed) then
     591        Restore(Form);
     592    end;
    546593end;
    547594
Note: See TracChangeset for help on using the changeset viewer.