def OnEndDragLeft(self, x, y, keys=0, attachment=0): ControlPoint.OnEndDragLeft(self, x, y, keys, attachment) dc = wx.ClientDC(self.canvas) self.canvas.PrepareDC(dc) division = self._shape divisionParent = division.GetParent() # Need to check it's within the bounds of the parent composite x1 = divisionParent.x - divisionParent.w / 2.0 y1 = divisionParent.y - divisionParent.h / 2.0 x2 = divisionParent.x + divisionParent.w / 2.0 y2 = divisionParent.y + divisionParent.h / 2.0 # Need to check it has not made the division zero or negative # width / height dx1 = division.x - division.w / 2.0 dy1 = division.y - division.h / 2.0 dx2 = division.x + division.w / 2.0 dy2 = division.y + division.h / 2.0 success = True if division.GetHandleSide() == DIVISION_SIDE_LEFT: if x <= x1 or x >= x2 or x >= dx2: success = False # Try it out first... elif not division.ResizeAdjoining(DIVISION_SIDE_LEFT, x, True): success = False else: division.ResizeAdjoining(DIVISION_SIDE_LEFT, x, False) elif division.GetHandleSide() == DIVISION_SIDE_TOP: if y <= y1 or y >= y2 or y >= dy2: success = False elif not division.ResizeAdjoining(DIVISION_SIDE_TOP, y, True): success = False else: division.ResizingAdjoining(DIVISION_SIDE_TOP, y, False) elif division.GetHandleSide() == DIVISION_SIDE_RIGHT: if x <= x1 or x >= x2 or x <= dx1: success = False elif not division.ResizeAdjoining(DIVISION_SIDE_RIGHT, x, True): success = False else: division.ResizeAdjoining(DIVISION_SIDE_RIGHT, x, False) elif division.GetHandleSide() == DIVISION_SIDE_BOTTOM: if y <= y1 or y >= y2 or y <= dy1: success = False elif not division.ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, True): success = False else: division.ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, False) if not success: division.SetSize(originalW, originalH) division.Move(dc, originalX, originalY) divisionParent.Draw(dc) division.handler.OnDrawControlPoints(dc)
def OnBeginDragLeft(self, x, y, keys=0, attachment=0): global originalX, originalY, originalW, originalH originalX = self._shape.x originalY = self._shape.y originalW = self._shape.w originalH = self._shape.h ControlPoint.OnBeginDragLeft(self, x, y, keys, attachment)
def OnDragLeft(self, draw, x, y, keys=0, attachment=0): ControlPoint.OnDragLeft(self, draw, x, y, keys, attachment)
def __init__(self, the_canvas, object, size, the_xoffset, the_yoffset, the_type): ControlPoint.__init__(self, the_canvas, object, size, the_xoffset, the_yoffset, the_type) self.SetEraseObject(False)
def __init__(self, the_canvas, object, region, size, the_m_xoffset, the_m_yoffset, the_type): ControlPoint.__init__(self, the_canvas, object, size, the_m_xoffset, the_m_yoffset, the_type) self.regionId = region