Changeset 44 for DockManager/Lazarus


Ignore:
Timestamp:
Sep 16, 2010, 2:15:02 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Částečná implementace umělého ukotvovacího okna.
Location:
DockManager/Lazarus
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • DockManager/Lazarus/Demo/UMainForm.lfm

    r42 r44  
    2929    DockSite = True
    3030    TabOrder = 1
    31     OnMouseDown = Panel1MouseDown
    3231  end
    3332end
  • DockManager/Lazarus/Demo/UMainForm.pas

    r43 r44  
    1919    procedure FormCreate(Sender: TObject);
    2020    procedure FormShow(Sender: TObject);
    21     procedure ListView1EndDrag(Sender, Target: TObject; X, Y: Integer);
    22     procedure ListView1StartDrag(Sender: TObject; var DragObject: TDragObject);
    23     procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
    24       Shift: TShiftState; X, Y: Integer);
    2521  private
    2622    { private declarations }
     
    2824    FormIndex: Integer;
    2925    LastDockForm: TDockForm;
     26    function NewDockForm: TDockForm;
    3027  end;
    3128
     
    4946  DockForm3: TDockForm;
    5047begin
    51   Button1Click(Self);
    52   DockForm1 := LastDockForm;
     48  DockForm1 := NewDockForm;
    5349  DockForm1.ManualDock(Panel1);
    5450
    55   Button1Click(Self);
    56   DockForm2 := LastDockForm;
     51  DockForm2 := NewDockForm;
    5752  DockForm2.ManualDock(Panel1);
    5853
    59   Button1Click(Self);
    60   DockForm3 := LastDockForm;
     54  DockForm3 := NewDockForm;
    6155  DockForm3.ManualDock(DockForm2);
    6256end;
    6357
    64 procedure TMainForm.ListView1EndDrag(Sender, Target: TObject; X, Y: Integer);
     58function TMainForm.NewDockForm: TDockForm;
    6559begin
    66 
    67 end;
    68 
    69 procedure TMainForm.ListView1StartDrag(Sender: TObject;
    70   var DragObject: TDragObject);
    71 begin
    72 
    73 end;
    74 
    75 procedure TMainForm.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
    76   Shift: TShiftState; X, Y: Integer);
    77 begin
    78 
     60  Result := TDockForm.Create(Self);
     61  Result.Name := 'Form' + IntToStr(FormIndex);
     62  Result.Memo1.Text := Result.Name;
     63  Result.DragKind := dkDock;
     64  Result.DragMode := dmAutomatic;
     65  Result.DockSite := True;
     66  Result.UseDockManager := True;
     67  Inc(FormIndex);
     68  Result.Show;
    7969end;
    8070
    8171procedure TMainForm.Button1Click(Sender: TObject);
    82 var
    83   NewForm: TDockForm;
    8472begin
    85   NewForm := TDockForm.Create(Self);
    86   NewForm.Name := 'Form' + IntToStr(FormIndex);
    87   NewForm.Memo1.Text := NewForm.Name;
    88   NewForm.DragKind := dkDock;
    89   NewForm.DragMode := dmAutomatic;
    90   NewForm.DockSite := True;
    91   NewForm.UseDockManager := True;
    92   Inc(FormIndex);
    93   NewForm.Show;
    94   LastDockForm := NewForm;
     73  NewDockForm;
    9574end;
    9675
  • DockManager/Lazarus/UCustomDockManager.pas

    r43 r44  
    1717  TCustomDockManager = class;
    1818
     19  { TConjoinDockForm }
     20
    1921  TConjoinDockForm = class(TForm)
    20 
     22    Panel: TPanel;
     23    constructor Create(TheOwner: TComponent); override;
    2124  end;
    2225
     
    130133  NewPanel: TDockClientPanel;
    131134  I: Integer;
    132 begin
    133   if FDockSite.DockClientCount = 2 then begin
    134     if (InsertAt = alTop) or (InsertAt = alBottom) then
    135       FDockDirection := ddVertical
    136     else
    137     if (InsertAt = alLeft) or (InsertAt = alRight) then
    138       FDockDirection := ddHorizontal
    139     else FDockDirection := ddHorizontal;
    140   end;
    141   if FDockSite.DockClientCount > 1 then begin
    142     NewSplitter := TSplitter.Create(nil);
    143     NewSplitter.Parent := FDockSite;
    144     NewSplitter.Visible := True;
    145     NewSplitter.Color := clRed;
    146     with NewSplitter do
    147     if FDockDirection = ddVertical then begin
    148       Align := alTop;
    149       Top := FDockSite.Height;
    150     end else
    151     if FDockDirection = ddHorizontal then begin
    152       Align := alLeft;
    153       Left := FDockSite.Width;
    154     end;
    155 
    156     with TDockClientPanel(FDockPanels.Last) do
    157     if FDockDirection = ddVertical then
    158       Align := alTop
    159     else
    160     if FDockDirection = ddHorizontal then
    161       Align := alLeft;
    162   end;
    163   NewPanel := TDockClientPanel.Create(nil);
    164   with NewPanel do begin
    165     Splitter := NewSplitter;
    166     Parent := FDockSite;
    167     OwnerDockManager := Self;
    168     Visible := True;
    169     Align := alClient;
    170   end;
    171   NewPanel.Control := Control;
    172   Control.Parent := NewPanel;
    173   FDockPanels.Add(NewPanel);
    174 
    175   for I := 0 to FDockPanels.Count - 1 do begin
    176     TDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div
    177       FDockSite.DockClientCount;
    178     TDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div
    179       FDockSite.DockClientCount;
     135  NewConjoinDockForm: TConjoinDockForm;
     136begin
     137  if (FDockSite is TForm) and (not Assigned(FDockSite.Parent)) then begin
     138    NewConjoinDockForm := TConjoinDockForm.Create(nil);
     139    NewConjoinDockForm.Visible := True;
     140    Control.ManualDock(NewConjoinDockForm.Panel);
     141    FDockSite.ManualDock(NewConjoinDockForm.Panel);
     142  end else
     143  if FDockSite is TPanel then begin
     144    if FDockSite.DockClientCount = 2 then begin
     145      if (InsertAt = alTop) or (InsertAt = alBottom) then
     146        FDockDirection := ddVertical
     147      else
     148      if (InsertAt = alLeft) or (InsertAt = alRight) then
     149        FDockDirection := ddHorizontal
     150      else FDockDirection := ddHorizontal;
     151    end;
     152    if FDockSite.DockClientCount > 1 then begin
     153      NewSplitter := TSplitter.Create(nil);
     154      NewSplitter.Parent := FDockSite;
     155      NewSplitter.Visible := True;
     156      NewSplitter.Color := clRed;
     157      with NewSplitter do
     158      if FDockDirection = ddVertical then begin
     159        Align := alTop;
     160        Top := FDockSite.Height;
     161      end else
     162      if FDockDirection = ddHorizontal then begin
     163        Align := alLeft;
     164        Left := FDockSite.Width;
     165      end;
     166
     167      with TDockClientPanel(FDockPanels.Last) do
     168      if FDockDirection = ddVertical then
     169        Align := alTop
     170      else
     171      if FDockDirection = ddHorizontal then
     172        Align := alLeft;
     173    end;
     174    NewPanel := TDockClientPanel.Create(nil);
     175    with NewPanel do begin
     176      Splitter := NewSplitter;
     177      Parent := FDockSite;
     178      OwnerDockManager := Self;
     179      Visible := True;
     180      Align := alClient;
     181    end;
     182    NewPanel.Control := Control;
     183    Control.Parent := NewPanel;
     184    FDockPanels.Add(NewPanel);
     185
     186    for I := 0 to FDockPanels.Count - 1 do begin
     187      TDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div
     188        FDockSite.DockClientCount;
     189      TDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div
     190        FDockSite.DockClientCount;
     191    end;
    180192  end;
    181193
     
    243255  if Control.HostDockSite = Self.FDockSite then begin
    244256    ClientPanel := FindControlInPanels(Control);
    245     //ClientPanel.Splitter.Free;
     257    //if Assigned(ClientPanel) then ClientPanel.Splitter.Free;
    246258    FDockPanels.Remove(ClientPanel);
    247259    if FDockSite.DockClientCount = 2 then FDockDirection := ddNone;
     
    350362end;
    351363
     364{ TConjoinDockForm }
     365
     366constructor TConjoinDockForm.Create(TheOwner: TComponent);
     367begin
     368  inherited Create(TheOwner);
     369  Panel := TPanel.Create(Self);
     370  with Panel do begin
     371    Parent := Self;
     372    DockSite := True;
     373    UseDockManager := True;
     374    Align := alClient;
     375  end;
     376  DragKind := dkDock;
     377  DragMode := dmAutomatic;
     378end;
     379
    352380initialization
    353381  DefaultDockManagerClass := TCustomDockManager;
Note: See TracChangeset for help on using the changeset viewer.