mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 14:29:07 +02:00
Implemented unicode support for menus on the windows interface
git-svn-id: trunk@11584 -
This commit is contained in:
parent
a963094291
commit
c44cc0e9c3
@ -199,12 +199,27 @@ var
|
|||||||
oldFont: HFONT;
|
oldFont: HFONT;
|
||||||
newFont: HFONT;
|
newFont: HFONT;
|
||||||
tmpRect: Windows.RECT;
|
tmpRect: Windows.RECT;
|
||||||
|
AnsiBuffer: ansistring;
|
||||||
|
WideBuffer: widestring;
|
||||||
begin
|
begin
|
||||||
tmpRect.right := 0;
|
tmpRect.right := 0;
|
||||||
tmpRect.left := 0;
|
tmpRect.left := 0;
|
||||||
newFont := getMenuItemFont(aDecoration);
|
newFont := getMenuItemFont(aDecoration);
|
||||||
oldFont := SelectObject(aHDC, newFont);
|
oldFont := SelectObject(aHDC, newFont);
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
WideBuffer := Utf8Decode(aCaption);
|
||||||
|
DrawTextW(aHDC, PWideChar(WideBuffer), length(WideBuffer), @TmpRect, DT_CALCRECT);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
AnsiBuffer := Utf8ToAnsi(aCaption);
|
||||||
|
DrawText(aHDC, pChar(AnsiBuffer), length(AnsiBuffer), @TmpRect, DT_CALCRECT);
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
DrawText(aHDC, pChar(aCaption), length(aCaption), @TmpRect, DT_CALCRECT);
|
DrawText(aHDC, pChar(aCaption), length(aCaption), @TmpRect, DT_CALCRECT);
|
||||||
|
{$endif}
|
||||||
SelectObject(aHDC, oldFont);
|
SelectObject(aHDC, oldFont);
|
||||||
DeleteObject(newFont);
|
DeleteObject(newFont);
|
||||||
Result.cx := TmpRect.right - TmpRect.left;
|
Result.cx := TmpRect.right - TmpRect.left;
|
||||||
@ -394,6 +409,8 @@ var
|
|||||||
IsRightToLeft: Boolean;
|
IsRightToLeft: Boolean;
|
||||||
etoFlags: Cardinal;
|
etoFlags: Cardinal;
|
||||||
dtFlags: Word;
|
dtFlags: Word;
|
||||||
|
AnsiBuffer: ansistring;
|
||||||
|
WideBuffer: widestring;
|
||||||
begin
|
begin
|
||||||
crText := TextColorMenu(aSelected, aMenuItem.Enabled);
|
crText := TextColorMenu(aSelected, aMenuItem.Enabled);
|
||||||
crBkgnd := BackgroundColorMenu(aSelected, aMenuItem.IsInMenuBar);
|
crBkgnd := BackgroundColorMenu(aSelected, aMenuItem.IsInMenuBar);
|
||||||
@ -420,13 +437,43 @@ begin
|
|||||||
ExtTextOut(aHDC, 0, 0, etoFlags, @aRect, PChar(''), 0, nil);
|
ExtTextOut(aHDC, 0, 0, etoFlags, @aRect, PChar(''), 0, nil);
|
||||||
TmpLength := aRect.right - aRect.left;
|
TmpLength := aRect.right - aRect.left;
|
||||||
TmpHeight := aRect.bottom - aRect.top;
|
TmpHeight := aRect.bottom - aRect.top;
|
||||||
|
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
WideBuffer := Utf8Decode(aMenuItem.Caption);
|
||||||
|
DrawTextW(aHDC, PWideChar(WideBuffer), length(WideBuffer), @WorkRect, DT_CALCRECT);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
AnsiBuffer := Utf8ToAnsi(aMenuItem.Caption);
|
||||||
|
DrawText(aHDC, pChar(AnsiBuffer), length(AnsiBuffer), @WorkRect, DT_CALCRECT);
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
DrawText(aHDC, pChar(aMenuItem.Caption), length(aMenuItem.Caption), @WorkRect, DT_CALCRECT);
|
DrawText(aHDC, pChar(aMenuItem.Caption), length(aMenuItem.Caption), @WorkRect, DT_CALCRECT);
|
||||||
|
{$endif}
|
||||||
|
|
||||||
if IsRightToLeft then
|
if IsRightToLeft then
|
||||||
Dec(aRect.Right, leftCaptionPosition(TmpLength, WorkRect.Right - WorkRect.Left, aMenuItem))
|
Dec(aRect.Right, leftCaptionPosition(TmpLength, WorkRect.Right - WorkRect.Left, aMenuItem))
|
||||||
else
|
else
|
||||||
Inc(aRect.Left, leftCaptionPosition(TmpLength, WorkRect.Right - WorkRect.Left, aMenuItem));
|
Inc(aRect.Left, leftCaptionPosition(TmpLength, WorkRect.Right - WorkRect.Left, aMenuItem));
|
||||||
Inc(aRect.Top, topPosition(TmpHeight, WorkRect.Bottom - WorkRect.Top));
|
Inc(aRect.Top, topPosition(TmpHeight, WorkRect.Bottom - WorkRect.Top));
|
||||||
|
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
WideBuffer := Utf8Decode(aMenuItem.Caption);
|
||||||
|
DrawTextW(aHDC, PWideChar(WideBuffer), length(WideBuffer), @aRect, dtFlags);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
AnsiBuffer := Utf8ToAnsi(aMenuItem.Caption);
|
||||||
|
DrawText(aHDC, pChar(AnsiBuffer), length(AnsiBuffer), @aRect, dtFlags);
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
DrawText(aHDC, pChar(aMenuItem.Caption), length(aMenuItem.Caption), @aRect, dtFlags);
|
DrawText(aHDC, pChar(aMenuItem.Caption), length(aMenuItem.Caption), @aRect, dtFlags);
|
||||||
|
{$endif}
|
||||||
|
|
||||||
if aMenuItem.ShortCut <> scNone then
|
if aMenuItem.ShortCut <> scNone then
|
||||||
begin
|
begin
|
||||||
shortCutText := ShortCutToText(aMenuItem.ShortCut);
|
shortCutText := ShortCutToText(aMenuItem.ShortCut);
|
||||||
@ -440,7 +487,21 @@ begin
|
|||||||
Dec(aRect.Right, GetSystemMetrics(SM_CXMENUCHECK));
|
Dec(aRect.Right, GetSystemMetrics(SM_CXMENUCHECK));
|
||||||
dtFlags := DT_RIGHT;
|
dtFlags := DT_RIGHT;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
WideBuffer := Utf8Decode(shortCutText);
|
||||||
|
DrawTextW(aHDC, PWideChar(WideBuffer), length(WideBuffer), @aRect, dtFlags);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
AnsiBuffer := Utf8ToAnsi(shortCutText);
|
||||||
|
DrawText(aHDC, pChar(AnsiBuffer), length(AnsiBuffer), @aRect, dtFlags);
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
DrawText(aHDC, pChar(shortCutText), Length(shortCutText), @aRect, dtFlags);
|
DrawText(aHDC, pChar(shortCutText), Length(shortCutText), @aRect, dtFlags);
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
SelectObject(aHDC, oldFont);
|
SelectObject(aHDC, oldFont);
|
||||||
DeleteObject(newFont);
|
DeleteObject(newFont);
|
||||||
|
Loading…
Reference in New Issue
Block a user