Пример #1
0
void AbstractContent::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    // find out whether to draw the selection
    const bool drawSelection = RenderOpts::HQRendering ? false : isSelected();

    // change opacity
    qreal opacity = contentOpacity();
    if (opacity < 1.0)
        painter->setOpacity(opacity);

    if (m_frame) {
        // draw the Frame
        m_frame->drawFrame(painter, m_frameRect.toRect(), drawSelection, contentOpaque());

        // use clip path for contents, if set
        if (m_frame->clipContents())
            painter->setClipPath(m_frame->contentsClipPath(m_contentRect));
    }

#if 0
    if (RenderOpts::OpenGLWindow && drawSelection)
        painter->setCompositionMode(QPainter::CompositionMode_Plus);
#endif

    // paint the inner contents
    const QRect tcRect = QRect(0, 0, m_contentRect.width(), m_contentRect.height());
    painter->translate(m_contentRect.topLeft());
    drawContent(painter, tcRect, Qt::IgnoreAspectRatio);

    // restore opacity
    if (opacity < 1.0)
        painter->setOpacity(1.0);

    // overlay a selection
    if (drawSelection && !m_frame) {
        painter->setRenderHint(QPainter::Antialiasing, true);
        QPen selPen(RenderOpts::hiColor, 2.0);
        selPen.setJoinStyle(Qt::MiterJoin);
        painter->setPen(selPen);
        painter->setBrush(Qt::NoBrush);
        painter->drawRect(tcRect.adjusted(1, 1, -1, -1));
    }
}
Пример #2
0
void AbstractContent::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    const bool opaqueContent = contentOpaque();
    const bool drawSelection = RenderOpts::HQRendering ? false : isSelected();
    const QRect frameRect = m_frameRect.toRect();

    if (!m_frame) {
        // draw the selection only as done in EmptyFrame.cpp
        if (drawSelection) {
            painter->setRenderHint(QPainter::Antialiasing, true);
            painter->setPen(QPen(RenderOpts::hiColor, 1.0));
            // FIXME: this draws OUTSIDE (but inside the safe 2px area)
            painter->drawRect(QRectF(frameRect).adjusted(-0.5, -0.5, +0.5, +0.5));
        }
    } else {
        // draw the Frame
        m_frame->paint(painter, frameRect, drawSelection, opaqueContent);

        // use clip path for contents, if set
        if (m_frame->clipContents())
            painter->setClipPath(m_frame->contentsClipPath(m_contentsRect));
    }
}