mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 14:29:31 +02:00
win32: use ThemeServices to draw TBitBtn (maybe fix issue #0013920)
git-svn-id: trunk@20538 -
This commit is contained in:
parent
adb0522aff
commit
dda7ce7306
@ -148,12 +148,22 @@ var
|
||||
{$ENDIF}
|
||||
|
||||
procedure DrawBitmap(AState: TButtonState; UseThemes: Boolean);
|
||||
const
|
||||
ButtonsDetail: array[TButtonState] of TThemedButton = (
|
||||
{ bsUp } tbPushButtonNormal,
|
||||
{ bsDisabled } tbPushButtonDisabled,
|
||||
{ bsDown } tbPushButtonPressed,
|
||||
{ bsExclusive } tbPushButtonNormal,
|
||||
{ bsHot } tbPushButtonHot
|
||||
);
|
||||
|
||||
var
|
||||
TextFlags: integer; // flags for caption (enabled or disabled)
|
||||
glyphWidth, glyphHeight: integer;
|
||||
OldBitmapHandle: HBITMAP; // Handle of the provious bitmap in hdcNewBitmap
|
||||
AIndex: Integer;
|
||||
AEffect: TGraphicsDrawEffect;
|
||||
Details: TThemedElementDetails;
|
||||
begin
|
||||
glyphWidth := srcWidth;
|
||||
glyphHeight := srcHeight;
|
||||
@ -215,19 +225,28 @@ var
|
||||
end;
|
||||
end;
|
||||
SetBkMode(hdcNewBitmap, TRANSPARENT);
|
||||
{$IFDEF WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
if not UseThemes then
|
||||
begin
|
||||
ButtonCaptionW := UTF8ToUTF16(ButtonCaption);
|
||||
DrawStateW(hdcNewBitmap, 0, nil, LPARAM(ButtonCaptionW), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
{$IFDEF WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
begin
|
||||
ButtonCaptionW := UTF8ToUTF16(ButtonCaption);
|
||||
DrawStateW(hdcNewBitmap, 0, nil, LPARAM(ButtonCaptionW), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
end
|
||||
else begin
|
||||
ButtonCaptionA := Utf8ToAnsi(ButtonCaption);
|
||||
DrawState(hdcNewBitmap, 0, nil, LPARAM(ButtonCaptionA), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
end;
|
||||
{$ELSE}
|
||||
DrawState(hdcNewBitmap, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
{$ENDIF}
|
||||
end
|
||||
else begin
|
||||
ButtonCaptionA := Utf8ToAnsi(ButtonCaption);
|
||||
DrawState(hdcNewBitmap, 0, nil, LPARAM(ButtonCaptionA), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
else
|
||||
begin
|
||||
Details := ThemeServices.GetElementDetails(ButtonsDetail[AState]);
|
||||
ThemeServices.DrawText(hdcNewBitmap, Details, ButtonCaption,
|
||||
Rect(XDestText, YDestText, XDestText + TextSize.cx, YDestText + TextSize.cy), 0, 0);
|
||||
end;
|
||||
{$ELSE}
|
||||
DrawState(hdcNewBitmap, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
{$ENDIF}
|
||||
SelectObject(hdcNewBitmap, OldBitmapHandle);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user