diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index de637a6d79..8a8cebbd55 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -2773,7 +2773,7 @@ var LinePos: PChar; begin with TDeviceContext(DC) do begin - if Dx=nil then begin + if (Dx=nil) then begin // no dist array -> write as one block gdk_draw_text(Drawable, UseFont, GC, TxtPt.X, TxtPt.Y, LineStart, LineLen); @@ -2806,32 +2806,57 @@ begin if Result then with TDeviceContext(DC) do begin - if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) then begin - UseFont := GetDefaultFont; - UnRef := True; - UnderLine := false; - end else begin - UseFont := CurrentFont^.GDIFontObject; - UnRef := False; - UnderLine := (CurrentFont^.LogFont.lfUnderline<>0); - end; - if GC = nil then begin WriteLn('WARNING: [TgtkObject.ExtTextOut] Uninitialized GC'); Result := False; end - else if UseFont = nil then begin - WriteLn('WARNING: [TgtkObject.ExtTextOut] Missing Font'); - Result := False; - end else if ((Options and (ETO_OPAQUE+ETO_CLIPPED)) <> 0) and (Rect=nil) then begin WriteLn('WARNING: [TgtkObject.ExtTextOut] Rect=nil'); Result := False; end else begin // TODO: implement other parameters. + + // to reduce flickering calculate first and then paint DCOrigin:=GetDCOffset(TDeviceContext(DC)); + + UseFont:=nil; + if (Str<>nil) and (Count>0) then begin + if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) then begin + UseFont := GetDefaultFont; + UnRef := True; + UnderLine := false; + end else begin + UseFont := CurrentFont^.GDIFontObject; + UnRef := False; + UnderLine := (CurrentFont^.LogFont.lfUnderline<>0); + end; + + if UseFont = nil then begin + WriteLn('WARNING: [TgtkObject.ExtTextOut] Missing Font'); + Result := False; + end else begin + if (Options and ETO_CLIPPED) <> 0 then + begin + X := Rect^.Left; + Y := Rect^.Top; + IntersectClipRect(DC, Rect^.Left, Rect^.Top, + Rect^.Right, Rect^.Bottom); + end; + LineLen := FindChar(#10,Str,Count); + TopY := Y; + UpdateDCTextMetric(TDeviceContext(DC)); + TxtPt.X := X + DCOrigin.X; + {$IfDef Win32} + LineHeight := DCTextMetric.TextMetric.tmHeight div 2; + {$Else} + LineHeight := DCTextMetric.TextMetric.tmAscent; + {$EndIf} + TxtPt.Y := TopY + LineHeight + DCOrigin.Y; + end; + end; + if ((Options and ETO_OPAQUE) <> 0) then begin Width := Rect^.Right - Rect^.Left; @@ -2842,46 +2867,33 @@ begin Rect^.Left+DCOrigin.X, Rect^.Top+DCOrigin.Y, Width, Height); end; - if (Options and ETO_CLIPPED) <> 0 then - begin - X := Rect^.Left; - Y := Rect^.Top; - IntersectClipRect(DC, Rect^.Left, Rect^.Top, - Rect^.Right, Rect^.Bottom); - end; - LineLen := FindChar(#10,Str,Count); - TopY := Y; - UpdateDCTextMetric(TDeviceContext(DC)); - TxtPt.X := X + DCOrigin.X; - {$IfDef Win32} - LineHeight := DCTextMetric.TextMetric.tmHeight div 2; - {$Else} - LineHeight := DCTextMetric.TextMetric.tmAscent; - {$EndIf} - TxtPt.Y := TopY + LineHeight + DCOrigin.Y; - SelectGDKTextProps(DC); - LineStart:=Str; - if LineLen < 0 then begin - LineLen:=Count; - if Count> 0 then DrawTextLine; - end else - Begin //write multiple lines - StrEnd:=Str+Count; - while LineStart < StrEnd do begin - LineEnd:=LineStart+LineLen; - if LineLen>0 then DrawTextLine; - inc(TxtPt.Y,LineHeight); - LineStart:=LineEnd+1; // skip #10 - if (LineStartnil then begin + SelectGDKTextProps(DC); + + LineStart:=Str; + if LineLen < 0 then begin + LineLen:=Count; + if Count> 0 then DrawTextLine; + end else + Begin //write multiple lines + StrEnd:=Str+Count; + while LineStart < StrEnd do begin + LineEnd:=LineStart+LineLen; + if LineLen>0 then DrawTextLine; + inc(TxtPt.Y,LineHeight); + LineStart:=LineEnd+1; // skip #10 + if (LineStart