customdrawn: Starts the Pascal to Java JNI ifdefs and adds a skeleton for text drawing/metrics support

git-svn-id: trunk@33884 -
This commit is contained in:
sekelsenmat 2011-12-01 11:04:22 +00:00
parent 7a4de2176d
commit 66de3a943b
7 changed files with 145 additions and 168 deletions

View File

@ -3,6 +3,8 @@
{$modeswitch objectivec1} {$modeswitch objectivec1}
{$endif} {$endif}
{$define CD_Android_DontUsePascalToJNI}
// For now default to Android for arm-linux, // For now default to Android for arm-linux,
// because LCL-CustomDrawn is our main Android widgetset. // because LCL-CustomDrawn is our main Android widgetset.
// Remove this when Android gets it's own target // Remove this when Android gets it's own target
@ -10,7 +12,8 @@
{$define Android} {$define Android}
{$endif}{$endif}{$endif} {$endif}{$endif}{$endif}
// Check if a backend is already defined
// Check if a backend which can be utilized in multiple-systems is already defined
{$if defined(CD_X11)} {$if defined(CD_X11)}
{$else} {$else}
// Choosing the default backend // Choosing the default backend

View File

@ -133,38 +133,56 @@ const NativeMethods: array[0..1] of JNINativeMethod=
function JNI_OnLoad(vm:PJavaVM;reserved:pointer):jint; cdecl; function JNI_OnLoad(vm:PJavaVM;reserved:pointer):jint; cdecl;
begin begin
curVM:=vm; curVM:=vm;
{ __android_log_write(ANDROID_LOG_INFO,'nativetest','JNI_OnLoad called');
__android_log_write(ANDROID_LOG_INFO,'nativetest',PChar(Format('CurVM=%x', [PtrInt(CurVM)]))); {
__android_log_write(ANDROID_LOG_INFO,'nativetest',PChar(Format('CurVM^=%x', [PtrInt(CurVM^)]))); vm^^.GetEnv crashes HTC Wildfire, Alcatel and the Emulator for unknown reasons,
__android_log_write(ANDROID_LOG_INFO,'nativetest',PChar(Format('CurVM^^.reserved0=%x', [PtrInt(CurVM^^.reserved0)]))); see: http://groups.google.com/group/android-ndk/browse_thread/thread/ba542483f062a828/ef9077617794e0f5
__android_log_write(ANDROID_LOG_INFO,'nativetest',PChar(Format('CurVM^^.GetEnv=%x', [PtrInt(Pointer(@CurVM^^.GetEnv))])));
if vm^^.GetEnv(curVM,@curEnv,JNI_VERSION_1_4)<>JNI_OK then begin //<<<--- THIS CRASHES This prevents using Pascal to Java calls completely in those platforms.
__android_log_write(ANDROID_LOG_INFO{FATAL},'nativetest','curVM^.GetEnv failed'); To turn on a work around one can use CD_Android_DontUsePascalToJNI
and then try to implement the missing functionality by other means.
Not that Java to Pascal calls always work
}
{$ifndef CD_Android_DontUsePascalToJNI}
__android_log_write(ANDROID_LOG_INFO, 'lclapp', 'JNI_OnLoad called');
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(Format('CurVM=%x', [PtrInt(CurVM)])));
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(Format('CurVM^=%x', [PtrInt(CurVM^)])));
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(Format('CurVM^^.reserved0=%x', [PtrInt(CurVM^^.reserved0)])));
__android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(Format('CurVM^^.GetEnv=%x', [PtrInt(Pointer(@CurVM^^.GetEnv))])));
if vm^^.GetEnv(curVM,@curEnv,JNI_VERSION_1_4)<>JNI_OK then
begin
__android_log_write(ANDROID_LOG_FATAL, 'lclapp', 'curVM^.GetEnv failed');
result:=JNI_ERR; result:=JNI_ERR;
exit; exit;
end; end;
__android_log_write(ANDROID_LOG_INFO,'nativetest','Reading curClass'); __android_log_write(ANDROID_LOG_INFO,'lclapp','Reading curClass');
curClass:=curEnv^^.FindClass(curEnv,'com/pascal/lcltest/LCLActivity'); curJavaClass:=curEnv^^.FindClass(curEnv,'com/pascal/lcltest/LCLActivity');
if not assigned(curClass) then begin if not assigned(curJavaClass) then
__android_log_write(ANDROID_LOG_FATAL,'nativetest','curEnv^.FindClass failed'); begin
result:=JNI_ERR; __android_log_write(ANDROID_LOG_FATAL, 'lclapp', 'curEnv^.FindClass failed');
exit; result:=JNI_ERR;
exit;
end; end;
if curEnv^^.RegisterNatives(curEnv,curClass,@NativeMethods[0],length(NativeMethods))<0 then begin if curEnv^^.RegisterNatives(curEnv, curJavaClass, @NativeMethods[0],length(NativeMethods))<0 then
__android_log_write(ANDROID_LOG_FATAL,'nativetest','curEnv^.RegisterNatives failed'); begin
result:=JNI_ERR; __android_log_write(ANDROID_LOG_FATAL, 'nativetest', 'curEnv^.RegisterNatives failed');
exit; result:=JNI_ERR;
exit;
end; end;
nativeCodeLoaded:=curEnv^^.GetFieldID(curEnv,curClass,'nativeCodeLoaded','J'); nativeCodeLoaded:=curEnv^^.GetFieldID(curEnv, curJavaClass, 'nativeCodeLoaded','J');
if not assigned(nativeCodeLoaded) then begin if not assigned(nativeCodeLoaded) then
__android_log_write(ANDROID_LOG_FATAL,'nativetest','curEnv^.GetFieldID failed'); begin
result:=JNI_ERR; __android_log_write(ANDROID_LOG_FATAL, 'nativetest', 'curEnv^.GetFieldID failed');
exit; result:=JNI_ERR;
end; } exit;
end;
{$endif}
result:=JNI_VERSION_1_4;// 1_6? result:=JNI_VERSION_1_4;// 1_6 is another option
end; end;
procedure JNI_OnUnload(vm:PJavaVM;reserved:pointer); cdecl; procedure JNI_OnUnload(vm:PJavaVM;reserved:pointer); cdecl;

View File

@ -1,6 +1,6 @@
{%MainUnit customdrawnint.pp} {%MainUnit customdrawnint.pp}
{****************************************************************************** {******************************************************************************
All CustomDrawn X11 specific Winapi implementations. All CustomDrawn Android specific Winapi implementations.
!! Keep alphabetical !! !! Keep alphabetical !!
@ -2168,7 +2168,7 @@ begin
end end
else else
Result := inherited ExtSelectClipRGN(DC, RGN, Mode); Result := inherited ExtSelectClipRGN(DC, RGN, Mode);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: ExtTextOut Function: ExtTextOut
@ -2177,20 +2177,20 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; function TCDWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint;
Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
var {var
WideStr: WideString; WideStr: WideString;
QtDC: TQtDeviceContext absolute DC; QtDC: TQtDeviceContext absolute DC;
B: Boolean; B: Boolean; }
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI ExtTextOut]'); WriteLn('[WinAPI ExtTextOut]');
{$endif} {$endif}
Result := False; Result := False;
if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then { if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then
exit; exit;
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
@ -2220,10 +2220,10 @@ begin
QtDC.drawText(X, Y, @WideStr); QtDC.drawText(X, Y, @WideStr);
end; end;
Result := True; Result := True;}
end; end;
{------------------------------------------------------------------------------ (*{------------------------------------------------------------------------------
Function: FillRect Function: FillRect
Params: none Params: none
Returns: Nothing Returns: Nothing
@ -4084,29 +4084,29 @@ begin
end; end;
end; end;
Result := True; Result := True;
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: GetTextExtentPoint Function: GetTextExtentPoint
Params: none Params: none
Returns: Nothing Returns: Nothing
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; function TCDWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
var {var
WideStr: WideString; WideStr: WideString;
QtDC: TQtDeviceContext absolute DC; QtDC: TQtDeviceContext absolute DC;}
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI GetTextExtentPoint]'); DebugLn('[WinAPI GetTextExtentPoint]');
{$endif} {$endif}
Result := False; Result := False;
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
WideStr := GetUtf8String(Str); { WideStr := GetUtf8String(Str);
Size.cx := QtDC.Metrics.width(@WideStr, Count); Size.cx := QtDC.Metrics.width(@WideStr, Count);
Size.cy := QtDC.Metrics.height; Size.cy := QtDC.Metrics.height;}
Result := True; Result := True;
end; end;
@ -4117,20 +4117,20 @@ end;
TM - The structure to receive the font information TM - The structure to receive the font information
Returns: If successfull Returns: If successfull
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; function TCDWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
var {var
QtFontMetrics: TQtFontMetrics; QtFontMetrics: TQtFontMetrics;
FontFamily: WideString; FontFamily: WideString;
QtDC: TQtDeviceContext absolute DC; QtDC: TQtDeviceContext absolute DC;
FontWeight: Integer; FontWeight: Integer;}
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI GetTextMetrics]'); DebugLn('[WinAPI GetTextMetrics]');
{$endif} {$endif}
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then (* if Result then
begin begin
QtFontMetrics := QtDC.Metrics; QtFontMetrics := QtDC.Metrics;
TM.tmHeight := QtFontMetrics.height; TM.tmHeight := QtFontMetrics.height;
@ -4180,10 +4180,10 @@ begin
TM.tmPitchAndFamily := FIXED_PITCH or TRUETYPE_FONTTYPE; TM.tmPitchAndFamily := FIXED_PITCH or TRUETYPE_FONTTYPE;
TM.tmCharSet := DEFAULT_CHARSET; TM.tmCharSet := DEFAULT_CHARSET;
end; end; *)
end; end;
function TQtWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer; (*function TQtWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer;
var var
R: TRect; R: TRect;
begin begin
@ -6371,7 +6371,7 @@ begin
else else
Result := False; Result := False;
end end
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TextOut Function: TextOut
@ -6383,29 +6383,27 @@ end;
Returns: Returns:
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : PChar; Count: Integer) : Boolean; function TCDWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : PChar; Count: Integer) : Boolean;
var
WideStr: WideString;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI TextOut]'); DebugLn('[WinAPI TextOut]');
{$endif} {$endif}
Result := False; Result := False;
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
if Count >= 0 then { if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count)) WideStr := GetUtf8String(Copy(Str, 1, Count))
else else
WideStr := GetUtf8String(Str); WideStr := GetUtf8String(Str);
TQtDeviceContext(DC).drawText(X, Y, @WideStr); TQtDeviceContext(DC).drawText(X, Y, @WideStr);
Result := True; Result := True;}
end; end;
{------------------------------------------------------------------------------ (*{------------------------------------------------------------------------------
Method: UpdateWindow Method: UpdateWindow
Params: Handle Params: Handle
Returns: Returns:

View File

@ -890,7 +890,7 @@ begin
Exit; Exit;
end; end;
with ctx do Result:=RGBToColorFloat(TR, TG, TB); with ctx do Result:=RGBToColorFloat(TR, TG, TB);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: GetTextExtentPoint Method: GetTextExtentPoint
@ -902,19 +902,19 @@ end;
Computes the width and height of the specified string of text Computes the width and height of the specified string of text
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCocoaWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; function TCDWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
var var
ctx : TCocoaContext; ctx : TCocoaContext;
begin begin
{$IFDEF VerboseWinAPI} {$IFDEF VerboseCDWinAPI}
DebugLn('[TCocoaWidgetSet.GetTextExtentPoint] DC: %x Str: %s Count: %d', [DC, Str, Count]); DebugLn('[TCDWidgetSet.GetTextExtentPoint] DC: %x Str: %s Count: %d', [DC, Str, Count]);
{$ENDIF} {$ENDIF}
ctx:=CheckDC(DC); { ctx:=CheckDC(DC);
Result:=Assigned(ctx); Result:=Assigned(ctx);
if not Assigned(ctx) then Exit(False); if not Assigned(ctx) then Exit(False);
Result := ctx.GetTextExtentPoint(Str, Count, Size); Result := ctx.GetTextExtentPoint(Str, Count, Size);}
{$IFDEF VerboseWinAPI} {$IFDEF VerboseCDWinAPI}
DebugLn('[TCocoaWidgetSet.GetTextExtentPoint] Size: %d,%d', [Size.cx, Size.cy]); DebugLn('[TCDWidgetSet.GetTextExtentPoint] Size: %d,%d', [Size.cx, Size.cy]);
{$ENDIF} {$ENDIF}
end; end;
@ -933,26 +933,26 @@ var
begin begin
Result := False; Result := False;
{$IFDEF VerboseWinAPI} {$IFDEF VerboseCDWinAPI}
DebugLn('TCocoaWidgetSet.GetTextMetrics DC: ' + DbgS(DC)); DebugLn('TCDWidgetSet.GetTextMetrics DC: ' + DbgS(DC));
{$ENDIF} {$ENDIF}
ctx:=CheckDC(DC); { ctx:=CheckDC(DC);
if not Assigned(ctx) then Exit(False); if not Assigned(ctx) then Exit(False);
Result := ctx.GetTextMetrics(TM); Result := ctx.GetTextMetrics(TM);}
{$IFDEF VerboseWinAPI} {$IFDEF VerboseCDWinAPI}
DebugLn('TCocoaWidgetSet.GetTextMetrics Result: ' + DbgS(Result) + DebugLn('TCDWidgetSet.GetTextMetrics Result: ' + DbgS(Result) +
' TextMetric: ' + DbgS(TM)); ' TextMetric: ' + DbgS(TM));
{$ENDIF} {$ENDIF}
end; end;
function TCocoaWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean; function TCDWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean;
begin begin
Result:=ExtTextOut(DC, X, Y, 0, nil, Str, Count, nil); //Result:=ExtTextOut(DC, X, Y, 0, nil, Str, Count, nil);
end; end;
function TCocoaWidgetSet.SaveDC(DC: HDC): Integer; (*function TCocoaWidgetSet.SaveDC(DC: HDC): Integer;
var var
ctx : TCocoaContext; ctx : TCocoaContext;
cg : CGContextRef; cg : CGContextRef;

View File

@ -1346,7 +1346,7 @@ begin
LB.lbColor := ColorToRGB(TColor(lplb.lbColor)); LB.lbColor := ColorToRGB(TColor(lplb.lbColor));
LB.lbHatch := lplb.lbHatch; LB.lbHatch := lplb.lbHatch;
Result := Windows.ExtCreatePen(dwPenStyle, dwWidth, LB, dwStyleCount, lpStyle); Result := Windows.ExtCreatePen(dwPenStyle, dwWidth, LB, dwStyleCount, lpStyle);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: ExtTextOut Method: ExtTextOut
@ -1362,14 +1362,11 @@ end;
Draws a character string by using the currently selected font. Draws a character string by using the currently selected font.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32WidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; function TCDWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
{$ifdef WindowsUnicodeSupport}
var var
s: AnsiString; s: AnsiString;
w: WideString; w: WideString;
{$ENDIF}
begin begin
{$ifdef WindowsUnicodeSupport}
// use temp buffer, if count is set, there might be no null terminator // use temp buffer, if count is set, there might be no null terminator
if count = -1 then if count = -1 then
s := str s := str
@ -1379,24 +1376,12 @@ begin
move(str^, PChar(s)^, count); move(str^, PChar(s)^, count);
end; end;
// the length of utf8 vs Wide/Ansi the strings differ, so recalc. // the length of utf8 vs Wide/Ansi the strings differ, so recalc.
if UnicodeEnabledOS // TODO: use the real number of chars (and not the lenght)
then W := UTF8ToUTF16(S);
begin Result := Windows.ExtTextOutW(DC, X, Y, Options, LPRECT(Rect), PWideChar(W), Length(W), Dx);
// TODO: use the real number of chars (and not the lenght)
W := UTF8ToUTF16(S);
Result := Windows.ExtTextOutW(DC, X, Y, Options, LPRECT(Rect), PWideChar(W), Length(W), Dx);
end
else
begin
S := Utf8ToAnsi(S);
Result := Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), PChar(S), Length(S), Dx);
end;
{$else}
Result := Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), Str, Count, Dx);
{$endif}
end; end;
{------------------------------------------------------------------------------ (*{------------------------------------------------------------------------------
Function: ExtSelectClipRGN Function: ExtSelectClipRGN
Params: dc, RGN, Mode Params: dc, RGN, Mode
Returns: integer Returns: integer
@ -2082,7 +2067,7 @@ begin
Result := Windows.GetTextExtentExPoint(DC, pchar(s), length(s), Result := Windows.GetTextExtentExPoint(DC, pchar(s), length(s),
MaxWidth, MaxCount, PartialWidths, Size); MaxWidth, MaxCount, PartialWidths, Size);
end; end;
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: GetTextExtentPoint Method: GetTextExtentPoint
@ -2095,14 +2080,11 @@ end;
Computes the width and height of the specified string of text. Computes the width and height of the specified string of text.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32WidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; function TCDWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
{$ifdef WindowsUnicodeSupport}
var var
s: AnsiString; s: AnsiString;
w: WideString; w: WideString;
{$ENDIF}
begin begin
{$ifdef WindowsUnicodeSupport}
// use temp buffer, if count is set, there might be no null terminator // use temp buffer, if count is set, there might be no null terminator
if count = -1 then if count = -1 then
s := str s := str
@ -2112,22 +2094,9 @@ begin
move(str^, PChar(s)^, count); move(str^, PChar(s)^, count);
end; end;
// the length of utf8 vs Wide/Ansi the strings differ, so recalc. // the length of utf8 vs Wide/Ansi the strings differ, so recalc.
if UnicodeEnabledOS then // TODO: use the real number of chars (and not the length)
begin w := UTF8ToUTF16(S);
// TODO: use the real number of chars (and not the length) Result := Windows.GetTextExtentPoint32W(DC, PWideChar(W), Length(W), @Size);
w := UTF8ToUTF16(S);
Result := Windows.GetTextExtentPoint32W(DC, PWideChar(W), Length(W), @Size);
end else
begin
// Important: Althougth the MSDN Docs point that GetTextExtentPoint32W
// works under Windows 9x, tests showed that this function produces
// a wrong output
s := Utf8ToAnsi(s);
Result := Windows.GetTextExtentPoint32(DC, pchar(s), length(s), @Size);
end;
{$else}
Result := Windows.GetTextExtentPoint32(DC, Str, Count, @Size);
{$endif}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -2138,12 +2107,12 @@ end;
Fills the specified buffer with the metrics for the currently selected font. Fills the specified buffer with the metrics for the currently selected font.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32WidgetSet.GetTextMetrics(DC: HDC; Var TM: TTextMetric): Boolean; function TCDWidgetSet.GetTextMetrics(DC: HDC; Var TM: TTextMetric): Boolean;
begin begin
Result := Boolean(Windows.GetTextMetrics(DC, @TM)); Result := Boolean(Windows.GetTextMetrics(DC, @TM));
end; end;
function TWin32WidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer; (*function TWin32WidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer;
begin begin
Result := Integer(Windows.GetViewPortExtEx(DC, LPSize(Size))); Result := Integer(Windows.GetViewPortExtEx(DC, LPSize(Size)));
end; end;
@ -3627,7 +3596,7 @@ end;
function TWin32WidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool; function TWin32WidgetSet.SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool;
begin begin
Result := Windows.SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni); Result := Windows.SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TextOut Method: TextOut
@ -3641,21 +3610,15 @@ end;
Writes a character string at the specified location, using the currently Writes a character string at the specified location, using the currently
selected font. selected font.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean; function TCDWidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean;
{$ifdef WindowsUnicodeSupport}
var var
ws: widestring; ws: widestring;
{$endif}
begin begin
{$ifdef WindowsUnicodeSupport}
ws := UTF8ToUTF16(copy(str,1,Count)); ws := UTF8ToUTF16(copy(str,1,Count));
Result := Boolean(Windows.TextOutW(DC, X, Y, PWideChar(ws), length(ws))); Result := Boolean(Windows.TextOutW(DC, X, Y, PWideChar(ws), length(ws)));
{$else}
Result := Boolean(Windows.TextOut(DC, X, Y, Str, Count));
{$endif}
end; end;
function TWin32WidgetSet.UpdateWindow(Handle: HWND): Boolean; (*function TWin32WidgetSet.UpdateWindow(Handle: HWND): Boolean;
begin begin
Result:=Windows.UpdateWindow(Handle); Result:=Windows.UpdateWindow(Handle);
end; end;

View File

@ -2168,7 +2168,7 @@ begin
end end
else else
Result := inherited ExtSelectClipRGN(DC, RGN, Mode); Result := inherited ExtSelectClipRGN(DC, RGN, Mode);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: ExtTextOut Function: ExtTextOut
@ -2177,11 +2177,11 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; function TCDWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint;
Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
var var
WideStr: WideString; WideStr: WideString;
QtDC: TQtDeviceContext absolute DC; // QtDC: TQtDeviceContext absolute DC;
B: Boolean; B: Boolean;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
@ -2190,7 +2190,7 @@ begin
Result := False; Result := False;
if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then { if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then
exit; exit;
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
@ -2220,10 +2220,10 @@ begin
QtDC.drawText(X, Y, @WideStr); QtDC.drawText(X, Y, @WideStr);
end; end;
Result := True; Result := True; }
end; end;
{------------------------------------------------------------------------------ (*{------------------------------------------------------------------------------
Function: FillRect Function: FillRect
Params: none Params: none
Returns: Nothing Returns: Nothing
@ -4084,31 +4084,31 @@ begin
end; end;
end; end;
Result := True; Result := True;
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: GetTextExtentPoint Function: GetTextExtentPoint
Params: none Params: none
Returns: Nothing Returns: Nothing
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; function TCDWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
var {var
WideStr: WideString; WideStr: WideString;
QtDC: TQtDeviceContext absolute DC; QtDC: TQtDeviceContext absolute DC;}
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI GetTextExtentPoint]'); DebugLn('[WinAPI GetTextExtentPoint]');
{$endif} {$endif}
Result := False; Result := False;
if not IsValidDC(DC) then Exit; { if not IsValidDC(DC) then Exit;
WideStr := GetUtf8String(Str); WideStr := GetUtf8String(Str);
Size.cx := QtDC.Metrics.width(@WideStr, Count); Size.cx := QtDC.Metrics.width(@WideStr, Count);
Size.cy := QtDC.Metrics.height; Size.cy := QtDC.Metrics.height;
Result := True; Result := True; }
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -4117,20 +4117,15 @@ end;
TM - The structure to receive the font information TM - The structure to receive the font information
Returns: If successfull Returns: If successfull
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; function TCDWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
var
QtFontMetrics: TQtFontMetrics;
FontFamily: WideString;
QtDC: TQtDeviceContext absolute DC;
FontWeight: Integer;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI GetTextMetrics]'); WriteLn('[WinAPI GetTextMetrics]');
{$endif} {$endif}
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then { if Result then
begin begin
QtFontMetrics := QtDC.Metrics; QtFontMetrics := QtDC.Metrics;
TM.tmHeight := QtFontMetrics.height; TM.tmHeight := QtFontMetrics.height;
@ -4180,10 +4175,10 @@ begin
TM.tmPitchAndFamily := FIXED_PITCH or TRUETYPE_FONTTYPE; TM.tmPitchAndFamily := FIXED_PITCH or TRUETYPE_FONTTYPE;
TM.tmCharSet := DEFAULT_CHARSET; TM.tmCharSet := DEFAULT_CHARSET;
end; end; }
end; end;
function TQtWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer; (*function TQtWidgetSet.GetViewPortExtEx(DC: HDC; Size: PSize): Integer;
var var
R: TRect; R: TRect;
begin begin
@ -6369,7 +6364,7 @@ begin
else else
Result := False; Result := False;
end end
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TextOut Function: TextOut
@ -6381,16 +6376,16 @@ end;
Returns: Returns:
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : PChar; Count: Integer) : Boolean; function TCDWidgetSet.TextOut(DC: HDC; X,Y : Integer; Str : PChar; Count: Integer) : Boolean;
var //var
WideStr: WideString; // WideStr: WideString;
begin begin
{$ifdef VerboseQtWinAPI} // {$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI TextOut]'); // WriteLn('[WinAPI TextOut]');
{$endif} // {$endif}
Result := False; Result := False;
{
if not IsValidDC(DC) then Exit; if not IsValidDC(DC) then Exit;
if Count >= 0 then if Count >= 0 then
@ -6400,10 +6395,10 @@ begin
TQtDeviceContext(DC).drawText(X, Y, @WideStr); TQtDeviceContext(DC).drawText(X, Y, @WideStr);
Result := True; Result := True;}
end; end;
{------------------------------------------------------------------------------ (*{------------------------------------------------------------------------------
Method: UpdateWindow Method: UpdateWindow
Params: Handle Params: Handle
Returns: Returns:

View File

@ -83,8 +83,8 @@ function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumPro
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override; function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override; function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override; function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override; function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;*)
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;*) function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override; function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
(*function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override; (*function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
@ -130,10 +130,10 @@ function GetSysColor(nIndex: Integer): DWORD; override;
function GetSysColorBrush(nIndex: Integer): HBrush; override; function GetSysColorBrush(nIndex: Integer): HBrush; override;
function GetSystemMetrics(nIndex: Integer): Integer; override; function GetSystemMetrics(nIndex: Integer): Integer; override;
function GetTextColor(DC: HDC) : TColorRef; Override; function GetTextColor(DC: HDC) : TColorRef; Override;
function GetTextExtentExPoint(DC: HDC; Str: PChar; Count, MaxWidth: Integer; MaxCount, PartialWidths: PInteger; var Size: TSize): Boolean; override; function GetTextExtentExPoint(DC: HDC; Str: PChar; Count, MaxWidth: Integer; MaxCount, PartialWidths: PInteger; var Size: TSize): Boolean; override;*)
function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override; function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override;
function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; override; function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean; override;
function GetViewPortExtEx(DC: HDC; Size: PSize): Integer; override; (*function GetViewPortExtEx(DC: HDC; Size: PSize): Integer; override;
function GetViewPortOrgEx(DC: HDC; P: PPoint): Integer; override; function GetViewPortOrgEx(DC: HDC; P: PPoint): Integer; override;
function GetWindowExtEx(DC: HDC; Size: PSize): Integer; override; function GetWindowExtEx(DC: HDC; Size: PSize): Integer; override;
function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override; function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override;
@ -220,10 +220,10 @@ function StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer;
function StretchMaskBlt(DestDC: HDC; X, Y, Width, Height: Integer; function StretchMaskBlt(DestDC: HDC; X, Y, Width, Height: Integer;
SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Mask: HBITMAP; SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; Mask: HBITMAP;
XMask, YMask: Integer; Rop: DWORD): Boolean; override; XMask, YMask: Integer; Rop: DWORD): Boolean; override;
function SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool; override; function SystemParametersInfo(uiAction: DWord; uiParam: DWord; pvParam: Pointer; fWinIni: DWord): LongBool; override;*)
function TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean; override; function TextOut(DC: HDC; X,Y : Integer; Str : Pchar; Count: Integer) : Boolean; override;
function UpdateWindow(Handle: HWND): Boolean; override; (*function UpdateWindow(Handle: HWND): Boolean; override;
function WindowFromPoint(APoint: TPoint): HWND; override; function WindowFromPoint(APoint: TPoint): HWND; override;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line //##apiwiz##eps## // Do not remove, no wizard declaration after this line