mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 09:40:28 +02:00
Improved UTF-8 support on the Unicode Windows IDE and fixed Unicode version of ListBox, ComboBox and other TStrings based controls on Unicode Windows.
git-svn-id: trunk@11621 -
This commit is contained in:
parent
316cb557d7
commit
2e324f401a
@ -127,6 +127,31 @@ begin
|
||||
Result := lProcessEvent;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: ExtUTF8Out
|
||||
|
||||
As ExtTextOut except that Str is treated as UTF8
|
||||
------------------------------------------------------------------------------}
|
||||
function TWin32WidgetSet.ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean;
|
||||
begin
|
||||
Result := ExtTextOut(DC, X, Y, Options, Rect, Str, Count, Dx);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function FontCanUTF8(Font: HFont): boolean;
|
||||
|
||||
True if font recognizes Unicode UTF8 encoding.
|
||||
------------------------------------------------------------------------------}
|
||||
function TWin32WidgetSet.FontCanUTF8(Font: HFont): boolean;
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
Result := True;
|
||||
{$else}
|
||||
Result := False;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TWin32WidgetSet.HandleProcessEvent(AData: PtrInt; AFlags: dword);
|
||||
var
|
||||
lProcessEvent: PProcessEvent absolute AData;
|
||||
|
@ -42,6 +42,11 @@ function CreateStandardCursor(ACursor: SmallInt): hCursor; override;
|
||||
procedure DeallocateHWnd(Wnd: HWND); override;
|
||||
procedure DrawArrow(Arrow: TComponent; Canvas: TPersistent); override;
|
||||
|
||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||
|
||||
function FontCanUTF8(Font: HFont): boolean; override;
|
||||
|
||||
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
|
||||
function GetControlConstraints(Constraints: TObject): boolean; override;
|
||||
function GetListBoxIndexAtY(ListBox: TComponent; y: integer): integer; override;
|
||||
|
@ -130,7 +130,7 @@ begin
|
||||
Begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
AnIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0,
|
||||
AnIndex := Windows.SendMessageW(FWin32List, FFlagAddString, 0,
|
||||
LPARAM(PWideChar(Utf8Decode(TheStrings[Counter])))) //Insert
|
||||
else
|
||||
AnIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0,
|
||||
@ -235,7 +235,7 @@ begin
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
FLastInsertedIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0, LPARAM(PWideChar(Utf8Decode(S))))
|
||||
FLastInsertedIndex := Windows.SendMessageW(FWin32List, FFlagAddString, 0, LPARAM(PWideChar(Utf8Decode(S))))
|
||||
else
|
||||
FLastInsertedIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0, LPARAM(PChar(Utf8ToAnsi(S))));
|
||||
{$else}
|
||||
@ -246,7 +246,7 @@ begin
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
Windows.SendMessage(FWin32List, FFlagInsertString, Index, LPARAM(PWideChar(Utf8Decode(S))))
|
||||
Windows.SendMessageW(FWin32List, FFlagInsertString, Index, LPARAM(PWideChar(Utf8Decode(S))))
|
||||
else
|
||||
Windows.SendMessage(FWin32List, FFlagInsertString, Index, LPARAM(PChar(Utf8ToAnsi(S))));
|
||||
{$else}
|
||||
|
@ -1385,20 +1385,23 @@ begin
|
||||
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
// use temp buffer, if count is set, there might be no null terminator
|
||||
if count = -1
|
||||
then s := str
|
||||
else begin
|
||||
if count = -1 then
|
||||
s := str
|
||||
else
|
||||
begin
|
||||
SetLength(s, count);
|
||||
move(str^, s[1], count);
|
||||
end;
|
||||
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
||||
if UnicodeEnabledOS
|
||||
then begin
|
||||
then
|
||||
begin
|
||||
// TODO: use the real number of chars (and not the lenght)
|
||||
W := Utf8Decode(S);
|
||||
Result := Windows.ExtTextOutW(DC, X, Y, Options, LPRECT(Rect), PWideChar(W), Length(W), Dx);
|
||||
end
|
||||
else begin
|
||||
else
|
||||
begin
|
||||
S := Utf8ToAnsi(S);
|
||||
Result := Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), PChar(S), Length(S), Dx);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user