Exemplo n.º 1
0
    def init_pallete(self):
        groups = bric_data.get_groups()
        for name, expbmap, colbmap in groups:
            self.add_group(name, expbmap, colbmap)

        brics = bric_data.get_brics()
        for name, group in brics:
            if group != "Hide":
                bmap = bric_data.get_bric_bmap(name)
                sel_bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
                dis_bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_DISABLED)

                self.add_item_bmap(group, name, bmap, sel_bmap, dis_bmap)
Exemplo n.º 2
0
    def init_pallete(self):
        groups = bric_data.get_groups()
        for name, expbmap, colbmap in groups:
            self.add_group(name, expbmap, colbmap)

        brics = bric_data.get_brics()
        for name, group in brics:
            if (group != "Hide"):
                bmap = bric_data.get_bric_bmap(name)
                sel_bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
                dis_bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_DISABLED)

                self.add_item_bmap(group, name, bmap, sel_bmap, dis_bmap)
Exemplo n.º 3
0
    def on_mouse_motion(self, event):
        if (self.drag_id < 0 or not event.Dragging() or not event.LeftIsDown()):
            return

        ok_to_drag = win_data.program().check_drag(self.drag_id, self.drag_name)
        if (not ok_to_drag):
            return

        raw_pt = event.GetPosition()
        check_pt = self.CalcUnscrolledPosition(raw_pt)

        
        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(check_pt.x/self.zoom, check_pt.y/self.zoom)
            #print "Move, raw:", raw_pt, "check:", check_pt

            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

            #print "Start drag with movement:", dx, dy
            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_id, self.drag_name)
            win_data.program().start_move(self.drag_id, self.drag_which)
            # force the work area to redraw
            self.Refresh()
            self.Update()

            # get the selected variant since we had to click to get here
            bmp = bric_data.get_bric_bmap(self.drag_name, bric_data.BRIC_SELECTED)
            
            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 = bmp.GetSize()
            hotspot = (dev_x/2, dev_y/2)
            

            self.drag_image.BeginDrag(hotspot, self, False, self.GetClientRect())
            loc, update,which_id = self.local_move_centre_pt(raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)
            self.drag_image.Show()
            
        else:
            
            loc, update,which_id = self.local_move_centre_pt(raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)
            
            if (update):
                self.drag_image.Show()
Exemplo n.º 4
0
    def compute_bmap(self, name, x, bric_id):
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)

        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        x += bmap.GetWidth()
        return x
Exemplo n.º 5
0
    def compute_bmap(self, name, x, bric_id):
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)
            
        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        x += bmap.GetWidth()
        return x
Exemplo n.º 6
0
    def draw_bmap(self, dc, name, x, cl, bric_id):
        # **BED** scale bitmap if needed
        #print "Drawing:", name, "x:",x, "cl:", cl, "bric_id:", bric_id

        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)

        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        y = cl - bmap.GetHeight() / 2

        dc.DrawBitmap(bmap, x, y, True)
        x += bmap.GetWidth()
        return (x, bmap.GetSize())
Exemplo n.º 7
0
    def draw_bmap(self, dc, name, x, cl, bric_id):
        # **BED** scale bitmap if needed
        #print "Drawing:", name, "x:",x, "cl:", cl, "bric_id:", bric_id
        
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)
            
        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        y = cl - bmap.GetHeight()/2
            
        dc.DrawBitmap(bmap, x, y, True)
        x += bmap.GetWidth()
        return (x, bmap.GetSize())
Exemplo n.º 8
0
    def on_mouse_motion(self, event):
        if (self.drag_id < 0 or not event.Dragging()
                or not event.LeftIsDown()):
            return

        ok_to_drag = win_data.program().check_drag(self.drag_id,
                                                   self.drag_name)
        if (not ok_to_drag):
            return

        raw_pt = event.GetPosition()
        check_pt = self.CalcUnscrolledPosition(raw_pt)

        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(check_pt.x / self.zoom, check_pt.y / self.zoom)
            #print "Move, raw:", raw_pt, "check:", check_pt

            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

            #print "Start drag with movement:", dx, dy
            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_id, self.drag_name)
            win_data.program().start_move(self.drag_id, self.drag_which)
            # force the work area to redraw
            self.Refresh()
            self.Update()

            # get the selected variant since we had to click to get here
            bmp = bric_data.get_bric_bmap(self.drag_name,
                                          bric_data.BRIC_SELECTED)

            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 = bmp.GetSize()
            hotspot = (dev_x / 2, dev_y / 2)

            self.drag_image.BeginDrag(hotspot, self, False,
                                      self.GetClientRect())
            loc, update, which_id = self.local_move_centre_pt(
                raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)
            self.drag_image.Show()

        else:

            loc, update, which_id = self.local_move_centre_pt(
                raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)

            if (update):
                self.drag_image.Show()