Example #1
0
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
                                   QPainter *painter, const QWidget *widget) const
{
    if (!panelWidget(widget))
        return QProxyStyle::drawPrimitive(element, option, painter, widget);

    bool animating = (option->state & State_Animating);
    int state = option->state;
    QRect rect = option->rect;
    QRect oldRect;
    QRect newRect;
    if (widget && (element == PE_PanelButtonTool) && !animating) {
        QWidget *w = const_cast<QWidget *> (widget);
        int oldState = w->property("_q_stylestate").toInt();
        oldRect = w->property("_q_stylerect").toRect();
        newRect = w->rect();
        w->setProperty("_q_stylestate", (int)option->state);
        w->setProperty("_q_stylerect", w->rect());

        // Determine the animated transition
        bool doTransition = ((state & State_On)         != (oldState & State_On)     ||
                             (state & State_MouseOver)  != (oldState & State_MouseOver));
        if (oldRect != newRect)
        {
            doTransition = false;
            d->animator.stopAnimation(widget);
        }

        if (doTransition) {
            QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
            QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
            Animation *anim = d->animator.widgetAnimation(widget);
            QStyleOption opt = *option;
            opt.state = (QStyle::State)oldState;
            opt.state |= State_Animating;
            startImage.fill(0);
            Transition *t = new Transition;
            t->setWidget(w);
            QPainter startPainter(&startImage);
            if (!anim) {
                drawPrimitive(element, &opt, &startPainter, widget);
            } else {
                anim->paint(&startPainter, &opt);
                d->animator.stopAnimation(widget);
            }
            QStyleOption endOpt = *option;
            endOpt.state |= State_Animating;
            t->setStartImage(startImage);
            d->animator.startAnimation(t);
            endImage.fill(0);
            QPainter endPainter(&endImage);
            drawPrimitive(element, &endOpt, &endPainter, widget);
            t->setEndImage(endImage);
            if (oldState & State_MouseOver)
                t->setDuration(150);
            else
                t->setDuration(75);
            t->setStartTime(QTime::currentTime());
        }
    }

    switch (element) {
    case PE_IndicatorDockWidgetResizeHandle:
        painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
        break;
    case PE_FrameDockWidget:
        QCommonStyle::drawPrimitive(element, option, painter, widget);
        break;
    case PE_PanelLineEdit:
        {
            painter->save();

            // Fill the line edit background
            QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
            painter->setBrushOrigin(filledRect.topLeft());
            painter->fillRect(filledRect, option->palette.base());

            if (option->state & State_Enabled)
                Utils::StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5);
            else
                Utils::StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5);

            if (option->state & State_HasFocus || option->state & State_MouseOver) {
                QColor hover = Utils::StyleHelper::baseColor();
                if (state & State_HasFocus)
                    hover.setAlpha(100);
                else
                    hover.setAlpha(50);

                painter->setPen(QPen(hover, 1));
                painter->drawRect(option->rect.adjusted(1, 1, -2 ,-2));
            }
            painter->restore();
        }
        break;

    case PE_FrameStatusBarItem:
        break;

    case PE_PanelButtonTool: {
            Animation *anim = d->animator.widgetAnimation(widget);
            if (!animating && anim) {
                anim->paint(painter, option);
            } else {
                bool pressed = option->state & State_Sunken || option->state & State_On;
                QColor shadow(0, 0, 0, 30);
                painter->setPen(shadow);
                if (pressed) {
                    QColor shade(0, 0, 0, 40);
                    painter->fillRect(rect, shade);
                    painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
                    painter->drawLine(rect.topLeft(), rect.bottomLeft());
                    painter->drawLine(rect.topRight(), rect.bottomRight());
                   // painter->drawLine(rect.bottomLeft()  + QPoint(1, 0), rect.bottomRight()  - QPoint(1, 0));
                    QColor highlight(255, 255, 255, 30);
                    painter->setPen(highlight);
                }
                else if (option->state & State_Enabled &&
                         option->state & State_MouseOver) {
                    QColor lighter(255, 255, 255, 37);
                    painter->fillRect(rect, lighter);
                }
                if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
                    QColor highlight = option->palette.highlight().color();
                    highlight.setAlphaF(0.4);
                    painter->setPen(QPen(highlight.lighter(), 1));
                    highlight.setAlphaF(0.3);
                    painter->setBrush(highlight);
                    painter->setRenderHint(QPainter::Antialiasing);
                    QRectF rect = option->rect;
                    rect.translate(0.5, 0.5);
                    painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2);
                }
           }
        }
        break;

    case PE_PanelStatusBar:
        {
            painter->save();
            QLinearGradient grad = Utils::StyleHelper::statusBarGradient(rect);
            painter->fillRect(rect, grad);
            painter->setPen(QColor(255, 255, 255, 60));
            painter->drawLine(rect.topLeft() + QPoint(0,1),
                              rect.topRight()+ QPoint(0,1));
            painter->setPen(Utils::StyleHelper::borderColor().darker(110));
            painter->drawLine(rect.topLeft(), rect.topRight());
            painter->restore();
        }
        break;

    case PE_IndicatorToolBarSeparator:
        {
            QColor separatorColor = Utils::StyleHelper::borderColor();
            separatorColor.setAlpha(100);
            painter->setPen(separatorColor);
            const int margin = 6;
            if (option->state & State_Horizontal) {
                const int offset = rect.width()/2;
                painter->drawLine(rect.bottomLeft().x() + offset,
                            rect.bottomLeft().y() - margin,
                            rect.topLeft().x() + offset,
                            rect.topLeft().y() + margin);
            } else { //Draw vertical separator
                const int offset = rect.height()/2;
                painter->setPen(QPen(option->palette.background().color().darker(110)));
                painter->drawLine(rect.topLeft().x() + margin ,
                            rect.topLeft().y() + offset,
                            rect.topRight().x() - margin,
                            rect.topRight().y() + offset);
            }
        }
        break;

    case PE_IndicatorToolBarHandle:
        {
            bool horizontal = option->state & State_Horizontal;
            painter->save();
            QPainterPath path;
            int x = option->rect.x() + (horizontal ? 2 : 6);
            int y = option->rect.y() + (horizontal ? 6 : 2);
            static const int RectHeight = 2;
            if (horizontal) {
                while (y < option->rect.height() - RectHeight - 6) {
                    path.moveTo(x, y);
                    path.addRect(x, y, RectHeight, RectHeight);
                    y += 6;
                }
            } else {
                while (x < option->rect.width() - RectHeight - 6) {
                    path.moveTo(x, y);
                    path.addRect(x, y, RectHeight, RectHeight);
                    x += 6;
                }
            }

            painter->setPen(Qt::NoPen);
            QColor dark = Utils::StyleHelper::borderColor();
            dark.setAlphaF(0.4);

            QColor light = Utils::StyleHelper::baseColor();
            light.setAlphaF(0.4);

            painter->fillPath(path, light);
            painter->save();
            painter->translate(1, 1);
            painter->fillPath(path, dark);
            painter->restore();
            painter->translate(3, 3);
            painter->fillPath(path, light);
            painter->translate(1, 1);
            painter->fillPath(path, dark);
            painter->restore();
        }
        break;
    case PE_IndicatorArrowUp:
    case PE_IndicatorArrowDown:
    case PE_IndicatorArrowRight:
    case PE_IndicatorArrowLeft:
        {
            Utils::StyleHelper::drawArrow(element, painter, option);
        }
        break;

    default:
        QProxyStyle::drawPrimitive(element, option, painter, widget);
        break;
    }
}
/*!
    \reimp
*/
void QTransformedScreen::blit(const QImage &image, const QPoint &topLeft,
                              const QRegion &region)
{
    const Transformation trans = d_ptr->transformation;
    if (trans == None) {
        QProxyScreen::blit(image, topLeft, region);
        return;
    }

    const QVector<QRect> rects = region.rects();
    const QRect bound = QRect(0, 0, QScreen::w, QScreen::h)
                        & QRect(topLeft, image.size());

    BlitFunc func = 0;
#ifdef QT_QWS_DEPTH_GENERIC
    if (d_ptr->doGenericColors && depth() == 16) {
        if (image.depth() == 16)
            SET_BLIT_FUNC(qrgb_generic16, quint16, trans, func);
        else
            SET_BLIT_FUNC(qrgb_generic16, quint32, trans, func);
    } else
#endif
    switch (depth()) {
#ifdef QT_QWS_DEPTH_32
    case 32:
#ifdef QT_QWS_DEPTH_16
        if (image.depth() == 16)
            SET_BLIT_FUNC(quint32, quint16, trans, func);
        else
#endif
            SET_BLIT_FUNC(quint32, quint32, trans, func);
        break;
#endif
#if defined(QT_QWS_DEPTH_24) || defined(QT_QWS_DEPTH18)
    case 24:
    case 18:
        SET_BLIT_FUNC(quint24, quint24, trans, func);
        break;
#endif
#if defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15) || defined(QT_QWS_DEPTH_12)
    case 16:
#if defined QT_QWS_ROTATE_BGR
        if (pixelType() == BGRPixel && image.depth() == 16) {
            SET_BLIT_FUNC(qbgr565, quint16, trans, func);
            break;
        } //fall-through here!!!
#endif
    case 15:
#if defined QT_QWS_ROTATE_BGR
        if (pixelType() == BGRPixel && image.format() == QImage::Format_RGB555) {
            SET_BLIT_FUNC(qbgr555, qrgb555, trans, func);
            break;
        } //fall-through here!!!
#endif
    case 12:
        if (image.depth() == 16)
            SET_BLIT_FUNC(quint16, quint16, trans, func);
        else
            SET_BLIT_FUNC(quint16, quint32, trans, func);
        break;
#endif
#ifdef QT_QWS_DEPTH_8
    case 8:
        if (image.format() == QImage::Format_RGB444)
            SET_BLIT_FUNC(quint8, qrgb444, trans, func);
        else if (image.depth() == 16)
            SET_BLIT_FUNC(quint8, quint16, trans, func);
        else
            SET_BLIT_FUNC(quint8, quint32, trans, func);
        break;
#endif
    default:
        return;
    }
    if (!func)
        return;

    QWSDisplay::grab();
    for (int i = 0; i < rects.size(); ++i) {
        const QRect r = rects.at(i) & bound;

        QPoint dst;
        switch (trans) {
        case Rot90:
            dst = mapToDevice(r.topRight(), QSize(w, h));
            break;
        case Rot180:
            dst = mapToDevice(r.bottomRight(), QSize(w, h));
            break;
        case Rot270:
            dst = mapToDevice(r.bottomLeft(), QSize(w, h));
            break;
        default:
            break;
        }
        func(this, image, r.translated(-topLeft), dst);
    }
    QWSDisplay::ungrab();

}
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
    if (!validIndex(tabIndex)) {
        qWarning("invalid index");
        return;
    }
    painter->save();

    QRect rect = tabRect(tabIndex);
    bool selected = (tabIndex == m_currentIndex);
    bool enabled = isTabEnabled(tabIndex);

    if (selected) {
        //background
        painter->save();
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, QColor(255, 255, 255, 140));
        grad.setColorAt(1, QColor(255, 255, 255, 210));
//        grad.setColorAt(0, QColor(0, 0, 255, 140));
//        grad.setColorAt(1, QColor(255, 255, 255, 210));
        painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
        painter->restore();

        //shadows
        painter->setPen(QColor(0, 0, 0, 110));
        painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1));
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->setPen(QColor(0, 0, 0, 40));
        painter->drawLine(rect.topLeft(), rect.bottomLeft());

        //highlights
        painter->setPen(QColor(255, 255, 255, 50));
        painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
        painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
        painter->setPen(QColor(255, 255, 255, 40));
        painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
        painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
        painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
    }

    QString tabText(this->tabText(tabIndex));
    QRect tabTextRect(tabRect(tabIndex));
    QRect tabIconRect(tabTextRect);
    tabTextRect.translate(0, -2);
    QFont boldFont(painter->font());
    boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    painter->setFont(boldFont);
    painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
    int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap;
    if (enabled) {
        painter->drawText(tabTextRect, textFlags, tabText);
        painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
    } else {
        painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
    }
#ifndef Q_WS_MAC
    if (!selected && enabled) {
        painter->save();
        int fader = int(m_tabs[tabIndex]->fader());
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, Qt::transparent);
        grad.setColorAt(0.5, QColor(255, 255, 255, fader));
        grad.setColorAt(1, Qt::transparent);
        painter->fillRect(rect, grad);
        painter->setPen(QPen(grad, 1.0));
        painter->drawLine(rect.topLeft(), rect.topRight());
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->restore();
    }
#endif

    if (!enabled)
        painter->setOpacity(0.7);

    int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
    tabIconRect.adjust(0, 4, 0, -textHeight);
    Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);

    painter->translate(0, -1);
    painter->drawText(tabTextRect, textFlags, tabText);
    painter->restore();
}
Example #4
0
QList<int> SM::findHighlight( QRect rect )
{
	QList<int> frameIndex;
	_INIT = false;
	highLightedList.clear();
	int selected = -1;
	int begin = TDHelper::Min( rect.topLeft().x(), rect.topRight().x() );
	int end = begin + abs( rect.width() );
	for(int i = 0; i < 3; i++)
	{
		int currentX = i*SPACE + OFFSET;
		if( currentX >= begin && currentX <= end )
		{
			selected = i;
		}
	}
	if( selected == -1 )
	{
		return frameIndex;
	}
	//			begin find
	if( this->_data[selected]->getType() == 2 )
	{
		int endFrame = this->mapFrame( rect.y() );
		int beginFrame = this->mapFrame( rect.y() + rect.height() );
		for( int i = beginFrame; i <= endFrame; i++ )
		{
			highLightedList.append( i );
			frameIndex.append( i );
		}
	}
	else
	if( this->_data[selected]->getType() == 1 || this->_data[selected]->getType() == 3 )
	{
		//		find max
		int maxHeight, minHeight;
		maxHeight = TDHelper::Max( rect.y(), rect.y() + rect.height() );
		minHeight = TDHelper::Min( rect.y(), rect.y() + rect.height() );
		//************************************************
		float curDataMAM = this->_data[selected]->getMIN() - (( this->HEIGHT/2.0f - minHeight ) * ( this->_data[selected]->getMIN() - this->_data[selected]->getMAX() ) / this->HEIGHT );
		float curDataMIN = this->_data[selected]->getMIN() - (( this->HEIGHT/2.0f - maxHeight ) * ( this->_data[selected]->getMIN() - this->_data[selected]->getMAX() ) / this->HEIGHT );
		//************************************************
		//maxHeight = 
		//max = this->HEIGHT/2 - rect.y();
		//max = _data[1]->getMAX() * max / this->HEIGHT;
		//min = this->HEIGHT/2 - rect.y() - rect.height();
		//min = _data[selected]->getMIN * min / this->HEIGHT; 
		//
		for( int i = 0; i < 50; i++)
		{
			float percent = _data[selected]->percentage_At(i);
			float currentValue = percent * ( _data[selected]->getMAX() - _data[selected]->getMIN() ) + _data[selected]->getMIN() ;
			if( currentValue >= curDataMIN && currentValue <= curDataMAM )
			{
				highLightedList.append( i );
				frameIndex.append( int( _data[1]->percentage_At(i) * ( _data[1]->getMAX() - _data[1]->getMIN() ) + _data[1]->getMIN() ));
			}
		}
	}
	return frameIndex;
}
Example #5
0
void QToolButtonPrivate::popupTimerDone()
{
    Q_Q(QToolButton);
    popupTimer.stop();
    if (!menuButtonDown && !down)
        return;

    menuButtonDown = true;
    QPointer<QMenu> actualMenu;
    bool mustDeleteActualMenu = false;
    if(menuAction) {
        actualMenu = menuAction->menu();
    } else if (defaultAction && defaultAction->menu()) {
        actualMenu = defaultAction->menu();
    } else {
        actualMenu = new QMenu(q);
        mustDeleteActualMenu = true;
        for(int i = 0; i < actions.size(); i++)
            actualMenu->addAction(actions.at(i));
    }
    repeat = q->autoRepeat();
    q->setAutoRepeat(false);
    bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
    QToolBar *tb = qobject_cast<QToolBar*>(parent);
    if (tb && tb->orientation() == Qt::Vertical)
        horizontal = false;
#endif
    QPoint p;
    QRect screen = QApplication::desktop()->availableGeometry(q);
    QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
    QRect rect = q->rect();
    if (horizontal) {
        if (q->isRightToLeft()) {
            if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
                p = q->mapToGlobal(rect.bottomRight());
            } else {
                p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
            }
            p.rx() -= sh.width();
        } else {
            if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
                p = q->mapToGlobal(rect.bottomLeft());
            } else {
                p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
            }
        }
    } else {
        if (q->isRightToLeft()) {
            if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) {
                p = q->mapToGlobal(rect.topRight());
            } else {
                p = q->mapToGlobal(rect.topLeft());
                p.rx() -= sh.width();
            }
        } else {
            if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) {
                p = q->mapToGlobal(rect.topRight());
            } else {
                p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0));
            }
        }
    }
    p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
    p.ry() += 1;
    QPointer<QToolButton> that = q;
    actualMenu->setNoReplayFor(q);
    if (!mustDeleteActualMenu) //only if action are not in this widget
        QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
    QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
    actualMenu->d_func()->causedPopup.widget = q;
    actualMenu->d_func()->causedPopup.action = defaultAction;
    actionsCopy = q->actions(); //(the list of action may be modified in slots)
    actualMenu->exec(p);
    QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
    if (mustDeleteActualMenu)
        delete actualMenu;
    else
        QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));

    if (!that)
        return;

    actionsCopy.clear();

    if (repeat)
        q->setAutoRepeat(true);
}
Example #6
0
void WindowsModernStyle::drawControl( ControlElement element, const QStyleOption* option,
                                      QPainter* painter, const QWidget* widget ) const
{
    switch ( element ) {
    case CE_MenuBarEmptyArea:
        return;

    case CE_MenuBarItem:
        if ( option->state & QStyle::State_Sunken && option->state & QStyle::State_Enabled ) {
            painter->setPen( m_colorMenuBorder );
            QLinearGradient gradient( option->rect.topLeft(), option->rect.bottomLeft() );
            gradient.setColorAt( 0.0, m_colorMenuTitleBegin );
            gradient.setColorAt( 1.0, m_colorMenuTitleEnd );
            painter->setBrush( gradient );
            painter->drawRect( option->rect.adjusted( 0, 0, -1, 0 ) );
        } else if ( option->state & QStyle::State_Selected && option->state & QStyle::State_Enabled ) {
            painter->setPen( m_colorItemBorder );
            QLinearGradient gradient( option->rect.topLeft(), option->rect.bottomLeft() );
            gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
            gradient.setColorAt( 1.0, m_colorItemBackgroundEnd );
            painter->setBrush( gradient );
            painter->drawRect( option->rect.adjusted( 0, 0, -1, -1 ) );
        }
        if ( const QStyleOptionMenuItem* optionItem = qstyleoption_cast<const QStyleOptionMenuItem*>( option ) ) {
            int flags = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
            if ( !styleHint( SH_UnderlineShortcut, option, widget ) )
                flags |= Qt::TextHideMnemonic;
            if ( !optionItem->icon.isNull() ) {
                QPixmap pixmap = optionItem->icon.pixmap( pixelMetric( PM_SmallIconSize, option, widget ), QIcon::Normal );
                drawItemPixmap( painter, option->rect, flags, pixmap );
            } else {
                drawItemText( painter, option->rect, flags, option->palette, true, optionItem->text, QPalette::Text );
            }
        }
        return;

    case CE_MenuEmptyArea:
        painter->fillRect( option->rect, m_colorMenuBackground );
        return;

    case CE_MenuItem: {
        if ( option->state & QStyle::State_Selected && option->state & QStyle::State_Enabled ) {
            painter->setPen( m_colorItemBorder );
            painter->setBrush( m_colorItemBackgroundBegin );
            painter->drawRect( option->rect.adjusted( 1, 0, -3, -1 ) );
        } else {
            QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 25, 0 ) );
            gradient.setColorAt( 0.0, m_colorBarBegin );
            gradient.setColorAt( 1.0, m_colorBarEnd );
            QRect margin = option->rect;
            margin.setWidth( 25 );
            painter->fillRect( margin, gradient );
            QRect background = option->rect;
            background.setLeft( margin.right() + 1 );
            painter->fillRect( background, m_colorMenuBackground );
        }
        if ( const QStyleOptionMenuItem* optionItem = qstyleoption_cast<const QStyleOptionMenuItem*>( option ) ) {
            if ( optionItem->menuItemType == QStyleOptionMenuItem::Separator ) {
                painter->setPen( m_colorSeparator );
                painter->drawLine( option->rect.left() + 32, ( option->rect.top() + option->rect.bottom() ) / 2,
                                   option->rect.right(), ( option->rect.top() + option->rect.bottom() ) / 2 );
                return;
            }
            QRect checkRect = option->rect.adjusted( 2, 1, -2, -2 );
            checkRect.setWidth( 20 );
            if ( optionItem->checked && option->state & QStyle::State_Enabled ) {
                painter->setPen( m_colorItemBorder );
                if ( option->state & QStyle::State_Selected && option->state & QStyle::State_Enabled )
                    painter->setBrush( m_colorItemSunkenBegin );
                else
                    painter->setBrush( m_colorItemCheckedBegin );
                painter->drawRect( checkRect );
            }
            if ( !optionItem->icon.isNull() ) {
                QIcon::Mode mode;
                if ( optionItem->state & State_Enabled )
                    mode = ( optionItem->state & State_Selected ) ? QIcon::Active : QIcon::Normal;
                else
                    mode = QIcon::Disabled;
                QIcon::State state = optionItem->checked ? QIcon::On : QIcon::Off;
                QPixmap pixmap = optionItem->icon.pixmap( pixelMetric( PM_SmallIconSize, option, widget ), mode, state );
                QRect rect = pixmap.rect();
                rect.moveCenter( checkRect.center() );
                painter->drawPixmap( rect.topLeft(), pixmap );
            } else if ( optionItem->checked ) {
                QStyleOption optionCheckMark;
                optionCheckMark.initFrom( widget );
                optionCheckMark.rect = checkRect;
                if ( !( option->state & State_Enabled ) )
                    optionCheckMark.palette.setBrush( QPalette::Text, optionCheckMark.palette.brush( QPalette::Disabled, QPalette::Text ) );
                drawPrimitive( PE_IndicatorMenuCheckMark, &optionCheckMark, painter, widget );
            }
            QRect textRect = option->rect.adjusted( 32, 1, -16, -1 );
            int flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
            if ( !styleHint( SH_UnderlineShortcut, option, widget ) )
                flags |= Qt::TextHideMnemonic;
            QString text = optionItem->text;
            int pos = text.indexOf( '\t' );
            if ( pos >= 0 ) {
                drawItemText( painter, textRect, flags | Qt::AlignRight, option->palette, option->state & State_Enabled,
                              text.mid( pos + 1 ), QPalette::Text );
                text = text.left( pos );
            }
            drawItemText( painter, textRect, flags, option->palette, option->state & State_Enabled, text, QPalette::Text );
            if ( optionItem->menuItemType == QStyleOptionMenuItem::SubMenu ) {
                QStyleOption optionArrow;
                optionArrow.initFrom( widget );
                optionArrow.rect = option->rect.adjusted( 0, 4, -4, -4 );
                optionArrow.rect.setLeft( option->rect.right() - 12 );
                optionArrow.state = option->state & State_Enabled;
                drawPrimitive( PE_IndicatorArrowRight, &optionArrow, painter, widget );
            }
        }
        return;
    }

    case CE_ToolBar: {
        QRect rect = option->rect;
        bool vertical = false;
        if ( const QToolBar* toolBar = qobject_cast<const QToolBar*>( widget ) ) {
            vertical = ( toolBar->orientation() == Qt::Vertical );
            if ( vertical )
                rect.setBottom( toolBar->childrenRect().bottom() + 2 );
            else
                rect.setRight( toolBar->childrenRect().right() + 2 );
        }
        painter->save();
        QRegion region = rect.adjusted( 2, 0, -2, 0 );
        region += rect.adjusted( 0, 2, 0, -2 );
        region += rect.adjusted( 1, 1, -1, -1 );
        painter->setClipRegion( region );
        QLinearGradient gradient;
        if ( vertical )
            gradient = QLinearGradient( rect.topLeft(), rect.topRight() );
        else
            gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() );
        gradient.setColorAt( 0.0, m_colorBarBegin );
        gradient.setColorAt( 0.4, m_colorBarMiddle );
        gradient.setColorAt( 0.6, m_colorBarMiddle );
        gradient.setColorAt( 1.0, m_colorBarEnd );
        painter->fillRect( rect, gradient );

        painter->setPen( vertical ? m_colorBorderLight : m_colorBorder );
        painter->drawLine( rect.bottomLeft() + QPoint( 2, 0 ), rect.bottomRight() - QPoint( 2, 0 ) );
        painter->setPen( vertical ? m_colorBorder : m_colorBorderLight );
        painter->drawLine( rect.topRight() + QPoint( 0, 2 ), rect.bottomRight() - QPoint( 0, 2 ) );
        painter->setPen( m_colorBorderLight );
        painter->drawPoint( rect.bottomRight() - QPoint( 1, 1 ) );
        painter->restore();
        return;
    }

    case CE_DockWidgetTitle: {
        QLinearGradient gradient( option->rect.topLeft(), option->rect.bottomLeft() );
        gradient.setColorAt( 0.0, m_colorBarBegin );
        gradient.setColorAt( 1.0, m_colorBarEnd );
        painter->fillRect( option->rect, gradient );
        if ( const QStyleOptionDockWidget* optionDockWidget = qstyleoption_cast<const QStyleOptionDockWidget*>( option ) ) {
            QRect rect = option->rect.adjusted( 6, 0, -4, 0 );
            if ( optionDockWidget->closable )
                rect.adjust( 0, 0, -16, 0 );
            if ( optionDockWidget->floatable )
                rect.adjust( 0, 0, -16, 0 );
            QString text = painter->fontMetrics().elidedText( optionDockWidget->title, Qt::ElideRight, rect.width() );
            drawItemText( painter, rect, Qt::AlignLeft | Qt::AlignVCenter, option->palette,
                          option->state & State_Enabled, text, QPalette::WindowText );
        }
        return;
    }

    case CE_TabBarTabShape:
        if ( isStyledTabBar( widget ) ) {
            bool firstTab = false;
            bool lastTab = false;
            bool bottom = false;
            if ( const QStyleOptionTab* optionTab = qstyleoption_cast<const QStyleOptionTab*>( option ) ) {
                if ( optionTab->position == QStyleOptionTab::Beginning )
                    firstTab = true;
                else if ( optionTab->position == QStyleOptionTab::End )
                    lastTab = true;
                else if ( optionTab->position == QStyleOptionTab::OnlyOneTab )
                    firstTab = lastTab = true;
                if ( optionTab->shape == QTabBar::RoundedSouth )
                    bottom = true;
            }
            QRect rect = option->rect;
            painter->save();
            if ( option->state & State_Selected ) {
                if ( bottom )
                    rect.adjust( firstTab ? 0 : -2, -1, lastTab ? -1 : 1, -1 );
                else
                    rect.adjust( firstTab ? 0 : -2, 0, lastTab ? -1 : 1, 1 );
            } else {
                if ( bottom ) {
                    rect.adjust( 0, -1, lastTab ? -1 : 0, -2 );
                    painter->setClipRect( rect.adjusted( 0, 1, 1, 1 ) );
                } else {
                    rect.adjust( 0, 1, lastTab ? -1 : 0, 0 );
                    painter->setClipRect( rect.adjusted( 0, 0, 1, 0 ) );
                }
            }
            QLinearGradient gradient;
            if ( bottom )
                gradient = QLinearGradient( rect.bottomLeft(), rect.topLeft() );
            else
                gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() );
            if ( option->state & State_Selected ) {
                gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
                gradient.setColorAt( 1.0, option->palette.window().color() );
                painter->setPen( m_colorBorder );
            } else if ( option->state & State_MouseOver && option->state & State_Enabled ) {
                gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
                gradient.setColorAt( 1.0, m_colorItemBackgroundEnd );
                painter->setPen( m_colorBorderLight );
            } else {
                gradient.setColorAt( 0.0, m_colorBarMiddle );
                gradient.setColorAt( 1.0, m_colorBarEnd );
                painter->setPen( m_colorBorderLight );
            }
            painter->setBrush( gradient );
            painter->drawRect( rect );
            painter->restore();
            return;
        }
        break;

    case CE_ToolBoxTabShape: {
        QRect rect = option->rect.adjusted( 0, 0, -1, -1 );
        QLinearGradient gradient( rect.topLeft(), rect.bottomLeft() );
        if ( option->state & QStyle::State_Sunken ) {
            gradient.setColorAt( 0.0, m_colorItemSunkenBegin );
            gradient.setColorAt( 1.0, m_colorItemSunkenEnd );
            painter->setPen( m_colorBorder );
        } else if ( option->state & State_MouseOver && option->state & State_Enabled ) {
            gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
            gradient.setColorAt( 1.0, m_colorItemBackgroundEnd );
            painter->setPen( m_colorBorder );
        } else {
            gradient.setColorAt( 0.0, m_colorBarMiddle );
            gradient.setColorAt( 1.0, m_colorBarEnd );
            painter->setPen( m_colorBorderLight );
        }
        painter->setBrush( gradient );
        painter->drawRect( rect );
        return;
    }

    case CE_Splitter:
        if ( qobject_cast<const QMainWindow*>( widget->window() ) )
            return;
        break;

    default:
        break;
    }

    if ( useVista() )
        QWindowsVistaStyle::drawControl( element, option, painter, widget );
    else
        QWindowsXPStyle::drawControl( element, option, painter, widget );
}
Example #7
0
void OdClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
    QRect r = rect();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    QColor bckgrnd = p.backgroundColor();
    double zoom = the_canvas()->zoom();

    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    FILE * fp = svg();

    if (fp != 0)
      fputs("<g>\n", fp);
    
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
    
    if (used_color != UmlTransparent)
      p.fillRect(r, co);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
    
    BrowserClass * cl = 
      ((ClassInstanceData *) browser_node->get_data())->get_class();
	  
    if (((ClassData *) cl->get_data())->get_is_active()) {
      const int eight = (int) (8 * zoom);
      
      r.setLeft(r.left() + eight);
      r.setRight(r.right() - eight);
      
      p.drawLine(r.topLeft(), r.bottomLeft());
      p.drawLine(r.topRight(), r.bottomRight());

      if (fp != 0)
	fprintf(fp,
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.left(), r.bottom(),
		r.right(), r.top(), r.right(), r.bottom());
    }
    
    const int two = (int) (2 * zoom);
    int he = fm.height() + two;
    
    p.setFont(the_canvas()->get_font(UmlNormalUnderlinedFont));

    r.setTop(r.top() + two);
    if (horiz) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 full_name());
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  full_name(),
		  p.font(), fp);
    }
    else {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 get_name() + ":");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  get_name() + ":",
		  p.font(), fp);
      r.setTop(r.top() + fm.height());
      
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 cl->contextual_name(used_show_context_mode));
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  cl->contextual_name(used_show_context_mode),
		  p.font(), fp);
    }
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));

    const QValueList<SlotAttr> & attributes = 
      ((ClassInstanceData *) browser_node->get_data())->get_attributes();

    if (!attributes.isEmpty()) {
      r.setTop(r.top() + he + two);
      p.drawLine(r.topLeft(), r.topRight());
      if (fp != 0)
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.right(), r.top());

      r.setTop(r.top() + two);
      r.setLeft(r.left() + (int) (4 * zoom));
      
      QValueList<SlotAttr>::ConstIterator it = attributes.begin();
      QString egal = " = ";

      do {
	QString s = (*it).att->get_name() + egal + (*it).value;

	p.drawText(r, ::Qt::AlignTop, s);
	if (fp != 0)
	  draw_text(r, ::Qt::AlignTop, s,
		    p.font(), fp);
	r.setTop(r.top() + he);
	++it;
      } while (it != attributes.end());
    }

    if (fp != 0)
      fputs("</g>\n", fp);
        
    if (selected())
      show_mark(p, rect());
  }
}
Example #8
0
    QPalette pal = m_tabBar->palette();
    pal.setBrush(QPalette::Mid, brush);
    m_tabBar->setPalette(pal);
}

void FancyTabWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)
    if (m_selectionWidget->isVisible()) {
        QPainter painter(this);

        QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
        rect = style()->visualRect(layoutDirection(), geometry(), rect);
        StyleHelper::verticalGradient(&painter, rect, rect);
        painter.setPen(StyleHelper::borderColor());
        painter.drawLine(rect.topRight(), rect.bottomRight());

        QColor light = StyleHelper::sidebarHighlight();
        painter.setPen(light);
        painter.drawLine(rect.bottomLeft(), rect.bottomRight());
    }
}


int FancyTabWidget::currentIndex() const
{
    return m_tabBar->currentIndex();
}

void FancyTabWidget::setCurrentIndex(int index)
{
void PluginItemDelegate::paint( QPainter *painter,
                                const QStyleOptionViewItem& option,
                                const QModelIndex& index ) const
{
    Q_ASSERT( index.isValid() );
    QRect rect = option.rect;
    QStyle *style = QApplication::style();

    painter->save();

    // Drawing the background
    QStyleOption background = option;
    style->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter );

    painter->translate( rect.topLeft() );

    // rect is now represented in item coordinates
    rect.moveTopLeft( QPoint( 0, 0 ) );
    // The point at the top left of the available drawing area.
    QPoint topLeft( 0, 0 );
    // The point at the top right of the available drawing area.
    QPoint topRight( rect.topRight() );

    QRect nameRect = rect;
    
    // Painting the checkbox
    QStyleOptionButton checkBox = checkboxOption( option, index, topLeft.x(), Qt::AlignLeft );
    painter->save();
    style->drawControl( QStyle::CE_CheckBox, &checkBox, painter );
    painter->restore();

    nameRect.setLeft( checkBox.rect.right() + 1 );
    
    // Painting the About Button
    QStyleOptionButton button = buttonOption( option, index, PluginItemDelegate::About,
                                              topRight.x(), Qt::AlignRight );
    style->drawControl( QStyle::CE_PushButton, &button, painter );
    topRight -= QPoint( button.rect.width(), 0 );

    // Painting the Configure Button
    if ( index.data( RenderPluginModel::ConfigurationDialogAvailable ).toBool() ) {
        QStyleOptionButton button = buttonOption( option, index, PluginItemDelegate::Configure,
                                                  topRight.x(), Qt::AlignRight );
        style->drawControl( QStyle::CE_PushButton, &button, painter );
        topRight -= QPoint( button.rect.width(), 0 );
        
        nameRect.setRight( button.rect.left() -1 );
    }

    // Painting the Icon
    const QIcon icon = index.data( Qt::DecorationRole ).value<QIcon>();
    const QPixmap iconPixmap = icon.pixmap(16, 16);

    nameRect.moveBottom( nameRect.bottom()+5 );
    style->drawItemPixmap( painter,
                           nameRect,
                           Qt::AlignLeft,
                           iconPixmap );

    nameRect.setLeft( nameRect.left() + 16 + 5 );
    nameRect.moveBottom( nameRect.bottom()-5 );

    // Painting the Name string
    QString name = index.data( Qt::DisplayRole ).toString();
    
    style->drawItemText( painter,
                         nameRect,
                         Qt::AlignLeft | Qt::AlignVCenter,
                         option.palette,
                         true,
                         name );

    painter->restore();
}
	void paintContact(QPainter* mp, const QStyleOptionViewItem& option, const QModelIndex& index, GCUserViewItem* item) const
	{
		mp->save();
		QStyleOptionViewItem o = option;
		QPalette palette = o.palette;
		MUCItem::Role r = item->s.mucItem().role();
		QRect rect = o.rect;

		if(nickColoring_) {
			if(r == MUCItem::Moderator)
				palette.setColor(QPalette::Text, colorModerator_);
			else if(r == MUCItem::Participant)
				palette.setColor(QPalette::Text, colorParticipant_);
			else if(r == MUCItem::Visitor)
				palette.setColor(QPalette::Text, colorVisitor_);
			else
				palette.setColor(QPalette::Text, colorNoRole_);
		}

		mp->fillRect(rect, (o.state & QStyle::State_Selected) ? palette.color(QPalette::Highlight) : palette.color(QPalette::Base));

		if(showAvatar_) {
			QPixmap ava = item->avatar();
			if(ava.isNull()) {
				ava = IconsetFactory::iconPixmap("psi/default_avatar");
			}
			ava = AvatarFactory::roundedAvatar(ava, avatarRadius_, avatarSize_);
			QRect avaRect(rect);
			avaRect.setWidth(ava.width());
			avaRect.setHeight(ava.height());
			if(!avatarAtLeft_) {
				avaRect.moveTopRight(rect.topRight());
				avaRect.translate(-1, 1);
				rect.setRight(avaRect.left() - 1);
			}
			else {
				avaRect.translate(1, 1);
				rect.setLeft(avaRect.right() + 1);
			}
			mp->drawPixmap(avaRect, ava);
		}

		QPixmap status = showStatusIcons_ ? item->icon() : QPixmap();
		int h = rect.height();
		int sh = status.isNull() ? 0 : status.height();
		rect.setHeight(qMax(sh, fontHeight_));
		rect.moveTop(rect.top() + (h - rect.height())/2);
		if(!status.isNull()) {
			QRect statusRect(rect);
			statusRect.setWidth(status.width());
			statusRect.setHeight(status.height());
			statusRect.translate(1, 1);
			mp->drawPixmap(statusRect, status);
			rect.setLeft(statusRect.right() + 2);
		}
		else
			rect.setLeft(rect.left() + 2);

		mp->setPen(QPen((o.state & QStyle::State_Selected) ? palette.color(QPalette::HighlightedText) : palette.color(QPalette::Text)));
		mp->setFont(o.font);
		mp->setClipRect(rect);
		QTextOption to;
		to.setWrapMode(QTextOption::NoWrap);
		mp->drawText(rect, index.data(Qt::DisplayRole).toString(), to);

		QList<QPixmap> rightPixs;
		if(showClients_) {
			GCUserView *gcuv = (GCUserView*)item->treeWidget();
			GCMainDlg* dlg = gcuv->mainDlg();
			QPixmap clientPix;
			if(dlg) {
				UserListItem u;
				const QString &nick = item->text(0);
				Jid caps_jid(/*s.mucItem().jid().isEmpty() ? */ dlg->jid().withResource(nick) /* : s.mucItem().jid()*/);
				CapsManager *cm = dlg->account()->client()->capsManager();
				QString client_name = cm->clientName(caps_jid);
				QString client_version = (client_name.isEmpty() ? QString() : cm->clientVersion(caps_jid));
				UserResource ur;
				ur.setStatus(item->s);
				ur.setClient(client_name,client_version,"");
				u.userResourceList().append(ur);
				QStringList clients = u.clients();
				if(!clients.isEmpty())
					clientPix = IconsetFactory::iconPixmap("clients/" + clients.takeFirst());
			}
			if(!clientPix.isNull())
				rightPixs.push_back(clientPix);
		}

		if(showAffiliations_) {
			MUCItem::Affiliation a = item->s.mucItem().affiliation();
			QPixmap pix;
			if(a == MUCItem::Owner)
				pix = IconsetFactory::iconPixmap("affiliation/owner");
			else if(a == MUCItem::Admin)
				pix = IconsetFactory::iconPixmap("affiliation/admin");
			else if(a == MUCItem::Member)
				pix = IconsetFactory::iconPixmap("affiliation/member");
			else if(a == MUCItem::Outcast)
				pix = IconsetFactory::iconPixmap("affiliation/outcast");
			else
				pix = IconsetFactory::iconPixmap("affiliation/noaffiliation");
			if(!pix.isNull())
				rightPixs.push_back(pix);
		}

		mp->restore();

		if(rightPixs.isEmpty())
			return;

		int sumWidth = 0;
		foreach (const QPixmap& pix, rightPixs) {
				sumWidth += pix.width();
		}
		sumWidth += rightPixs.count();

		QColor bgc = (option.state & QStyle::State_Selected) ? palette.color(QPalette::Highlight) : palette.color(QPalette::Base);
		QColor tbgc = bgc;
		tbgc.setAlpha(0);
		QLinearGradient grad(rect.right() - sumWidth - 20, 0, rect.right() - sumWidth, 0);
		grad.setColorAt(0, tbgc);
		grad.setColorAt(1, bgc);
		QBrush tbakBr(grad);
		QRect gradRect(rect);
		gradRect.setLeft(gradRect.right() - sumWidth - 20);
		mp->fillRect(gradRect, tbakBr);

		QRect iconRect(rect);
		for (int i=0; i<rightPixs.size(); i++) {
			const QPixmap pix = rightPixs[i];
			iconRect.setRight(iconRect.right() - pix.width() -1);
			mp->drawPixmap(iconRect.topRight(), pix);
		}

	}
Example #11
0
// Experimental, using a mockup from Nuno Pinheiro (new_slider_nuno)
void SvgHandler::paintCustomSlider( QPainter *p, QStyleOptionSlider *slider, qreal percentage, bool paintMoodbar )
{
    int sliderHeight = slider->rect.height() - 6;
    const bool inverse = ( slider->orientation == Qt::Vertical ) ? slider->upsideDown :
                         ( (slider->direction == Qt::RightToLeft) != slider->upsideDown );
    QRect knob = sliderKnobRect( slider->rect, percentage, inverse );
    QPoint pt = slider->rect.topLeft() + QPoint( 0, 2 );

    //debug() << "rel: " << knobRelPos << ", width: " << width << ", height:" << height << ", %: " << percentage;

    //if we should paint moodbar, paint this as the bottom layer
    bool moodbarPainted = false;
    if ( paintMoodbar )
    {
        Meta::TrackPtr currentTrack = The::engineController()->currentTrack();
        if ( currentTrack )
        {
            if( The::moodbarManager()->hasMoodbar( currentTrack ) )
            {
                QPixmap moodbar = The::moodbarManager()->getMoodbar( currentTrack, slider->rect.width() - sliderHeight, sliderHeight, inverse );
                p->drawPixmap( pt, renderSvg( "moodbar_end_left", sliderHeight / 2, sliderHeight, "moodbar_end_left" ) );

                pt.rx() += sliderHeight / 2;
                p->drawPixmap( pt, moodbar );

                pt.rx() += slider->rect.width() - sliderHeight;
                p->drawPixmap( pt, renderSvg( "moodbar_end_right", sliderHeight / 2, sliderHeight, "moodbar_end_right" ) );

                moodbarPainted = true;
            }
        }
    }

    if( !moodbarPainted )
    {
        // Draw the slider background in 3 parts

        p->drawPixmap( pt, renderSvg( "progress_slider_left", sliderHeight, sliderHeight, "progress_slider_left" ) );

        pt.rx() += sliderHeight;
        QRect midRect(pt, QSize(slider->rect.width() - sliderHeight * 2, sliderHeight) );
        p->drawTiledPixmap( midRect, renderSvg( "progress_slider_mid", 32, sliderHeight, "progress_slider_mid" ) );

        pt = midRect.topRight() + QPoint( 1, 0 );
        p->drawPixmap( pt, renderSvg( "progress_slider_right", sliderHeight, sliderHeight, "progress_slider_right" ) );

        //draw the played background.

        int playedBarHeight = sliderHeight - 6;

        int sizeOfLeftPlayed = qBound( 0, inverse ? slider->rect.right() - knob.right() + 2 :
                                                    knob.x() - 2, playedBarHeight );

        if( sizeOfLeftPlayed > 0 )
        {
            QPoint tl, br;
            if ( inverse )
            {
                tl = knob.topRight() + QPoint( -5, 5 ); // 5px x padding to avoid a "gap" between it and the top and bottom of the round knob.
                br = slider->rect.topRight() + QPoint( -3, 5 + playedBarHeight - 1 );
                QPixmap rightEnd = renderSvg( "progress_slider_played_right", playedBarHeight, playedBarHeight, "progress_slider_played_right" );
                p->drawPixmap( br.x() - rightEnd.width() + 1, tl.y(), rightEnd, qMax(0, rightEnd.width() - (sizeOfLeftPlayed + 3)), 0, sizeOfLeftPlayed + 3, playedBarHeight );
                br.rx() -= playedBarHeight;
            }
            else
            {
                tl = slider->rect.topLeft() + QPoint( 3, 5 );
                br = QPoint( knob.x() + 5, tl.y() + playedBarHeight - 1 );
                QPixmap leftEnd = renderSvg( "progress_slider_played_left", playedBarHeight, playedBarHeight, "progress_slider_played_left" );
                p->drawPixmap( tl.x(), tl.y(), leftEnd, 0, 0, sizeOfLeftPlayed + 3, playedBarHeight );
                tl.rx() += playedBarHeight;
            }
            if ( sizeOfLeftPlayed == playedBarHeight )
                p->drawTiledPixmap( QRect(tl, br), renderSvg( "progress_slider_played_mid", 32, playedBarHeight, "progress_slider_played_mid" ) );

        }
    }

    if ( slider->state & QStyle::State_Enabled )
    {   // Draw the knob (handle)
        const char *string = ( slider->activeSubControls & QStyle::SC_SliderHandle ) ?
                             "slider_knob_200911_active" : "slider_knob_200911";
        p->drawPixmap( knob.topLeft(), renderSvg( string, knob.width(), knob.height(), string ) );
    }
}
Example #12
0
void UserListDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const {

    // Get title, description and icon
    QIcon mediaIcon = QIcon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole)));
    QString title = index.data(Qt::DisplayRole).toString();
    QString description = index.data(Qt::UserRole + 1).toString();
    QString time = index.data(Qt::ToolTipRole).toString();

    QRect r = option.rect;
    QPen linePen(QColor::fromRgb(211,211,211), 1, Qt::SolidLine);
    QPen lineMarkedPen(QColor::fromRgb(0,90,131), 1, Qt::SolidLine);
    QPen fontPen(QColor::fromRgb(51,51,51), 1, Qt::SolidLine);
    QPen fontMarkedPen(Qt::white, 1, Qt::SolidLine);

    // If a user is selected (pressed), changing the color(background) and size of the border area
    if (option.state & QStyle::State_Selected) {

        QLinearGradient gradientSelected(r.left(),r.top(),r.left(),r.height()+r.top());
        gradientSelected.setColorAt(0.0, QColor::fromRgb(195,213,255));
        gradientSelected.setColorAt(1.0, QColor::fromRgb(177,215,246));
        painter->setBrush(gradientSelected);
        painter->drawRect(r);

        //BORDER
        painter->setPen(lineMarkedPen);
        painter->drawLine(r.topLeft(),r.topRight());
        painter->drawLine(r.topRight(),r.bottomRight());
        painter->drawLine(r.bottomLeft(),r.bottomRight());
        painter->drawLine(r.topLeft(),r.bottomLeft());

        painter->setPen(fontMarkedPen);

    } else {

        //BACKGROUND
        //ALTERNATING COLORS
        painter->setBrush( (index.row() % 2) ? Qt::white : QColor(252,252,252) );
        painter->drawRect(r);

        //BORDER
        painter->setPen(linePen);
        painter->drawLine(r.topLeft(),r.topRight());
        painter->drawLine(r.topRight(),r.bottomRight());
        painter->drawLine(r.bottomLeft(),r.bottomRight());
        painter->drawLine(r.topLeft(),r.bottomLeft());

        painter->setPen(fontPen);
    }

    //  The offset for the installation image
    int imageSpace = 10;
    if (!mediaIcon.isNull())
    {
        r = option.rect.adjusted(2, 2, -1, -1);
        mediaIcon.paint(painter, r, Qt::AlignVCenter|Qt::AlignLeft);
        imageSpace = 85;
    }

    //TITLE
    r = option.rect.adjusted(imageSpace, 10, -10, -27);
    painter->setFont( QFont( "Lucida Grande", 12, QFont::Normal ) );
    painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignTop|Qt::AlignLeft, title, &r);
    // TIME
    r = option.rect.adjusted(60, 10, -10, -27);
    painter->setFont( QFont( "Lucida Grande", 8, QFont::Normal ) );
    painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignTop|Qt::AlignRight, time , &r);
    //DESCRIPTION
    r = option.rect.adjusted(imageSpace, 35, -10, 10);
    painter->setFont( QFont( "Lucida Grande", 8, QFont::Normal ) );

    //If the last message is long, it is cut, for convenient display
    if (description.size() > 30)
    {
        description.remove(30, description.size());
        description.append("...");
    }
    painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignLeft, description, &r);

}
    /**
     *  \brief Paint sequence to screen.
     */
    void KeyComponent::paint(QPainter * painter, const QRect & rect)
    {
        // Only if parented
        if (this->alignmentView())
        {
            // Set font to be a little smaller than usual
            QFont font = painter->font();
            font.setPointSizeF(8);
            painter->setFont(font);

            QPair< int, AlignmentView::ComponentPosition > logicalKeyPosition = this->alignmentView()->componentPosition(this);
            int actualKeyPosition = this->alignmentView()->logicalToActualComponent(logicalKeyPosition.first, logicalKeyPosition.second);
            bool top = actualKeyPosition != 0;
            bool bottom = actualKeyPosition != (this->alignmentView()->componentCount() - 1);

            // Draw control
            painter->setPen(Qt::NoPen);
            painter->setBrush(QColor(245, 245, 255));
            painter->drawRect(rect);

            // Set style
            painter->setPen(this->alignmentView()->palette().color(QPalette::Dark));
            QPen pen = painter->pen();
            pen.setWidth(1);
            painter->setPen(pen);

            // Find cell sizes
            double unitSize = this->alignmentView()->unitSizeF();
            int firstUnit = this->alignmentIndexAt(rect.topLeft());
            int lastUnit = this->alignmentIndexAt(rect.topRight());
            int height = this->height();

            // Calculate legend frequency
            int interval = 1;
            if (unitSize < 100)
            {
                double unitsIn100 = 100 / unitSize;
                double log = log10(unitsIn100);
                interval = pow(10, ceil(log));
//            if (log > 1.3) { interval = 20; }
//            else if (log > 0.8) { interval = 10; }
//            else { interval = 5; }
            }

            for (int actual = firstUnit; actual <= lastUnit; ++actual)
            {
                int index = actual + 1;
                QRectF unitRect = this->rectAt(actual);
                int unitMiddle = unitRect.center().x();
                int ext = 0;
                if (index % interval == 0)
                {
                    ext = 3;
                }

                // Ticks
                if (bottom)
                {
                    painter->drawLine(unitMiddle, this->height() - 1, unitMiddle, this->height() - 3 - ext);
                }
                if (top)
                {
                    painter->drawLine(unitMiddle, 0, unitMiddle, 2 + ext);
                }

                // Legend
                if (index % interval == 0)
                {
                    QRect textRect(unitRect.left() - 30, unitRect.top() + 1, unitRect.width() + 60, unitRect.bottom());
                    painter->drawText(textRect, Qt::AlignVCenter | Qt::AlignHCenter, QString("%1").arg(index));
                }
            }

            pen = painter->pen();
            pen.setWidth(1);
            painter->setPen(pen);
            if (bottom)
            {
                painter->drawLine(rect.left(), this->height() - 1, rect.right(), this->height() - 1);
            }
            if (top)
            {
                painter->drawLine(rect.left(), 0, rect.right(), 0);
            }
        }
    }
Example #14
0
void BalloonTip::setArrowPosition( BalloonTip::ArrowPosition arrowPos ) {
  my_arrowPos = arrowPos;
  QRect r = relativePopupRect();
  my_closeButton->move( r.topRight() - QPoint( 30, - 5 ) );
}
Example #15
0
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
                                 QPainter *painter, const QWidget *widget) const
{
    if (!panelWidget(widget))
        return QProxyStyle::drawControl(element, option, painter, widget);

    switch (element) {
    case CE_Splitter:
        painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
        break;

    case CE_TabBarTabShape:
        // Most styles draw a single dark outline. This looks rather ugly when combined with our
        // single pixel dark separator so we adjust the first tab to compensate for this

        if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) {
            QStyleOptionTabV3 adjustedTab = *tab;
            if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && (
                    tab->position == QStyleOptionTab::Beginning ||
                    tab->position == QStyleOptionTab::OnlyOneTab))
            {
                if (option->direction == Qt::LeftToRight)
                    adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
                else
                    adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0);
            }
            QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
            return;
        }
        break;

    case CE_MenuBarItem:
        painter->save();
        if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
            QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120);
            bool act = mbi->state & State_Sunken;
            bool dis = !(mbi->state & State_Enabled);
            Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
            QStyleOptionMenuItem item = *mbi;
            item.rect = mbi->rect;
            QPalette pal = mbi->palette;
            pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
            item.palette = pal;
            QCommonStyle::drawControl(element, &item, painter, widget);
            QRect r = option->rect;

            if (act) {
                // Fill|
                QColor baseColor = Utils::StyleHelper::baseColor();
                QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft());
                grad.setColorAt(0, baseColor.lighter(120));
                grad.setColorAt(1, baseColor.lighter(130));
                painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad);

                // Outline
                painter->setPen(QPen(highlightOutline, 0));
                painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom()));
                painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom()));
                painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
                highlightOutline.setAlpha(60);
                painter->setPen(QPen(highlightOutline, 0));
                painter->drawPoint(r.topLeft());
                painter->drawPoint(r.topRight());

                QPalette pal = mbi->palette;
                uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
                if (!styleHint(SH_UnderlineShortcut, mbi, widget))
                    alignment |= Qt::TextHideMnemonic;
                pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
                drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
                pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
                drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
            }
        }
        painter->restore();
        break;

    case CE_ComboBoxLabel:
        if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
            if (panelWidget(widget)) {
                painter->save();
                QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
                QPalette customPal = cb->palette;
                bool drawIcon = !(widget && widget->property("hideicon").toBool());

                if (!cb->currentIcon.isNull() && drawIcon) {
                    QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
                                                                 : QIcon::Disabled;
                    QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
                    QRect iconRect(editRect);
                    iconRect.setWidth(cb->iconSize.width() + 4);
                    iconRect = alignedRect(cb->direction,
                                           Qt::AlignLeft | Qt::AlignVCenter,
                                           iconRect.size(), editRect);
                    if (cb->editable)
                        painter->fillRect(iconRect, customPal.brush(QPalette::Base));
                    drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);

                    if (cb->direction == Qt::RightToLeft)
                        editRect.translate(-4 - cb->iconSize.width(), 0);
                    else
                        editRect.translate(cb->iconSize.width() + 4, 0);

                    // Reserve some space for the down-arrow
                    editRect.adjust(0, 0, -13, 0);
                }

                QLatin1Char asterisk('*');
                int elideWidth = editRect.width();

                bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
                                        && cb->currentText.endsWith(asterisk)
                                        && option->fontMetrics.width(cb->currentText) > elideWidth;

                QString text;
                if (notElideAsterisk) {
                    elideWidth -= option->fontMetrics.width(asterisk);
                    text = asterisk;
                }
                text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));

                if ((option->state & State_Enabled)) {
                    painter->setPen(QColor(0, 0, 0, 70));
                    painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
                } else {
                    painter->setOpacity(0.8);
                }
                painter->setPen(Utils::StyleHelper::panelTextColor());
                painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);

                painter->restore();
            } else {
                QProxyStyle::drawControl(element, option, painter, widget);
            }
        }
        break;

    case CE_SizeGrip: {
            painter->save();
            QColor dark = Qt::white;
            dark.setAlphaF(0.1);
            int x, y, w, h;
            option->rect.getRect(&x, &y, &w, &h);
            int sw = qMin(h, w);
            if (h > w)
                painter->translate(0, h - w);
            else
                painter->translate(w - h, 0);
            int sx = x;
            int sy = y;
            int s = 4;
            painter->setPen(dark);
            if (option->direction == Qt::RightToLeft) {
                sx = x + sw;
                for (int i = 0; i < 4; ++i) {
                    painter->drawLine(x, sy, sx, sw);
                    sx -= s;
                    sy += s;
                }
            } else {
                for (int i = 0; i < 4; ++i) {
                    painter->drawLine(sx, sw, sw, sy);
                    sx += s;
                    sy += s;
                }
            }
            painter->restore();
        }
        break;

    case CE_MenuBarEmptyArea: {
            Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
            painter->save();
            painter->setPen(Utils::StyleHelper::borderColor());
            painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
            painter->restore();
        }
        break;

    case CE_ToolBar:
        {
            QRect rect = option->rect;
            bool horizontal = option->state & State_Horizontal;
            rect = option->rect;

            // Map offset for global window gradient
            QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
                            widget->mapToGlobal(option->rect.topLeft());
            QRect gradientSpan;
            if (widget)
                gradientSpan = QRect(offset, widget->window()->size());

            bool drawLightColored = lightColored(widget);
            if (horizontal)
                Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
            else
                Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);

            if (!drawLightColored)
                painter->setPen(Utils::StyleHelper::borderColor());
            else
                painter->setPen(QColor(0x888888));

            if (horizontal) {
                // Note: This is a hack to determine if the
                // toolbar should draw the top or bottom outline
                // (needed for the find toolbar for instance)
                QColor lighter(Utils::StyleHelper::sidebarHighlight());
                if (drawLightColored)
                    lighter = QColor(255, 255, 255, 180);
                if (widget && widget->property("topBorder").toBool()) {
                    painter->drawLine(rect.topLeft(), rect.topRight());
                    painter->setPen(lighter);
                    painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
                } else {
                    painter->drawLine(rect.bottomLeft(), rect.bottomRight());
                    painter->setPen(lighter);
                    painter->drawLine(rect.topLeft(), rect.topRight());
                }
            } else {
                painter->drawLine(rect.topLeft(), rect.bottomLeft());
                painter->drawLine(rect.topRight(), rect.bottomRight());
            }
        }
        break;

    default:
        QProxyStyle::drawControl(element, option, painter, widget);
        break;
    }
}
Example #16
0
void KkrBoardView::drawCell(QPainter &p, int col, int row) const
{
    static const char * digits[] = {
        " ",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
        "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
        "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
        "40", "41", "42", "43", "44", "45"
    };
    const QRect cellRect{getCellRect(col, row)};
    switch(m_pBoardData->getCellType(col, row)) {
    case CellType::CellAnswer:
    {
        if(m_curCol == col && m_curRow == row) {
            QBrush brCyan(Qt::cyan);
            p.fillRect(cellRect, brCyan);
        }
        const int ans = m_pBoardData->getAnswer(col, row);
        if(ans != EMPTY_ANSWER) {
            p.setFont(m_fontAns);
            p.drawText(cellRect, Qt::AlignCenter | Qt::AlignHCenter, digits[ans]);
        }
    }
        break;
    case CellType::CellClue:
    {
        const bool onCursor = m_curCol==col && m_curRow==row;
        QBrush brWhite(Qt::white);
        QBrush brBlack(Qt::black);
        QBrush brCyan(Qt::cyan);

        if(onCursor && m_curClue==CursorClue::None)
            p.setBrush(brCyan);
        else
            p.setBrush(brBlack);
        std::array<QPoint, 3> points;

        // upper right triangle
        points[0] = cellRect.topLeft(); points[0] += QPoint(2,1);
        points[1] = cellRect.topRight(); points[1] += QPoint(-1,1);
        points[2] = cellRect.bottomRight(); points[2] += QPoint(-1,-2);
        p.drawPolygon(points.data(), static_cast<int>(points.size()));

        // bottom left triangle
        points[0] = cellRect.topLeft(); points[0] += QPoint(1,2);
        points[1] = cellRect.bottomLeft(); points[1] += QPoint(1,-1);
        points[2] = cellRect.bottomRight(); points[2] += QPoint(-2,-1);
        p.drawPolygon(points.data(), static_cast<int>(points.size()));

        if(m_pBoardData->getClueRight(col, row) != CLOSED_CLUE) {
            const QRect clueRect{getClueRectRight(cellRect)};
            if(onCursor && m_curClue==CursorClue::Right)
                p.fillRect(clueRect, brCyan);
            else
                p.fillRect(clueRect, brWhite);
            p.setFont(m_fontClue);
            p.drawText(clueRect, Qt::AlignCenter | Qt::AlignHCenter,
                        digits[m_pBoardData->getClueRight(col, row)]);
        }

        if(m_pBoardData->getClueDown(col, row) != CLOSED_CLUE) {
            const QRect clueRect{getClueRectDown(cellRect)};
            if(onCursor && m_curClue==CursorClue::Down)
                p.fillRect(clueRect, brCyan);
            else
                p.fillRect(clueRect, brWhite);
            p.setFont(m_fontClue);
            p.drawText(clueRect, Qt::AlignCenter | Qt::AlignHCenter,
                       digits[m_pBoardData->getClueDown(col, row)]);
        }
    }
        break;
    default:
        Q_ASSERT(false);
    }
}
Example #17
0
void WindowsModernStyle::drawPrimitive( PrimitiveElement element, const QStyleOption* option,
                                        QPainter* painter, const QWidget* widget ) const
{
    switch ( element ) {
    case PE_Widget:
        if ( qobject_cast<const QMainWindow*>( widget ) ) {
            QRect rect = option->rect;
            if ( QStatusBar* statusBar = widget->findChild<QStatusBar*>() ) {
                rect.adjust( 0, 0, 0, -statusBar->height() );
                painter->setPen( option->palette.light().color() );
                painter->drawLine( rect.bottomLeft() + QPoint( 0, 1 ),
                                   rect.bottomRight() + QPoint( 0, 1 ) );
            }
            QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
            gradient.setColorAt( 0.0, m_colorBackgroundBegin );
            gradient.setColorAt( 0.6, m_colorBackgroundEnd );
            painter->fillRect( rect, gradient );
            return;
        }

        if ( qobject_cast<const QToolBox*>( widget ) ) {
            QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
            gradient.setColorAt( 0.4, m_colorBackgroundBegin );
            gradient.setColorAt( 1.0, m_colorBackgroundEnd );
            painter->fillRect( option->rect, gradient );
            return;
        }

        if ( isToolBoxPanel( widget ) ) {
            QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
            gradient.setColorAt( 0.4, m_colorBarMiddle );
            gradient.setColorAt( 1.0, m_colorBarBegin );
            painter->fillRect( option->rect, gradient );
            return;
        }
        break;

    case PE_WindowGradient: {
        QLinearGradient gradient( option->rect.topLeft(), option->rect.topRight() );
        gradient.setColorAt( 0.0, m_colorBackgroundBegin );
        gradient.setColorAt( 0.6, m_colorBackgroundEnd );
        painter->fillRect( option->rect, gradient );
        return;
    }

    case PE_PanelMenuBar:
        return;

    case PE_FrameMenu:
        painter->setPen( m_colorMenuBorder );
        painter->setBrush( Qt::NoBrush );
        painter->drawRect( option->rect.adjusted( 0, 0, -1, -1 ) );

        if ( const QMenu* menu = qobject_cast<const QMenu*>( widget ) ) {
            if ( const QMenuBar* menuBar = qobject_cast<const QMenuBar*>( menu->parent() ) ) {
                QRect rect = menuBar->actionGeometry( menu->menuAction() );
                if ( !rect.isEmpty() ) {
                    painter->setPen( m_colorMenuBackground );
                    painter->drawLine( 1, 0, rect.width() - 2, 0 );
                }
            }
        }

        if ( const QToolBar* toolBar = qobject_cast<const QToolBar*>( widget ) ) {
            QRect rect = option->rect.adjusted( 1, 1, -1, -1 );
            QLinearGradient gradient;
            if ( toolBar->orientation() == Qt::Vertical )
                gradient = QLinearGradient( rect.topLeft(), rect.topRight() );
            else
                gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() );
            gradient.setColorAt( 0.0, m_colorBarBegin );
            gradient.setColorAt( 0.4, m_colorBarMiddle );
            gradient.setColorAt( 0.6, m_colorBarMiddle );
            gradient.setColorAt( 1.0, m_colorBarEnd );
            painter->fillRect( rect, gradient );
        }
        return;

    case PE_IndicatorToolBarHandle:
        if ( option->state & State_Horizontal ) {
            for ( int i = option->rect.height() / 5; i <= 4 * ( option->rect.height() / 5 ); i += 5 ) {
                int x = option->rect.left() + 3;
                int y = option->rect.top() + i + 1;
                painter->fillRect( x + 1, y, 2, 2, m_colorHandleLight );
                painter->fillRect( x, y - 1, 2, 2, m_colorHandle );
            }
        } else {
            for ( int i = option->rect.width() / 5; i <= 4 * ( option->rect.width() / 5 ); i += 5 ) {
                int x = option->rect.left() + i + 1;
                int y = option->rect.top() + 3;
                painter->fillRect( x, y + 1, 2, 2, m_colorHandleLight );
                painter->fillRect( x - 1, y, 2, 2, m_colorHandle );
            }
        }
        return;

    case PE_IndicatorToolBarSeparator:
        painter->setPen( m_colorSeparator );
        if ( option->state & State_Horizontal )
            painter->drawLine( ( option->rect.left() + option->rect.right() - 1 ) / 2, option->rect.top() + 2,
                               ( option->rect.left() + option->rect.right() - 1 ) / 2, option->rect.bottom() - 2 );
        else
            painter->drawLine( option->rect.left() + 2, ( option->rect.top() + option->rect.bottom() - 1 ) / 2,
                               option->rect.right() - 2, ( option->rect.top() + option->rect.bottom() - 1 ) / 2 );
        painter->setPen( m_colorSeparatorLight );
        if ( option->state & State_Horizontal )
            painter->drawLine( ( option->rect.left() + option->rect.right() + 1 ) / 2, option->rect.top() + 2,
                               ( option->rect.left() + option->rect.right() + 1 ) / 2, option->rect.bottom() - 2 );
        else
            painter->drawLine( option->rect.left() + 2, ( option->rect.top() + option->rect.bottom() + 1 ) / 2,
                               option->rect.right() - 2, ( option->rect.top() + option->rect.bottom() + 1 ) / 2 );
        return;

    case PE_IndicatorButtonDropDown: {
        QToolBar* toolBar;
        if ( widget && ( toolBar = qobject_cast<QToolBar*>( widget->parentWidget() ) ) ) {
            QRect rect = option->rect.adjusted( -1, 0, -1, -1 );
            bool selected = option->state & State_MouseOver && option->state & State_Enabled;
            bool sunken = option->state & State_Sunken;
            if ( selected || sunken ) {
                painter->setPen( m_colorItemBorder );
                if ( toolBar->orientation() == Qt::Vertical ) {
                    if ( sunken )
                        painter->setBrush( m_colorItemSunkenEnd );
                    else
                        painter->setBrush( m_colorItemBackgroundEnd );
                } else {
                    QLinearGradient gradient( rect.topLeft(), rect.bottomLeft() );
                    if ( sunken ) {
                        gradient.setColorAt( 0.0, m_colorItemSunkenBegin );
                        gradient.setColorAt( 0.5, m_colorItemSunkenMiddle );
                        gradient.setColorAt( 1.0, m_colorItemSunkenEnd );
                    } else {
                        gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
                        gradient.setColorAt( 0.5, m_colorItemBackgroundMiddle );
                        gradient.setColorAt( 1.0, m_colorItemBackgroundEnd );
                    }
                    painter->setBrush( gradient );
                }
                painter->drawRect( rect );
            }
            QStyleOption optionArrow = *option;
            optionArrow.rect.adjust( 2, 2, -2, -2 );
            drawPrimitive( PE_IndicatorArrowDown, &optionArrow, painter, widget );
            return;
        }
    }

    case PE_IndicatorDockWidgetResizeHandle:
        return;

    case PE_PanelButtonTool:
        if ( widget && widget->inherits( "QDockWidgetTitleButton" ) ) {
            if ( option->state & ( QStyle::State_MouseOver | QStyle::State_Sunken ) ) {
                painter->setPen( m_colorItemBorder );
                painter->setBrush( ( option->state & QStyle::State_Sunken ) ? m_colorItemSunkenMiddle : m_colorItemBackgroundMiddle );
                painter->drawRect( option->rect.adjusted( 0, 0, -1, -1 ) );
            }
            return;
        }
        break;

    case PE_FrameTabWidget:
        if ( isStyledTabWidget( widget ) ) {
            painter->fillRect( option->rect, option->palette.window() );
            return;
        }
        break;

    case PE_FrameTabBarBase:
        if ( isStyledTabBar( widget ) )
            return;
        break;

    default:
        break;
    }

    if ( useVista() )
        QWindowsVistaStyle::drawPrimitive( element, option, painter, widget );
    else
        QWindowsXPStyle::drawPrimitive( element, option, painter, widget );
}
Example #18
0
QPoint GLDMaskBox::calcPosOfOwner()
{
    QPoint pt(0, 0);

    do
    {
        // 计算owner位置对应屏幕中心的象限
        if (!m_oTipBoxParam.m_wgtOwner)
        {
            break;
        }

        QPoint ptGlobalOwnerCenter = m_oTipBoxParam.m_wgtOwner->mapToGlobal(
            m_oTipBoxParam.m_wgtOwner->rect().center());
        QPoint ptGlobalScreen = QApplication::desktop()->screenGeometry().center();
        QPoint ptDelta = ptGlobalOwnerCenter - ptGlobalScreen;

        if (ptDelta.x() >= 0 && ptDelta.y() <= 0)
        {
            // 第一象限
            pt = QPoint(ptGlobalOwnerCenter.x() - m_oTipBoxParam.m_wgtOwner->width()/2,
                            ptGlobalOwnerCenter.y() + m_oTipBoxParam.m_wgtOwner->height()/2);
            pt += QPoint(-this->width()/2, 0);
        }
        else if (ptDelta.x() <= 0 && ptDelta.y() <= 0)
        {
            // 第二象限
            pt = QPoint(ptGlobalOwnerCenter.x() + m_oTipBoxParam.m_wgtOwner->width()/2,
                            ptGlobalOwnerCenter.y() + m_oTipBoxParam.m_wgtOwner->height()/2);
            pt += QPoint(-this->width()/2, 0);
        }
        else if (ptDelta.x() <= 0 && ptDelta.y() >= 0)
        {
            // 第三象限
            pt = QPoint(ptGlobalOwnerCenter.x() + m_oTipBoxParam.m_wgtOwner->width()/2,
                            ptGlobalOwnerCenter.y() - m_oTipBoxParam.m_wgtOwner->height()/2);
            pt += QPoint(-this->width()/2, -this->height());
        }
        else if (ptDelta.x() >= 0 && ptDelta.y() >= 0)
        {
            // 第四象限
            pt = QPoint(ptGlobalOwnerCenter.x() - m_oTipBoxParam.m_wgtOwner->width()/2,
                        ptGlobalOwnerCenter.y() - m_oTipBoxParam.m_wgtOwner->height()/2);
            pt += QPoint(-this->width()/2, -this->height());
        }

        // 超出屏幕范围的校准
        QRect rcThis(pt, pt + QPoint(this->width(), this->height()));
        QRect rcScreen = QApplication::desktop()->screenGeometry();

        if (!rcScreen.contains(rcThis.topLeft()))
        {
            int nXOffset = rcThis.topLeft().x() - rcScreen.topLeft().x();
            int nYOffset = rcThis.topLeft().y() - rcScreen.topLeft().y();

            if (nXOffset < 0)
            {
                pt.setX(pt.x() - nXOffset);
            }

            if (nYOffset < 0)
            {
                pt.setY(pt.y() - nYOffset);
            }
        }
        else if (!rcScreen.contains(rcThis.topRight()))
        {
            int nXOffset = rcThis.topRight().x() - rcScreen.topRight().x();
            int nYOffset = rcThis.topRight().y() - rcScreen.topRight().y();

            if (nXOffset > 0)
            {
                pt.setX(pt.x() - nXOffset);
            }

            if (nYOffset < 0)
            {
                pt.setY(pt.y() - nYOffset);
            }
        }
        else if (!rcScreen.contains(rcThis.bottomLeft()))
        {
            int nXOffset = rcThis.bottomLeft().x() - rcScreen.bottomLeft().x();
            int nYOffset = rcThis.bottomLeft().y() - rcScreen.bottomLeft().y();

            if (nXOffset < 0)
            {
                pt.setX(pt.x() - nXOffset);
            }

            if (nYOffset > 0)
            {
                pt.setY(pt.y() - nYOffset);
            }
        }
        else if (!rcScreen.contains(rcThis.bottomRight()))
        {
            int nXOffset = rcThis.bottomRight().x() - rcScreen.bottomRight().x();
            int nYOffset = rcThis.bottomRight().y() - rcScreen.bottomRight().y();

            if (nXOffset > 0)
            {
                pt.setX(pt.x() - nXOffset);
            }

            if (nYOffset > 0)
            {
                pt.setY(pt.y() - nYOffset);
            }
        }

    } while(0);

    return pt;
}
Example #19
0
void WindowsModernStyle::drawComplexControl( ComplexControl control, const QStyleOptionComplex* option,
        QPainter* painter, const QWidget* widget ) const
{
    switch ( control ) {
    case CC_ToolButton: {
        QToolBar* toolBar;
        if ( widget && ( toolBar = qobject_cast<QToolBar*>( widget->parentWidget() ) ) ) {
            if ( const QStyleOptionToolButton* optionToolButton = qstyleoption_cast<const QStyleOptionToolButton*>( option ) ) {
                QRect buttonRect = subControlRect( control, option, SC_ToolButton, widget );
                QStyle::State buttonState = option->state & ~State_Sunken;
                if ( option->state & State_Sunken ) {
                    if ( optionToolButton->activeSubControls & SC_ToolButton )
                        buttonState |= State_Sunken;
                    else if ( optionToolButton->activeSubControls & SC_ToolButtonMenu )
                        buttonState |= State_MouseOver;
                }
                bool selected = buttonState & State_MouseOver && option->state & State_Enabled;
                bool checked = buttonState & State_On;
                bool sunken = buttonState & State_Sunken;
                if ( selected || checked || sunken ) {
                    QRect rect = buttonRect.adjusted( 0, 0, -1, -1 );
                    painter->setPen( m_colorItemBorder );
                    QLinearGradient gradient;
                    if ( toolBar->orientation() == Qt::Vertical )
                        gradient = QLinearGradient( rect.topLeft(), rect.topRight() );
                    else
                        gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() );
                    if ( sunken || (selected && checked) ) {
                        gradient.setColorAt( 0.0, m_colorItemSunkenBegin );
                        gradient.setColorAt( 0.5, m_colorItemSunkenMiddle );
                        gradient.setColorAt( 1.0, m_colorItemSunkenEnd );
                    } else if ( checked ) {
                        gradient.setColorAt( 0.0, m_colorItemCheckedBegin );
                        gradient.setColorAt( 0.5, m_colorItemCheckedMiddle );
                        gradient.setColorAt( 1.0, m_colorItemCheckedEnd );
                    } else {
                        gradient.setColorAt( 0.0, m_colorItemBackgroundBegin );
                        gradient.setColorAt( 0.5, m_colorItemBackgroundMiddle );
                        gradient.setColorAt( 1.0, m_colorItemBackgroundEnd );
                    }
                    painter->setBrush( gradient );
                    painter->drawRect( rect );
                }
                QStyleOptionToolButton optionLabel = *optionToolButton;
                int fw = pixelMetric( PM_DefaultFrameWidth, option, widget );
                optionLabel.rect = buttonRect.adjusted( fw, fw, -fw, -fw );
                drawControl( CE_ToolButtonLabel, &optionLabel, painter, widget );
                if ( optionToolButton->subControls & SC_ToolButtonMenu ) {
                    QStyleOption optionMenu = *optionToolButton;
                    optionMenu.rect = subControlRect( control, option, SC_ToolButtonMenu, widget );
                    optionMenu.state = optionToolButton->state & ~State_Sunken;
                    if ( optionToolButton->state & State_Sunken ) {
                        if ( optionToolButton->activeSubControls & SC_ToolButton )
                            optionMenu.state |= State_MouseOver | State_Sunken;
                        else if ( optionToolButton->activeSubControls & SC_ToolButtonMenu )
                            optionMenu.state |= State_Sunken;
                    }
                    drawPrimitive( PE_IndicatorButtonDropDown, &optionMenu, painter, widget );
                } else if ( optionToolButton->features & QStyleOptionToolButton::HasMenu ) {
                    int size = pixelMetric( PM_MenuButtonIndicator, option, widget );
                    QRect rect = optionToolButton->rect;
                    QStyleOptionToolButton optionArrow = *optionToolButton;
                    optionArrow.rect = QRect( rect.right() + 4 - size, rect.height() - size + 4, size - 5, size - 5 );
                    drawPrimitive( PE_IndicatorArrowDown, &optionArrow, painter, widget );
                }
                return;
            }
        }
        break;
    }

    default:
        break;
    }

    if ( useVista() )
        QWindowsVistaStyle::drawComplexControl( control, option, painter, widget );
    else
        QWindowsXPStyle::drawComplexControl( control, option, painter, widget );
}
Example #20
0
	void ModeTabBar::paintEvent(QPaintEvent *event)
	{
		QPainter p(this);
		IconManager *iconManager = IconManager::instance();

		QLinearGradient bgGrad(rect().topLeft(), rect().topRight());
		bgGrad.setColorAt(0.5, palette().color(QPalette::Window));
		bgGrad.setColorAt(1.0, palette().color(QPalette::Midlight));
		p.fillRect(rect(), bgGrad);

		p.setPen(palette().color(QPalette::Shadow));
		p.drawLine(width() - 1, 0, width() - 1, height());

		for(int i = 0; i < count(); ++i) {
			p.save();

			QFont labelFont = font();
			labelFont.setBold(true);
			p.setFont(labelFont);

			QRect rect = tabRect(i);

			int textHeight = p.fontMetrics().boundingRect(QRect(0, 0, width(), height()), 0, tabLabel(i)).height();
			QRect labelRect(QPoint(rect.left() + tabPadding, rect.bottom() - textHeight - tabPadding), QSize(rect.width() - (tabPadding * 2), textHeight));

			int iconSize = rect.height() - textHeight - (3 * tabPadding);
			QRect iconRect(QPoint((rect.width() - iconSize) / 2, rect.top() + tabPadding), QSize(iconSize, iconSize));

			bool isSelected = (i == m_currentIndex);
			bool isEnabled = isTabEnabled(i);
			bool isHovered = (i == m_hoverIndex);

			if(isHovered && isEnabled) {
				p.fillRect(rect.adjusted(0, 0, -1, 0), QColor(0, 0, 0, 24));
			}

			if(isSelected) {
				p.save();

				p.setPen(palette().color(QPalette::Shadow));
				p.drawLine(rect.topLeft(), rect.topRight());
				p.drawLine(rect.bottomLeft(), rect.bottomRight());

				p.fillRect(rect.adjusted(0, 0, -1, 0), QColor(0, 0, 0, 32));
				p.translate(rect.width() - 6, rect.top() + (rect.height() / 2) - 12);

				QPolygon arrowPoly;
				arrowPoly.append(QPoint(7, 0));
				arrowPoly.append(QPoint(7, 24));
				arrowPoly.append(QPoint(0, 12));

				p.translate(0, 1);
				p.setBrush(palette().color(QPalette::Shadow));
				p.setPen(palette().color(QPalette::Shadow));
				p.setRenderHint(QPainter::Antialiasing);
				p.drawPolygon(arrowPoly);

				p.translate(0, -1);
				p.setBrush(palette().color(QPalette::Light));
				p.drawPolygon(arrowPoly);

				p.restore();
			}

			if(!isEnabled)
				p.setOpacity(0.6);

			QIcon icon(iconManager->icon(tabIcon(i)));
			QPixmap pixmap = icon.pixmap(iconSize, iconSize, isEnabled ? QIcon::Normal : QIcon::Disabled);

			p.drawPixmap(iconRect, pixmap);

			p.setPen(palette().color(QPalette::Text));
			p.drawText(labelRect, Qt::AlignCenter, tabLabel(i));
			p.restore();
		}
	}
Example #21
0
void DoubleTabWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)
    QPainter painter(this);
    QRect r = rect();

    // draw top level tab bar
    r.setHeight(StyleHelper::navigationWidgetHeight());

    if (creatorTheme()->widgetStyle () == Theme::StyleDefault) {
        QPoint offset = window()->mapToGlobal(QPoint(0, 0)) - mapToGlobal(r.topLeft());
        QRect gradientSpan = QRect(offset, window()->size());
        StyleHelper::horizontalGradient(&painter, gradientSpan, r);
        painter.setPen(StyleHelper::borderColor());
        QColor lighter(255, 255, 255, 40);
        painter.drawLine(r.bottomLeft(), r.bottomRight());
        painter.setPen(lighter);
        painter.drawLine(r.topLeft(), r.topRight());
    } else {
        painter.fillRect(r, creatorTheme()->color(Theme::DoubleTabWidget1stEmptyAreaBackgroundColor));
    }

    QFontMetrics fm(font());
    int baseline = (r.height() + fm.ascent()) / 2 - 1;

    // top level title
    if (!m_title.isEmpty()) {
        painter.setPen(StyleHelper::panelTextColor());
        painter.drawText(MARGIN, baseline, m_title);
    }

    QLinearGradient grad(QPoint(0, 0), QPoint(0, r.height() + OTHER_HEIGHT - 1));
    if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
        grad.setColorAt(0, creatorTheme()->color(Theme::DoubleTabWidget1stTabBackgroundColor));
    } else {
        grad.setColorAt(0, QColor(247, 247, 247));
        grad.setColorAt(1, QColor(205, 205, 205));
    }

    // draw background of second bar
    painter.fillRect(QRect(0, r.height(), r.width(), OTHER_HEIGHT), grad);
    if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
        painter.setPen(QColor(0x505050));
        painter.drawLine(0, r.height() + OTHER_HEIGHT,
                         r.width(), r.height() + OTHER_HEIGHT);
        painter.setPen(Qt::white);
        painter.drawLine(0, r.height(),
                         r.width(), r.height());
    }

    // top level tabs
    int x = m_title.isEmpty() ? 0 :
            2 * MARGIN + qMax(fm.width(m_title), MIN_LEFT_MARGIN);

    // calculate sizes
    QList<int> nameWidth;
    int width = x;
    int indexSmallerThanOverflow = -1;
    int indexSmallerThanWidth = -1;
    for (int i = 0; i < m_tabs.size(); ++i) {
        const Tab &tab = m_tabs.at(i);
        int w = fm.width(tab.displayName());
        nameWidth << w;
        width += 2 * MARGIN + w;
        if (width < r.width())
            indexSmallerThanWidth = i;
        if (width < r.width() - OVERFLOW_DROPDOWN_WIDTH)
            indexSmallerThanOverflow = i;
    }
    m_lastVisibleIndex = -1;
    m_currentTabIndices.resize(m_tabs.size());
    if (indexSmallerThanWidth == m_tabs.size() - 1) {
        // => everything fits
        for (int i = 0; i < m_tabs.size(); ++i)
            m_currentTabIndices[i] = i;
        m_lastVisibleIndex = m_tabs.size()-1;
    } else {
        // => we need the overflow thingy
        if (m_currentIndex <= indexSmallerThanOverflow) {
            // easy going, simply draw everything that fits
            for (int i = 0; i < m_tabs.size(); ++i)
                m_currentTabIndices[i] = i;
            m_lastVisibleIndex = indexSmallerThanOverflow;
        } else {
            // now we need to put the current tab into
            // visible range. for that we need to find the place
            // to put it, so it fits
            width = x;
            int index = 0;
            bool handledCurrentIndex = false;
            for (int i = 0; i < m_tabs.size(); ++i) {
                if (index != m_currentIndex) {
                    if (!handledCurrentIndex) {
                        // check if enough room for current tab after this one
                        if (width + 2 * MARGIN + nameWidth.at(index)
                                + 2 * MARGIN + nameWidth.at(m_currentIndex)
                                < r.width() - OVERFLOW_DROPDOWN_WIDTH) {
                            m_currentTabIndices[i] = index;
                            ++index;
                            width += 2 * MARGIN + nameWidth.at(index);
                        } else {
                            m_currentTabIndices[i] = m_currentIndex;
                            handledCurrentIndex = true;
                            m_lastVisibleIndex = i;
                        }
                    } else {
                        m_currentTabIndices[i] = index;
                        ++index;
                    }
                } else {
                    ++index;
                    --i;
                }
            }
        }
    }

    // actually draw top level tabs
    for (int i = 0; i <= m_lastVisibleIndex; ++i) {
        int actualIndex = m_currentTabIndices.at(i);
        Tab tab = m_tabs.at(actualIndex);
        if (actualIndex == m_currentIndex) {
            painter.setPen(StyleHelper::borderColor());
            painter.drawLine(x - 1, 0, x - 1, r.height() - 1);
            painter.fillRect(QRect(x, 0,
                                   2 * MARGIN + fm.width(tab.displayName()),
                                   r.height() + 1),
                             grad);

            if (actualIndex != 0 && creatorTheme()->widgetStyle() == Theme::StyleDefault) {
                painter.setPen(QColor(255, 255, 255, 170));
                painter.drawLine(x, 0, x, r.height());
            }
            x += MARGIN;
            painter.setPen(creatorTheme()->color(Theme::DoubleTabWidget1stTabActiveTextColor));
            painter.drawText(x, baseline, tab.displayName());
            x += nameWidth.at(actualIndex);
            x += MARGIN;
            if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
                painter.setPen(StyleHelper::borderColor());
                painter.drawLine(x, 0, x, r.height() - 1);
                painter.setPen(QColor(0, 0, 0, 20));
                painter.drawLine(x + 1, 0, x + 1, r.height() - 1);
                painter.setPen(QColor(255, 255, 255, 170));
                painter.drawLine(x - 1, 0, x - 1, r.height());
            }
        } else {
            if (i == 0 && creatorTheme()->widgetStyle() == Theme::StyleDefault)
                drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
            x += MARGIN;
            painter.setPen(creatorTheme()->color(Theme::DoubleTabWidget1stTabInactiveTextColor));
            painter.drawText(x + 1, baseline, tab.displayName());
            x += nameWidth.at(actualIndex);
            x += MARGIN;
            drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
        }
    }

    // draw overflow button
    if (m_lastVisibleIndex < m_tabs.size() - 1) {
        QStyleOption opt;
        opt.rect = QRect(x, 0, OVERFLOW_DROPDOWN_WIDTH - 1, r.height() - 1);
        style()->drawPrimitive(QStyle::PE_IndicatorArrowDown,
                               &opt, &painter, this);
        drawFirstLevelSeparator(&painter, QPoint(x + OVERFLOW_DROPDOWN_WIDTH, 0),
                                QPoint(x + OVERFLOW_DROPDOWN_WIDTH, r.height()-1));
    }

    // second level tabs
    if (m_currentIndex != -1) {
        int y = r.height() + (OTHER_HEIGHT - m_left.height()) / 2.;
        int imageHeight = m_left.height();
        Tab currentTab = m_tabs.at(m_currentIndex);
        QStringList subTabs = currentTab.subTabs;
        x = 0;
        for (int i = 0; i < subTabs.size(); ++i) {
            x += MARGIN;
            int textWidth = fm.width(subTabs.at(i));
            if (currentTab.currentSubTab == i) {
                if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
                    painter.drawPixmap(x, y, m_left);
                    painter.drawPixmap(QRect(x + SELECTION_IMAGE_WIDTH, y,
                                             textWidth, imageHeight),
                                       m_mid, QRect(0, 0, m_mid.width(), m_mid.height()));
                    painter.drawPixmap(x + SELECTION_IMAGE_WIDTH + textWidth, y, m_right);
                } else {
                    painter.setBrush(creatorTheme()->color(Theme::DoubleTabWidget2ndTabBackgroundColor));
                    painter.setPen(Qt::NoPen);
                    painter.drawRoundedRect(QRect(x,y,2*SELECTION_IMAGE_WIDTH+textWidth, m_mid.height()), 5,5);
                }
                painter.setPen(creatorTheme()->color(Theme::DoubleTabWidget2ndTabActiveTextColor));
            } else {
                painter.setPen(creatorTheme()->color(Theme::DoubleTabWidget2ndTabInactiveTextColor));
            }
            x += SELECTION_IMAGE_WIDTH;
            painter.drawText(x, y + (imageHeight + fm.ascent()) / 2. - 1,
                             subTabs.at(i));
            x += textWidth + SELECTION_IMAGE_WIDTH + MARGIN;
            drawSecondLevelSeparator(&painter, QPoint(x, y), QPoint(x, y + imageHeight));
        }
    }
}
Example #22
0
void KCategoryDrawer::drawCategory(const QModelIndex &index,
                                   int /*sortRole*/,
                                   const QStyleOption &option,
                                   QPainter *painter) const
{
    painter->setRenderHint(QPainter::Antialiasing);

    const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
    const QRect optRect = option.rect;
    QFont font(QApplication::font());
    font.setBold(true);
    const QFontMetrics fontMetrics = QFontMetrics(font);

    QColor outlineColor = option.palette.text().color();
    outlineColor.setAlphaF(0.35);

    //BEGIN: top left corner
    {
        painter->save();
        painter->setPen(outlineColor);
        const QPointF topLeft(optRect.topLeft());
        QRectF arc(topLeft, QSizeF(4, 4));
        arc.translate(0.5, 0.5);
        painter->drawArc(arc, 1440, 1440);
        painter->restore();
    }
    //END: top left corner

    //BEGIN: left vertical line
    {
        QPoint start(optRect.topLeft());
        start.ry() += 3;
        QPoint verticalGradBottom(optRect.topLeft());
        verticalGradBottom.ry() += fontMetrics.height() + 5;
        QLinearGradient gradient(start, verticalGradBottom);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, Qt::transparent);
        painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
    }
    //END: left vertical line

    //BEGIN: horizontal line
    {
        QPoint start(optRect.topLeft());
        start.rx() += 3;
        QPoint horizontalGradTop(optRect.topLeft());
        horizontalGradTop.rx() += optRect.width() - 6;
        painter->fillRect(QRect(start, QSize(optRect.width() - 6, 1)), outlineColor);
    }
    //END: horizontal line

    //BEGIN: top right corner
    {
        painter->save();
        painter->setPen(outlineColor);
        QPointF topRight(optRect.topRight());
        topRight.rx() -= 4;
        QRectF arc(topRight, QSizeF(4, 4));
        arc.translate(0.5, 0.5);
        painter->drawArc(arc, 0, 1440);
        painter->restore();
    }
    //END: top right corner

    //BEGIN: right vertical line
    {
        QPoint start(optRect.topRight());
        start.ry() += 3;
        QPoint verticalGradBottom(optRect.topRight());
        verticalGradBottom.ry() += fontMetrics.height() + 5;
        QLinearGradient gradient(start, verticalGradBottom);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, Qt::transparent);
        painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
    }
    //END: right vertical line

    //BEGIN: text
    {
        QRect textRect(option.rect);
        textRect.setTop(textRect.top() + 7);
        textRect.setLeft(textRect.left() + 7);
        textRect.setHeight(fontMetrics.height());
        textRect.setRight(textRect.right() - 7);

        painter->save();
        painter->setFont(font);
        QColor penColor(option.palette.text().color());
        penColor.setAlphaF(0.6);
        painter->setPen(penColor);
        painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, category);
        painter->restore();
    }
    //END: text
}
Example #23
0
void KateCategoryDrawer::drawCategory(const QModelIndex &index,
                                            int sortRole,
                                            const QStyleOption &option,
                                            QPainter *painter) const
{
    Q_UNUSED( sortRole )

    painter->setRenderHint(QPainter::Antialiasing);

    const QRect optRect = option.rect;
    QFont font(QApplication::font());
    font.setBold(true);
    const QFontMetrics fontMetrics = QFontMetrics(font);
    const int height = categoryHeight(index, option);
    const bool leftToRight = painter->layoutDirection() == Qt::LeftToRight;

    //BEGIN: decoration gradient
    {
        QPainterPath path(optRect.bottomLeft());

        path.lineTo(QPoint(optRect.topLeft().x(), optRect.topLeft().y() - 3));
        const QPointF topLeft(optRect.topLeft());
        QRectF arc(topLeft, QSizeF(4, 4));
        path.arcTo(arc, 180, -90);
        path.lineTo(optRect.topRight());
        path.lineTo(optRect.bottomRight());
        path.lineTo(optRect.bottomLeft());

        QColor window(option.palette.window().color());
        const QColor base(option.palette.base().color());

        window.setAlphaF(0.4);

        QLinearGradient decoGradient1;
        if (leftToRight) {
            decoGradient1.setStart(optRect.topLeft());
            decoGradient1.setFinalStop(optRect.bottomLeft());
        } else {
            decoGradient1.setStart(optRect.topRight());
            decoGradient1.setFinalStop(optRect.bottomRight());
        }
        decoGradient1.setColorAt(0, window);
        decoGradient1.setColorAt(1, Qt::transparent);

        QLinearGradient decoGradient2;
        if (leftToRight) {
            decoGradient2.setStart(optRect.topLeft());
            decoGradient2.setFinalStop(optRect.topRight());
        } else {
            decoGradient2.setStart(optRect.topRight());
            decoGradient2.setFinalStop(optRect.topLeft());
        }
        decoGradient2.setColorAt(0, Qt::transparent);
        decoGradient2.setColorAt(1, base);

        painter->fillPath(path, decoGradient1);
        painter->fillPath(path, decoGradient2);
    }
    //END: decoration gradient

    {
        QRect newOptRect(optRect);

        if (leftToRight) {
            newOptRect.translate(1, 1);
        } else {
            newOptRect.translate(-1, 1);
        }

        //BEGIN: inner top left corner
        {
            painter->save();
            painter->setPen(option.palette.base().color());
            QRectF arc;
            if (leftToRight) {
                const QPointF topLeft(newOptRect.topLeft());
                arc = QRectF(topLeft, QSizeF(4, 4));
                arc.translate(0.5, 0.5);
                painter->drawArc(arc, 1440, 1440);
            } else {
                QPointF topRight(newOptRect.topRight());
                topRight.rx() -= 4;
                arc = QRectF(topRight, QSizeF(4, 4));
                arc.translate(-0.5, 0.5);
                painter->drawArc(arc, 0, 1440);
            }
            painter->restore();
        }
        //END: inner top left corner

        //BEGIN: inner left vertical line
        {
            QPoint start;
            QPoint verticalGradBottom;
            if (leftToRight) {
                start = newOptRect.topLeft();
                verticalGradBottom = newOptRect.topLeft();
            } else {
                start = newOptRect.topRight();
                verticalGradBottom = newOptRect.topRight();
            }
            start.ry() += 3;
            verticalGradBottom.ry() += newOptRect.height() - 3;
            QLinearGradient gradient(start, verticalGradBottom);
            gradient.setColorAt(0, option.palette.base().color());
            gradient.setColorAt(1, Qt::transparent);
            painter->fillRect(QRect(start, QSize(1, newOptRect.height() - 3)), gradient);
        }
        //END: inner left vertical line

        //BEGIN: inner horizontal line
        {
            QPoint start;
            QPoint horizontalGradTop;
            if (leftToRight) {
                start = newOptRect.topLeft();
                horizontalGradTop = newOptRect.topLeft();
                start.rx() += 3;
                horizontalGradTop.rx() += newOptRect.width() - 3;
            } else {
                start = newOptRect.topRight();
                horizontalGradTop = newOptRect.topRight();
                start.rx() -= 3;
                horizontalGradTop.rx() -= newOptRect.width() - 3;
            }
            QLinearGradient gradient(start, horizontalGradTop);
            gradient.setColorAt(0, option.palette.base().color());
            gradient.setColorAt(1, Qt::transparent);
            QSize rectSize;
            if (leftToRight) {
                rectSize = QSize(newOptRect.width() - 3, 1);
            } else {
                rectSize = QSize(-newOptRect.width() + 3, 1);
            }
            painter->fillRect(QRect(start, rectSize), gradient);
        }
        //END: inner horizontal line
    }

    QColor outlineColor = option.palette.text().color();
    outlineColor.setAlphaF(0.35);

    //BEGIN: top left corner
    {
        painter->save();
        painter->setPen(outlineColor);
        QRectF arc;
        if (leftToRight) {
            const QPointF topLeft(optRect.topLeft());
            arc = QRectF(topLeft, QSizeF(4, 4));
            arc.translate(0.5, 0.5);
            painter->drawArc(arc, 1440, 1440);
        } else {
            QPointF topRight(optRect.topRight());
            topRight.rx() -= 4;
            arc = QRectF(topRight, QSizeF(4, 4));
            arc.translate(-0.5, 0.5);
            painter->drawArc(arc, 0, 1440);
        }
        painter->restore();
    }
    //END: top left corner

    //BEGIN: left vertical line
    {
        QPoint start;
        QPoint verticalGradBottom;
        if (leftToRight) {
            start = optRect.topLeft();
            verticalGradBottom = optRect.topLeft();
        } else {
            start = optRect.topRight();
            verticalGradBottom = optRect.topRight();
        }
        start.ry() += 3;
        verticalGradBottom.ry() += optRect.height() - 3;
        QLinearGradient gradient(start, verticalGradBottom);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, option.palette.base().color());
        painter->fillRect(QRect(start, QSize(1, optRect.height() - 3)), gradient);
    }
    //END: left vertical line

    //BEGIN: horizontal line
    {
        QPoint start;
        QPoint horizontalGradTop;
        if (leftToRight) {
            start = optRect.topLeft();
            horizontalGradTop = optRect.topLeft();
            start.rx() += 3;
            horizontalGradTop.rx() += optRect.width() - 3;
        } else {
            start = optRect.topRight();
            horizontalGradTop = optRect.topRight();
            start.rx() -= 3;
            horizontalGradTop.rx() -= optRect.width() - 3;
        }
        QLinearGradient gradient(start, horizontalGradTop);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, option.palette.base().color());
        QSize rectSize;
        if (leftToRight) {
            rectSize = QSize(optRect.width() - 3, 1);
        } else {
            rectSize = QSize(-optRect.width() + 3, 1);
        }
        painter->fillRect(QRect(start, rectSize), gradient);
    }
    //END: horizontal line

    //BEGIN: draw text
    {
        const QString category = index.model()->data(index, Qt::DisplayRole).toString(); // KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
        QRect textRect = QRect(option.rect.topLeft(), QSize(option.rect.width() - 2 - 3 - 3, height));
        textRect.setTop(textRect.top() + 2 + 3 /* corner */);
        textRect.setLeft(textRect.left() + 2 + 3 /* corner */ + 3 /* a bit of margin */);
        painter->save();
        painter->setFont(font);
        QColor penColor(option.palette.text().color());
        penColor.setAlphaF(0.6);
        painter->setPen(penColor);
        painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, category);
        painter->restore();
    }
    //END: draw text
}
Example #24
0
QPainterPath VeeWipeStrategy::clipPath(int step, const QRect &area)
{
    qreal percent = static_cast<qreal>(step) / static_cast<qreal>(StepCount);
    if(reverse())
        percent = static_cast<qreal>(StepCount-step) / static_cast<qreal>(StepCount);

    int stepx = static_cast<int>(2 * area.width() * percent);
    int stepy = static_cast<int>(2 * area.height() * percent);

    int width_2 = area.width() >> 1;
    int height_2 = area.height() >> 1;

    QPainterPath path;
    switch(subType())
    {
        case VeeWipeEffectFactory::FromTop:
        {
            QPoint move(0, stepy - 2 * area.height());
            path.moveTo(move + area.topLeft());
            path.lineTo(move + area.bottomLeft());
            path.lineTo(move + QPoint(width_2, 2 * area.height()));
            path.lineTo(move + area.bottomRight());
            path.lineTo(move + area.topRight());
            break;
        }
        case VeeWipeEffectFactory::FromRight:
        {
            QPoint move(2 * area.width()-stepx, 0);
            path.moveTo(move + area.topRight());
            path.lineTo(move + area.topLeft());
            path.lineTo(move + QPoint(-area.width(), height_2));
            path.lineTo(move + area.bottomLeft());
            path.lineTo(move + area.bottomRight());
            break;
        }
        case VeeWipeEffectFactory::FromBottom:
        {
            QPoint move(0, 2 * area.height() - stepy);
            path.moveTo(move + area.bottomLeft());
            path.lineTo(move + area.topLeft());
            path.lineTo(move + QPoint(width_2, -area.height()));
            path.lineTo(move + area.topRight());
            path.lineTo(move + area.bottomRight());
            break;
        }
        case VeeWipeEffectFactory::FromLeft:
        {
            QPoint move(stepx - 2 * area.width(), 0);
            path.moveTo(move + area.topLeft());
            path.lineTo(move + area.topRight());
            path.lineTo(move + QPoint(2 * area.width(), height_2));
            path.lineTo(move + area.bottomRight());
            path.lineTo(move + area.bottomLeft());
            break;
        }
        default:
            return QPainterPath();
    }

    path.closeSubpath();

    if(reverse())
    {
        QPainterPath areaPath;
        areaPath.addRect(area);
        path = areaPath.subtracted(path);
    }

    return path;
}
void QToolBarAreaLayout::apply(bool animate)
{
    QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
    Q_ASSERT(layout != 0);

    Qt::LayoutDirection dir = mainWindow->layoutDirection();

    for (int i = 0; i < QInternal::DockCount; ++i) {
        const QToolBarAreaLayoutInfo &dock = docks[i];

        for (int j = 0; j < dock.lines.count(); ++j) {
            const QToolBarAreaLayoutLine &line = dock.lines.at(j);
            if (line.skip())
                continue;

            for (int k = 0; k < line.toolBarItems.count(); ++k) {
                const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
                if (item.skip() || item.gap)
                    continue;

                QRect geo;
                if (visible) {
                    if (line.o == Qt::Horizontal) {
                        geo.setTop(line.rect.top());
                        geo.setBottom(line.rect.bottom());
                        geo.setLeft(line.rect.left() + item.pos);
                        geo.setRight(line.rect.left() + item.pos + item.size - 1);
                    } else {
                        geo.setLeft(line.rect.left());
                        geo.setRight(line.rect.right());
                        geo.setTop(line.rect.top() + item.pos);
                        geo.setBottom(line.rect.top() + item.pos + item.size - 1);
                    }
                }

                QWidget *widget = item.widgetItem->widget();
                if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
                    QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(toolBar->layout());
                    if (tbl->expanded) {
                        QPoint tr = geo.topRight();
                        QSize size = tbl->expandedSize(geo.size());
                        geo.setSize(size);
                        geo.moveTopRight(tr);
                        if (geo.bottom() > rect.bottom())
                            geo.moveBottom(rect.bottom());
                        if (geo.right() > rect.right())
                            geo.moveRight(rect.right());
                        if (geo.left() < 0)
                            geo.moveLeft(0);
                        if (geo.top() < 0)
                            geo.moveTop(0);
                    }
                }

                if (visible && dock.o == Qt::Horizontal)
                    geo = QStyle::visualRect(dir, line.rect, geo);

                layout->widgetAnimator.animate(widget, geo, animate);
            }
        }
    }
}
Example #26
0
void WaveformView::paintEvent(QPaintEvent *event)
{
	PG_UNUSED(event);

	QPainter	dc(this);

	int32		clientWidth = width();
	int32		clientHeight = height();

	if (fDoc == NULL)
	{
		dc.drawText(QRect(0, 0, clientWidth, clientHeight), Qt::AlignHCenter | Qt::AlignVCenter, tr("Drop WAV audio file here"));
		return;
	}

	int32		topBorder = 16; // should be the height of frame label text
	int32		halfClientHeight;
	int32		sampleHeight, halfSampleHeight, textHeight;
	int32		fps = fDoc->Fps();
	int32		x = 0;
	int32		frameX;
	int32		sample = 0;
	int32		frame = 0;
	bool		drawPlayMarker = false;
	QRect		r;
	QColor		textCol(64, 64, 64);
	QColor		sampleFillCol(162, 205, 242);
	QColor		sampleOutlineCol(30, 121, 198);
	QColor		playBackCol(255, 127, 127);
	QColor		playForeCol(209, 102, 121, 128);
	QColor		playOutlineCol(128, 0, 0);
	QColor		frameCol(192, 192, 192);
	QColor		phraseFillCol(205, 242, 162);
	QColor		phraseOutlineCol(121, 198, 30);
	QColor		wordFillCol(242, 205, 162);
	QColor		wordOutlineCol(198, 121, 30);
	QColor		wordMissingFillCol(255, 127, 127);
	QColor		wordMissingOutlineCol(255, 0, 0);
	QColor		phonemeFillCol(231, 185, 210);
	QColor		phonemeOutlineCol(173, 114, 146);
	QMediaPlayer	*audioPlayer = fDoc->GetAudioPlayer();

	textHeight = dc.fontMetrics().height() + 4;
	topBorder = textHeight;
	halfClientHeight = (clientHeight - textHeight) / 2;

	if (audioPlayer && audioPlayer->state() == QMediaPlayer::PlayingState)
	{
		drawPlayMarker = true;
		x = fCurFrame * fFrameWidth;
		dc.fillRect(QRect(x, 0, fFrameWidth, clientHeight), playBackCol);
	}

	x = 0;
	for (int32 i = 0; i < fNumSamples; i++)
	{
		if (((sample + 1) % fSamplesPerFrame) == 0)
		{
			dc.setPen(frameCol);
			// draw frame marker
			frameX = (frame + 1) * fFrameWidth;
			if (fSampleWidth >= 2 && ((fFrameWidth > 2) || ((frame + 2) % fps == 0)))
			{
				dc.drawLine(frameX, topBorder, frameX, clientHeight);
			}
			// draw frame label
			if ((fFrameWidth > 30) || ((frame + 2) % fps == 0))
			{
				dc.drawLine(frameX, 0, frameX, topBorder);
				dc.drawText(frameX + 2, textHeight - 4, QString::number(frame + 2));
			}
		}

		sampleHeight = PG_ROUND(fAmp[i] * (real)(clientHeight - topBorder));
		halfSampleHeight = sampleHeight / 2;
		r.setRect(x, topBorder + halfClientHeight - halfSampleHeight, fSampleWidth + 1, sampleHeight);
		dc.fillRect(r, sampleFillCol);
		dc.setPen(sampleOutlineCol);
		dc.drawLine(r.topLeft(), r.topRight());
		dc.drawLine(r.bottomLeft(), r.bottomRight());
		dc.drawLine(r.topRight(), r.bottomRight());
		if (i == 0)
		{
			dc.drawLine(r.topLeft(), r.bottomLeft());
		}
		else if (fAmp[i] > fAmp[i - 1])
		{
			sampleHeight = PG_ROUND(fAmp[i - 1] * (real)(clientHeight - topBorder));
			halfSampleHeight = sampleHeight / 2;
			dc.drawLine(r.topLeft(), QPoint(r.left(), topBorder + halfClientHeight - halfSampleHeight));
			dc.drawLine(r.bottomLeft(), QPoint(r.left(), topBorder + halfClientHeight - halfSampleHeight + sampleHeight - 1));
		}

		x += fSampleWidth;
		sample++;
		if ((sample % fSamplesPerFrame) == 0)
			frame++;
	}

	if (fDoc->fCurrentVoice)
	{
		topBorder += 4;
		for (int32 p = 0; p < fDoc->fCurrentVoice->fPhrases.size(); p++)
		{
			LipsyncPhrase *phrase = fDoc->fCurrentVoice->fPhrases[p];
			r = QRect(phrase->fStartFrame * fFrameWidth, topBorder, (phrase->fEndFrame - phrase->fStartFrame + 1) * fFrameWidth, textHeight);
			phrase->fTop = r.top();
			phrase->fBottom = r.bottom();
			dc.fillRect(r, phraseFillCol);
			dc.setPen(phraseOutlineCol);
			dc.drawRect(r);
			dc.setClipRect(r);
			dc.setPen(textCol);
			r = r.marginsRemoved(QMargins(2, 2, 2, 2));
			dc.drawText(QPoint(r.left(), r.bottom() - 2), phrase->fText);
			dc.setClipping(false);

			for (int32 w = 0; w < phrase->fWords.size(); w++)
			{
				LipsyncWord *word = phrase->fWords[w];
				r = QRect(word->fStartFrame * fFrameWidth, topBorder + 4 + textHeight, (word->fEndFrame - word->fStartFrame + 1) * fFrameWidth, textHeight);
				if (w & 1)
					r.translate(0, textHeight - textHeight / 4);
				word->fTop = r.top();
				word->fBottom = r.bottom();
				if (word->fPhonemes.size() == 0)
				{
					dc.fillRect(r, wordMissingFillCol);
					dc.setPen(wordMissingOutlineCol);
				}
				else
				{
					dc.fillRect(r, wordFillCol);
					dc.setPen(wordOutlineCol);
				}
				dc.drawRect(r);
				dc.setClipRect(r);
				dc.setPen(textCol);
				r = r.marginsRemoved(QMargins(2, 2, 2, 2));
				dc.drawText(QPoint(r.left(), r.bottom() - 2), word->fText);
				dc.setClipping(false);

				for (int32 i = 0; i < word->fPhonemes.size(); i++)
				{
					LipsyncPhoneme *phoneme = word->fPhonemes[i];
					r = QRect(phoneme->fFrame * fFrameWidth, clientHeight - 4 - textHeight, fFrameWidth, textHeight);
					if (i & 1)
						r.translate(0, -(textHeight - textHeight / 4));
					phoneme->fTop = r.top();
					phoneme->fBottom = r.bottom();
					dc.fillRect(r, phonemeFillCol);
					dc.setPen(phonemeOutlineCol);
					dc.drawRect(r);
					dc.setPen(textCol);
					r = r.marginsRemoved(QMargins(2, 2, 2, 2));
					dc.drawText(QPoint(r.left(), r.bottom() - 2), phoneme->fText);
				} // for i
			} // for w
		} // for p
	}

	if (drawPlayMarker)
	{
		x = fCurFrame * fFrameWidth;
		dc.fillRect(QRect(x, 0, fFrameWidth, clientHeight), playForeCol);
		dc.setPen(playOutlineCol);
		dc.drawRect(QRect(x, 0, fFrameWidth, clientHeight));
	}
}