Ejemplo n.º 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)
Ejemplo n.º 2
0
    def getDC(self):
        """Returns DC which can be used by the outside to draw to our buffer.

        As soon as dc dies (and it will at the end of the calling function)
        the contents of self._buffer will be blitted to the screen.
        """

        cdc = wx.wxClientDC(self)
        # set device origin according to scroll position                
        self.PrepareDC(cdc)
        dc = wx.wxBufferedDC(cdc, self._buffer)
        return dc
Ejemplo n.º 3
0
    def getDC(self):
        """Returns DC which can be used by the outside to draw to our buffer.

        As soon as dc dies (and it will at the end of the calling function)
        the contents of self._buffer will be blitted to the screen.
        """

        cdc = wx.wxClientDC(self)
        # set device origin according to scroll position
        self.PrepareDC(cdc)
        dc = wx.wxBufferedDC(cdc, self._buffer)
        return dc
Ejemplo n.º 4
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)