mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-29 18:42:56 +01:00
LCL: scale control default size when needed. Solves issue #32702
git-svn-id: trunk@58125 -
This commit is contained in:
parent
7d10edbadb
commit
3ec78f9640
@ -1474,6 +1474,7 @@ type
|
|||||||
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); virtual;
|
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); virtual;
|
||||||
procedure SetZOrder(TopMost: Boolean); virtual;
|
procedure SetZOrder(TopMost: Boolean); virtual;
|
||||||
class function GetControlClassDefaultSize: TSize; virtual;
|
class function GetControlClassDefaultSize: TSize; virtual;
|
||||||
|
function GetScaledControlClassDefaultSize: TSize;
|
||||||
function ColorIsStored: boolean; virtual;
|
function ColorIsStored: boolean; virtual;
|
||||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
const AXProportion, AYProportion: Double); virtual;
|
const AXProportion, AYProportion: Double); virtual;
|
||||||
|
|||||||
@ -1409,6 +1409,13 @@ begin
|
|||||||
Result := ColorToRGB(GetColorResolvingParent());
|
Result := ColorToRGB(GetColorResolvingParent());
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TControl.GetScaledControlClassDefaultSize: TSize;
|
||||||
|
begin
|
||||||
|
Result := GetControlClassDefaultSize;
|
||||||
|
Result.cx := Scale96ToFont(Result.cx);
|
||||||
|
Result.cy := Scale96ToFont(Result.cy);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TControl.DoConstrainedResize
|
TControl.DoConstrainedResize
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -5570,14 +5577,14 @@ function TControl.GetDefaultWidth: integer;
|
|||||||
begin
|
begin
|
||||||
if WidthIsAnchored then
|
if WidthIsAnchored then
|
||||||
// if width is anchored the read and base bounds were changed at designtime
|
// if width is anchored the read and base bounds were changed at designtime
|
||||||
Result := GetControlClassDefaultSize.cx
|
Result := GetScaledControlClassDefaultSize.cx
|
||||||
else if cfBaseBoundsValid in FControlFlags then
|
else if cfBaseBoundsValid in FControlFlags then
|
||||||
Result := FBaseBounds.Right - FBaseBounds.Left
|
Result := FBaseBounds.Right - FBaseBounds.Left
|
||||||
else
|
else
|
||||||
if cfWidthLoaded in FControlFlags then
|
if cfWidthLoaded in FControlFlags then
|
||||||
Result := FReadBounds.Right - FReadBounds.Left
|
Result := FReadBounds.Right - FReadBounds.Left
|
||||||
else
|
else
|
||||||
Result := GetControlClassDefaultSize.cx;
|
Result := GetScaledControlClassDefaultSize.cx;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -5590,14 +5597,14 @@ function TControl.GetDefaultHeight: integer;
|
|||||||
begin
|
begin
|
||||||
if HeightIsAnchored then
|
if HeightIsAnchored then
|
||||||
// if height is anchored the read and base bounds were changed at designtime
|
// if height is anchored the read and base bounds were changed at designtime
|
||||||
Result := GetControlClassDefaultSize.cy
|
Result := GetScaledControlClassDefaultSize.cy
|
||||||
else if cfBaseBoundsValid in FControlFlags then
|
else if cfBaseBoundsValid in FControlFlags then
|
||||||
Result := BaseBounds.Bottom - BaseBounds.Top
|
Result := BaseBounds.Bottom - BaseBounds.Top
|
||||||
else
|
else
|
||||||
if cfHeightLoaded in FControlFlags then
|
if cfHeightLoaded in FControlFlags then
|
||||||
Result := FReadBounds.Bottom - FReadBounds.Top
|
Result := FReadBounds.Bottom - FReadBounds.Top
|
||||||
else
|
else
|
||||||
Result := GetControlClassDefaultSize.CY;
|
Result := GetScaledControlClassDefaultSize.cy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -1431,10 +1431,10 @@ begin
|
|||||||
// if no preferred size is valid use the class defaults
|
// if no preferred size is valid use the class defaults
|
||||||
if not IsPrefWidthValid then
|
if not IsPrefWidthValid then
|
||||||
PreferredSize[asboHorizontal]:=
|
PreferredSize[asboHorizontal]:=
|
||||||
Control.Constraints.MinMaxWidth(Control.GetControlClassDefaultSize.CX);
|
Control.Constraints.MinMaxWidth(Control.GetScaledControlClassDefaultSize.CX);
|
||||||
if not IsPrefHeightValid then
|
if not IsPrefHeightValid then
|
||||||
PreferredSize[asboVertical]:=
|
PreferredSize[asboVertical]:=
|
||||||
Control.Constraints.MinMaxHeight(Control.GetControlClassDefaultSize.CX);
|
Control.Constraints.MinMaxHeight(Control.GetScaledControlClassDefaultSize.CY);
|
||||||
|
|
||||||
//DebugLn(['TAutoSizeBox.SetControl ',DbgSName(Control),' ',PreferredSize[asboHorizontal]]);
|
//DebugLn(['TAutoSizeBox.SetControl ',DbgSName(Control),' ',PreferredSize[asboHorizontal]]);
|
||||||
Control.BorderSpacing.GetSpaceAround(Border);
|
Control.BorderSpacing.GetSpaceAround(Border);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user