Ejemplo n.º 1
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))
Ejemplo n.º 2
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