Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QPainter::drawText ( const QPointF position,
const QString text 
) [inherited]

Draws the given text with the currently defined text direction, beginning at the given position.

This function does not break text into multiple lines. Use the QPainter::drawText() overload that takes a rectangle instead if you want line breaking.

Definition at line 4456 of file qpainter.cpp.

References QByteArray::constData(), QPainter::drawTextItem(), QPainter::isActive(), QString::isEmpty(), QPainter::pen(), QPen::style(), QString::toLatin1(), QPointF::x(), and QPointF::y().

Referenced by QPainter::boundingRect(), Q3CanvasText::draw(), QCommonStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QSplashScreen::drawContents(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), QCleanlooksStyle::drawItemText(), QStyle::drawItemText(), QPainter::drawText(), QPicture::exec(), Q3ListBoxPixmap::paint(), Q3CheckTableItem::paint(), Q3TableItem::paint(), Q3ComboTableItem::paint(), Q3ListBoxText::paint(), Q3ListViewItem::paintCell(), QStatusBar::paintEvent(), Q3ComboBox::paintEvent(), Q3DataTable::paintField(), and Q3IconViewItem::paintItem().

{
#ifdef QT_DEBUG_DRAW
    if (qt_show_painter_debug_output)
        printf("QPainter::drawText(), pos=[%.2f,%.2f], str='%s'\n", p.x(), p.y(), str.toLatin1().constData());
#endif

    if (!isActive() || str.isEmpty() || pen().style() == Qt::NoPen)
        return;

    Q_D(QPainter);

    QStackTextEngine engine(str, d->state->font);
    engine.option.setTextDirection(d->state->layoutDirection);
    engine.itemize();

    int nItems = engine.layoutData->items.size();
    QVarLengthArray<int> visualOrder(nItems);
    QVarLengthArray<uchar> levels(nItems);
    for (int i = 0; i < nItems; ++i)
        levels[i] = engine.layoutData->items[i].analysis.bidiLevel;
    QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());

    QFixed x = QFixed::fromReal(p.x());
    QFixed ox = x;

    for (int i = 0; i < nItems; ++i) {
        int item = visualOrder[i];
        const QScriptItem &si = engine.layoutData->items.at(item);
        engine.shape(item);
        if (si.isObject || si.isTab) {
            if (si.isTab)
                x = engine.nextTab(&si, x - ox) + ox;
            else
                x += si.width;
            continue;
        }
        QTextItemInt gf(si, &d->state->font);
        gf.num_glyphs = si.num_glyphs;
        gf.glyphs = engine.glyphs(&si);
        gf.chars = engine.layoutData->string.unicode() + si.position;
        gf.num_chars = engine.length(item);
        gf.width = si.width;
        gf.logClusters = engine.logClusters(&si);

        drawTextItem(QPointF(x.toReal(), p.y()), gf);

        x += si.width;
    }
}


Generated by  Doxygen 1.6.0   Back to index