mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 19:23:49 +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}
|
||||
end; //else use existing control
|
||||
NoteBookAdd(NoteBook, Control);
|
||||
//FDockSite.Invalidate;
|
||||
FDockSite.Invalidate; //update notebook caption
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
@ -21,7 +21,6 @@ object EasyDockBook: TEasyDockBook
|
||||
Caption = 'Tabs'
|
||||
ChildSizing.HorizontalSpacing = 2
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousSpaceResize
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
Color = clBtnFace
|
||||
EdgeBorders = [ebTop, ebBottom]
|
||||
Flat = False
|
||||
|
@ -1,3 +1,5 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TEasyDockBook','FORMDATA',[
|
||||
'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
|
||||
@ -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'
|
||||
+'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'
|
||||
+'paceResize'#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#5'Co'
|
||||
+'lor'#7#9'clBtnFace'#11'EdgeBorders'#11#5'ebTop'#8'ebBottom'#0#4'Flat'#8#10
|
||||
+'Font.Style'#11#6'fsBold'#0#4'List'#9#11'ParentColor'#8#10'ParentFont'#8#12
|
||||
+'ShowCaptions'#9#8'TabOrder'#2#0#0#0#6'TPanel'#7'pnlDock'#4'Left'#2#0#6'Heig'
|
||||
+'ht'#3#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClient'#7'Caption'#6
|
||||
+#7'pnlDock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15'pnlDockDockDro'
|
||||
+'p'#8'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
||||
+'paceResize'#5'Color'#7#9'clBtnFace'#11'EdgeBorders'#11#5'ebTop'#8'ebBottom'
|
||||
+#0#4'Flat'#8#10'Font.Style'#11#6'fsBold'#0#4'List'#9#11'ParentColor'#8#10'Pa'
|
||||
+'rentFont'#8#12'ShowCaptions'#9#8'TabOrder'#2#0#0#0#6'TPanel'#7'pnlDock'#4'L'
|
||||
+'eft'#2#0#6'Height'#3#16#1#3'Top'#2#28#5'Width'#3#144#1#5'Align'#7#8'alClien'
|
||||
+'t'#7'Caption'#6#7'pnlDock'#8'DockSite'#9#8'TabOrder'#2#1#10'OnDockDrop'#7#15
|
||||
+'pnlDockDockDrop'#8'OnUnDock'#7#13'pnlDockUnDock'#0#0#0
|
||||
]);
|
||||
|
@ -1,4 +1,15 @@
|
||||
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+}
|
||||
|
||||
@ -29,6 +40,7 @@ type
|
||||
CurTab: TTabButton;
|
||||
protected
|
||||
function GetDefaultDockCaption: string; override;
|
||||
function GetControlTab(AControl: TControl): TTabButton;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -38,6 +50,20 @@ implementation
|
||||
|
||||
{ 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;
|
||||
var
|
||||
i: integer;
|
||||
@ -58,40 +84,63 @@ procedure TEasyDockBook.pnlDockDockDrop(Sender: TObject; Source: TDragDockObject
|
||||
var
|
||||
btn: TTabButton;
|
||||
begin
|
||||
{ TODO : make buttons big enough for the text }
|
||||
//Tabs.BeginUpdate; - doesn't help
|
||||
btn := TTabButton.Create(Tabs);
|
||||
btn.Control := Source.Control;
|
||||
btn.Control.Align := alClient;
|
||||
btn.Caption := GetDockCaption(btn.Control);
|
||||
//btn.Caption := ' ' + GetDockCaption(btn.Control) + ' ';
|
||||
//btn.AutoSize := True; - doesn't help
|
||||
btn.OnClick := @ToolButton1Click;
|
||||
btn.Down := True;
|
||||
btn.Click;
|
||||
//Tabs.EndUpdate;
|
||||
{ this also doesn't help
|
||||
Tabs.ShowCaptions := False;
|
||||
Tabs.ShowCaptions := True;
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TEasyDockBook.pnlDockUnDock(Sender: TObject; Client: TControl;
|
||||
NewTarget: TWinControl; var Allow: Boolean);
|
||||
var
|
||||
i: integer;
|
||||
btn: TTabButton;
|
||||
begin
|
||||
(* Client undocked, remove associated tab.
|
||||
We'll have to find the tab, associated with the control.
|
||||
*)
|
||||
Allow := true;
|
||||
//assert(CurTab.Control = Client, 'diff client');
|
||||
i := CurTab.Index;
|
||||
btn := GetControlTab(Client);
|
||||
//i := CurTab.Index;
|
||||
i := btn.Index;
|
||||
if btn = CurTab then begin
|
||||
CurTab := nil;
|
||||
end else begin
|
||||
Client.Visible := True; //make hidden page control visible
|
||||
end;
|
||||
Tabs.ButtonList.Delete(i);
|
||||
CurTab.Free; //seems to work
|
||||
//Tabs.removebutton
|
||||
CurTab := nil;
|
||||
if i >= Tabs.ButtonCount then
|
||||
dec(i);
|
||||
btn.Free; //seems to work
|
||||
//special handle remove of current and last tab
|
||||
if Tabs.ButtonCount > 0 then begin
|
||||
CurTab := Tabs.Buttons[i] as TTabButton;
|
||||
CurTab.Down := True;
|
||||
CurTab.Click;
|
||||
end else if HostDockSite <> nil then begin
|
||||
//undock before closing
|
||||
ManualDock(nil);
|
||||
//tab moved?
|
||||
if CurTab = nil then begin //current button removed
|
||||
//find next tab to show
|
||||
if i >= Tabs.ButtonCount then
|
||||
dec(i);
|
||||
//activate new tab
|
||||
CurTab := Tabs.Buttons[i] as TTabButton;
|
||||
CurTab.Down := True;
|
||||
CurTab.Click;
|
||||
end;
|
||||
end else begin
|
||||
//last tab removed
|
||||
if HostDockSite <> nil then
|
||||
ManualDock(nil); //undock before closing
|
||||
Close;
|
||||
end else
|
||||
close;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEasyDockBook.ToolButton1Click(Sender: TObject);
|
||||
@ -115,6 +164,8 @@ begin
|
||||
Grouped := True;
|
||||
AllowAllUp := False;
|
||||
Style := tbsCheck;
|
||||
//self.Constraints.MinWidth:=200; //.Options;
|
||||
self.Width := 100;
|
||||
AutoSize := True;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user