Initial implementation for non-native Text in LCL-CustomDrawn

git-svn-id: trunk@35688 -
This commit is contained in:
sekelsenmat 2012-03-03 20:01:10 +00:00
parent 946004d921
commit 994179a76f
5 changed files with 57 additions and 10 deletions

View File

@ -40,6 +40,8 @@ uses
{$ifdef WinCE}aygshell,{$endif}
// Widgetset
customdrawnproc,
// LazFreeType
LazFreeTypeIntfDrawer, LazFreeType, EasyLazFreeType,
// LCL
customdrawn_common, customdrawncontrols, customdrawndrawers,
lazcanvas, lazregions, lazdeviceapis,

View File

@ -2162,25 +2162,57 @@ end;*)
function TCDWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint;
Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
var
LazDC: TLazCanvas absolute DC;
lDestCanvas: TLazCanvas absolute DC;
lDestIntfImage: TLazIntfImage;
lFontSize: Integer;
FTDrawer: TIntfFreeTypeDrawer;
ftFont: TFreeTypeFont;
RealX, RealY: Integer;
begin
{$ifdef VerboseCDWinAPI}
DebugLn('[WinAPI ExtTextOut]');
{$ifdef VerboseCDText}
DebugLn(Format(':>[WinAPI ExtTextOut] DC=%x Str=%s X=%d Y=%d',
[DC, StrPas(Str), X, Y]));
{$endif}
Result := False;
if Rect <> nil then
begin
Rect^ := Bounds(0, 0, 0, 0);
end;
if (Str = nil) or (Str = '') then Exit;
{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;
if not IsValidDC(DC) then Exit;
if Rect <> nil then Rect^ := Bounds(0, 0, 0, 0);
if ((Options and ETO_OPAQUE) <> 0) then
if not IsValidDC(DC) then Exit;
lDestIntfImage := TLazIntfImage(lDestCanvas.Image);
if (lDestCanvas.Font = nil) or (lDestCanvas.Font.Size = 0) then lFontSize := 10
else lFontSize := Abs(lDestCanvas.Font.Size);
// Preparations finished, draw it using LazFreeType
FTDrawer := TIntfFreeTypeDrawer.Create(lDestIntfImage);
ftFont := TFreeTypeFont.Create; //only one font at once for now...
try
ftFont.Name := BackendGetFontPath(DC);
ftFont.Hinted := true;
ftFont.ClearType := true;
ftFont.Quality := grqHighQuality;
RealX := X + lDestCanvas.WindowOrg.X + lDestCanvas.BaseWindowOrg.X;
RealY := Y + lDestCanvas.WindowOrg.Y + lDestCanvas.BaseWindowOrg.Y;
FTDrawer.DrawText(Str, ftFont, RealX, RealY, colBlack, 255);
finally
ftFont.Free;
FTDrawer.Free;
end;
{$ifdef VerboseCDText}
DebugLn(':<[WinAPI ExtTextOut]');
{$endif}
Result := True;
{ if ((Options and ETO_OPAQUE) <> 0) then
QtDC.fillRect(Rect^.Left, Rect^.Top, Rect^.Right - Rect^.Left, Rect^.Bottom - Rect^.Top);
if Str <> nil then

View File

@ -384,6 +384,11 @@ begin
lazdc := TLazCanvas(DC);
lazdc.AlphaBlend(ScreenDC, X, Y, 0, 0, ScreenBitmapWidth, ScreenBitmapHeight);
end;
{$else}
function TCDWidgetSet.BackendGetFontPath(DC: HDC): string;
begin
Result := '/Library/Fonts/Arial.ttf';
end;
{$endif}
(*{------------------------------------------------------------------------------

View File

@ -2084,6 +2084,11 @@ begin
Result := True; }
end;
{$else}
function TCDWidgetSet.BackendGetFontPath(DC: HDC): string;
begin
Result := '/Library/Fonts/Arial.ttf';
end;
{$endif}
(*{------------------------------------------------------------------------------

View File

@ -91,6 +91,9 @@ function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExPr
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 ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
{$ifndef CD_UseNativeText}
function BackendGetFontPath(DC: HDC): string;
{$endif}
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
//function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;