Example #1
0
 def paint(self, painter, index):
     if self._rubberBandRect is None:
         return
     widget = self.parent()
     if index != widget.activeIndex():
         return
     rect = self._rubberBandRect
     if platformSpecific.useBuiltinRubberBand():
         widgetOrigin = widget.mapFromCanvas(rect.bottomLeft())
         widgetMove = widget.mapFromCanvas(rect.topRight())
         option = QStyleOptionRubberBand()
         option.initFrom(widget)
         option.opaque = False
         option.rect = QRectF(widgetOrigin, widgetMove).toRect()
         option.shape = QRubberBand.Rectangle
         painter.save()
         painter.setRenderHint(QPainter.Antialiasing, False)
         painter.resetTransform()
         widget.style().drawControl(QStyle.CE_RubberBand, option, painter,
                                    widget)
         painter.restore()
     else:
         highlight = widget.palette().color(QPalette.Active,
                                            QPalette.Highlight)
         painter.save()
         painter.setRenderHint(QPainter.Antialiasing, False)
         pen = painter.pen()
         pen.setColor(highlight.darker(120))
         pen.setWidth(0)
         painter.setPen(pen)
         highlight.setAlphaF(0.35)
         painter.setBrush(highlight)
         painter.drawRect(rect)
         painter.restore()
Example #2
0
 def paint(self, painter):
     if self._rubberBandRect is None:
         return
     widget = self.parent()
     rect = self._rubberBandRect
     # TODO: maybe extract this to drawRubberBand
     if platformSpecific.needsCustomRubberBand():
         highlight = widget.palette(
             ).color(QPalette.Active, QPalette.Highlight)
         painter.save()
         painter.setRenderHint(QPainter.Antialiasing, False)
         painter.setPen(highlight.darker(120))
         highlight.setAlphaF(.35)
         painter.setBrush(highlight)
         painter.drawRect(rect)
         painter.restore()
     else:
         # okay, OS-native rubber band does not support painting with
         # floating-point coordinates
         # paint directly on the widget with unscaled context
         widgetOrigin = widget.mapFromCanvas(rect.bottomLeft())
         widgetMove = widget.mapFromCanvas(rect.topRight())
         option = QStyleOptionRubberBand()
         option.initFrom(widget)
         option.opaque = False
         option.rect = QRectF(widgetOrigin, widgetMove).toRect()
         option.shape = QRubberBand.Rectangle
         painter.save()
         painter.setRenderHint(QPainter.Antialiasing, False)
         painter.resetTransform()
         widget.style().drawControl(
             QStyle.CE_RubberBand, option, painter, widget)
         painter.restore()
Example #3
0
 def paint(self, painter):
     if self._rubberBandRect is None:
         return
     widget = self.parent()
     # okay, OS-native rubber band does not support painting with
     # floating-point coordinates
     # paint directly on the widget with unscaled context
     widgetOrigin = widget.mapToWidget(self._rubberBandRect.bottomLeft())
     widgetMove = widget.mapToWidget(self._rubberBandRect.topRight())
     option = QStyleOptionRubberBand()
     option.initFrom(widget)
     option.opaque = False
     option.rect = QRectF(widgetOrigin, widgetMove).toRect()
     option.shape = QRubberBand.Rectangle
     painter.save()
     painter.setRenderHint(QPainter.Antialiasing, False)
     painter.setTransform(QTransform())
     widget.style().drawControl(QStyle.CE_RubberBand, option, painter,
                                widget)
     painter.restore()
Example #4
0
 def paint(self, painter):
     if self._rubberBandRect is None:
         return
     widget = self.parent()
     # okay, OS-native rubber band does not support painting with
     # floating-point coordinates
     # paint directly on the widget with unscaled context
     widgetOrigin = widget.mapFromCanvas(self._rubberBandRect.bottomLeft())
     widgetMove = widget.mapFromCanvas(self._rubberBandRect.topRight())
     option = QStyleOptionRubberBand()
     option.initFrom(widget)
     option.opaque = False
     option.rect = QRectF(widgetOrigin, widgetMove).toRect()
     option.shape = QRubberBand.Rectangle
     painter.save()
     painter.setRenderHint(QPainter.Antialiasing, False)
     painter.setTransform(QTransform())
     widget.style().drawControl(
         QStyle.CE_RubberBand, option, painter, widget)
     painter.restore()