diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-22 09:19:12 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-22 09:19:12 (GMT) |
commit | dab883be81f6037361e5c870d957686961515f4e (patch) | |
tree | 1aa67b8652108c74467da9e4bea411c15d85745c /src/gui/text | |
parent | f25f7a2a19ba4c21b7a5d9fee02a9ae71c9f60ef (diff) | |
parent | 9462e7966b5b7db20249c9cb077f425c631afebf (diff) | |
download | Qt-dab883be81f6037361e5c870d957686961515f4e.zip Qt-dab883be81f6037361e5c870d957686961515f4e.tar.gz Qt-dab883be81f6037361e5c870d957686961515f4e.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase_win.cpp | 14 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 21 | ||||
-rw-r--r-- | src/gui/text/qstatictext_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 26 | ||||
-rw-r--r-- | src/gui/text/qtextcursor.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 19 |
6 files changed, 64 insertions, 19 deletions
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp index b30a6c3..c50d363 100644 --- a/src/gui/text/qfontdatabase_win.cpp +++ b/src/gui/text/qfontdatabase_win.cpp @@ -336,8 +336,18 @@ void addFontToDatabase(QString familyName, const QString &scriptName, signature->fsCsb[0], signature->fsCsb[1] }; QList<QFontDatabase::WritingSystem> systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); - for (int i = 0; i < systems.count(); ++i) - family->writingSystems[systems.at(i)] = QtFontFamily::Supported; + + for (int i = 0; i < systems.count(); ++i) { + QFontDatabase::WritingSystem writingSystem = systems.at(i); + + // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains + // the symbol for Baht, and Windows thus reports that it supports the Thai script. + // Since it's the default UI font on this platform, most widgets will be unable to + // display Thai text by default. As a temporary work around, we special case Segoe UI + // and remove the Thai script from its list of supported writing systems. + if (writingSystem != QFontDatabase::Thai || familyName != QLatin1String("Segoe UI")) + family->writingSystems[writingSystem] = QtFontFamily::Supported; + } } else if (!family->writingSystemCheck) { //qDebug("family='%s' script=%s", family->name.latin1(), script.latin1()); if (scriptName == QLatin1String("Western") diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 9313e65..952d998 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -384,11 +384,11 @@ namespace { DrawTextItemRecorder(int expectedItemCount, QStaticTextItem *items, int expectedGlyphCount, QFixedPoint *positionPool, glyph_t *glyphPool) : m_items(items), + m_itemCount(0), m_glyphCount(0), m_expectedItemCount(expectedItemCount), m_expectedGlyphCount(expectedGlyphCount), - m_itemCount(0), m_glyphCount(0), - m_positionPool(positionPool), - m_glyphPool(glyphPool) + m_glyphPool(glyphPool), + m_positionPool(positionPool) { } @@ -530,7 +530,7 @@ namespace { }; } -void QStaticTextPrivate::paintText(QPainter *p) +void QStaticTextPrivate::paintText(const QPointF &pos, QPainter *p) { bool preferRichText = textFormat == Qt::RichText || (textFormat == Qt::AutoText && Qt::mightBeRichText(text)); @@ -538,13 +538,13 @@ void QStaticTextPrivate::paintText(QPainter *p) if (!preferRichText) { if (maximumSize.isValid()) { QRectF boundingRect; - p->drawText(QRectF(QPointF(0, 0), maximumSize), Qt::TextWordWrap, text, &boundingRect); + p->drawText(QRectF(pos, maximumSize), Qt::TextWordWrap, text, &boundingRect); actualSize = boundingRect.size(); needsClipRect = boundingRect.width() > maximumSize.width() || boundingRect.height() > maximumSize.height(); } else { - p->drawText(0, 0, text); + p->drawText(pos, text); needsClipRect = false; QFontMetrics fm(font); @@ -555,9 +555,12 @@ void QStaticTextPrivate::paintText(QPainter *p) document.setDefaultFont(font); document.setHtml(text); - QRectF rect = maximumSize.isValid() ? QRectF(QPointF(0, 0), maximumSize) : QRectF(); + QRectF rect = maximumSize.isValid() ? QRectF(pos, maximumSize) : QRectF(); document.adjustSize(); + p->save(); + p->translate(pos); document.drawContents(p, rect); + p->restore(); actualSize = document.size(); needsClipRect = maximumSize.isValid() && (actualSize.width() > maximumSize.width() @@ -581,7 +584,7 @@ void QStaticTextPrivate::init() painter.setFont(font); painter.setTransform(matrix); - paintText(&painter); + paintText(QPointF(0, 0), &painter); } @@ -605,7 +608,7 @@ void QStaticTextPrivate::init() painter.setFont(font); painter.setTransform(matrix); - paintText(&painter); + paintText(QPointF(0, 0), &painter); } } diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 89483d8..e758244 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -116,7 +116,7 @@ public: ~QStaticTextPrivate(); void init(); - void paintText(QPainter *p); + void paintText(const QPointF &pos, QPainter *p); QAtomicInt ref; // 4 bytes per text diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c81d538..c91df3c 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1145,7 +1145,7 @@ void QTextCursor::setPosition(int pos, MoveMode m) Returns the absolute position of the cursor within the document. The cursor is positioned between characters. - \sa setPosition() movePosition() anchor() + \sa setPosition() movePosition() anchor() positionInBlock() */ int QTextCursor::position() const { @@ -1155,6 +1155,22 @@ int QTextCursor::position() const } /*! + \since 4.7 + Returns the relative position of the cursor within the block. + The cursor is positioned between characters. + + This is equivalent to \c{ position() - block().position()}. + + \sa position() +*/ +int QTextCursor::positionInBlock() const +{ + if (!d || !d->priv) + return 0; + return d->position - d->block().position(); +} + +/*! Returns the anchor position; this is the same as position() unless there is a selection in which case position() marks one end of the selection and anchor() marks the other end. Just like the cursor @@ -2414,9 +2430,17 @@ int QTextCursor::blockNumber() const return d->block().blockNumber(); } + /*! \since 4.2 Returns the position of the cursor within its containing line. + + Note that this is the column number relative to a wrapped line, + not relative to the block (i.e. the paragraph). + + You probably want to call positionInBlock() instead. + + \sa positionInBlock() */ int QTextCursor::columnNumber() const { diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 38bc39d..3e968a3 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -89,6 +89,7 @@ public: void setPosition(int pos, MoveMode mode = MoveAnchor); int position() const; + int positionInBlock() const; int anchor() const; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 44e6ba5..9a1b70c 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -435,16 +435,23 @@ void QTextDocument::redo(QTextCursor *cursor) } } +/*! \enum QTextDocument::Stacks + + \value UndoStack The undo stack. + \value RedoStack The redo stack. + \value UndoAndRedoStacks Both the undo and redo stacks. +*/ + /*! \since 4.7 - Clears the specified stacks. + Clears the stacks specified by \a stacksToClear. - This method clears any commands on the undo stack, the redo stack, or both (the - default). If any commands got cleared, the appropriate signals - (\a QTextDocument::undoAvailable or \a QTextDocument::redoAvailable) get - emitted. + This method clears any commands on the undo stack, the redo stack, + or both (the default). If commands are cleared, the appropriate + signals are emitted, QTextDocument::undoAvailable() or + QTextDocument::redoAvailable(). - \sa QTextDocument::undoAvailable QTextDocument::redoAvailable + \sa QTextDocument::undoAvailable() QTextDocument::redoAvailable() */ void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear) { |