def on_left_up(self, event): loc = -1 if (self.drag_image): pt = event.GetPosition() loc,update,dummy = self.local_move_centre_pt(pt, self.drag_name, self.drag_image) self.drag_bmp = None self.drag_image.Hide() self.drag_image.EndDrag() self.drag_image = None # check if we are removing it, is the program using it? if (win_data.config_check(loc, self.drag_name)): win_data.config_move_end(loc) win_data.click_sound() else: if (win_data.get_ok_to_delete("Module")): if (not win_data.config_move_to_trash()): # can't drop it - put it back error_message="Can not delete the device as it is used in the program.\n" +\ "Delete it from the program before deleting it here." wx.MessageBox(error_message, caption="Can't delete device.", style=wx.OK | wx.ICON_ERROR) win_data.config_move_abort() else: win_data.config_move_abort() # force the work area to redraw self.SetCursor(wx.NullCursor) self.Refresh() win_data.force_redraw('config')
def on_left_up(self, event): loc = -1 if (self.drag_image): pt = event.GetPosition() loc, update, dummy = self.local_move_centre_pt( pt, self.drag_name, self.drag_image) self.drag_bmp = None self.drag_image.Hide() self.drag_image.EndDrag() self.drag_image = None # check if we are removing it, is the program using it? if (win_data.config_check(loc, self.drag_name)): win_data.config_move_end(loc) win_data.click_sound() else: if (win_data.get_ok_to_delete("Module")): if (not win_data.config_move_to_trash()): # can't drop it - put it back error_message="Can not delete the device as it is used in the program.\n" +\ "Delete it from the program before deleting it here." wx.MessageBox(error_message, caption="Can't delete device.", style=wx.OK | wx.ICON_ERROR) win_data.config_move_abort() else: win_data.config_move_abort() # force the work area to redraw self.SetCursor(wx.NullCursor) self.Refresh() win_data.force_redraw('config')
def local_move_centre_pt(self, centre_pt, name, drag_image): # check in zones to speed things up location = -1 update = False detail_index = -1 centre_pt = self.CalcUnscrolledPosition(centre_pt) which_id = 0 # BED zooming support if (self.zoom != 1.0): centre_pt.Set(centre_pt.x/self.zoom, centre_pt.y/self.zoom) for loc, rect in self.locations_empty: if (rect.InsideXY(centre_pt.x, centre_pt.y)): location = loc break if (location != self.zone_hit): good = win_data.config_check(location, name) dc = None origin = self.mb_origin[:] if (good): # put the overlay on overlay = device_data.get_overlay_bmap(location) else: # put no overlay on overlay = device_data.get_overlay_bmap() if (self.zoom != 1.0): image = overlay.ConvertToImage() w = image.GetWidth() * self.zoom h = image.GetHeight() * self.zoom image.Rescale(w, h) overlay = image.ConvertToBitmap() origin[0] *= self.zoom origin[1] *= self.zoom dc = wx.ClientDC(self) self.DoPrepareDC(dc) drag_image.Hide() update = True dc.DrawBitmap(overlay, origin[0], origin[1], True) self.zone_hit = location return location, update, None
def local_move_centre_pt(self, centre_pt, name, drag_image): # check in zones to speed things up location = -1 update = False detail_index = -1 centre_pt = self.CalcUnscrolledPosition(centre_pt) which_id = 0 # BED zooming support if (self.zoom != 1.0): centre_pt.Set(centre_pt.x / self.zoom, centre_pt.y / self.zoom) for loc, rect in self.locations_empty: if (rect.InsideXY(centre_pt.x, centre_pt.y)): location = loc break if (location != self.zone_hit): good = win_data.config_check(location, name) dc = None origin = self.mb_origin[:] if (good): # put the overlay on overlay = device_data.get_overlay_bmap(location) else: # put no overlay on overlay = device_data.get_overlay_bmap() if (self.zoom != 1.0): image = overlay.ConvertToImage() w = image.GetWidth() * self.zoom h = image.GetHeight() * self.zoom image.Rescale(w, h) overlay = image.ConvertToBitmap() origin[0] *= self.zoom origin[1] *= self.zoom dc = wx.ClientDC(self) self.DoPrepareDC(dc) drag_image.Hide() update = True dc.DrawBitmap(overlay, origin[0], origin[1], True) self.zone_hit = location return location, update, None