jvcllaz: Implement lcl scaling for TJvRollOut. Adapt demo project.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7287 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-01-14 21:50:21 +00:00
parent d44027354c
commit 001c4a6db2
3 changed files with 59 additions and 9 deletions

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="12"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="JvRollOutDemo"/> <Title Value="JvRollOutDemo"/>
<Scaled Value="True"/> <Scaled Value="True"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
@ -21,9 +23,10 @@
<Version Value="2"/> <Version Value="2"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
<Item1> <Item1>

View File

@ -13,7 +13,6 @@ object Form1: TForm1
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
Scaled = False
object Splitter1: TSplitter object Splitter1: TSplitter
Cursor = crSizeWE Cursor = crSizeWE
Left = 280 Left = 280
@ -51,7 +50,7 @@ object Form1: TForm1
Left = 16 Left = 16
Height = 19 Height = 19
Top = 40 Top = 40
Width = 67 Width = 66
Caption = 'Tab Stop' Caption = 'Tab Stop'
Checked = True Checked = True
OnClick = chkTabStopClick OnClick = chkTabStopClick
@ -62,7 +61,7 @@ object Form1: TForm1
Left = 128 Left = 128
Height = 19 Height = 19
Top = 16 Top = 16
Width = 113 Width = 112
Caption = 'Toggle Anywhere' Caption = 'Toggle Anywhere'
OnClick = chkToggleAnywhereClick OnClick = chkToggleAnywhereClick
TabOrder = 2 TabOrder = 2
@ -1066,7 +1065,10 @@ object Form1: TForm1
Width = 131 Width = 131
Align = alBottom Align = alBottom
ButtonFont.Color = clWindowText ButtonFont.Color = clWindowText
ButtonFont.Height = -27
ButtonFont.Name = 'Courier'
ButtonFont.Style = [fsBold] ButtonFont.Style = [fsBold]
ButtonHeight = 60
Caption = '&J' Caption = '&J'
Font.Color = clWindowText Font.Color = clWindowText
GroupIndex = 1 GroupIndex = 1
@ -1080,7 +1082,7 @@ object Form1: TForm1
FAWidth = 145 FAWidth = 145
FAHeight = 170 FAHeight = 170
FCWidth = 22 FCWidth = 22
FCHeight = 22 FCHeight = 62
end end
object RO19: TJvRollOut object RO19: TJvRollOut
Left = 0 Left = 0

View File

@ -226,6 +226,17 @@ type
property OnCollapse: TNotifyEvent read FOnCollapse write FOnCollapse; property OnCollapse: TNotifyEvent read FOnCollapse write FOnCollapse;
property OnExpand: TNotifyEvent read FOnExpand write FOnExpand; property OnExpand: TNotifyEvent read FOnExpand write FOnExpand;
{ LCL scaling }
protected
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
public
{$IF LCL_FullVersion >= 2010000}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
{$IFEND}
procedure ScaleFontsPPI({$IF LCL_FullVersion >= 1080100}const AToPPI: Integer;{$IFEND}
const AProportion: Double); override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -1610,6 +1621,40 @@ begin
end; end;
end; end;
{ LCL scaling }
procedure TJvCustomRollOut.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FButtonHeight := round(FButtonHeight * AYProportion);
FChildOffset := round(FChildOffset * AXProportion);
FCWidth := round(FCWidth * AXProportion);
FCHeight := round(FCHeight * AYProportion);
FAWidth := round(FAWidth * AXProportion);
FAHeight := round(FAHeight * AYProportion);
end;
end;
{$IF LCL_FullVersion >= 2010000}
procedure TJvCustomRollOut.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin
inherited;
DoFixDesignFontPPI(FButtonFont, ADesignTimePPI);
end;
{$IFEND}
procedure TJvCustomRollOut.ScaleFontsPPI(
{$IF LCL_FullVersion >= 1080100}const AToPPI: Integer;{$IFEND}
const AProportion: Double);
begin
inherited;
DoScaleFontPPI(FButtonFont, AToPPI, AProportion);
end;
//=== { TJvRollOutAction } =================================================== //=== { TJvRollOutAction } ===================================================
destructor TJvRollOutAction.Destroy; destructor TJvRollOutAction.Destroy;