def paintEvent(self, event): Panel.paintEvent(self, event) painter = QtGui.QPainter(self) for top, block_nbr, block in self.editor.visible_blocks: user_data = block.userData() if hasattr(user_data, "markers"): markers = user_data.markers for i, marker in enumerate(markers): if (hasattr(marker, 'panel_ref') and marker.panel_ref == self): # only draw our markers if marker in self._to_remove: try: user_data.markers.remove(None) self._to_remove.remove(marker) except ValueError: pass continue if marker and marker.icon: rect = QtCore.QRect() rect.setX(0) rect.setY(top) rect.setWidth(self.sizeHint().width()) rect.setHeight(self.sizeHint().height()) if isinstance(marker.icon, tuple): key = marker.icon[0] else: key = marker.icon if key not in self._icons: key, val = self.make_marker_icon(marker.icon) if key and val: self._icons[key] = val else: continue self._icons[key].paint(painter, rect)
def paintEvent(self, event): super(PromptLineEdit, self).paintEvent(event) qt_api = os.environ['QT_API'].lower() if self._prompt_text and not self.text() and self.isEnabled(): if qt_api in PYQT4_API: from PyQt4.QtGui import QStyleOptionFrameV3 option = QStyleOptionFrameV3() elif qt_api in PYSIDE_API: from PySide.QtGui import QStyleOptionFrameV3 option = QStyleOptionFrameV3() elif qt_api in PYQT5_API: from PyQt5.QtWidgets import QStyleOptionFrame option = QStyleOptionFrame() else: msg = 'Qt bindings "%s" is not supported' % qt_api raise PythonQtError(msg) self.initStyleOption(option) left, top, right, bottom = self.getTextMargins() va = self.style().visualAlignment(self.layoutDirection(), self.alignment()) rect = self.style().subElementRect( QtWidgets.QStyle.SE_LineEditContents, option, self).adjusted(2, 0, 0, 0).adjusted(left, top, -right, -bottom) fm = QtGui.QFontMetrics(self.font()) text = fm.elidedText(self._prompt_text, QtCore.Qt.ElideRight, rect.width()) painter = QtGui.QPainter(self) painter.setPen(self.palette().color(QtGui.QPalette.Disabled, QtGui.QPalette.Text)) painter.drawText(rect, va, text)
def paintEvent(self, event): # Paints the line numbers self._line_color_u = drift_color(self._background_brush.color(), 250) self._line_color_s = drift_color(self._background_brush.color(), 280) Panel.paintEvent(self, event) if self.isVisible(): painter = QtGui.QPainter(self) # get style options (font, size) width = self.width() height = self.editor.fontMetrics().height() font = self.editor.font() bold_font = self.editor.font() bold_font.setBold(True) pen = QtGui.QPen(self._line_color_u) pen_selected = QtGui.QPen(self._line_color_s) painter.setFont(font) # get selection range sel_start, sel_end = TextHelper(self.editor).selection_range() has_sel = sel_start != sel_end cl = TextHelper(self.editor).current_line_nbr() # draw every visible blocks for top, line, block in self.editor.visible_blocks: if ((has_sel and sel_start <= line <= sel_end) or (not has_sel and cl == line)): painter.setPen(pen_selected) painter.setFont(bold_font) else: painter.setPen(pen) painter.setFont(font) painter.drawText(-3, top, width, height, QtCore.Qt.AlignRight, str(line + 1))
def paintEvent(self, event): """ Fills the panel background. """ super(ReadOnlyPanel, self).paintEvent(event) if self.isVisible(): # fill background painter = QtGui.QPainter(self) self._background_brush = QtGui.QBrush(self._color) painter.fillRect(event.rect(), self._background_brush)
def paintEvent(self, event): """ Fills the panel background. """ # pylint: disable=invalid-name if self.isVisible(): # fill background self._background_brush = QtGui.QBrush(self.editor.background) painter = QtGui.QPainter(self) painter.fillRect(event.rect(), self._background_brush)
def paintEvent(self, event): # Fills the panel background using QPalette if self.isVisible(): # fill background self._background_brush = QtGui.QBrush( QtGui.QColor(self.palette().window().color())) self._foreground_pen = QtGui.QPen( QtGui.QColor(self.palette().windowText().color())) painter = QtGui.QPainter(self) painter.fillRect(event.rect(), self._background_brush)
def _paint_margin(self, event): """ Paints the right margin after editor paint event. """ font = QtGui.QFont(self.editor.font_name, self.editor.font_size + self.editor.zoom_level) metrics = QtGui.QFontMetricsF(font) pos = self._margin_pos offset = self.editor.contentOffset().x() + \ self.editor.document().documentMargin() x80 = round(metrics.width(' ') * pos) + offset painter = QtGui.QPainter(self.editor.viewport()) painter.setPen(self._pen) painter.drawLine(x80, 0, x80, 2**16)
def paintEvent(self, event): """ Pains the messages and the visible area on the panel. :param event: paint event infos """ if self.isVisible(): # fill background self._background_brush = QtGui.QBrush(self.editor.background) painter = QtGui.QPainter(self) painter.fillRect(event.rect(), self._background_brush) self._draw_messages(painter) self._draw_visible_area(painter)
def paintEvent(self, event): Panel.paintEvent(self, event) painter = QtGui.QPainter(self) for top, block_nbr, block in self.editor.visible_blocks: for marker in self._markers: if marker.block == block and marker.icon: rect = QtCore.QRect() rect.setX(0) rect.setY(top) rect.setWidth(self.sizeHint().width()) rect.setHeight(self.sizeHint().height()) marker.icon.paint(painter, rect)
def _paint_margins(self, event): """ Paints the right margin after editor paint event. """ font = QtGui.QFont(self.editor.font_name, self.editor.font_size + self.editor.zoom_level) metrics = QtGui.QFontMetricsF(font) painter = QtGui.QPainter(self.editor.viewport()) for pos, pen in zip(self._positions, self._pens): if pos < 0: # margin not visible continue offset = self.editor.contentOffset().x() + \ self.editor.document().documentMargin() x_pos = round(metrics.width(' ') * pos) + offset painter.setPen(pen) painter.drawLine(x_pos, 0, x_pos, 2**16)
def paintEvent(self, event): super(CheckerPanel, self).paintEvent(event) painter = QtGui.QPainter(self) for top, block_nbr, block in self.editor.visible_blocks: user_data = block.userData() if user_data and user_data.messages: for msg in user_data.messages: icon = self._icon_from_message(msg) if icon: rect = QtCore.QRect() rect.setX(0) rect.setY(top) rect.setWidth(self.sizeHint().width()) rect.setHeight(self.sizeHint().height()) icon.paint(painter, rect)
def paintEvent(self, event): p = QtGui.QPainter() p.begin(self) pal = self.palette() p.fillRect(QtCore.QRect(QtCore.QPoint(), self.size()), pal.color(pal.Background)) textSize = self.textRect(' ' * self._vt.columns).size() bound = QtCore.QRect(QtCore.QPoint(), textSize) flags = QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom for line in self._vt.display: p.drawText(bound, flags, line) bound.translate(0, bound.height()) if self.hasFocus(): p.fillRect(self.cursorRect(), pal.color(pal.Foreground)) else: p.drawRect(self.cursorRect()) p.end()
def paintEvent(self, event): # Paints the fold indicators and the possible fold region background # on the folding panel. super(FoldingPanel, self).paintEvent(event) painter = QtGui.QPainter(self) # Draw background over the selected non collapsed fold region if self._mouse_over_line is not None: block = self.editor.document().findBlockByNumber( self._mouse_over_line) try: self._draw_fold_region_background(block, painter) except ValueError: pass # Draw fold triggers for top_position, line_number, block in self.editor.visible_blocks: if TextBlockHelper.is_fold_trigger(block): collapsed = TextBlockHelper.get_fold_trigger_state(block) mouse_over = self._mouse_over_line == line_number self._draw_fold_indicator( top_position, mouse_over, collapsed, painter) if collapsed: # check if the block already has a decoration, it might # have been folded by the parent editor/document in the # case of cloned editor for deco in self._block_decos: if deco.block == block: # no need to add a deco, just go to the next block break else: self._add_fold_decoration(block, FoldScope(block)) else: for deco in self._block_decos: # check if the block decoration has been removed, it # might have been unfolded by the parent # editor/document in the case of cloned editor if deco.block == block: # remove it and self._block_decos.remove(deco) self.editor.decorations.remove(deco) del deco break