示例#1
0
    def __init__(self, parent, id=-1, size=wx.wxDefaultSize):
        # parent 1 ctor
        wx.wxScrolledWindow.__init__(self, parent, id, wx.wxPoint(0, 0), size,
                                     wx.wxSUNKEN_BORDER)
        # parent 2 ctor
        canvasSubject.__init__(self)

        self._cobjects = []
        self._previousRealCoords = None
        self._mouseDelta = (0, 0)
        self._potentiallyDraggedObject = None
        self._draggedObject = None

        self._observers = {'drag': [], 'buttonDown': [], 'buttonUp': []}

        self.SetBackgroundColour("WHITE")

        wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent)
        wx.EVT_PAINT(self, self.OnPaint)

        self.virtualWidth = 2048
        self.virtualHeight = 2048

        self._buffer = None
        self._buffer = wx.wxEmptyBitmap(self.virtualWidth, self.virtualHeight)

        # we're only going to draw into the buffer, so no real client DC
        dc = wx.wxBufferedDC(None, self._buffer)
        dc.SetBackground(wx.wxBrush(self.GetBackgroundColour()))
        dc.Clear()
        self.doDrawing(dc)

        self.SetVirtualSize((self.virtualWidth, self.virtualHeight))
        self.SetScrollRate(20, 20)
示例#2
0
    def dragObject(self, cobj, delta):
        if abs(delta[0]) > 0 or abs(delta[1]) > 0:
            # calculate new position
            cpos = cobj.getPosition()
            npos = (cpos[0] + delta[0], cpos[1] + delta[1])
            cobj.setPosition(npos)

            # setup DC
            dc = self.getDC()

            dc.BeginDrawing()

            # we're only going to draw a dotted outline
            dc.SetBrush(wx.wxBrush('WHITE', wx.wxTRANSPARENT))
            dc.SetPen(wx.wxPen('BLACK', 1, wx.wxDOT))
            dc.SetLogicalFunction(wx.wxINVERT)
            bounds = cobj.getBounds()

            # first delete the old rectangle
            dc.DrawRectangle(cpos[0], cpos[1], bounds[0], bounds[1])
            # then draw the new one
            dc.DrawRectangle(npos[0], npos[1], bounds[0], bounds[1])

            # thar she goes
            dc.EndDrawing()
示例#3
0
    def doDrawing(self, dc):
        """This function actually draws the complete shebang to the passed
        dc.
        """

        dc.BeginDrawing()
        # clear the whole shebang to background
        dc.SetBackground(wx.wxBrush(self.GetBackgroundColour(), wx.wxSOLID))
        dc.Clear()

        # draw glyphs last (always)
        glyphs = []
        theRest = []
        for i in self._cobjects:
            if isinstance(i, coGlyph):
                glyphs.append(i)
            else:
                theRest.append(i)

        for cobj in theRest:
            cobj.draw(dc)

        for cobj in glyphs:
            cobj.draw(dc)

        # draw all objects
        #for cobj in self._cobjects:
        #    cobj.draw(dc)

        dc.EndDrawing()
示例#4
0
    def dragObject(self, cobj, delta):
        if abs(delta[0]) > 0 or abs(delta[1]) > 0:
            # calculate new position
            cpos = cobj.getPosition()
            npos = (cpos[0] + delta[0], cpos[1] + delta[1])
            cobj.setPosition(npos)
            
            # setup DC
            dc = self.getDC()

            dc.BeginDrawing()

            # we're only going to draw a dotted outline
            dc.SetBrush(wx.wxBrush('WHITE', wx.wxTRANSPARENT))
            dc.SetPen(wx.wxPen('BLACK', 1, wx.wxDOT))
            dc.SetLogicalFunction(wx.wxINVERT)
            bounds = cobj.getBounds()

            # first delete the old rectangle
            dc.DrawRectangle(cpos[0], cpos[1], bounds[0], bounds[1])
            # then draw the new one
            dc.DrawRectangle(npos[0], npos[1], bounds[0], bounds[1])

            # thar she goes
            dc.EndDrawing()
示例#5
0
    def doDrawing(self, dc):
        """This function actually draws the complete shebang to the passed
        dc.
        """

        dc.BeginDrawing()
        # clear the whole shebang to background
        dc.SetBackground(wx.wxBrush(self.GetBackgroundColour(), wx.wxSOLID))
        dc.Clear()

        # draw glyphs last (always)
        glyphs = []
        theRest = []
        for i in self._cobjects:
            if isinstance(i, coGlyph):
                glyphs.append(i)
            else:
                theRest.append(i)
                
        for cobj in theRest:
            cobj.draw(dc)

        for cobj in glyphs:
            cobj.draw(dc)
        
        # draw all objects
        #for cobj in self._cobjects:
        #    cobj.draw(dc)

        dc.EndDrawing()
示例#6
0
    def __init__(self, parent, id = -1, size = wx.wxDefaultSize):
        # parent 1 ctor
        wx.wxScrolledWindow.__init__(self, parent, id, wx.wxPoint(0, 0), size,
                                    wx.wxSUNKEN_BORDER)
        # parent 2 ctor
        canvasSubject.__init__(self)

        self._cobjects = []
        self._previousRealCoords = None
        self._mouseDelta = (0,0)
        self._potentiallyDraggedObject = None
        self._draggedObject = None

        self._observers = {'drag' : [],
                           'buttonDown' : [],
                           'buttonUp' : []}

        self.SetBackgroundColour("WHITE")

        wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent)
        wx.EVT_PAINT(self, self.OnPaint)

        self.virtualWidth = 2048
        self.virtualHeight = 2048
        
        self._buffer = None
        self._buffer = wx.wxEmptyBitmap(self.virtualWidth, self.virtualHeight)

        # we're only going to draw into the buffer, so no real client DC
        dc = wx.wxBufferedDC(None, self._buffer)
        dc.SetBackground(wx.wxBrush(self.GetBackgroundColour()))
        dc.Clear()
        self.doDrawing(dc)

        self.SetVirtualSize((self.virtualWidth, self.virtualHeight))
        self.SetScrollRate(20,20)