示例#1
0
    def paintEvent(self, event):
        """Paints the margin"""
        if self.__firstTime:
            self.__updateWidth()
            self.__firstTime = False

        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)

        block = self._qpart.firstVisibleBlock()
        blockNumber = block.blockNumber()
        top = int(
            self._qpart.blockBoundingGeometry(block).translated(
                self._qpart.contentOffset()).top())
        bottom = top + int(self._qpart.blockBoundingRect(block).height())

        boundingRect = self._qpart.blockBoundingRect(block)
        availableWidth = self.__width - self._RIGHT_MARGIN - self._LEFT_MARGIN

        # The margin font could be smaller than the main area font
        topShift = int(
            (self._qpart.fontMetrics().height() - self.fontMetrics().height())
            / 2)
        if topShift < 0:
            topShift = 0

        availableHeight = self._qpart.fontMetrics().height()
        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                lineno = blockNumber + 1
                props = self.__data.get(lineno, [(None, None, None)])
                text = props[0][0]
                if text:
                    msgType = props[0][2]
                    color = CDMRedirectedIOMargin.MSG_TYPE_PROPS[msgType][1]
                    if color is None:
                        color = self.__fgColor
                    painter.setPen(color)
                    painter.drawText(self._LEFT_MARGIN, top + topShift,
                                     availableWidth, availableHeight,
                                     Qt.AlignRight, text)
            block = block.next()
            boundingRect = self._qpart.blockBoundingRect(block)
            top = bottom
            bottom = top + int(boundingRect.height())
            blockNumber += 1
示例#2
0
    def paintEvent(self, event):
        """Paints the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                lineNo = block.blockNumber() + 1
                pixmap = None
                if lineNo == self.excptionLine:
                    pixmap = MARKS[self.EXC_MARK]
                elif lineNo == self.currentDebugLine:
                    pixmap = MARKS[self.CURRENT_MARK]
                elif self.isBlockMarked(block):
                    if lineNo in self.__ccMessages:
                        pixmap = MARKS[self.__ccMessages[lineNo][1]]
                    else:
                        pixmap = MARKS[self.FLAKES_MARK]

                if pixmap:
                    xPos = 0
                    yPos = top
                    pixmapSide = self.width()  # Pixmap is square!
                    if oneLineHeight >= pixmapSide:
                        # More than enough vertical space, width is fixed
                        yPos += math.ceil((oneLineHeight - pixmapSide) / 2)
                    else:
                        # Not enough vertical space, width is fixed
                        xPos += math.ceil((pixmapSide - oneLineHeight) / 2)
                        pixmapSide = oneLineHeight
                    painter.drawPixmap(xPos, yPos, pixmapSide, pixmapSide,
                                       pixmap)
            top += height
示例#3
0
    def paintEvent(self, event):
        """Paint the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                # lineNo = block.blockNumber() + 1
                blockValue = self.getBlockValue(block)
                pixmap = None
                if blockValue != 0:
                    bpoint = self.__breakpoints[blockValue]
                    if not bpoint.isEnabled():
                        markType = self.DISABLED_BPOINT_MARK
                    elif bpoint.isTemporary():
                        markType = self.TMP_BPOINT_MARK
                    else:
                        markType = self.BPOINT_MARK
                    pixmap, edge = self.__marks[markType]

                if pixmap:
                    xPos = 0
                    yPos = top
                    if edge <= oneLineHeight:
                        yPos += math.ceil((oneLineHeight - edge) / 2)
                    else:
                        edge = oneLineHeight
                        xPos = math.ceil((self.width() - edge) / 2)
                    painter.drawPixmap(xPos, yPos, edge, edge, pixmap)
            top += height
示例#4
0
    def paintEvent(self, event):
        """Paints the margin"""
        if self.__firstTime:
            self.__updateWidth()
            self.__firstTime = False

        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        painter.setPen(self.__fgColor)

        block = self._qpart.firstVisibleBlock()
        blockNumber = block.blockNumber()
        top = int(
            self._qpart.blockBoundingGeometry(block).translated(
                self._qpart.contentOffset()).top())
        bottom = top + int(self._qpart.blockBoundingRect(block).height())

        boundingRect = self._qpart.blockBoundingRect(block)
        availableWidth = self.__width - self._RIGHT_MARGIN - self._LEFT_MARGIN

        # The margin font could be smaller than the main area font
        topShift = int(
            (self._qpart.fontMetrics().height() - self.fontMetrics().height())
            / 2)
        if topShift < 0:
            topShift = 0

        availableHeight = self._qpart.fontMetrics().height()
        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                number = str(blockNumber + 1)
                painter.drawText(self._LEFT_MARGIN, top + topShift,
                                 availableWidth, availableHeight,
                                 Qt.AlignRight, number)
            block = block.next()
            boundingRect = self._qpart.blockBoundingRect(block)
            top = bottom
            bottom = top + int(boundingRect.height())
            blockNumber += 1
示例#5
0
    def paintEvent(self, event):
        """Paints the margin"""
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.__bgColor)
        oneLineHeight = self._qpart.fontMetrics().height()

        block = self._qpart.firstVisibleBlock()
        geometry = self._qpart.blockBoundingGeometry(block)
        blockBoundingGeometry = geometry.translated(
            self._qpart.contentOffset())
        top = blockBoundingGeometry.top()
        # bottom = top + blockBoundingGeometry.height()

        for block in qutepart.iterateBlocksFrom(block):
            height = self._qpart.blockBoundingGeometry(block).height()
            if top > event.rect().bottom():
                break
            if block.isVisible():
                lineNo = block.blockNumber() + 1
                pixmap = None
                if lineNo == self.excptionLine:
                    pixmap, edge = self.__marks[self.EXC_MARK]
                elif lineNo == self.currentDebugLine:
                    pixmap, edge = self.__marks[self.CURRENT_MARK]
                elif self.isBlockMarked(block):
                    pixmap, edge = self.__marks[self.FLAKES_MARK]

                if pixmap:
                    xPos = 0
                    yPos = top
                    if edge <= oneLineHeight:
                        yPos += math.ceil((oneLineHeight - edge) / 2)
                    else:
                        edge = oneLineHeight
                        xPos = math.ceil((self.width() - edge) / 2)
                    painter.drawPixmap(xPos, yPos, edge, edge, pixmap)
            top += height