mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 08:38:11 +02:00
implemented fsUnderLine for ExtTextOut for gtk
git-svn-id: trunk@2017 -
This commit is contained in:
parent
c5cc5de28a
commit
b07c5b226d
@ -2758,27 +2758,44 @@ function TgtkObject.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint;
|
|||||||
var
|
var
|
||||||
LineStart, LineEnd, StrEnd: PChar;
|
LineStart, LineEnd, StrEnd: PChar;
|
||||||
Width, Height: Integer;
|
Width, Height: Integer;
|
||||||
AY, Num : Integer;
|
TopY, LineLen, LineHeight : Integer;
|
||||||
TXTPt : TPoint;
|
TXTPt : TPoint;
|
||||||
//ADC : hDC;
|
|
||||||
UseFont : PGDKFont;
|
UseFont : PGDKFont;
|
||||||
UnRef : Boolean;
|
UnRef : Boolean;
|
||||||
DCOrigin: TPoint;
|
DCOrigin: TPoint;
|
||||||
|
UnderLine: boolean;
|
||||||
|
|
||||||
|
procedure DrawTextLine;
|
||||||
|
var
|
||||||
|
UnderLineLen, Y: integer;
|
||||||
|
begin
|
||||||
|
with TDeviceContext(DC) do begin
|
||||||
|
gdk_draw_text(Drawable, UseFont, GC, TxtPt.X, TxtPt.Y,
|
||||||
|
LineStart, LineLen);
|
||||||
|
if UnderLine then begin
|
||||||
|
UnderLineLen := Rect^.Right-Rect^.Left;
|
||||||
|
Y := TxtPt.Y + 1;
|
||||||
|
gdk_draw_line(Drawable, GC, TxtPt.X, Y, TxtPt.X+UnderLineLen, Y);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Assert(False, Format('trace:> [TgtkObject.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
|
Assert(False, Format('trace:> [TgtkObject.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
|
||||||
Result := IsValidDC(DC);
|
Result := IsValidDC(DC);
|
||||||
if Result
|
if Result
|
||||||
then with TDeviceContext(DC) do
|
then with TDeviceContext(DC) do
|
||||||
begin
|
begin
|
||||||
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
|
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) then begin
|
||||||
then begin
|
UseFont := GetDefaultFont;
|
||||||
UseFont := GetDefaultFont;
|
UnRef := True;
|
||||||
UnRef := True;
|
UnderLine := false;
|
||||||
end
|
end else begin
|
||||||
else begin
|
UseFont := CurrentFont^.GDIFontObject;
|
||||||
UseFont := CurrentFont^.GDIFontObject;
|
UnRef := False;
|
||||||
UnRef := False;
|
UnderLine := (CurrentFont^.LogFont.lfUnderline<>0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if GC = nil
|
if GC = nil
|
||||||
then begin
|
then begin
|
||||||
WriteLn('WARNING: [TgtkObject.ExtTextOut] Uninitialized GC');
|
WriteLn('WARNING: [TgtkObject.ExtTextOut] Uninitialized GC');
|
||||||
@ -2794,7 +2811,6 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end else begin
|
end else begin
|
||||||
// TODO: implement other parameters.
|
// TODO: implement other parameters.
|
||||||
//ADC := SaveDC(DC);
|
|
||||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||||
if ((Options and ETO_OPAQUE) <> 0) then
|
if ((Options and ETO_OPAQUE) <> 0) then
|
||||||
begin
|
begin
|
||||||
@ -2813,45 +2829,37 @@ begin
|
|||||||
IntersectClipRect(DC, Rect^.Left, Rect^.Top,
|
IntersectClipRect(DC, Rect^.Left, Rect^.Top,
|
||||||
Rect^.Right, Rect^.Bottom);
|
Rect^.Right, Rect^.Bottom);
|
||||||
end;
|
end;
|
||||||
Num := FindChar(#10,Str,Count);
|
LineLen := FindChar(#10,Str,Count);
|
||||||
AY := Y;
|
TopY := Y;
|
||||||
UpdateDCTextMetric(TDeviceContext(DC));
|
UpdateDCTextMetric(TDeviceContext(DC));
|
||||||
TxtPt.X := X;
|
TxtPt.X := X + DCOrigin.X;
|
||||||
{$IfDef Win32}
|
{$IfDef Win32}
|
||||||
TxtPt.Y := AY + DCTextMetric.TextMetric.tmHeight div 2;
|
LineHeight := DCTextMetric.TextMetric.tmHeight div 2;
|
||||||
{$Else}
|
{$Else}
|
||||||
TxtPt.Y := AY + DCTextMetric.TextMetric.tmAscent;
|
LineHeight := DCTextMetric.TextMetric.tmAscent;
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
TxtPt.Y := TopY + LineHeight + DCOrigin.Y;
|
||||||
SelectGDKTextProps(DC);
|
SelectGDKTextProps(DC);
|
||||||
if Num < 0 then begin
|
LineStart:=Str;
|
||||||
if Count> 0 then
|
if LineLen < 0 then begin
|
||||||
gdk_draw_text(Drawable, UseFont, GC,
|
LineLen:=Count;
|
||||||
TxtPt.X+DCOrigin.X, TxtPt.Y+DCOrigin.Y, Str, Count);
|
if Count> 0 then DrawTextLine;
|
||||||
end else
|
end else
|
||||||
Begin //write multiple lines
|
Begin //write multiple lines
|
||||||
LineStart:=Str;
|
|
||||||
StrEnd:=Str+Count;
|
StrEnd:=Str+Count;
|
||||||
while LineStart < StrEnd do begin
|
while LineStart < StrEnd do begin
|
||||||
LineEnd:=LineStart+Num;
|
LineEnd:=LineStart+LineLen;
|
||||||
if Num>0 then
|
if LineLen>0 then DrawTextLine;
|
||||||
gdk_draw_text(Drawable, UseFont, GC,
|
inc(TxtPt.Y,LineHeight);
|
||||||
TxtPt.X+DCOrigin.X, TxtPt.Y+DCOrigin.Y, LineStart, Num);
|
|
||||||
AY := TxtPt.Y;
|
|
||||||
{$IfDef Win32}
|
|
||||||
TxtPt.Y := AY + DCTextMetric.TextMetric.tmHeight div 2;
|
|
||||||
{$Else}
|
|
||||||
TxtPt.Y := AY + DCTextMetric.TextMetric.tmAscent;
|
|
||||||
{$EndIf}
|
|
||||||
LineStart:=LineEnd+1; // skip #10
|
LineStart:=LineEnd+1; // skip #10
|
||||||
if (LineStart<StrEnd) and (LineStart^=#13) then
|
if (LineStart<StrEnd) and (LineStart^=#13) then
|
||||||
inc(LineStart); // skip #10
|
inc(LineStart); // skip #10
|
||||||
Count:=StrEnd-LineStart;
|
Count:=StrEnd-LineStart;
|
||||||
Num:=FindChar(#10,LineStart,Count);
|
LineLen:=FindChar(#10,LineStart,Count);
|
||||||
if Num<0 then
|
if LineLen<0 then
|
||||||
Num:=Count;
|
LineLen:=Count;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//RestoreDC(DC, ADC);
|
|
||||||
If UnRef then
|
If UnRef then
|
||||||
GDK_Font_UnRef(UseFont);
|
GDK_Font_UnRef(UseFont);
|
||||||
end;
|
end;
|
||||||
@ -7512,6 +7520,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.191 2002/12/05 17:26:02 mattias
|
||||||
|
implemented fsUnderLine for ExtTextOut for gtk
|
||||||
|
|
||||||
Revision 1.190 2002/11/23 13:48:46 mattias
|
Revision 1.190 2002/11/23 13:48:46 mattias
|
||||||
added Timer patch from Vincent Snijders
|
added Timer patch from Vincent Snijders
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user