Ignore:
Timestamp:
Mar 9, 2011, 2:11:40 PM (14 years ago)
Author:
george
Message:
  • Added: Default layout initialization in Demo IDE.
  • Fixed: Tab position switching through popup menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r181 r182  
    4040  end;
    4141
    42   // TObjectList<TCoolDockClientPanel>
    4342
    4443  { TCoolDockPanels }
    4544
     45  // TCoolDockPanels = TObjectList<TCoolDockClientPanel>
    4646  TCoolDockPanels = class(TObjectList)
    4747    destructor Destroy; override;
     
    5050  { TCoolDockManager }
    5151
    52   TCoolDockManager = class(TDockManager)
     52  TCoolDockManager = class(TCoolDockManagerBase)
    5353  private
    5454    FMaster: TCoolDockMaster;
     
    104104    property HeaderPos: THeaderPos read GetHeaderPos write SetHeaderPos;
    105105    property Visible: Boolean write SetVisible;
     106    property DockDirection: TDockDirection read FDockDirection
     107      write FDockDirection;
    106108  end;
    107109
     
    120122    procedure SetTabsEnabled(const AValue: Boolean);
    121123  public
    122     procedure SaveLayoutToStream(Stream: TStream);
    123     procedure LoadLayoutFromStream(Stream: TStream);
    124     procedure SaveLayoutToFile(FileName: string);
    125     procedure LoadLayoutFromFile(FileName: string);
    126124    constructor Create(AOwner: TComponent); override;
    127125    destructor Destroy; override;
     
    332330    Control.Parent := NewPanel.ClientAreaPanel;
    333331    Control.Align := alClient;
    334     FDockPanels.Add(NewPanel);
     332    if (InsertAt = alTop) or (InsertAt = alLeft) then
     333      FDockPanels.Insert(0, NewPanel)
     334      else FDockPanels.Add(NewPanel);
    335335    UpdateClientSize;
    336336end;
     
    550550  with TCoolDockManager(Panel.DockManager) do
    551551  for I := 0 to DockPanels.Count - 1 do
    552     if Assigned(TCoolDockClientPanel(DockPanels[I]).Control) then
    553     TCoolDockClientPanel(DockPanels[I]).Control.Hide;
     552    if Assigned(TCoolDockClientPanel(DockPanels[I]).Control) then begin
     553      TCoolDockClientPanel(DockPanels[I]).Control.Tag := Integer(dhtTemporal);
     554      TCoolDockClientPanel(DockPanels[I]).Control.Hide;
     555    end;
    554556end;
    555557
     
    614616  if FShowIcons = AValue then Exit;
    615617  FShowIcons := AValue;
    616 end;
    617 
    618 procedure TCoolDockMaster.SaveLayoutToStream(Stream: TStream);
    619 var
    620   Doc: TXMLDocument;
    621   RootNode: TDOMNode;
    622   NewNode: TDOMNode;
    623   NewNode2: TDOMNode;
    624   I: Integer;
    625 begin
    626   Doc := TXMLDocument.Create;
    627   with Doc do try
    628     RootNode := CreateElement('DockLayout');
    629     AppendChild(RootNode);
    630     with RootNode do begin
    631       for I := 0 to Application.ComponentCount - 1 do begin
    632         if Application.Components[I] is TForm then
    633         with Application.Components[I] as TForm do
    634         if Assigned(HostDockSite) then
    635         begin
    636           NewNode := OwnerDocument.CreateElement('Form');
    637 
    638           if HostDockSite.Parent is TForm then begin
    639             NewNode2 := OwnerDocument.CreateElement('ParentFormName');
    640             NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.Name);
    641             NewNode.AppendChild(NewNode2);
    642 
    643             NewNode2 := OwnerDocument.CreateElement('ParentFormClassName');
    644             NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.ClassName);
    645             NewNode.AppendChild(NewNode2);
    646           end;
    647 
    648           NewNode2 := OwnerDocument.CreateElement('Name');
    649           NewNode2.TextContent := UTF8Decode(Name);
    650           NewNode.AppendChild(NewNode2);
    651 
    652           NewNode2 := OwnerDocument.CreateElement('Caption');
    653           NewNode2.TextContent := UTF8Decode(Caption);
    654           NewNode.AppendChild(NewNode2);
    655 
    656           NewNode2 := OwnerDocument.CreateElement('Width');
    657           NewNode2.TextContent := IntToStr(Width);
    658           NewNode.AppendChild(NewNode2);
    659 
    660           NewNode2 := OwnerDocument.CreateElement('Height');
    661           NewNode2.TextContent := IntToStr(Height);
    662           NewNode.AppendChild(NewNode2);
    663 
    664           NewNode2 := OwnerDocument.CreateElement('UndockWidth');
    665           NewNode2.TextContent := IntToStr(UndockWidth);
    666           NewNode.AppendChild(NewNode2);
    667 
    668           NewNode2 := OwnerDocument.CreateElement('UndockHeight');
    669           NewNode2.TextContent := IntToStr(UndockHeight);
    670           NewNode.AppendChild(NewNode2);
    671 
    672           NewNode2 := OwnerDocument.CreateElement('FormState');
    673           NewNode2.TextContent := IntToStr(Integer(FormState));
    674           NewNode.AppendChild(NewNode2);
    675 
    676           NewNode2 := OwnerDocument.CreateElement('Visible');
    677           NewNode2.TextContent := IntToStr(Integer(Visible));
    678           NewNode.AppendChild(NewNode2);
    679 
    680           AppendChild(NewNode);
    681         end;
    682       end;
    683     end;
    684     WriteXMLFile(Doc, Stream);
    685   finally
    686     Free;
    687   end;
    688 end;
    689 
    690 procedure TCoolDockMaster.LoadLayoutFromStream(Stream: TStream);
    691 begin
    692 
    693 end;
    694 
    695 procedure TCoolDockMaster.SaveLayoutToFile(FileName: string);
    696 var
    697   LayoutFile: TFileStream;
    698 begin
    699   try
    700     if FileExistsUTF8(FileName) then
    701     LayoutFile := TFileStream.Create(FileName, fmOpenReadWrite)
    702     else LayoutFile := TFileStream.Create(FileName, fmCreate);
    703     SaveLayoutToStream(LayoutFile);
    704   finally
    705     LayoutFile.Free;
    706   end;
    707 end;
    708 
    709 procedure TCoolDockMaster.LoadLayoutFromFile(FileName: string);
    710 var
    711   LayoutFile: TFileStream;
    712 begin
    713   LayoutFile := TFileStream.Create(FileName, fmOpenRead);
    714   try
    715     LoadLayoutFromStream(LayoutFile);
    716   finally
    717     Free;
    718   end;
    719618end;
    720619
Note: See TracChangeset for help on using the changeset viewer.