diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index f3bd4e1b48..4f9c3e1177 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -226,6 +226,7 @@ type TQtDeviceContext = class(TObject) private + FPenPos: TQtPoint; FOwnPainter: Boolean; SelFont: TQTFont; SelBrush: TQTBrush; @@ -273,6 +274,9 @@ type procedure setBrushOrigin(x, y: Integer); procedure brushOrigin(retval: PPoint); + procedure getPenPos(retval: PPoint); + procedure setPenPos(x, y: Integer); + function font: TQtFont; procedure setFont(f: TQtFont); function brush: TQtBrush; @@ -1266,6 +1270,8 @@ begin end; FOwnPainter := True; CreateObjects; + FPenPos.X := 0; + FPenPos.Y := 0; end; constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH); @@ -1653,6 +1659,18 @@ begin retval^.y := QtPoint.y; end; +procedure TQtDeviceContext.getPenPos(retval: PPoint); +begin + retval^.x := FPenPos.x; + retval^.y := FPenPos.y; +end; + +procedure TQtDeviceContext.setPenPos(x, y: Integer); +begin + FPenPos.X := x; + FPenPos.Y := y; +end; + {------------------------------------------------------------------------------ Function: TQtDeviceContext.font Params: None diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index a5591eb85c..7b503552b2 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -3272,7 +3272,7 @@ end; ------------------------------------------------------------------------------} function TQtWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean; var - BrushPos: TPoint; + PenPos: TPoint; begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI LineTo]'); @@ -3282,11 +3282,9 @@ begin if not IsValidDC(DC) then Exit; - //TODO: check this brushorigin stuff, don't smell good. - // replace with DC local point. - TQtDeviceContext(DC).brushOrigin(@BrushPos); + TQtDeviceContext(DC).getPenPos(@PenPos); - TQtDeviceContext(DC).drawLine( BrushPos.X, BrushPos.Y, X, Y); + TQtDeviceContext(DC).drawLine( PenPos.X, PenPos.Y, X, Y); MoveToEx(DC, X, Y, nil); @@ -3326,9 +3324,9 @@ begin if not IsValidDC(DC) then Exit; - if (OldPoint <> nil) then TQtDeviceContext(DC).brushOrigin(OldPoint); + if (OldPoint <> nil) then TQtDeviceContext(DC).getPenPos(OldPoint); - TQtDeviceContext(DC).setBrushOrigin(X, Y); + TQtDeviceContext(DC).setPenPos(X, Y); Result := True; end;