LCL: Call TThemeServices.GetDetailSizeForPPI with proper arguments. Revert 1138d26280.

This commit is contained in:
Juha 2023-04-27 17:21:18 +03:00
parent ee395fe65a
commit c14934764c
17 changed files with 44 additions and 37 deletions

View File

@ -6998,7 +6998,9 @@ end;
procedure TAnchorDockCloseButton.CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean);
begin
with ThemeServices.GetDetailSize(ThemeServices.GetElementDetails({$IFDEF LCLWIN32}twCloseButtonNormal{$ELSE}twSmallCloseButtonNormal{$ENDIF})) do
with ThemeServices.GetDetailSizeForPPI(ThemeServices.GetElementDetails(
{$IFDEF LCLWIN32}twCloseButtonNormal{$ELSE}twSmallCloseButtonNormal{$ENDIF}),
Font.PixelsPerInch) do
begin
PreferredWidth:=cx;
PreferredHeight:=cy;
@ -7040,7 +7042,9 @@ end;
procedure TAnchorDockMinimizeButton.CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean);
begin
with ThemeServices.GetDetailSize(ThemeServices.GetElementDetails({$IFDEF LCLGtk2}twMDIRestoreButtonNormal{$ELSE}twMinButtonNormal{$ENDIF})) do
with ThemeServices.GetDetailSizeForPPI(ThemeServices.GetElementDetails(
{$IFDEF LCLGtk2}twMDIRestoreButtonNormal{$ELSE}twMinButtonNormal{$ENDIF}),
Font.PixelsPerInch) do
begin
PreferredWidth:=cx;
PreferredHeight:=cy;

View File

@ -2036,15 +2036,14 @@ begin
inherited FontChanged(Sender);
end;
function TCustomDateTimePicker.GetCheckBoxRect(
IgnoreRightToLeft: Boolean): TRect;
function TCustomDateTimePicker.GetCheckBoxRect(IgnoreRightToLeft: Boolean): TRect;
var
Details: TThemedElementDetails;
CSize: TSize;
begin
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
CSize := ThemeServices.GetDetailSize(Details);
CSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
CSize.cx := ScaleScreenToFont(CSize.cx);
CSize.cy := ScaleScreenToFont(CSize.cy);
@ -3869,7 +3868,7 @@ procedure TDTSpeedButton.Paint;
else
ArrowState := ttbSplitButtonDropDownDisabled;
Details := ThemeServices.GetElementDetails(ArrowState);
ASize := ThemeServices.GetDetailSize(Details);
ASize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
ARect := Rect(0, 0, Width, Height);
InflateRect(ARect, -(ARect.Right - ARect.Left - ASize.cx) div 2, 0);
ThemeServices.DrawElement(Canvas.Handle, Details, ARect);

View File

@ -1025,7 +1025,7 @@ begin
FSplitterX:=100;
FPreferredSplitterX:=FSplitterX;
Details := ThemeServices.GetElementDetails(ttGlyphOpened);
FIndent := ThemeServices.GetDetailSize(Details).cx;
FIndent := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch).cx;
FBackgroundColor:=DefBackgroundColor;
FReferencesColor:=DefReferencesColor;
@ -2401,7 +2401,7 @@ begin
// WasValueClick param is only for Boolean checkboxes, toggled if user
// clicks the square. It has no effect for Boolean ComboBox editor.
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
Sz := ThemeServices.GetDetailSize(Details);
Sz := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
SetItemIndexAndFocus(Index, (X>SplitterX) and (X<=SplitterX+Sz.cx));
SetCaptureControl(Self);
Column := oipgcValue;
@ -2976,7 +2976,7 @@ var
Details := ThemeServices.GetElementDetails(ttGlyphClosed);
if CanExpandRow(CurRow) then
begin
sz := ThemeServices.GetDetailSize(Details);
sz := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
IconY:=((NameRect.Bottom - NameRect.Top - sz.cy) div 2) + NameRect.Top;
ThemeServices.DrawElement(Canvas.Handle, Details,
Rect(IconX, IconY, IconX + sz.cx, IconY + sz.cy), nil)

View File

@ -30,7 +30,7 @@ uses
StdCtrls, Buttons, Menus, ExtCtrls, ComCtrls, Dialogs, EditBtn, Grids, ValEdit,
FileCtrl, PropertyStorage, Themes,
// LazControls
{$IFnDEF UseOINormalCheckBox} CheckBoxThemed, {$ENDIF}
CheckBoxThemed,
// LazUtils
FileUtil, StringHashList, LazMethodList, LazLoggerBase, LazUtilities, LazStringUtils,
GraphType, UITypes, FPCAdds, // for StrToQWord in older fpc versions
@ -302,7 +302,9 @@ type
FPropList: PInstPropList;
protected
// Draw Checkbox for Boolean and Set element editors.
{$IFDEF UseOINormalCheckBox}
function DrawCheckbox(ACanvas: TCanvas; const ARect: TRect; IsTrue: Boolean): TRect;
{$ENDIF}
function DrawCheckValue(ACanvas: TCanvas; const ARect: TRect;
{%H-}AState: TPropEditDrawState; {%H-}IsTrue: Boolean): TRect;
procedure DrawValue(const AValue: string; ACanvas:TCanvas; const ARect:TRect;
@ -2775,6 +2777,7 @@ begin
Result := (FPropList^[0].Instance <> nil) and IsStoredProp(FPropList^[0].Instance, FPropList^[0].PropInfo);
end;
{$IFDEF UseOINormalCheckBox}
function TPropertyEditor.DrawCheckbox(ACanvas: TCanvas; const ARect: TRect;
IsTrue: Boolean): TRect;
// Draws a Checkbox using theme services for editing booleans.
@ -2796,7 +2799,7 @@ begin
else
Check := tbCheckBoxUncheckedNormal;
Details := ThemeServices.GetElementDetails(Check);
Sz := ThemeServices.GetDetailSize(Details);
Sz := TCustomCheckBoxThemed.GetCheckBoxSize(ScreenInfo.PixelsPerInchX);
TopMargin := (ARect.Bottom - ARect.Top - Sz.cy) div 2;
BRect := ARect;
// Left varies by widgetset and theme etc. Real Checkbox itself has a left margin.
@ -2809,6 +2812,7 @@ begin
// Text will be written after the box.
Inc(Result.Left, Sz.cx + 4);
end;
{$ENDIF}
function TPropertyEditor.DrawCheckValue(ACanvas: TCanvas; const ARect: TRect;
AState: TPropEditDrawState; IsTrue: Boolean): TRect;

View File

@ -53,8 +53,6 @@ type
procedure SetState(AValue: TCheckBoxState);
private class var
FThemeCheckBoxSize: TSize;
protected
class function GetCheckBoxSize(const PixelsPerInch: Integer): TSize;
protected
CheckBoxPressed: Boolean;
KnobPosUnchecked, KnobPosChecked, KnobPosGrayed: Integer;
@ -83,6 +81,7 @@ type
cFocusBorder: SmallInt = 2;
cIndent: SmallInt = 5;
public
class function GetCheckBoxSize(const PixelsPerInch: Integer): TSize;
class procedure PaintSelf(ACanvas: TCanvas; ACaption: string; ARect: TRect;
AState: TCheckBoxState; ARightToLeft, AHovered, APressed, AFocused: Boolean;
AAlignment: TLeftRight; AEnabled: Boolean = True);
@ -236,9 +235,11 @@ begin
end;
class procedure TCustomCheckBoxThemed.InitCheckBoxSize;
var
Detail: TThemedElementDetails;
begin
with ThemeServices do
FThemeCheckBoxSize := GetDetailSize(GetElementDetails(tbCheckBoxCheckedNormal));
Detail := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
FThemeCheckBoxSize := ThemeServices.GetDetailSizeForPPI(Detail, Screen.PixelsPerInch);
end;
function TCustomCheckBoxThemed.DialogChar(var Message: TLMKey): Boolean;
@ -285,8 +286,7 @@ begin
Result := TCheckBoxThemedActionLink;
end;
class function TCustomCheckBoxThemed.GetCheckBoxSize(
const PixelsPerInch: Integer): TSize;
class function TCustomCheckBoxThemed.GetCheckBoxSize(const PixelsPerInch: Integer): TSize;
begin
if FThemeCheckBoxSize.cx<=0 then
InitCheckBoxSize;

View File

@ -126,7 +126,7 @@ begin
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal)
else
Details := ThemeServices.GetElementDetails(tbCheckBoxUncheckedNormal);
R.Right:=R.Left+ThemeServices.GetDetailSize(Details).cx;
R.Right:=R.Left+ThemeServices.GetDetailSizeForPPI(Details, PixelsPerInch).cx;
ThemeServices.DrawElement(ItemsTreeView.Canvas.Handle, Details, R, nil);
end;
end;
@ -248,8 +248,8 @@ begin
if Visible and (ImageList1.Count=0) then begin
CheckedDetails := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
UnCheckedDetails := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
CheckedSize:=ThemeServices.GetDetailSize(CheckedDetails);
UnCheckedSize:=ThemeServices.GetDetailSize(UnCheckedDetails);
CheckedSize:=ThemeServices.GetDetailSizeForPPI(CheckedDetails, PixelsPerInch);
UnCheckedSize:=ThemeServices.GetDetailSizeForPPI(UnCheckedDetails, PixelsPerInch);
ImageList1.Width:=Max(CheckedSize.cx,UnCheckedSize.cx);
ImageList1.Height:=Max(CheckedSize.cy,UnCheckedSize.cy);
Bmp:=TBitmap.Create;

View File

@ -519,7 +519,7 @@ begin
Details := ThemeServices.GetElementDetails(tbRadioButtonUncheckedNormal);
details_chek:=ThemeServices.GetElementDetails(tbRadioButtonCheckedNormal);
CSize := ThemeServices.GetDetailSize(Details);
CSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
while (AY < DRect.Bottom) and (i<TRadioGroup(FControl).Items.Count) do
@ -627,7 +627,7 @@ begin
i:=0;
Details := ThemeServices.GetElementDetails(tbCheckBoxUncheckedNormal);
CSize := ThemeServices.GetDetailSize(Details);
CSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
aH:=Max(Canvas.TextHeight(Text) div 2, CSize.cy);
@ -1210,7 +1210,7 @@ var
details: TThemedElementDetails;
begin
Details := ThemeServices.GetElementDetails(GetCheckStyle(Checked));
CSize := ThemeServices.GetDetailSize(Details);
CSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
PaintRect.Left := DRect.Left;
PaintRect.Top := (DRect.Top + DRect.Bottom - CSize.cy) div 2;
PaintRect := Bounds(PaintRect.Left, PaintRect.Top, CSize.cx, CSize.cy);

View File

@ -24375,7 +24375,7 @@ begin
if UseThemes then
begin
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
checkSize := ThemeServices.GetDetailSize(Details).CX;
checkSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch).CX;
R := Rect(XPos, YPos, XPos + checkSize, YPos + checkSize);
Details.Element := teButton;
case Index of

View File

@ -840,7 +840,7 @@ begin
FedPressed:=ThemeServices.GetElementDetails(tbRadioButtonCheckedPressed);
FedUncheckedHot:=ThemeServices.GetElementDetails(tbRadioButtonUncheckedHot);
FedCheckedHot:=ThemeServices.GetElementDetails(tbRadioButtonCheckedHot);
FedSize:=ThemeServices.GetDetailSize(FedUnChecked);
FedSize:=ThemeServices.GetDetailSizeForPPI(FedUnChecked, Font.PixelsPerInch);
FRadioHeight:=Max(FedSize.cy, anImgList.Height);
topOffset:=(FRadioHeight - FedSize.cy) div 2;
FRadioRect:=Rect(0, topOffset, FedSize.cx, topOffset+FedSize.cy);

View File

@ -299,7 +299,7 @@ begin
Exit;
Details := ThemeServices.GetElementDetails(tbPushButtonNormal);
DefButtonSize := ThemeServices.GetDetailSize(Details);
DefButtonSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
FButtonsWidth := DefButtonSize.cx;
FButtonsHeight := DefButtonSize.cy;
@ -382,7 +382,7 @@ begin
Exit;
Details := ThemeServices.GetElementDetails(tbPushButtonNormal);
DefButtonSize := ThemeServices.GetDetailSize(Details);
DefButtonSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomButtonPanel.UpdateButtonSize'){$ENDIF};
try

View File

@ -4354,7 +4354,7 @@ begin
soDescending: Details := ThemeServices.GetElementDetails(thHeaderSortArrowSortedDown);
end;
s := ThemeServices.GetDetailSize(Details);
s := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
end else
s := Size(-1, -1);
if s.cx>0 then // theme services support sorted arrows
@ -4839,7 +4839,7 @@ begin
end else
begin
Details := ThemeServices.GetElementDetails(arrtb[AState]);
CSize := ThemeServices.GetDetailSize(Details);
CSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch);
CSize.cx := MulDiv(CSize.cx, Font.PixelsPerInch, Screen.PixelsPerInch);
CSize.cy := MulDiv(CSize.cy, Font.PixelsPerInch, Screen.PixelsPerInch);
end;

View File

@ -646,7 +646,7 @@ begin { do not call inherited ! }
[aEnabled, aState, not aDropped and FCheckHighlight]);
if FNeedMeasure then
begin
FCheckSize:=ThemeServices.GetDetailSize(aDetail);
FCheckSize:=ThemeServices.GetDetailSizeForPPI(aDetail, Font.PixelsPerInch);
FTextHeight:=Canvas.TextHeight('ŠjÁÇ');
if not aDropped then
begin

View File

@ -881,7 +881,7 @@ procedure TCustomSplitter.Paint;
BF_ADJUST or BF_RECT, @ARect);
GripperRect := ARect;
GripperSize := ThemeServices.GetDetailSize(GripperDetails);
GripperSize := ThemeServices.GetDetailSizeForPPI(GripperDetails, Font.PixelsPerInch);
if (GripperSize.cx <> -1) or (GripperSize.cy <> -1) then
begin
if ResizeAnchor in [akLeft,akRight] then

View File

@ -90,9 +90,9 @@ begin
FFlat := True;
Height := 32;
Details := ThemeServices.GetElementDetails(ttbSplitButtonDropDownNormal);
FThemeDropDownWidth := ThemeServices.GetDetailSize(Details).cx;
FThemeDropDownWidth := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch).cx;
Details := ThemeServices.GetElementDetails(ttbDropDownButtonNormal);
FThemeButtonDropWidth := ThemeServices.GetDetailSize(Details).cx;
FThemeButtonDropWidth := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch).cx;
FButtonHeight := -1;
FButtonWidth := -1;
FDropDownWidth := -1;

View File

@ -3475,7 +3475,7 @@ begin
FExpandSignSize := -1;
FExpandSignWidth := 2;
Details := ThemeServices.GetElementDetails(ttGlyphOpened);
FThemeExpandSignSize := ThemeServices.GetDetailSize(Details).cx;
FThemeExpandSignSize := ThemeServices.GetDetailSizeForPPI(Details, Font.PixelsPerInch).cx;
FTreeNodes := CreateNodes;
BorderStyle := bsSingle;
BorderWidth := 0;

View File

@ -477,7 +477,7 @@ type
function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
function GetElementDetails(Detail: TThemedWindow): TThemedElementDetails; overload;
function GetDetailSize(Details: TThemedElementDetails): TSize; virtual;
function GetDetailSize(Details: TThemedElementDetails): TSize; virtual; deprecated 'use GetDetailSizeForPPI';
function GetDetailSizeForWindow(Details: TThemedElementDetails; const AWindow: HWND): TSize; virtual;
function GetDetailSizeForPPI(Details: TThemedElementDetails; PPI: Integer): TSize; virtual;
function GetDetailRegion(DC: HDC; Details: TThemedElementDetails; const R: TRect): HRGN; virtual;

View File

@ -241,7 +241,7 @@ begin
else
Detail := tbCheckBoxUncheckedNormal;
Details := ThemeServices.GetElementDetails(Detail);
aSize := ThemeServices.GetDetailSize(Details);
aSize := ThemeServices.GetDetailSizeForPPI(Details, PixelsPerInch);
NodeRect:=Node.DisplayRect(false);
r:=Bounds(Node.DisplayIconLeft+(ImageList1.Width-aSize.cx) div 2,
NodeRect.Top+(NodeRect.Bottom-NodeRect.Top-aSize.cy) div 2,
@ -392,7 +392,7 @@ begin
ButtonPanel1.OKButton.OnClick:=@OkButtonClick;
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
aSize := ThemeServices.GetDetailSize(Details);
aSize := ThemeServices.GetDetailSizeForPPI(Details, PixelsPerInch);
ImageList1.Width:=Max(16,aSize.cx);
ImageList1.Height:=Max(16,aSize.cy);
// add empty images