Пример #1
0
    def on_paint(self, e = None):
        dc = BufferedPaintDC(self)

        # Draw empty background
        b = wx.WHITE_BRUSH#Brush(Color(40, 40, 40)) @UndefinedVariable
        #b.SetStipple(self.stipple)
        dc.Brush = b

        dc.Pen   = wx.TRANSPARENT_PEN #@UndefinedVariable
        dc.DrawRectangle(0,0,*self.Size)

        # Draw the bitmap
        self.paint_bitmap(dc)

        # Draw the picker square
        dc.Brush = wx.TRANSPARENT_BRUSH #@UndefinedVariable
        dc.Pen   = wx.RED_PEN #@UndefinedVariable

        x,y = self.middle
        x -= self.picksize[0] / 2
        y -= self.picksize[1] / 2
        dc.SetLogicalFunction(wx.INVERT)
        dc.DrawRectangle(x,y,self.picksize[0],self.picksize[1])
Пример #2
0
    def on_paint(self, e=None):
        dc = BufferedPaintDC(self)

        # Draw empty background
        b = wx.WHITE_BRUSH  #Brush(Color(40, 40, 40)) @UndefinedVariable
        #b.SetStipple(self.stipple)
        dc.Brush = b

        dc.Pen = wx.TRANSPARENT_PEN  #@UndefinedVariable
        dc.DrawRectangle(0, 0, *self.Size)

        # Draw the bitmap
        self.paint_bitmap(dc)

        # Draw the picker square
        dc.Brush = wx.TRANSPARENT_BRUSH  #@UndefinedVariable
        dc.Pen = wx.RED_PEN  #@UndefinedVariable

        x, y = self.middle
        x -= self.picksize[0] / 2
        y -= self.picksize[1] / 2
        dc.SetLogicalFunction(wx.INVERT)
        dc.DrawRectangle(x, y, self.picksize[0], self.picksize[1])
Пример #3
0
 def OnPaint(self, event):
     'Draws an outline around the control.'
     dc = BufferedPaintDC(self)
     dc.Brush = wx.TRANSPARENT_BRUSH
     dc.Pen = wx.Pen(OUTLINE_COLOR)
     dc.DrawRectangleRect(RectS(self.ClientSize))
Пример #4
0
    def paint(self, e):
        #
        # translation from C++ version in VListBox::OnPaint
        #


        clientSize = self.ClientSize
        dc = BufferedPaintDC(self)

        # the update rectangle
        rectUpdate = self.GetUpdateClientRect()

        # fill background
        crect = self.ClientRect

        if self.bg is not None:
            self.bg.Draw(dc, crect)
        else:
            dc.Brush = Brush(self.BackgroundColour)
            dc.Pen   = wx.TRANSPARENT_PEN #@UndefinedVariable
            dc.DrawRectangleRect(RectS(self.Size))

        self.PaintMoreBackground(dc, crect)

        # the bounding rectangle of the current line
        rectLine = Rect(0, 0, clientSize.x, 0)

        # iterate over all visible lines
        lineMax = self.GetVisibleEnd()
        lineh    = self.OnMeasureItem
        drawbg   = self.OnDrawBackground
        drawsep  = self.OnDrawSeparator
        drawitem = self.OnDrawItem
        margins  = self.GetMargins()

        for line in xrange(self.GetFirstVisibleLine(), lineMax):
            try:
                hLine = lineh(line)
            except TypeError:
                log.critical('self.OnMeasureItem was None, returning')
                del dc
                return

            rectLine.height = hLine

            # and draw the ones which intersect the update rect
            if rectLine.Intersects(rectUpdate):
                # don't allow drawing outside of the lines rectangle
                clip = DCClipper(dc, rectLine)
                rect = Rect(*rectLine)

                try:
                    drawbg(dc,  Rect(*rect), line)
                except Exception:
                    print_exc()

                try:
                    drawsep(dc, Rect(*rect), line)
                except Exception:
                    print_exc()

                rect.Deflate(margins.x, margins.y)

                try:
                    drawitem(dc, rect, line)
                except Exception:
                    print_exc()
                del clip

            else: # no intersection
                if rectLine.Top > rectUpdate.Bottom:
                    # we are already below the update rect, no need to continue
                    # further
                    break
                else: #the next line may intersect the update rect
                    pass

            rectLine.y += hLine

        return dc