mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:39:10 +02:00
LCL-GTK3: TextOut cleanup. Issue #36568, patch from CudaText man.
git-svn-id: trunk@62552 -
This commit is contained in:
parent
872fe5d89c
commit
6e3d70b796
@ -4420,7 +4420,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
///
|
|
||||||
function CreateNewCodeBuffer(Descriptor: TProjectFileDescriptor;
|
function CreateNewCodeBuffer(Descriptor: TProjectFileDescriptor;
|
||||||
NewOwner: TObject; NewFilename: string;
|
NewOwner: TObject; NewFilename: string;
|
||||||
var NewCodeBuffer: TCodeBuffer; var NewUnitName: string): TModalResult;
|
var NewCodeBuffer: TCodeBuffer; var NewUnitName: string): TModalResult;
|
||||||
|
@ -220,8 +220,7 @@ type
|
|||||||
function getPixel(x, y: Integer): TColor;
|
function getPixel(x, y: Integer): TColor;
|
||||||
procedure drawRect(x1, y1, w, h: Integer; const AFill, ABorder: Boolean);
|
procedure drawRect(x1, y1, w, h: Integer; const AFill, ABorder: Boolean);
|
||||||
procedure drawRoundRect(x, y, w, h, rx, ry: Integer);
|
procedure drawRoundRect(x, y, w, h, rx, ry: Integer);
|
||||||
procedure drawText(x: Integer; y: Integer; const s: String); overload;
|
procedure drawText(x, y: Integer; AText: PChar; ALen: Integer);
|
||||||
procedure drawText(x,y,w,h,flags: Integer; const s: String); overload;
|
|
||||||
procedure drawEllipse(x, y, w, h: Integer; AFill, ABorder: Boolean);
|
procedure drawEllipse(x, y, w, h: Integer; AFill, ABorder: Boolean);
|
||||||
procedure drawSurface(targetRect: PRect; Surface: Pcairo_surface_t; sourceRect: PRect;
|
procedure drawSurface(targetRect: PRect; Surface: Pcairo_surface_t; sourceRect: PRect;
|
||||||
mask: PGdkPixBuf; maskRect: PRect);
|
mask: PGdkPixBuf; maskRect: PRect);
|
||||||
@ -1268,7 +1267,7 @@ begin
|
|||||||
RoundRect(x, y, w, h, rx, ry);
|
RoundRect(x, y, w, h, rx, ry);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk3DeviceContext.drawText(x: Integer; y: Integer; const s: String);
|
procedure TGtk3DeviceContext.drawText(x, y: Integer; AText: PChar; ALen: Integer);
|
||||||
var
|
var
|
||||||
e: cairo_font_extents_t;
|
e: cairo_font_extents_t;
|
||||||
R: Double;
|
R: Double;
|
||||||
@ -1292,7 +1291,7 @@ begin
|
|||||||
ColorToCairoRGB(TColor(CurrentTextColor), R, G , B);
|
ColorToCairoRGB(TColor(CurrentTextColor), R, G , B);
|
||||||
cairo_set_source_rgb(Widget, R, G, B);
|
cairo_set_source_rgb(Widget, R, G, B);
|
||||||
// writeln('DRAWINGTEXT ',S,' WITH R=',dbgs(R),' G=',dbgs(G),' B=',dbgs(B));
|
// writeln('DRAWINGTEXT ',S,' WITH R=',dbgs(R),' G=',dbgs(G),' B=',dbgs(B));
|
||||||
FCurrentFont.Layout^.set_text(PChar(S), length(S));
|
FCurrentFont.Layout^.set_text(AText, ALen);
|
||||||
// writeln('Family: ',FCurrentFont.Handle^.get_family,' size ',FCurrentFont.Handle^.get_size,' weight ',FCurrentFont.Handle^.get_weight);
|
// writeln('Family: ',FCurrentFont.Handle^.get_family,' size ',FCurrentFont.Handle^.get_size,' weight ',FCurrentFont.Handle^.get_weight);
|
||||||
pango_cairo_show_layout(Widget, FCurrentFont.Layout);
|
pango_cairo_show_layout(Widget, FCurrentFont.Layout);
|
||||||
finally
|
finally
|
||||||
@ -1300,35 +1299,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk3DeviceContext.drawText(x, y, w, h, flags: Integer; const s: String
|
|
||||||
);
|
|
||||||
var
|
|
||||||
e: cairo_font_extents_t;
|
|
||||||
R: Double;
|
|
||||||
G: Double;
|
|
||||||
B: Double;
|
|
||||||
// dx, dy: Double;
|
|
||||||
begin
|
|
||||||
cairo_save(Widget);
|
|
||||||
try
|
|
||||||
// TranslateCairoToDevice;
|
|
||||||
// cairo_surface_get_device_offset(CairoSurface, @dx, @dy);
|
|
||||||
cairo_font_extents(Widget, @e);
|
|
||||||
if e.ascent <> 0 then
|
|
||||||
begin
|
|
||||||
// writeln('2.EXTENTS !!!! ',Format('%2.2n',[e.ascent]));
|
|
||||||
end;
|
|
||||||
cairo_move_to(Widget, x, y + e.ascent);
|
|
||||||
ColorToCairoRGB(CurrentTextColor, R, G , B);
|
|
||||||
cairo_set_source_rgb(Widget, R, G, B);
|
|
||||||
// cairo_show_text(Widget, PChar(s));
|
|
||||||
FCurrentFont.Layout^.set_text(PChar(S), length(S));
|
|
||||||
pango_cairo_show_layout(Widget, FCurrentFont.Layout);
|
|
||||||
finally
|
|
||||||
cairo_restore(Widget);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TGtk3DeviceContext.drawEllipse(x, y, w, h: Integer; AFill, ABorder: Boolean);
|
procedure TGtk3DeviceContext.drawEllipse(x, y, w, h: Integer; AFill, ABorder: Boolean);
|
||||||
var
|
var
|
||||||
save_matrix:cairo_matrix_t;
|
save_matrix:cairo_matrix_t;
|
||||||
|
@ -1560,7 +1560,7 @@ begin
|
|||||||
if IsValidDC(DC) then
|
if IsValidDC(DC) then
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
TGtk3DeviceContext(DC).drawText(X, Y , Str);
|
TGtk3DeviceContext(DC).drawText(X, Y, Str, Count);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4098,23 +4098,18 @@ begin
|
|||||||
Result:=inherited SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
|
Result:=inherited SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: Pchar;
|
function TGtk3WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean;
|
||||||
Count: Integer): Boolean;
|
|
||||||
var
|
|
||||||
S: String;
|
|
||||||
begin
|
begin
|
||||||
// Result:=inherited TextOut(DC, X, Y, Str, Count);
|
|
||||||
{$IFDEF VerboseGtk3DeviceContext}
|
{$IFDEF VerboseGtk3DeviceContext}
|
||||||
DebugLn('TGtk3WidgetSet.TextOut x=',dbgs(x),' y=',dbgs(y),' Text ',dbgs(Str),' count ',dbgs(Count));
|
DebugLn('TGtk3WidgetSet.TextOut X=',dbgs(x),' Y=',dbgs(y),' Text=',dbgs(Str),' Count=',dbgs(Count));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result := False;
|
Result := False;
|
||||||
|
if Count <= 0 then
|
||||||
|
Exit;
|
||||||
if IsValidDC(DC) then
|
if IsValidDC(DC) then
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
S := StrPas(Str);
|
TGtk3DeviceContext(DC).drawText(X, Y, Str, Count);
|
||||||
if Count > 0 then
|
|
||||||
S := UTF8Copy(S, 1, Count);
|
|
||||||
TGtk3DeviceContext(DC).drawText(X, Y , S);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user