You've already forked lazarus-ccr
spktoolbar: Fix font scaling for Laz >= 1.8
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5985 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -315,9 +315,14 @@ type
|
|||||||
{ Setter for toolbar style, i.e. quick selection of new appearance theme }
|
{ Setter for toolbar style, i.e. quick selection of new appearance theme }
|
||||||
procedure SetStyle(const Value: TSpkStyle);
|
procedure SetStyle(const Value: TSpkStyle);
|
||||||
|
|
||||||
|
{ LCL Scaling }
|
||||||
{$IF lcl_fullversion >= 1080000}
|
{$IF lcl_fullversion >= 1080000}
|
||||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
const AXProportion, AYProportion: Double); override;
|
const AXProportion, AYProportion: Double); override;
|
||||||
|
|
||||||
|
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
|
||||||
|
|
||||||
|
procedure ScaleFontsPPI(const AProportion: Double); override;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -1394,7 +1399,6 @@ procedure TSpkToolbar.ValidateBuffer;
|
|||||||
TabRect := FTabRects[index];
|
TabRect := FTabRects[index];
|
||||||
|
|
||||||
FBuffer.canvas.font.Assign(AFont);
|
FBuffer.canvas.font.Assign(AFont);
|
||||||
SpkScaleFont(FBuffer.Canvas.Font);
|
|
||||||
|
|
||||||
if AOverrideTextColor <> clNone then
|
if AOverrideTextColor <> clNone then
|
||||||
clr := AOverrideTextColor else
|
clr := AOverrideTextColor else
|
||||||
@ -1737,7 +1741,6 @@ begin
|
|||||||
else
|
else
|
||||||
TabAppearance := FAppearance;
|
TabAppearance := FAppearance;
|
||||||
FBuffer.Canvas.font.Assign(TabAppearance.Tab.TabHeaderFont);
|
FBuffer.Canvas.font.Assign(TabAppearance.Tab.TabHeaderFont);
|
||||||
SpkScaleFont(FBuffer.Canvas.Font);
|
|
||||||
|
|
||||||
TabWidth := 2 + // Frame
|
TabWidth := 2 + // Frame
|
||||||
2 * TabCornerRadius +
|
2 * TabCornerRadius +
|
||||||
@ -1794,6 +1797,9 @@ procedure TSpkToolbar.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
|
if not (AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI]) then
|
||||||
|
exit;
|
||||||
|
|
||||||
LargeButtonDropdownFieldSize := round(LARGEBUTTON_DROPDOWN_FIELD_SIZE * AXProportion);
|
LargeButtonDropdownFieldSize := round(LARGEBUTTON_DROPDOWN_FIELD_SIZE * AXProportion);
|
||||||
LargeButtonGlyphMargin := round(LARGEBUTTON_GLYPH_MARGIN * AXProportion);
|
LargeButtonGlyphMargin := round(LARGEBUTTON_GLYPH_MARGIN * AXProportion);
|
||||||
LargeButtonCaptionHMargin := round(LARGEBUTTON_CAPTION_HMARGIN * AXProportion);
|
LargeButtonCaptionHMargin := round(LARGEBUTTON_CAPTION_HMARGIN * AXProportion);
|
||||||
@ -1869,6 +1875,23 @@ begin
|
|||||||
if ToolbarCornerRadius > 1 then
|
if ToolbarCornerRadius > 1 then
|
||||||
ToolbarCornerRadius := round(ToolbarCornerRadius * AXProportion);
|
ToolbarCornerRadius := round(ToolbarCornerRadius * AXProportion);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSpkToolbar.FixDesignFontsPPI(const ADesignTimePPI: Integer);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
DoFixDesignFontPPI(FAppearance.Tab.TabHeaderFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FAppearance.Pane.CaptionFont, ADesignTimePPI);
|
||||||
|
DoFixDesignFontPPI(FAppearance.Element.CaptionFont, ADesignTimePPI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSpkToolbar.ScaleFontsPPI(const AProportion: Double);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
DoScaleFontPPI(FAppearance.Tab.TabHeaderFont, AProportion);
|
||||||
|
DoScaleFontPPI(FAppearance.Pane.CaptionFont, AProportion);
|
||||||
|
DoScaleFontPPI(FAppearance.Element.CaptionFont, AProportion);
|
||||||
|
end;
|
||||||
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -1082,7 +1082,6 @@ begin
|
|||||||
// Text
|
// Text
|
||||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
ABuffer.Canvas.Font.Color := fontColor;
|
ABuffer.Canvas.Font.Color := fontColor;
|
||||||
SpkScaleFont(ABuffer.Canvas.Font);
|
|
||||||
|
|
||||||
if FButtonKind in [bkButton, bkToggle] then
|
if FButtonKind in [bkButton, bkToggle] then
|
||||||
FindBreakPlace(FCaption, breakPos, breakWidth)
|
FindBreakPlace(FCaption, breakPos, breakWidth)
|
||||||
@ -1148,7 +1147,6 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
SpkScaleFont(Bitmap.Canvas.Font);
|
|
||||||
|
|
||||||
Width := Bitmap.Canvas.TextWidth(FCaption);
|
Width := Bitmap.Canvas.TextWidth(FCaption);
|
||||||
|
|
||||||
@ -1241,7 +1239,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
// do not break the label
|
// do not break the label
|
||||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
SpkScaleFont(Bitmap.Canvas.Font);
|
|
||||||
TextWidth := 2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption);
|
TextWidth := 2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1322,7 +1319,6 @@ begin
|
|||||||
if FShowCaption then
|
if FShowCaption then
|
||||||
begin
|
begin
|
||||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
SpkScaleFont(Bitmap.Canvas.Font);
|
|
||||||
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
||||||
|
|
||||||
BtnWidth := BtnWidth + SmallButtonPadding + TextWidth;
|
BtnWidth := BtnWidth + SmallButtonPadding + TextWidth;
|
||||||
@ -1542,7 +1538,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
ABuffer.Canvas.Font.Color := fontColor;
|
ABuffer.Canvas.Font.Color := fontColor;
|
||||||
SpkScaleFont(ABuffer.Canvas.Font);
|
|
||||||
|
|
||||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
||||||
|
@ -200,7 +200,6 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
SpkScaleFont(Bitmap.Canvas.Font);
|
|
||||||
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
||||||
|
|
||||||
BtnWidth := SmallButtonPadding + SmallButtonGlyphWidth +
|
BtnWidth := SmallButtonPadding + SmallButtonGlyphWidth +
|
||||||
@ -334,7 +333,6 @@ begin
|
|||||||
|
|
||||||
// Text
|
// Text
|
||||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||||
SpkScaleFont(ABuffer.Canvas.Font);
|
|
||||||
|
|
||||||
case FButtonState of
|
case FButtonState of
|
||||||
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
||||||
|
@ -20,7 +20,6 @@ uses
|
|||||||
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
|
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
|
||||||
function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
||||||
function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
||||||
procedure SpkScaleFont(AFont: TFont; ToDPI: Integer = 0);
|
|
||||||
|
|
||||||
const
|
const
|
||||||
// ****************
|
// ****************
|
||||||
@ -391,25 +390,6 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SpkScaleFont(AFont: TFont; ToDPI: Integer = 0);
|
|
||||||
var
|
|
||||||
FromDPI: Integer;
|
|
||||||
begin
|
|
||||||
if ToDPI = 0 then
|
|
||||||
ToDPI := ScreenInfo.PixelsPerInchY;
|
|
||||||
|
|
||||||
FromDPI := AFont.PixelsPerInch;
|
|
||||||
|
|
||||||
if (not DPI_AWARE) or (ToDPI = FromDPI) then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
if AFont.Size = 0 then
|
|
||||||
AFont.Height := MulDiv(GetFontData(AFont.Reference.Handle).Height, FromDPI, ToDPI)
|
|
||||||
else
|
|
||||||
AFont.Height := MulDiv(AFont.Height, FromDPI, ToDPI);
|
|
||||||
AFont.PixelsPerInch := ToDPI;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
|
@ -316,7 +316,6 @@ begin
|
|||||||
|
|
||||||
// Pane label
|
// Pane label
|
||||||
ABuffer.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
ABuffer.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
||||||
SpkScaleFont(ABuffer.Canvas.Font);
|
|
||||||
x := FRect.Left + (FRect.Width - ABuffer.Canvas.TextWidth(FCaption)) div 2;
|
x := FRect.Left + (FRect.Width - ABuffer.Canvas.TextWidth(FCaption)) div 2;
|
||||||
y := FRect.Bottom - PaneBorderSize - PaneCaptionHeight + 1 +
|
y := FRect.Bottom - PaneBorderSize - PaneCaptionHeight + 1 +
|
||||||
(PaneCaptionHeight - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
(PaneCaptionHeight - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
||||||
@ -702,7 +701,6 @@ begin
|
|||||||
if tmpBitmap = nil then
|
if tmpBitmap = nil then
|
||||||
exit;
|
exit;
|
||||||
tmpBitmap.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
tmpBitmap.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
||||||
SpkScaleFont(tmpBitmap.Canvas.Font);
|
|
||||||
|
|
||||||
// *** Minimalna szerokoϾ tafli (tekstu) ***
|
// *** Minimalna szerokoϾ tafli (tekstu) ***
|
||||||
TextW := tmpBitmap.Canvas.TextWidth(FCaption);
|
TextW := tmpBitmap.Canvas.TextWidth(FCaption);
|
||||||
|
Reference in New Issue
Block a user