gui/tools/designer.py
def mouse_move(self, evt):
        "Move the selected object"
        if DEBUG: print "move!"
        if self.current and not self.overlay:
            wx_obj = self.current
            sx, sy = self.start
            x, y = wx.GetMousePosition()
            # calculate the new position (this will overwrite relative dimensions):
            x, y = (x + sx, y + sy)
            if evt.ShiftDown():     # snap to grid:
                x = x / GRID_SIZE[0] * GRID_SIZE[0]
                y = y / GRID_SIZE[1] * GRID_SIZE[1]
            # calculate the diff to use in the rest of the selected objects:
            ox, oy = wx_obj.obj.pos
            dx, dy = (x - ox), (y - oy)
            # move all selected objects:
            for obj in self.selection:
                x, y = obj.pos
                x = x + dx
                y = y + dy
                obj.pos = (wx.Point(x, y))
        elif self.overlay:
            wx_obj = self.current
            pos = evt.GetPosition()
            # convert to relative client coordinates of the containter:
            if evt.GetEventObject() != wx_obj:
                pos = evt.GetEventObject().ClientToScreen(pos)  # frame
                pos = wx_obj.ScreenToClient(pos)                # panel
            rect = wx.RectPP(self.pos, pos) 
            # Draw the rubber-band rectangle using an overlay so it 
            # will manage keeping the rectangle and the former window 
            # contents separate. 
            dc = wx.ClientDC(wx_obj) 
            odc = wx.DCOverlay(self.overlay, dc) 
            odc.Clear() 
            dc.SetPen(wx.Pen("blue", 2)) 
            if 'wxMac' in wx.PlatformInfo: 
                dc.SetBrush(wx.Brush(wx.Colour(0xC0, 0xC0, 0xC0, 0x80))) 
            else: 
                dc.SetBrush(wx.TRANSPARENT_BRUSH) 
            dc.DrawRectangleRect(rect)
            del odc
def mouse_move(self, evt):
        "Move the selected object"
        if DEBUG: print "move!"
        if self.current and not self.overlay:
            wx_obj = self.current
            sx, sy = self.start
            x, y = wx.GetMousePosition()
            # calculate the new position (this will overwrite relative dimensions):
            x, y = (x + sx, y + sy)
            if evt.ShiftDown():     # snap to grid:
                x = x / GRID_SIZE[0] * GRID_SIZE[0]
                y = y / GRID_SIZE[1] * GRID_SIZE[1]
            # calculate the diff to use in the rest of the selected objects:
            ox, oy = wx_obj.obj.pos
            dx, dy = (x - ox), (y - oy)
            # move all selected objects:
            for obj in self.selection:
                x, y = obj.pos
                x = x + dx
                y = y + dy
                obj.pos = (wx.Point(x, y))
        elif self.overlay:
            wx_obj = self.current
            pos = evt.GetPosition()
            # convert to relative client coordinates of the containter:
            if evt.GetEventObject() != wx_obj:
                pos = evt.GetEventObject().ClientToScreen(pos)  # frame
                pos = wx_obj.ScreenToClient(pos)                # panel
            rect = wx.RectPP(self.pos, pos) 
            # Draw the rubber-band rectangle using an overlay so it 
            # will manage keeping the rectangle and the former window 
            # contents separate. 
            dc = wx.ClientDC(wx_obj) 
            odc = wx.DCOverlay(self.overlay, dc) 
            odc.Clear() 
            dc.SetPen(wx.Pen("blue", 2)) 
            if 'wxMac' in wx.PlatformInfo: 
                dc.SetBrush(wx.Brush(wx.Colour(0xC0, 0xC0, 0xC0, 0x80))) 
            else: 
                dc.SetBrush(wx.TRANSPARENT_BRUSH) 
            dc.DrawRectangleRect(rect)
            del odc
Move the selected object