mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-10 02:38:12 +02:00
LCL themes: GetDetailSizeForPPI & GetDetailSizeForWindow
This commit is contained in:
parent
6a48c90712
commit
1163a2fcea
@ -45,7 +45,8 @@ type
|
|||||||
public
|
public
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
function GetDetailSizeForWindow(Details: TThemedElementDetails; const AWindow: HWND): TSize; override;
|
||||||
|
function GetDetailSizeForPPI(Details: TThemedElementDetails; PPI: Integer): TSize; override;
|
||||||
function GetDetailRegion(DC: HDC; Details: TThemedElementDetails; const R: TRect): HRGN; override;
|
function GetDetailRegion(DC: HDC; Details: TThemedElementDetails; const R: TRect): HRGN; override;
|
||||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
|
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
|
||||||
function GetStockImage(StockID: LongInt; const AWidth, AHeight: Integer; out Image, Mask: HBitmap): Boolean; override;
|
function GetStockImage(StockID: LongInt; const AWidth, AHeight: Integer; out Image, Mask: HBitmap): Boolean; override;
|
||||||
@ -184,7 +185,7 @@ begin
|
|||||||
FreeThemeLibrary;
|
FreeThemeLibrary;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWin32ThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
function TWin32ThemeServices.GetDetailSizeForPPI(Details: TThemedElementDetails; PPI: Integer): TSize;
|
||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
@ -200,13 +201,26 @@ begin
|
|||||||
(Details.Element = teTrackBar) or (Details.Element = teHeader) then
|
(Details.Element = teTrackBar) or (Details.Element = teHeader) then
|
||||||
begin
|
begin
|
||||||
R := Rect(0, 0, 800, 800);
|
R := Rect(0, 0, 800, 800);
|
||||||
GetThemePartSize(GetTheme(Details.Element), 0, Details.Part, Details.State, @R, TS_TRUE, Result);
|
GetThemePartSize(GetThemeForPPI(Details.Element, PPI), 0, Details.Part, Details.State, @R, TS_TRUE, Result);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := inherited GetDetailSize(Details);
|
Result := inherited GetDetailSizeForPPI(Details, PPI);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := inherited GetDetailSize(Details);
|
Result := inherited GetDetailSizeForPPI(Details, PPI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TWin32ThemeServices.GetDetailSizeForWindow(Details: TThemedElementDetails; const AWindow: HWND): TSize;
|
||||||
|
var
|
||||||
|
PPI: UINT;
|
||||||
|
begin
|
||||||
|
if (AWindow<>0) and AreDpiAwarenessContextsEqual(GetThreadDpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) then
|
||||||
|
PPI := GetDpiForWindow(AWindow)
|
||||||
|
else
|
||||||
|
PPI := 0;
|
||||||
|
if PPI=0 then
|
||||||
|
PPI := ScreenInfo.PixelsPerInchX;
|
||||||
|
Result := GetDetailSizeForPPI(Details, PPI);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWin32ThemeServices.GetImageAndMaskFromIcon(const Icon: HICON; out Image, Mask: HBITMAP): Boolean;
|
function TWin32ThemeServices.GetImageAndMaskFromIcon(const Icon: HICON; out Image, Mask: HBITMAP): Boolean;
|
||||||
|
@ -477,7 +477,9 @@ type
|
|||||||
function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
|
function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
|
||||||
function GetElementDetails(Detail: TThemedWindow): 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;
|
function GetDetailRegion(DC: HDC; Details: TThemedElementDetails; const R: TRect): HRGN; virtual;
|
||||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; virtual;
|
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; virtual;
|
||||||
function GetStockImage(StockID: LongInt; const AWidth, AHeight: Integer; out Image, Mask: HBitmap): Boolean; virtual;
|
function GetStockImage(StockID: LongInt; const AWidth, AHeight: Integer; out Image, Mask: HBitmap): Boolean; virtual;
|
||||||
@ -1874,6 +1876,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
function TThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||||
|
begin
|
||||||
|
Result := GetDetailSizeForPPI(Details, ScreenInfo.PixelsPerInchX);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TThemeServices.GetDetailSizeForPPI(Details: TThemedElementDetails; PPI: Integer): TSize;
|
||||||
begin
|
begin
|
||||||
// default values here
|
// default values here
|
||||||
// -1 mean that we do not know size of detail
|
// -1 mean that we do not know size of detail
|
||||||
@ -1905,9 +1912,14 @@ begin
|
|||||||
Result := Size(8, 5);
|
Result := Size(8, 5);
|
||||||
end;
|
end;
|
||||||
if (Result.cx>0) then
|
if (Result.cx>0) then
|
||||||
Result.cx := MulDiv(Result.cx, ScreenInfo.PixelsPerInchX, 96);
|
Result.cx := MulDiv(Result.cx, PPI, 96);
|
||||||
if (Result.cy>0) then
|
if (Result.cy>0) then
|
||||||
Result.cy := MulDiv(Result.cy, ScreenInfo.PixelsPerInchY, 96);
|
Result.cy := MulDiv(Result.cy, PPI, 96);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TThemeServices.GetDetailSizeForWindow(Details: TThemedElementDetails; const AWindow: HWND): TSize;
|
||||||
|
begin
|
||||||
|
Result := GetDetailSizeForPPI(Details, ScreenInfo.PixelsPerInchX);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TThemeServices.GetDetailRegion(DC: HDC;
|
function TThemeServices.GetDetailRegion(DC: HDC;
|
||||||
|
Loading…
Reference in New Issue
Block a user