Beispiel #1
0
    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')
Beispiel #2
0
    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')
Beispiel #3
0
    def remove_bric(self, id, which_id, no_delete=False):
        #print "Remove",
        #self.brics[id].dump()

        prev_id = self.brics[id].prev_id[0]
        next_id = self.brics[id].next_id[0]

        # handle removing an event - it must already be the only icon in the stream
        if (prev_id == 0):
            # find which stream and remove it
            for i in range(len(self.streams)):
                if (self.streams[i] == id):
                    del self.streams[i]
                    break
            win_data.update_dirty(True)
            win_data.initialise_unused_events()

            # refresh the programming pallete
            win_data.force_redraw("ppallete")

            del self.brics[id]
            self.bric_count -= 1
            return True

        if (self.brics[id].bric_name in ('If', 'Loop')):
            # removing an EMPTY If or Loop
            # have to jump the end bit
            next_id = self.brics[next_id].next_id[0]

        if (prev_id >= 0):
            if (self.brics[prev_id].bric_name == 'If'):
                # previous bric is an if bric
                self.brics[prev_id].next_id[which_id] = next_id
            else:
                self.brics[prev_id].next_id[0] = next_id

        if (next_id >= 0):
            if (self.brics[next_id].bric_name.startswith("End")):
                # next bric is an End bric
                self.brics[next_id].prev_id[which_id] = prev_id
            else:
                self.brics[next_id].prev_id[0] = prev_id

        if (not no_delete):
            if (self.brics[id].bric_name in ('If', 'Loop')):
                del self.brics[id]
                del self.brics[id + 1]
                self.bric_count -= 2
            else:
                del self.brics[id]
                self.bric_count -= 1

        win_data.update_dirty(True)
        return True
Beispiel #4
0
    def on_left_up(self, event):
        # do parent processing
        prev_id, bric_name, which_id = self.parent_on_left_up(event)
        if prev_id >= 0:
            # it is a valid drop!
            new_id = win_data.program().add_new_bric(prev_id, which_id, bric_name)
            # set the selection
            win_data.selection_take("pwork", bric_name, new_id)

        # force the work area to redraw
        win_data.force_redraw("pwork")
Beispiel #5
0
    def remove_bric(self, id, which_id, no_delete=False):
        #print "Remove",
        #self.brics[id].dump()

        prev_id = self.brics[id].prev_id[0]
        next_id = self.brics[id].next_id[0]

        # handle removing an event - it must already be the only icon in the stream
        if (prev_id == 0):
            # find which stream and remove it
            for i in range(len(self.streams)):
                if (self.streams[i] == id):
                    del self.streams[i]
                    break
            win_data.update_dirty(True)
            win_data.initialise_unused_events()

            # refresh the programming pallete
            win_data.force_redraw("ppallete")

            del self.brics[id]
            self.bric_count -= 1
            return True

        if (self.brics[id].bric_name in ('If', 'Loop')):
            # removing an EMPTY If or Loop
            # have to jump the end bit
            next_id = self.brics[next_id].next_id[0]

        if (prev_id >= 0):
            if (self.brics[prev_id].bric_name == 'If'):
                # previous bric is an if bric
                self.brics[prev_id].next_id[which_id] = next_id
            else:
                self.brics[prev_id].next_id[0] = next_id

        if (next_id >= 0):
            if (self.brics[next_id].bric_name.startswith("End")):
                # next bric is an End bric
                self.brics[next_id].prev_id[which_id] = prev_id
            else:
                self.brics[next_id].prev_id[0] = prev_id

        if (not no_delete):
            if (self.brics[id].bric_name in ('If', 'Loop')):
                del self.brics[id]
                del self.brics[id+1]
                self.bric_count -= 2
            else:
                del self.brics[id]
                self.bric_count -= 1

        win_data.update_dirty(True)
        return True
Beispiel #6
0
    def on_left_up(self, event):
        # do parent processing
        prev_id, bric_name, which_id = self.parent_on_left_up(event)
        if (prev_id >= 0):
            # it is a valid drop!
            new_id = win_data.program().add_new_bric(prev_id, which_id,
                                                     bric_name)
            # set the selection
            win_data.selection_take('pwork', bric_name, new_id)

        # force the work area to redraw
        win_data.force_redraw('pwork')
Beispiel #7
0
    def on_left_up(self, event):
        # do parent processing
        loc, name, dummy = self.parent_on_left_up(event)
        if (loc >= 0):
            # it is a valid drop!
            win_data.config_add(loc, name)
            win_data.selection_take('cwork', name, loc)
            win_data.click_sound()

        # force the work area to redraw
        win_data.force_redraw('cwork')
        win_data.force_redraw('config')
Beispiel #8
0
    def on_mouse_motion(self, event):
        if (self.drag_loc < 0 or not event.Dragging()
                or not event.LeftIsDown()):
            return

        pt = event.GetPosition()

        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(pt.x / self.zoom, pt.y / self.zoom)

            tolerance = 4

            dx = abs(check_pt.x - self.drag_start_pos.x)
            dy = abs(check_pt.y - self.drag_start_pos.y)
            if (dx <= tolerance and dy <= tolerance):
                return

            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_loc, self.drag_name)
            win_data.config_move_start(self.drag_loc)
            # force the work area to redraw
            self.Refresh()
            self.Update()
            win_data.force_redraw('config')

            # get the selected variant since we had to click to get here
            bmp = device_data.get_device_bmap(self.drag_name, True)
            if (self.zoom != 1.0):
                image = bmp.ConvertToImage()
                w = image.GetWidth() * self.zoom
                h = image.GetHeight() * self.zoom
                image.Rescale(w, h)
                bmp = image.ConvertToBitmap()

            self.drag_image = wx.DragImage(bmp, wx.StockCursor(wx.CURSOR_HAND))
            #dev_x,dev_y = device_data.get_device_size()
            dev_x, dev_y = bmp.GetSize()
            hotspot = (dev_x / 2, dev_y / 2)
            #print "on_mouse_motion: hotspot", hotspot

            self.drag_image.BeginDrag(hotspot, self, False,
                                      self.GetClientRect())
            loc, update, dummy = self.local_move_centre_pt(
                pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            self.drag_image.Show()
        else:
            loc, update, dummy = self.local_move_centre_pt(
                pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            if (update):
                self.drag_image.Show()
Beispiel #9
0
    def on_left_up(self, event):
        # do parent processing
        loc,name,dummy = self.parent_on_left_up(event)
        if (loc >= 0):
            # it is a valid drop!
            win_data.config_add(loc, name)
            win_data.selection_take('cwork', name, loc)
            win_data.click_sound()


        # force the work area to redraw
        win_data.force_redraw('cwork')
        win_data.force_redraw('config')
Beispiel #10
0
    def on_mouse_motion(self, event):
        if (self.drag_loc < 0 or not event.Dragging() or not event.LeftIsDown()):
            return

        pt = event.GetPosition()

        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(pt.x/self.zoom, pt.y/self.zoom)

            tolerance = 4

            dx = abs(check_pt.x - self.drag_start_pos.x)
            dy = abs(check_pt.y - self.drag_start_pos.y)
            if (dx <= tolerance and dy <= tolerance):
                return

            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_loc, self.drag_name)
            win_data.config_move_start(self.drag_loc)
            # force the work area to redraw
            self.Refresh()
            self.Update()
            win_data.force_redraw('config')

            # get the selected variant since we had to click to get here
            bmp = device_data.get_device_bmap(self.drag_name, True)
            if (self.zoom != 1.0):
                image = bmp.ConvertToImage()
                w = image.GetWidth() * self.zoom
                h = image.GetHeight() * self.zoom
                image.Rescale(w, h)
                bmp = image.ConvertToBitmap()

            self.drag_image = wx.DragImage(bmp, wx.StockCursor(wx.CURSOR_HAND))
            #dev_x,dev_y = device_data.get_device_size()
            dev_x,dev_y = bmp.GetSize()
            hotspot = (dev_x/2, dev_y/2)
            #print "on_mouse_motion: hotspot", hotspot

            self.drag_image.BeginDrag(hotspot, self, False, self.GetClientRect())
            loc,update,dummy = self.local_move_centre_pt(pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            self.drag_image.Show()
        else:
            loc,update,dummy = self.local_move_centre_pt(pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            if (update):
                self.drag_image.Show()