mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Merge pull request #2403 from mprosperi/fi-TypeError-in-wx.lib-ogl
wx.lib.ogl: fix float->int compatibility for py3.10+ (also fixes #2349)
This commit is contained in:
@@ -1377,11 +1377,11 @@ class Shape(ShapeEvtHandler):
|
||||
|
||||
def OnDrawOutline(self, dc, x, y, w, h):
|
||||
"""The draw outline handler."""
|
||||
points = [[x - w / 2.0, y - h / 2.0],
|
||||
[x + w / 2.0, y - h / 2.0],
|
||||
[x + w / 2.0, y + h / 2.0],
|
||||
[x - w / 2.0, y + h / 2.0],
|
||||
[x - w / 2.0, y - h / 2.0],
|
||||
points = [[int(x - w / 2.0), int(y - h / 2.0)],
|
||||
[int(x + w / 2.0), int(y - h / 2.0)],
|
||||
[int(x + w / 2.0), int(y + h / 2.0)],
|
||||
[int(x - w / 2.0), int(y + h / 2.0)],
|
||||
[int(x - w / 2.0), int(y - h / 2.0)],
|
||||
]
|
||||
|
||||
dc.DrawLines(points)
|
||||
@@ -3174,7 +3174,7 @@ class PolygonShape(Shape):
|
||||
dc.SetPen(self._pen)
|
||||
if self._brush:
|
||||
dc.SetBrush(self._brush)
|
||||
dc.DrawPolygon(self._points, self._xpos, self._ypos)
|
||||
dc.DrawPolygon(self._points, int(self._xpos), int(self._ypos))
|
||||
|
||||
def OnDrawOutline(self, dc, x, y, w, h):
|
||||
"""The draw outline handler."""
|
||||
@@ -3185,8 +3185,8 @@ class PolygonShape(Shape):
|
||||
|
||||
intPoints = []
|
||||
for point in self._originalPoints:
|
||||
intPoints.append(wx.Point(x_proportion * point[0], y_proportion * point[1]))
|
||||
dc.DrawPolygon(intPoints, x, y)
|
||||
intPoints.append(wx.Point(int(x_proportion * point[0]), int(y_proportion * point[1])))
|
||||
dc.DrawPolygon(intPoints, int(x), int(y))
|
||||
|
||||
# Make as many control points as there are vertices
|
||||
def MakeControlPoints(self):
|
||||
|
||||
@@ -116,7 +116,7 @@ class Diagram(object):
|
||||
dc.SetPen(wx.Pen(wx.BLACK, 1, wx.PENSTYLE_DOT))
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
|
||||
dc.DrawLines([[x1, y1], [x2, y1], [x2, y2], [x1, y2], [x1, y1]])
|
||||
dc.DrawLines([[int(x1), int(y1)], [int(x2), int(y1)], [int(x2), int(y2)], [int(x1), int(y2)], [int(x1), int(y1)]])
|
||||
|
||||
def RecentreAll(self, dc):
|
||||
"""Recentre all the text that should be centred.
|
||||
|
||||
@@ -165,21 +165,21 @@ class OpDraw(DrawOp):
|
||||
|
||||
def Do(self, dc, xoffset, yoffset):
|
||||
if self._op == DRAWOP_DRAW_LINE:
|
||||
dc.DrawLine(self._x1 + xoffset, self._y1 + yoffset, self._x2 + xoffset, self._y2 + yoffset)
|
||||
dc.DrawLine(int(self._x1 + xoffset), int(self._y1 + yoffset), int(self._x2 + xoffset), int(self._y2 + yoffset))
|
||||
elif self._op == DRAWOP_DRAW_RECT:
|
||||
dc.DrawRectangle(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2)
|
||||
dc.DrawRectangle(int(self._x1 + xoffset), int(self._y1 + yoffset), int(self._x2), int(self._y2))
|
||||
elif self._op == DRAWOP_DRAW_ROUNDED_RECT:
|
||||
dc.DrawRoundedRectangle(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2, self._radius)
|
||||
dc.DrawRoundedRectangle(int(self._x1 + xoffset), int(self._y1 + yoffset), int(self._x2), int(self._y2), self._radius)
|
||||
elif self._op == DRAWOP_DRAW_ELLIPSE:
|
||||
dc.DrawEllipse(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2)
|
||||
dc.DrawEllipse(int(self._x1 + xoffset), int(self._y1 + yoffset), int(self._x2), int(self._y2))
|
||||
elif self._op == DRAWOP_DRAW_ARC:
|
||||
dc.DrawArc(self._x2 + xoffset, self._y2 + yoffset, self._x3 + xoffset, self._y3 + yoffset, self._x1 + xoffset, self._y1 + yoffset)
|
||||
dc.DrawArc(int(self._x2 + xoffset), int(self._y2 + yoffset), int(self._x3 + xoffset), int(self._y3 + yoffset), int(self._x1 + xoffset), int(self._y1 + yoffset))
|
||||
elif self._op == DRAWOP_DRAW_ELLIPTIC_ARC:
|
||||
dc.DrawEllipticArc(self._x1 + xoffset, self._y1 + yoffset, self._x2, self._y2, self._x3 * 360 / (2 * math.pi), self._y3 * 360 / (2 * math.pi))
|
||||
dc.DrawEllipticArc(int(self._x1 + xoffset), int(self._y1 + yoffset), int(self._x2), int(self._y2), self._x3 * 360 / (2 * math.pi), self._y3 * 360 / (2 * math.pi))
|
||||
elif self._op == DRAWOP_DRAW_POINT:
|
||||
dc.DrawPoint(self._x1 + xoffset, self._y1 + yoffset)
|
||||
elif self._op == DRAWOP_DRAW_TEXT:
|
||||
dc.DrawText(self._textString, self._x1 + xoffset, self._y1 + yoffset)
|
||||
dc.DrawText(self._textString, int(self._x1 + xoffset), int(self._y1 + yoffset))
|
||||
def Scale(self, scaleX, scaleY):
|
||||
self._x1 *= scaleX
|
||||
self._y1 *= scaleY
|
||||
@@ -267,9 +267,9 @@ class OpPolyDraw(DrawOp):
|
||||
|
||||
def Do(self, dc, xoffset, yoffset):
|
||||
if self._op == DRAWOP_DRAW_POLYLINE:
|
||||
dc.DrawLines(self._points, xoffset, yoffset)
|
||||
dc.DrawLines(self._points, int(xoffset), int(yoffset))
|
||||
elif self._op == DRAWOP_DRAW_POLYGON:
|
||||
dc.DrawPolygon(self._points, xoffset, yoffset)
|
||||
dc.DrawPolygon(self._points, int(xoffset), int(yoffset))
|
||||
elif self._op == DRAWOP_DRAW_SPLINE:
|
||||
dc.DrawSpline(self._points) # no offsets in DrawSpline
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ def GetArrowPoints(x1, y1, x2, y2, length, width):
|
||||
x3 = -length * i_bar + x2
|
||||
y3 = -length * j_bar + y2
|
||||
|
||||
return x2, y2, width * -j_bar + x3, width * i_bar + y3, -width * -j_bar + x3, -width * i_bar + y3
|
||||
return int(x2), int(y2), int(width * -j_bar + x3), int(width * i_bar + y3), int(-width * -j_bar + x3), int(-width * i_bar + y3)
|
||||
|
||||
|
||||
def DrawArcToEllipse(x1, y1, width1, height1, x2, y2, x3, y3):
|
||||
|
||||
Reference in New Issue
Block a user