mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 11:19:24 +02:00
anchordocking: autosize headers
git-svn-id: trunk@26076 -
This commit is contained in:
parent
38d78b0487
commit
13d8b20deb
@ -59,6 +59,7 @@
|
|||||||
- move page left, right, leftmost, rightmost
|
- move page left, right, leftmost, rightmost
|
||||||
- close page
|
- close page
|
||||||
- tab position (default, left, top, right, bottom)
|
- tab position (default, left, top, right, bottom)
|
||||||
|
- options
|
||||||
- dock site: MakeDockSite for forms, that should be able to dock other sites,
|
- dock site: MakeDockSite for forms, that should be able to dock other sites,
|
||||||
but should not be docked themselves. Their Parent is always nil.
|
but should not be docked themselves. Their Parent is always nil.
|
||||||
- design time package for IDE
|
- design time package for IDE
|
||||||
@ -68,12 +69,9 @@
|
|||||||
ToDo:
|
ToDo:
|
||||||
- popup menu
|
- popup menu
|
||||||
- shrink side left, top, right, bottom
|
- shrink side left, top, right, bottom
|
||||||
- options
|
|
||||||
- fpdoc
|
- fpdoc
|
||||||
- examples on wiki:
|
- examples on wiki:
|
||||||
screenshots
|
|
||||||
example how to dock in code
|
example how to dock in code
|
||||||
step by step how to use it in applications
|
|
||||||
- simple way to make forms dockable at designtime
|
- simple way to make forms dockable at designtime
|
||||||
- minimize button and Hide => show in header
|
- minimize button and Hide => show in header
|
||||||
- on close button: save a default layout
|
- on close button: save a default layout
|
||||||
@ -105,6 +103,8 @@ type
|
|||||||
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
|
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
|
||||||
const AOffset: TPoint; AState: TButtonState; ATransparent: Boolean;
|
const AOffset: TPoint; AState: TButtonState; ATransparent: Boolean;
|
||||||
BiDiFlags: Longint): TRect; override;
|
BiDiFlags: Longint): TRect; override;
|
||||||
|
procedure CalculatePreferredSize(var PreferredWidth,
|
||||||
|
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -333,6 +333,7 @@ type
|
|||||||
TAnchorDockManagerClass = class of TAnchorDockManager;
|
TAnchorDockManagerClass = class of TAnchorDockManager;
|
||||||
|
|
||||||
TAnchorDockMaster = class;
|
TAnchorDockMaster = class;
|
||||||
|
|
||||||
{ TAnchorDockMaster }
|
{ TAnchorDockMaster }
|
||||||
|
|
||||||
TADCreateControlEvent = procedure(Sender: TObject; aName: string;
|
TADCreateControlEvent = procedure(Sender: TObject; aName: string;
|
||||||
@ -3842,12 +3843,34 @@ end;
|
|||||||
|
|
||||||
procedure TAnchorDockHeader.CalculatePreferredSize(var PreferredWidth,
|
procedure TAnchorDockHeader.CalculatePreferredSize(var PreferredWidth,
|
||||||
PreferredHeight: integer; WithThemeSpace: Boolean);
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
|
const
|
||||||
|
TestTxt = 'ABCXYZ123gqj';
|
||||||
|
var
|
||||||
|
DC: HDC;
|
||||||
|
R: TRect;
|
||||||
|
OldFont: HGDIOBJ;
|
||||||
|
Flags: cardinal;
|
||||||
|
NeededHeight: Integer;
|
||||||
begin
|
begin
|
||||||
if WithThemeSpace then ;
|
inherited CalculatePreferredSize(PreferredWidth,PreferredHeight,WithThemeSpace);
|
||||||
if Align in [alLeft,alRight] then begin
|
if Caption<>'' then begin
|
||||||
PreferredWidth:=20;
|
DC := GetDC(Parent.Handle);
|
||||||
end else begin
|
try
|
||||||
PreferredHeight:=20;
|
R := Rect(0, 0, 10000, 10000);
|
||||||
|
OldFont := SelectObject(DC, HGDIOBJ(Font.Reference.Handle));
|
||||||
|
Flags := DT_CALCRECT or DT_EXPANDTABS or DT_SINGLELINE or DT_NOPREFIX;
|
||||||
|
|
||||||
|
DrawText(DC, PChar(TestTxt), Length(TestTxt), R, Flags);
|
||||||
|
SelectObject(DC, OldFont);
|
||||||
|
NeededHeight := R.Bottom - R.Top + BevelWidth*2;
|
||||||
|
finally
|
||||||
|
ReleaseDC(Parent.Handle, DC);
|
||||||
|
end;
|
||||||
|
if Align in [alLeft,alRight] then begin
|
||||||
|
PreferredWidth:=Max(NeededHeight,PreferredWidth);
|
||||||
|
end else begin
|
||||||
|
PreferredHeight:=Max(NeededHeight,PreferredHeight);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3909,10 +3932,11 @@ begin
|
|||||||
Name:='CloseButton';
|
Name:='CloseButton';
|
||||||
Parent:=Self;
|
Parent:=Self;
|
||||||
Flat:=true;
|
Flat:=true;
|
||||||
BorderWidth:=1;
|
BorderWidth:=0;
|
||||||
ShowHint:=true;
|
ShowHint:=true;
|
||||||
Hint:=adrsClose;
|
Hint:=adrsClose;
|
||||||
OnClick:=@CloseButtonClick;
|
OnClick:=@CloseButtonClick;
|
||||||
|
AutoSize:=true;
|
||||||
end;
|
end;
|
||||||
Align:=alTop;
|
Align:=alTop;
|
||||||
AutoSize:=true;
|
AutoSize:=true;
|
||||||
@ -3949,7 +3973,7 @@ begin
|
|||||||
OrigBitmap.MaskHandle:=MaskHandle;
|
OrigBitmap.MaskHandle:=MaskHandle;
|
||||||
DockMaster.fCloseBtnBitmap:=TBitmap.Create;
|
DockMaster.fCloseBtnBitmap:=TBitmap.Create;
|
||||||
with DockMaster.fCloseBtnBitmap do begin
|
with DockMaster.fCloseBtnBitmap do begin
|
||||||
SetSize(12,12);
|
SetSize(10,10);
|
||||||
Canvas.Brush.Color:=clWhite;
|
Canvas.Brush.Color:=clWhite;
|
||||||
Canvas.FillRect(Rect(0,0,Width,Height));
|
Canvas.FillRect(Rect(0,0,Width,Height));
|
||||||
Canvas.StretchDraw(Rect(0,0,Width,Height),OrigBitmap);
|
Canvas.StretchDraw(Rect(0,0,Width,Height),OrigBitmap);
|
||||||
@ -3987,6 +4011,14 @@ begin
|
|||||||
ACanvas.Draw(Result.Left,Result.Top,DockMaster.fCloseBtnBitmap);
|
ACanvas.Draw(Result.Left,Result.Top,DockMaster.fCloseBtnBitmap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAnchorDockCloseButton.CalculatePreferredSize(var PreferredWidth,
|
||||||
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
|
begin
|
||||||
|
if WithThemeSpace then ;
|
||||||
|
PreferredWidth:=DockMaster.fCloseBtnBitmap.Width+4;
|
||||||
|
PreferredHeight:=DockMaster.fCloseBtnBitmap.Height+4;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TAnchorDockManager }
|
{ TAnchorDockManager }
|
||||||
|
|
||||||
constructor TAnchorDockManager.Create(ADockSite: TWinControl);
|
constructor TAnchorDockManager.Create(ADockSite: TWinControl);
|
||||||
|
@ -35,7 +35,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Math, Classes, SysUtils, LCLProc, Forms, Controls, FileUtil,
|
Math, Classes, SysUtils, LCLProc, Forms, Controls, FileUtil,
|
||||||
BaseIDEIntf, LazConfigStorage, LazIDEIntf, IDEWindowIntf, AnchorDocking;
|
BaseIDEIntf, LazConfigStorage, LazIDEIntf, IDEWindowIntf,
|
||||||
|
AnchorDocking, AnchorDockOptionsDlg;
|
||||||
|
|
||||||
const
|
const
|
||||||
DefaultConfigFileName = 'anchordocklayout.xml';
|
DefaultConfigFileName = 'anchordocklayout.xml';
|
||||||
@ -111,6 +112,7 @@ constructor TIDEAnchorDockMaster.Create;
|
|||||||
begin
|
begin
|
||||||
IDEAnchorDockMaster:=Self;
|
IDEAnchorDockMaster:=Self;
|
||||||
DockMaster.OnCreateControl:=@DockMasterCreateControl;
|
DockMaster.OnCreateControl:=@DockMasterCreateControl;
|
||||||
|
DockMaster.OnShowOptions:=@ShowAnchorDockOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TIDEAnchorDockMaster.Destroy;
|
destructor TIDEAnchorDockMaster.Destroy;
|
||||||
@ -121,14 +123,12 @@ end;
|
|||||||
|
|
||||||
procedure TIDEAnchorDockMaster.MakeIDEWindowDockSite(AForm: TCustomForm);
|
procedure TIDEAnchorDockMaster.MakeIDEWindowDockSite(AForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
if AForm<>Application.MainForm then
|
DockMaster.MakeDockSite(AForm,[akBottom],admrpChild);
|
||||||
DockMaster.MakeDockable(AForm,false);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIDEAnchorDockMaster.MakeIDEWindowDockable(AControl: TWinControl);
|
procedure TIDEAnchorDockMaster.MakeIDEWindowDockable(AControl: TWinControl);
|
||||||
begin
|
begin
|
||||||
if AControl<>Application.MainForm then
|
DockMaster.MakeDockable(AControl,false);
|
||||||
DockMaster.MakeDockable(AControl,false);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDEAnchorDockMaster.GetDefaultLayoutFilename: string;
|
function TIDEAnchorDockMaster.GetDefaultLayoutFilename: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user