mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 12:19:14 +02:00
dockmanager example: fixed undocking of other than current tab.
Enlarged default button size, AutoSize still does not work. git-svn-id: trunk@20228 -
This commit is contained in:
parent
7b05deb5c3
commit
43fc30db83
@ -471,7 +471,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end; //else use existing control
|
end; //else use existing control
|
||||||
NoteBookAdd(NoteBook, Control);
|
NoteBookAdd(NoteBook, Control);
|
||||||
//FDockSite.Invalidate;
|
FDockSite.Invalidate; //update notebook caption
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ object EasyDockBook: TEasyDockBook
|
|||||||
Caption = 'Tabs'
|
Caption = 'Tabs'
|
||||||
ChildSizing.HorizontalSpacing = 2
|
ChildSizing.HorizontalSpacing = 2
|
||||||
ChildSizing.EnlargeHorizontal = crsHomogenousSpaceResize
|
ChildSizing.EnlargeHorizontal = crsHomogenousSpaceResize
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
EdgeBorders = [ebTop, ebBottom]
|
EdgeBorders = [ebTop, ebBottom]
|
||||||
Flat = False
|
Flat = False
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TEasyDockBook','FORMDATA',[
|
LazarusResources.Add('TEasyDockBook','FORMDATA',[
|
||||||
'TPF0'#13'TEasyDockBook'#12'EasyDockBook'#4'Left'#3#7#1#6'Height'#3','#1#3'To'
|
'TPF0'#13'TEasyDockBook'#12'EasyDockBook'#4'Left'#3#7#1#6'Height'#3','#1#3'To'
|
||||||
+'p'#3#146#0#5'Width'#3#144#1#7'Caption'#6#12'EasyDockBook'#12'ClientHeight'#3
|
+'p'#3#146#0#5'Width'#3#144#1#7'Caption'#6#12'EasyDockBook'#12'ClientHeight'#3
|
||||||
@ -6,11 +8,10 @@ LazarusResources.Add('TEasyDockBook','FORMDATA',[
|
|||||||
+'t'#2#1#6'Height'#2#26#3'Top'#2#1#5'Width'#3#142#1#8'AutoSize'#9#20'BorderSp'
|
+'t'#2#1#6'Height'#2#26#3'Top'#2#1#5'Width'#3#142#1#8'AutoSize'#9#20'BorderSp'
|
||||||
+'acing.Around'#2#1#11'BorderWidth'#2#1#7'Caption'#6#4'Tabs'#29'ChildSizing.H'
|
+'acing.Around'#2#1#11'BorderWidth'#2#1#7'Caption'#6#4'Tabs'#29'ChildSizing.H'
|
||||||
+'orizontalSpacing'#2#2#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomogenousS'
|
+'orizontalSpacing'#2#2#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomogenousS'
|
||||||
+'paceResize'#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#5'Co'
|
+'paceResize'#5'Color'#7#9'clBtnFace'#11'EdgeBorders'#11#5'ebTop'#8'ebBottom'
|
||||||
+'lor'#7#9'clBtnFace'#11'EdgeBorders'#11#5'ebTop'#8'ebBottom'#0#4'Flat'#8#10
|
+#0#4'Flat'#8#10'Font.Style'#11#6'fsBold'#0#4'List'#9#11'ParentColor'#8#10'Pa'
|
||||||
+'Font.Style'#11#6'fsBold'#0#4'List'#9#11'ParentColor'#8#10'ParentFont'#8#12
|
+'rentFont'#8#12'ShowCaptions'#9#8'TabOrder'#2#0#0#0#6'TPanel'#7'pnlDock'#4'L'
|
||||||
+'ShowCaptions'#9#8'TabOrder'#2#0#0#0#6'TPanel'#7'pnlDock'#4'Left'#2#0#6'Heig'
|
+'eft'#2#0#6'Height'#3#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClien'
|
||||||
+'ht'#3#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClient'#7'Caption'#6
|
+'t'#7'Caption'#6#7'pnlDock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15
|
||||||
+#7'pnlDock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15'pnlDockDockDro'
|
+'pnlDockDockDrop'#8'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
||||||
+'p'#8'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
|
||||||
]);
|
]);
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
unit fDockBook;
|
unit fDockBook;
|
||||||
|
(* Notebook for docking multiple controls into a tabbed control.
|
||||||
|
By DoDi <DrDiettrich1@aol.com> 2009.
|
||||||
|
|
||||||
|
A tab is created for every docked control.
|
||||||
|
The currently visible tab remains down.
|
||||||
|
A control can be undocked by dragging the associated tab.
|
||||||
|
This makes the tabs act as grab regions, for undocking forms.
|
||||||
|
|
||||||
|
ToDo:
|
||||||
|
Currently the buttons have a uniform (too small) size.
|
||||||
|
*)
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
@ -29,6 +40,7 @@ type
|
|||||||
CurTab: TTabButton;
|
CurTab: TTabButton;
|
||||||
protected
|
protected
|
||||||
function GetDefaultDockCaption: string; override;
|
function GetDefaultDockCaption: string; override;
|
||||||
|
function GetControlTab(AControl: TControl): TTabButton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -38,6 +50,20 @@ implementation
|
|||||||
|
|
||||||
{ TEasyDockBook }
|
{ TEasyDockBook }
|
||||||
|
|
||||||
|
function TEasyDockBook.GetControlTab(AControl: TControl): TTabButton;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
btn: TToolButton absolute Result;
|
||||||
|
begin
|
||||||
|
for i := 0 to Tabs.ButtonCount - 1 do begin
|
||||||
|
btn := Tabs.Buttons[i];
|
||||||
|
if Result.Control = AControl then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
//not found - raise exception?
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TEasyDockBook.GetDefaultDockCaption: string;
|
function TEasyDockBook.GetDefaultDockCaption: string;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
@ -58,40 +84,63 @@ procedure TEasyDockBook.pnlDockDockDrop(Sender: TObject; Source: TDragDockObject
|
|||||||
var
|
var
|
||||||
btn: TTabButton;
|
btn: TTabButton;
|
||||||
begin
|
begin
|
||||||
|
{ TODO : make buttons big enough for the text }
|
||||||
|
//Tabs.BeginUpdate; - doesn't help
|
||||||
btn := TTabButton.Create(Tabs);
|
btn := TTabButton.Create(Tabs);
|
||||||
btn.Control := Source.Control;
|
btn.Control := Source.Control;
|
||||||
btn.Control.Align := alClient;
|
btn.Control.Align := alClient;
|
||||||
btn.Caption := GetDockCaption(btn.Control);
|
btn.Caption := GetDockCaption(btn.Control);
|
||||||
//btn.Caption := ' ' + GetDockCaption(btn.Control) + ' ';
|
//btn.Caption := ' ' + GetDockCaption(btn.Control) + ' ';
|
||||||
|
//btn.AutoSize := True; - doesn't help
|
||||||
btn.OnClick := @ToolButton1Click;
|
btn.OnClick := @ToolButton1Click;
|
||||||
btn.Down := True;
|
btn.Down := True;
|
||||||
btn.Click;
|
btn.Click;
|
||||||
|
//Tabs.EndUpdate;
|
||||||
|
{ this also doesn't help
|
||||||
|
Tabs.ShowCaptions := False;
|
||||||
|
Tabs.ShowCaptions := True;
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEasyDockBook.pnlDockUnDock(Sender: TObject; Client: TControl;
|
procedure TEasyDockBook.pnlDockUnDock(Sender: TObject; Client: TControl;
|
||||||
NewTarget: TWinControl; var Allow: Boolean);
|
NewTarget: TWinControl; var Allow: Boolean);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
|
btn: TTabButton;
|
||||||
begin
|
begin
|
||||||
|
(* Client undocked, remove associated tab.
|
||||||
|
We'll have to find the tab, associated with the control.
|
||||||
|
*)
|
||||||
Allow := true;
|
Allow := true;
|
||||||
//assert(CurTab.Control = Client, 'diff client');
|
//assert(CurTab.Control = Client, 'diff client');
|
||||||
i := CurTab.Index;
|
btn := GetControlTab(Client);
|
||||||
Tabs.ButtonList.Delete(i);
|
//i := CurTab.Index;
|
||||||
CurTab.Free; //seems to work
|
i := btn.Index;
|
||||||
//Tabs.removebutton
|
if btn = CurTab then begin
|
||||||
CurTab := nil;
|
CurTab := nil;
|
||||||
|
end else begin
|
||||||
|
Client.Visible := True; //make hidden page control visible
|
||||||
|
end;
|
||||||
|
Tabs.ButtonList.Delete(i);
|
||||||
|
btn.Free; //seems to work
|
||||||
|
//special handle remove of current and last tab
|
||||||
|
if Tabs.ButtonCount > 0 then begin
|
||||||
|
//tab moved?
|
||||||
|
if CurTab = nil then begin //current button removed
|
||||||
|
//find next tab to show
|
||||||
if i >= Tabs.ButtonCount then
|
if i >= Tabs.ButtonCount then
|
||||||
dec(i);
|
dec(i);
|
||||||
if Tabs.ButtonCount > 0 then begin
|
//activate new tab
|
||||||
CurTab := Tabs.Buttons[i] as TTabButton;
|
CurTab := Tabs.Buttons[i] as TTabButton;
|
||||||
CurTab.Down := True;
|
CurTab.Down := True;
|
||||||
CurTab.Click;
|
CurTab.Click;
|
||||||
end else if HostDockSite <> nil then begin
|
end;
|
||||||
//undock before closing
|
end else begin
|
||||||
ManualDock(nil);
|
//last tab removed
|
||||||
|
if HostDockSite <> nil then
|
||||||
|
ManualDock(nil); //undock before closing
|
||||||
Close;
|
Close;
|
||||||
end else
|
end;
|
||||||
close;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEasyDockBook.ToolButton1Click(Sender: TObject);
|
procedure TEasyDockBook.ToolButton1Click(Sender: TObject);
|
||||||
@ -115,6 +164,8 @@ begin
|
|||||||
Grouped := True;
|
Grouped := True;
|
||||||
AllowAllUp := False;
|
AllowAllUp := False;
|
||||||
Style := tbsCheck;
|
Style := tbsCheck;
|
||||||
|
//self.Constraints.MinWidth:=200; //.Options;
|
||||||
|
self.Width := 100;
|
||||||
AutoSize := True;
|
AutoSize := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user