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 }
|
||||
procedure SetStyle(const Value: TSpkStyle);
|
||||
|
||||
{ LCL Scaling }
|
||||
{$IF lcl_fullversion >= 1080000}
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
const AXProportion, AYProportion: Double); override;
|
||||
|
||||
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
|
||||
|
||||
procedure ScaleFontsPPI(const AProportion: Double); override;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
@ -1394,7 +1399,6 @@ procedure TSpkToolbar.ValidateBuffer;
|
||||
TabRect := FTabRects[index];
|
||||
|
||||
FBuffer.canvas.font.Assign(AFont);
|
||||
SpkScaleFont(FBuffer.Canvas.Font);
|
||||
|
||||
if AOverrideTextColor <> clNone then
|
||||
clr := AOverrideTextColor else
|
||||
@ -1737,7 +1741,6 @@ begin
|
||||
else
|
||||
TabAppearance := FAppearance;
|
||||
FBuffer.Canvas.font.Assign(TabAppearance.Tab.TabHeaderFont);
|
||||
SpkScaleFont(FBuffer.Canvas.Font);
|
||||
|
||||
TabWidth := 2 + // Frame
|
||||
2 * TabCornerRadius +
|
||||
@ -1794,6 +1797,9 @@ procedure TSpkToolbar.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if not (AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI]) then
|
||||
exit;
|
||||
|
||||
LargeButtonDropdownFieldSize := round(LARGEBUTTON_DROPDOWN_FIELD_SIZE * AXProportion);
|
||||
LargeButtonGlyphMargin := round(LARGEBUTTON_GLYPH_MARGIN * AXProportion);
|
||||
LargeButtonCaptionHMargin := round(LARGEBUTTON_CAPTION_HMARGIN * AXProportion);
|
||||
@ -1869,6 +1875,23 @@ begin
|
||||
if ToolbarCornerRadius > 1 then
|
||||
ToolbarCornerRadius := round(ToolbarCornerRadius * AXProportion);
|
||||
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}
|
||||
|
||||
end.
|
||||
|
@ -1082,7 +1082,6 @@ begin
|
||||
// Text
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
ABuffer.Canvas.Font.Color := fontColor;
|
||||
SpkScaleFont(ABuffer.Canvas.Font);
|
||||
|
||||
if FButtonKind in [bkButton, bkToggle] then
|
||||
FindBreakPlace(FCaption, breakPos, breakWidth)
|
||||
@ -1148,7 +1147,6 @@ begin
|
||||
exit;
|
||||
|
||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
SpkScaleFont(Bitmap.Canvas.Font);
|
||||
|
||||
Width := Bitmap.Canvas.TextWidth(FCaption);
|
||||
|
||||
@ -1241,7 +1239,6 @@ begin
|
||||
begin
|
||||
// do not break the label
|
||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
SpkScaleFont(Bitmap.Canvas.Font);
|
||||
TextWidth := 2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption);
|
||||
end;
|
||||
|
||||
@ -1322,7 +1319,6 @@ begin
|
||||
if FShowCaption then
|
||||
begin
|
||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
SpkScaleFont(Bitmap.Canvas.Font);
|
||||
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
||||
|
||||
BtnWidth := BtnWidth + SmallButtonPadding + TextWidth;
|
||||
@ -1542,7 +1538,6 @@ begin
|
||||
begin
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
ABuffer.Canvas.Font.Color := fontColor;
|
||||
SpkScaleFont(ABuffer.Canvas.Font);
|
||||
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
||||
|
@ -200,7 +200,6 @@ begin
|
||||
exit;
|
||||
|
||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
SpkScaleFont(Bitmap.Canvas.Font);
|
||||
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
||||
|
||||
BtnWidth := SmallButtonPadding + SmallButtonGlyphWidth +
|
||||
@ -334,7 +333,6 @@ begin
|
||||
|
||||
// Text
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
SpkScaleFont(ABuffer.Canvas.Font);
|
||||
|
||||
case FButtonState of
|
||||
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
||||
|
@ -20,7 +20,6 @@ uses
|
||||
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
|
||||
function SpkScaleX(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
|
||||
// ****************
|
||||
@ -391,25 +390,6 @@ begin
|
||||
|
||||
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
|
||||
|
||||
|
@ -316,7 +316,6 @@ begin
|
||||
|
||||
// Pane label
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
||||
SpkScaleFont(ABuffer.Canvas.Font);
|
||||
x := FRect.Left + (FRect.Width - ABuffer.Canvas.TextWidth(FCaption)) div 2;
|
||||
y := FRect.Bottom - PaneBorderSize - PaneCaptionHeight + 1 +
|
||||
(PaneCaptionHeight - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
||||
@ -702,7 +701,6 @@ begin
|
||||
if tmpBitmap = nil then
|
||||
exit;
|
||||
tmpBitmap.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
||||
SpkScaleFont(tmpBitmap.Canvas.Font);
|
||||
|
||||
// *** Minimalna szerokoϾ tafli (tekstu) ***
|
||||
TextW := tmpBitmap.Canvas.TextWidth(FCaption);
|
||||
|
Reference in New Issue
Block a user