Changeset 44
- Timestamp:
- Sep 16, 2010, 2:15:02 PM (14 years ago)
- Location:
- DockManager/Lazarus
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DockManager/Lazarus/Demo/UMainForm.lfm
r42 r44 29 29 DockSite = True 30 30 TabOrder = 1 31 OnMouseDown = Panel1MouseDown32 31 end 33 32 end -
DockManager/Lazarus/Demo/UMainForm.pas
r43 r44 19 19 procedure FormCreate(Sender: TObject); 20 20 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);25 21 private 26 22 { private declarations } … … 28 24 FormIndex: Integer; 29 25 LastDockForm: TDockForm; 26 function NewDockForm: TDockForm; 30 27 end; 31 28 … … 49 46 DockForm3: TDockForm; 50 47 begin 51 Button1Click(Self); 52 DockForm1 := LastDockForm; 48 DockForm1 := NewDockForm; 53 49 DockForm1.ManualDock(Panel1); 54 50 55 Button1Click(Self); 56 DockForm2 := LastDockForm; 51 DockForm2 := NewDockForm; 57 52 DockForm2.ManualDock(Panel1); 58 53 59 Button1Click(Self); 60 DockForm3 := LastDockForm; 54 DockForm3 := NewDockForm; 61 55 DockForm3.ManualDock(DockForm2); 62 56 end; 63 57 64 procedure TMainForm.ListView1EndDrag(Sender, Target: TObject; X, Y: Integer);58 function TMainForm.NewDockForm: TDockForm; 65 59 begin 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; 79 69 end; 80 70 81 71 procedure TMainForm.Button1Click(Sender: TObject); 82 var83 NewForm: TDockForm;84 72 begin 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; 95 74 end; 96 75 -
DockManager/Lazarus/UCustomDockManager.pas
r43 r44 17 17 TCustomDockManager = class; 18 18 19 { TConjoinDockForm } 20 19 21 TConjoinDockForm = class(TForm) 20 22 Panel: TPanel; 23 constructor Create(TheOwner: TComponent); override; 21 24 end; 22 25 … … 130 133 NewPanel: TDockClientPanel; 131 134 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; 136 begin 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; 180 192 end; 181 193 … … 243 255 if Control.HostDockSite = Self.FDockSite then begin 244 256 ClientPanel := FindControlInPanels(Control); 245 // ClientPanel.Splitter.Free;257 //if Assigned(ClientPanel) then ClientPanel.Splitter.Free; 246 258 FDockPanels.Remove(ClientPanel); 247 259 if FDockSite.DockClientCount = 2 then FDockDirection := ddNone; … … 350 362 end; 351 363 364 { TConjoinDockForm } 365 366 constructor TConjoinDockForm.Create(TheOwner: TComponent); 367 begin 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; 378 end; 379 352 380 initialization 353 381 DefaultDockManagerClass := TCustomDockManager;
Note:
See TracChangeset
for help on using the changeset viewer.