Beispiel #1
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
Beispiel #2
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
Beispiel #3
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