Ejemplo n.º 1
0
QString CustomLabel::elidedText() const
{
    QString elided = text();
    QStringList srcLines;
    QStringList dstLines;
    QRectF lr = contentsRect();
    int textWidth = lr.width();
    // eliding text
    // TODO: move to text change / resize event handler, make elided a member
    if (elideMode() != Qt::ElideNone)
    {
        QFontMetrics fm = fontMetrics();
        if (!wordWrap())
        {
            // single line elide
            elided = fm.elidedText(text(), elideMode(), textWidth);
        }
        else if (elideMode() == Qt::ElideRight)
        {
            // multiline elide
            srcLines = elided.split("\n");
            int pxPerLine = fm.lineSpacing();
            int lines = lr.height() / pxPerLine + 1;

            foreach (QString srcLine, srcLines)
            {
                int w = fm.width(srcLine);
                if (w >= textWidth)
                {
                    QStringList tmpList = srcLine.split(' ');
                    QString s;
                    int i = 0;
                    while (i < tmpList.count())
                    {
                        if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
                        {
                            if (!s.isEmpty())
                            {
                                dstLines += s;
                                s = QString::null;
                            }
                        }
                        if (!s.isEmpty())
                        {
                            s += " ";
                        }
                        s += tmpList.at(i);
                        i++;
                    }
                    dstLines += s;
                }
                else
                {
                    dstLines += srcLine;
                }
            }
Ejemplo n.º 2
0
void CTabBar::changeEvent(QEvent* event)
{
    if (event->type() == QEvent::StyleChange) {
        Qt::TextElideMode mode = elideMode();
        QTabBar::changeEvent(event);
        if (mode != elideMode())
            setElideMode(mode);
        return;
    }
    QTabBar::changeEvent(event);
}
Ejemplo n.º 3
0
int QTabBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Shape*>(_v) = shape(); break;
        case 1: *reinterpret_cast< int*>(_v) = currentIndex(); break;
        case 2: *reinterpret_cast< int*>(_v) = count(); break;
        case 3: *reinterpret_cast< bool*>(_v) = drawBase(); break;
        case 4: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 5: *reinterpret_cast< Qt::TextElideMode*>(_v) = elideMode(); break;
        case 6: *reinterpret_cast< bool*>(_v) = usesScrollButtons(); break;
        case 7: *reinterpret_cast< bool*>(_v) = tabsClosable(); break;
        case 8: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehaviorOnRemove(); break;
        case 9: *reinterpret_cast< bool*>(_v) = expanding(); break;
        case 10: *reinterpret_cast< bool*>(_v) = isMovable(); break;
        case 11: *reinterpret_cast< bool*>(_v) = documentMode(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setShape(*reinterpret_cast< Shape*>(_v)); break;
        case 1: setCurrentIndex(*reinterpret_cast< int*>(_v)); break;
        case 3: setDrawBase(*reinterpret_cast< bool*>(_v)); break;
        case 4: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 5: setElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 6: setUsesScrollButtons(*reinterpret_cast< bool*>(_v)); break;
        case 7: setTabsClosable(*reinterpret_cast< bool*>(_v)); break;
        case 8: setSelectionBehaviorOnRemove(*reinterpret_cast< SelectionBehavior*>(_v)); break;
        case 9: setExpanding(*reinterpret_cast< bool*>(_v)); break;
        case 10: setMovable(*reinterpret_cast< bool*>(_v)); break;
        case 11: setDocumentMode(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
int QTabBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: currentChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: selected((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: setCurrentIndex((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: setCurrentTab((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: d_func()->_q_scrollTabs(); break;
        }
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Shape*>(_v) = shape(); break;
        case 1: *reinterpret_cast< int*>(_v) = currentIndex(); break;
        case 2: *reinterpret_cast< int*>(_v) = count(); break;
        case 3: *reinterpret_cast< bool*>(_v) = drawBase(); break;
        case 4: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 5: *reinterpret_cast< Qt::TextElideMode*>(_v) = elideMode(); break;
        case 6: *reinterpret_cast< bool*>(_v) = usesScrollButtons(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setShape(*reinterpret_cast< Shape*>(_v)); break;
        case 1: setCurrentIndex(*reinterpret_cast< int*>(_v)); break;
        case 3: setDrawBase(*reinterpret_cast< bool*>(_v)); break;
        case 4: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 5: setElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 6: setUsesScrollButtons(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 5
0
void TabBar::pinTab()
{
    WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab));
    if (!webTab) {
        return;
    }

    webTab->pinTab(m_clickedTab);

    if (webTab->isPinned()) {
        m_pinnedTabsCount++;
    }
    else {
        m_pinnedTabsCount--;
    }

    // We need to recalculate size of all tabs and repaint tabbar
    // Unfortunately, Qt doesn't offer refresh() function as a public API

    // So we are calling the lightest function that calls d->refresh()
    setElideMode(elideMode());
}
Ejemplo n.º 6
0
int QDeclarativeText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 3: *reinterpret_cast< TextStyle*>(_v) = style(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = styleColor(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< bool*>(_v) = truncated(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumLineCount(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< TextElideMode*>(_v) = elideMode(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 15: *reinterpret_cast< qreal*>(_v) = lineHeight(); break;
        case 16: *reinterpret_cast< LineHeightMode*>(_v) = lineHeightMode(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 2: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setStyle(*reinterpret_cast< TextStyle*>(_v)); break;
        case 4: setStyleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 10: setMaximumLineCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setElideMode(*reinterpret_cast< TextElideMode*>(_v)); break;
        case 15: setLineHeight(*reinterpret_cast< qreal*>(_v)); break;
        case 16: setLineHeightMode(*reinterpret_cast< LineHeightMode*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        case 10: resetMaximumLineCount(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 7
0
void FancyTabProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *widget) const
{

    const QStyleOptionTabV3 *v3Opt = qstyleoption_cast<const QStyleOptionTabV3*>(option);

    if (element != CE_TabBarTab || !v3Opt) {
        QProxyStyle::drawControl(element, option, p, widget);
        return;
    }

    const QRect rect = v3Opt->rect;
    const bool selected = v3Opt->state  &State_Selected;
    const bool verticalTabs = v3Opt->shape == QTabBar::RoundedWest;
    const QString text = v3Opt->text;

    QTransform m;
    if (verticalTabs) {
        m = QTransform::fromTranslate(rect.left(), rect.bottom());
        m.rotate(-90);
    } else {
        m = QTransform::fromTranslate(rect.left(), rect.top());
    }

    const QRect draw_rect(QPoint(0, 0), m.mapRect(rect).size());

    if (!selected && GtkStyle::isActive()) {
        p->fillRect(option->rect, option->palette.background());
    }

    p->save();
    p->setTransform(m);

    QRect iconRect(QPoint(8, 0), v3Opt->iconSize);
    QRect textRect(iconRect.topRight() + QPoint(4, 0), draw_rect.size());
    textRect.setRight(draw_rect.width());
    iconRect.translate(0, (draw_rect.height() - iconRect.height()) / 2);

    QStyleOptionViewItemV4 styleOpt;
    styleOpt.palette=option->palette;
    styleOpt.rect=draw_rect;
    if (QStyleOptionTab::Beginning==v3Opt->position) {
        styleOpt.rect.adjust(0, 0, -1, 0);
    }
    styleOpt.state=option->state;
    styleOpt.state&=~(QStyle::State_Selected|QStyle::State_MouseOver);
    styleOpt.state|=QStyle::State_Selected|QStyle::State_Enabled;
    styleOpt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
    styleOpt.showDecorationSelected=true;
    bool drawBgnd=true;
    int fader = 1;

    if (!selected && drawBgnd) {
        const QString faderKey = "tab_" + text + "_fader";
        const QString animationKey = "tab_" + text + "_animation";

        const QString tab_hover = widget->property("tab_hover").toString();
        fader=widget->property(faderKey.toUtf8().constData()).toInt();
        QPropertyAnimation *animation = widget->property(animationKey.toUtf8().constData()).value<QPropertyAnimation*>();

        if (!animation) {
            QWidget* mut_widget = const_cast<QWidget*>(widget);
            fader = 0;
            mut_widget->setProperty(faderKey.toUtf8().constData(), fader);
            animation = new QPropertyAnimation(mut_widget, faderKey.toUtf8(), mut_widget);
            connect(animation, SIGNAL(valueChanged(QVariant)), mut_widget, SLOT(update()));
            mut_widget->setProperty(animationKey.toUtf8().constData(), QVariant::fromValue(animation));
        }

        if (text == tab_hover) {
            if (animation->state() != QAbstractAnimation::Running && fader != 40) {
                animation->stop();
                animation->setDuration(80);
                animation->setEndValue(50);
                animation->start();
            }
        } else {
            if (animation->state() != QAbstractAnimation::Running && fader != 0) {
                animation->stop();
                animation->setDuration(160);
                animation->setEndValue(0);
                animation->start();
            }
        }

        if (fader<1) {
            drawBgnd=false;
        } else {
            QColor col(styleOpt.palette.highlight().color());
            col.setAlpha(fader);
            styleOpt.palette.setColor(styleOpt.palette.currentColorGroup(), QPalette::Highlight, col);
        }
    }

    if (drawBgnd) {
        if (!selected && GtkStyle::isActive()) {
            GtkStyle::drawSelection(styleOpt, p, (fader*1.0)/150.0);
        } else {
            #ifdef Q_OS_MAC
            OSXStyle::self()->drawSelection(styleOpt, p, selected ? 1.0 : (fader*1.0)/150.0);
            #else
            #ifdef Q_OS_WIN
            if (QPalette::Active!=styleOpt.palette.currentColorGroup()) {
                styleOpt.palette.setColor(QPalette::Highlight, styleOpt.palette.color(QPalette::Window).darker(110));
            }
            #endif
            QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &styleOpt, p, 0);
            #endif
        }
    }

    int textFlags = Qt::AlignTop | Qt::AlignVCenter;
    #ifdef Q_OS_MAC
    p->setPen(selected && option->state&State_Active
              ? OSXStyle::self()->viewPalette().highlightedText().color() : OSXStyle::self()->viewPalette().foreground().color());
    #else
    p->setPen(selected && option->state&State_Active
              ? QApplication::palette().highlightedText().color() : QApplication::palette().foreground().color());
    #endif

    drawIcon(v3Opt->icon, iconRect, p, v3Opt->iconSize,
             selected && option->state&State_Active);

    QString txt=text;
    txt.replace("&", "");
    txt=p->fontMetrics().elidedText(txt, elideMode(), textRect.width());
    p->drawText(textRect.translated(0, -1), textFlags, txt);
    p->restore();
}
Ejemplo n.º 8
0
	void M11TabBar::paintEvent(QPaintEvent*)
	{
		QStyleOptionTab tabOverlap;
		tabOverlap.shape = shape();
		int overlap = style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, this);
		QWidget *theParent = parentWidget();
		QStyleOptionTabBarBase optTabBase;
		optTabBase.init(this);
		optTabBase.shape = shape();
		if (theParent && overlap > 0) {
			QRect rect;
			switch (tabOverlap.shape) {
			case M11TabBar::RoundedNorth:
			case M11TabBar::TriangularNorth:
				rect.setRect(0, height() - overlap, width(), overlap);
				break;
			case M11TabBar::RoundedSouth:
			case M11TabBar::TriangularSouth:
				rect.setRect(0, 0, width(), overlap);
				break;
			case M11TabBar::RoundedEast:
			case M11TabBar::TriangularEast:
				rect.setRect(0, 0, overlap, height());
				break;
			case M11TabBar::RoundedWest:
			case M11TabBar::TriangularWest:
				rect.setRect(width() - overlap, 0, overlap, height());
				break;
			}
			optTabBase.rect = rect;
		}

		QStylePainter p(this);
		p.fillRect(rect(), Utils::instance().gradientTopToBottom(rect()));
		QPen pen = p.pen();

		int selected = -1;
		int cut = -1;
		bool rtl = optTabBase.direction == Qt::RightToLeft;
		bool verticalTabs = (shape() == M11TabBar::RoundedWest || shape() == M11TabBar::RoundedEast
		                     || shape() == M11TabBar::TriangularWest
		                     || shape() == M11TabBar::TriangularEast);
		QStyleOptionTab cutTab;
		QStyleOptionTab selectedTab;
		for (int i = 0; i < count(); ++i) {
			QStyleOptionTabV2 tab = getStyleOption(i);
			if (!(tab.state & QStyle::State_Enabled)) {
				tab.palette.setCurrentColorGroup(QPalette::Disabled);
			}
			// If this tab is partially obscured, make a note of it so that we can pass the information
			// along when we draw the tear.
			if ((!verticalTabs && (!rtl && tab.rect.left() < 0) ||
			     (rtl && tab.rect.right() > width())) ||
			    (verticalTabs && tab.rect.top() < 0)) {
				cut = i;
				cutTab = tab;
			}
			// Don't bother drawing a tab if the entire tab is outside of the visible tab bar.
			if ((!verticalTabs && (tab.rect.right() < 0 || tab.rect.left() > width()))
			    || (verticalTabs && (tab.rect.bottom() < 0 || tab.rect.top() > height())))
				continue;

			optTabBase.tabBarRect |= tab.rect;
			if (i == currentIndex()) {
				selected = i;
				selectedTab = tab;
				optTabBase.selectedTabRect = tab.rect;
			}

			QIcon icon = tabIcon(i);
			QSize iconSize = icon.actualSize(QSize(tab.rect.height(), tab.rect.height()));
			int iconMargin = (tab.rect.height() - iconSize.height()) / 2;
			QRect iconRect(tab.rect.left() + iconMargin, tab.rect.top(), iconSize.width(), tab.rect.height());
			QString text = tabText(i);
			QRect textRect(
			    tab.rect.left() + iconMargin + iconSize.width(),
			    tab.rect.top(),
			    tab.rect.width() - iconSize.width(),
			    tab.rect.height()
			);

			p.fillRect(
			    tab.rect,
			    i == currentIndex() ?
			    Utils::instance().palette().base() :
			    tab.rect.contains(mapFromGlobal(QCursor::pos())) ?
			    Utils::instance().palette().light() : Utils::instance().gradientTopToBottom(tab.rect)
			);

			p.setPen(Utils::instance().palette().dark().color());

			switch (shape()) { // override the widget's border to make it consistent over inactive tabs
			case M11TabBar::RoundedNorth:
			case M11TabBar::TriangularNorth:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, 0, -1, 0));
				}
				else {
					p.drawLine(tab.rect.bottomLeft(), tab.rect.bottomRight());
				}
				break;
			case M11TabBar::RoundedSouth:
			case M11TabBar::TriangularSouth:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, -1, -1, -1));
				}
				else {
					p.drawLine(tab.rect.topLeft(), tab.rect.topRight());
				}
				break;
			case M11TabBar::RoundedEast:
			case M11TabBar::TriangularEast:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(-1, 0, -1, -1));
				}
				else {
					p.drawLine(tab.rect.topLeft(), tab.rect.bottomLeft());
				}
				break;
			case M11TabBar::RoundedWest:
			case M11TabBar::TriangularWest:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, 0, 0, -1));
				}
				else {
					p.drawLine(tab.rect.topRight(), tab.rect.bottomRight());
				}
				break;
			default:
				Q_ASSERT(false);
				break;
			}

			p.setPen(m_tabLabelColors.contains(i) ? m_tabLabelColors.value(i).color() : pen);

			QString textToDraw = fontMetrics().elidedText(
			                         text,
			                         elideMode(),
			                         1 + (
			                             verticalTabs ? tabRect(i).height() : tabRect(i).width()
			                         ) - style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &tab, this),
			                         Qt::TextShowMnemonic
			                     );

			p.drawItemPixmap(iconRect, Qt::AlignCenter, icon.pixmap(iconSize));

			p.drawItemText(
			    textRect,
			    Qt::AlignLeft | Qt::AlignVCenter,
			    QPalette(),
			    tab.state & QStyle::State_Enabled,
			    textToDraw
			);

			p.setPen(pen);
		}

		if (!drawBase()) {
			p.setBackgroundMode(Qt::TransparentMode);
		}
		else {
			// p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
		}

		// Only draw the tear indicator if necessary. Most of the time we don't need too.
		if (cut >= 0) {
			cutTab.rect = rect();
			cutTab.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicator, &cutTab, this);
			p.drawPrimitive(QStyle::PE_IndicatorTabTear, cutTab);
		}

		// p.setPen(Qt::black);
		// p.drawRect(rect());
	}
Ejemplo n.º 9
0
void CustomLabel::paintEvent(QPaintEvent * pe)
{
	if ((!text().isEmpty()) &&
			(textFormat() == Qt::PlainText ||
			 (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
	{
		QPainter painter(this);
		QRectF lr = contentsRect();
		lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
		QStyleOption opt;
		opt.initFrom(this);
		int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
		int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
		if (wordWrap())
			flags |= Qt::TextWordWrap;
		switch (shadowType)
		{
		case NoShadow:
			flags |= TF_NOSHADOW;
			break;
		case DarkShadow:
			flags |= TF_DARKSHADOW;
			break;
		case LightShadow:
			flags |= TF_LIGHTSHADOW;
			break;
		default:
			break;
		}
		QString textToDraw = text();
		int textWidth = lr.width();
		// eliding text
		// TODO: move to text change / resize event handler, make textToDraw a member
		if (elideMode() != Qt::ElideNone)
		{
			QFontMetrics fm = fontMetrics();
			if (!wordWrap())
			{
				textToDraw = fm.elidedText(text(), elideMode(), textWidth);
			}
			else if (elideMode() == Qt::ElideRight)
			{
				// multiline elide
				int pxPerLine = fontMetrics().lineSpacing();
				int lines = lr.height() / pxPerLine + 1;
#ifdef DEBUG_ENABLED
//				if (lines > 1)
//				{
//					qDebug() << pxPerLine << lines << lr << fm.height() << font().toString();
//				}
#endif
#ifdef Q_WS_MAC // mac hack, dunno why
				//lines--;
				// TODO: debug this!!!
#endif
				QStringList srcLines = text().split("\n");
				QStringList dstLines;
				foreach (QString srcLine, srcLines)
				{
					int w = fm.width(srcLine);
					if (w >= textWidth)
					{
						QStringList tmpList = srcLine.split(' ');
						QString s;
						int i = 0;
						while (i < tmpList.count())
						{
							if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
							{
								if (!s.isEmpty())
								{
									dstLines += s;
									s = QString::null;
								}
							}
							if (!s.isEmpty())
							{
								s += " ";
							}
							s += tmpList.at(i);
							i++;
						}
						dstLines += s;
					}
					else
					{
						dstLines += srcLine;
					}
				}