Ignore:
Timestamp:
Sep 20, 2010, 1:15:16 PM (14 years ago)
Author:
george
Message:
  • Opraveno: Neuvolněná paměť vytvářených sdružených oken.
  • Opraveno: Komponenta formuláře pro volby kotvení předělána z TForm na TComponent, které volá TForm.Show pomocí metody Execute.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r54 r55  
    99uses
    1010  Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls,
    11   Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil;
     11  Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil,
     12  UCoolDockCustomize, DOM, XMLWrite, XMLRead;
    1213
    1314const
     
    8889    procedure InsertControlPanel(Control: TControl; InsertAt: TAlign;
    8990      DropCtl: TControl);
     91    procedure PopupMenuTabCloseClick(Sender: TObject);
    9092    procedure SetDockStyle(const AValue: TDockStyle);
    9193    procedure SetMoveDuration(const AValue: Integer);
     
    102104    procedure PopupMenuPositionTopClick(Sender: TObject);
    103105    procedure PopupMenuPositionBottomClick(Sender: TObject);
     106    procedure PopupMenuUndockClick(Sender: TObject);
    104107    procedure Timer1Timer(Sender: TObject);
     108    procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;
     109      Shift: TShiftState; X, Y: Integer);
    105110  public
    106111    constructor Create(ADockSite: TWinControl); override;
     
    168173  SPositionRight = 'Right';
    169174  SPositionBottom = 'Bottom';
     175  SUndock = 'Undock';
    170176
    171177procedure Register;
    172178begin
    173179  RegisterComponents('CoolDocking', [TCoolDockMaster]);
     180  RegisterComponents('CoolDocking', [TCoolDockCustomize]);
    174181end;
    175182
     
    254261  NewMenuItem.Caption := SRenameForm;
    255262  NewMenuItem.OnClick := PopupMenuRenameClick;
     263  PopupMenu1.Items.Add(NewMenuItem);
     264
     265  NewMenuItem := TMenuItem.Create(PopupMenu1);
     266  NewMenuItem.Caption := SUndock;
     267  NewMenuItem.OnClick := PopupMenuUndockClick;
    256268  PopupMenu1.Items.Add(NewMenuItem);
    257269
     
    264276    OnChange := TabControlChange;
    265277    PopupMenu := PopupMenu1;
     278    OnMouseDown := TabControlMouseDown;
    266279  end;
    267280  TabsPos := hpTop;
     
    344357      if DockStyle = dsList then Visible := True;
    345358      Align := alClient;
    346       PopupMenu := PopupMenu1;
    347359    end;
    348360
     
    376388    if (not Assigned(FDockSite.Parent)) then begin
    377389      // Create conjointed form
    378       NewConjoinDockForm := TCoolDockConjoinForm.Create(nil);
     390      NewConjoinDockForm := TCoolDockConjoinForm.Create(Application);
    379391      NewConjoinDockForm.Visible := True;
    380392      NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect;
     
    382394      Control.ManualDock(NewConjoinDockForm.Panel, nil, InsertAt);
    383395    end else begin
    384       NewConjoinDockForm := TCoolDockConjoinForm.Create(nil);
     396      NewConjoinDockForm := TCoolDockConjoinForm.Create(Application);
    385397      NewConjoinDockForm.Visible := True;
    386398      NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect;
     
    464476    FDockPanels.Remove(ClientPanel);
    465477    if FDockSite.DockClientCount = 2 then FDockDirection := ddNone;
     478    UpdateClientSize;
    466479    //FDockSite.Invalidate;
    467480    //if (FDockSite is TCoolDockConjoinForm) and (FDockSite.DockClientCount = 1) then
     
    498511  NewConjoinDockForm: TCoolDockConjoinForm;
    499512begin
    500   NewConjoinDockForm := TCoolDockConjoinForm.Create(nil);
     513  NewConjoinDockForm := TCoolDockConjoinForm.Create(Application);
    501514  NewConjoinDockForm.Visible := True;
    502515  NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect;
     
    632645procedure TCoolDockManager.PopupMenuCloseClick(Sender: TObject);
    633646begin
    634 //  TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
     647  TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
     648end;
     649
     650procedure TCoolDockManager.PopupMenuTabCloseClick(Sender: TObject);
     651begin
     652  if TabControl.TabIndex <> -1 then
     653    TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control.Hide;
    635654end;
    636655
     
    665684end;
    666685
     686procedure TCoolDockManager.PopupMenuUndockClick(Sender: TObject);
     687begin
     688
     689end;
     690
    667691procedure TCoolDockManager.Timer1Timer(Sender: TObject);
    668692begin
    669693//  TimerMoveForm.Width := TimerMoveForm.Width
     694end;
     695
     696procedure TCoolDockManager.TabControlMouseDown(Sender: TObject; Button: TMouseButton;
     697      Shift: TShiftState; X, Y: Integer);
     698begin
     699  if (Button = mbLeft) and (TabControl.TabIndex <> -1) then begin
     700    DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1);
     701  end;
    670702end;
    671703
     
    803835
    804836procedure TCoolDockMaster.SaveLayoutToStream(Stream: TStream);
    805 begin
    806 
     837var
     838  Doc: TXMLDocument;
     839  RootNode: TDOMNode;
     840  NewNode: TDOMNode;
     841  NewNode2: TDOMNode;
     842  I: Integer;
     843begin
     844  Doc := TXMLDocument.Create;
     845  with Doc do try
     846    RootNode := CreateElement('DockLayout');
     847    AppendChild(RootNode);
     848    with RootNode do begin
     849      for I := 0 to Application.ComponentCount - 1 do begin
     850        if Application.Components[I] is TForm then
     851        with Application.Components[I] as TForm do
     852        if Assigned(HostDockSite) then
     853        begin
     854          NewNode := OwnerDocument.CreateElement('Form');
     855
     856          if HostDockSite.Parent is TForm then begin
     857            NewNode2 := OwnerDocument.CreateElement('ParentFormName');
     858            NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.Name);
     859            NewNode.AppendChild(NewNode2);
     860
     861            NewNode2 := OwnerDocument.CreateElement('ParentFormClassName');
     862            NewNode2.TextContent := UTF8Decode(HostDockSite.Parent.ClassName);
     863            NewNode.AppendChild(NewNode2);
     864          end;
     865
     866          NewNode2 := OwnerDocument.CreateElement('Name');
     867          NewNode2.TextContent := UTF8Decode(Name);
     868          NewNode.AppendChild(NewNode2);
     869
     870          NewNode2 := OwnerDocument.CreateElement('Caption');
     871          NewNode2.TextContent := UTF8Decode(Caption);
     872          NewNode.AppendChild(NewNode2);
     873
     874          NewNode2 := OwnerDocument.CreateElement('Width');
     875          NewNode2.TextContent := IntToStr(Width);
     876          NewNode.AppendChild(NewNode2);
     877
     878          NewNode2 := OwnerDocument.CreateElement('Height');
     879          NewNode2.TextContent := IntToStr(Height);
     880          NewNode.AppendChild(NewNode2);
     881
     882          NewNode2 := OwnerDocument.CreateElement('UndockWidth');
     883          NewNode2.TextContent := IntToStr(UndockWidth);
     884          NewNode.AppendChild(NewNode2);
     885
     886          NewNode2 := OwnerDocument.CreateElement('UndockHeight');
     887          NewNode2.TextContent := IntToStr(UndockHeight);
     888          NewNode.AppendChild(NewNode2);
     889
     890          NewNode2 := OwnerDocument.CreateElement('FormState');
     891          NewNode2.TextContent := IntToStr(Integer(FormState));
     892          NewNode.AppendChild(NewNode2);
     893
     894          NewNode2 := OwnerDocument.CreateElement('Visible');
     895          NewNode2.TextContent := IntToStr(Integer(Visible));
     896          NewNode.AppendChild(NewNode2);
     897
     898          AppendChild(NewNode);
     899        end;
     900      end;
     901    end;
     902    WriteXMLFile(Doc, Stream);
     903  finally
     904    Free;
     905  end;
    807906end;
    808907
Note: See TracChangeset for help on using the changeset viewer.