summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-15 05:42:44 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-15 05:42:44 (GMT)
commit40b11de259b6bdaf43ca9ccd0abd9106321a5616 (patch)
tree4dc235e775cf34454fe89b5e464b1293a091478f /src/gui/text
parent7390cfbcbd5000a7da3eb5dbef790d114b06d042 (diff)
parent9b07418b408d1858390add4a443ba5f3621a998f (diff)
downloadQt-40b11de259b6bdaf43ca9ccd0abd9106321a5616.zip
Qt-40b11de259b6bdaf43ca9ccd0abd9106321a5616.tar.gz
Qt-40b11de259b6bdaf43ca9ccd0abd9106321a5616.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixed error reporting in grayraster and reduced default pool size. Add QTextOption API to QStaticText
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qstatictext.cpp34
-rw-r--r--src/gui/text/qstatictext.h5
-rw-r--r--src/gui/text/qstatictext_p.h6
3 files changed, 39 insertions, 6 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 10870aa..c742455 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -324,6 +324,26 @@ QStaticText::PerformanceHint QStaticText::performanceHint() const
}
/*!
+ Sets the text option structure that controls the layout process to the given \a textOption.
+
+ \sa textOption()
+*/
+void QStaticText::setTextOption(const QTextOption &textOption)
+{
+ detach();
+ data->textOption = textOption;
+ data->invalidate();
+}
+
+/*!
+ Returns the current text option used to control the layout process.
+*/
+QTextOption QStaticText::textOption() const
+{
+ return data->textOption;
+}
+
+/*!
Sets the preferred width for this QStaticText. If the text is wider than the specified width,
it will be broken into multiple lines and grow vertically. If the text cannot be split into
multiple lines, it will be larger than the specified \a textWidth.
@@ -580,6 +600,7 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p)
QTextLayout textLayout;
textLayout.setText(text);
textLayout.setFont(font);
+ textLayout.setTextOption(textOption);
qreal leading = QFontMetricsF(font).leading();
qreal height = -leading;
@@ -610,21 +631,26 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p)
.arg(QString::number(color.blue(), 16), 2, QLatin1Char('0')));
#endif
document.setDefaultFont(font);
- document.setDocumentMargin(0.0);
- if (textWidth >= 0.0)
- document.setTextWidth(textWidth);
+ document.setDocumentMargin(0.0);
#ifndef QT_NO_TEXTHTMLPARSER
document.setHtml(text);
#else
document.setPlainText(text);
#endif
+ if (textWidth >= 0.0)
+ document.setTextWidth(textWidth);
+ else
+ document.adjustSize();
+ document.setDefaultTextOption(textOption);
- document.adjustSize();
p->save();
p->translate(topLeftPosition);
document.drawContents(p);
p->restore();
+ if (textWidth >= 0.0)
+ document.adjustSize(); // Find optimal size
+
actualSize = document.size();
}
}
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index f3bef93..4febde2 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -48,7 +48,7 @@
#include <QtGui/qtransform.h>
#include <QtGui/qfont.h>
-
+#include <QtGui/qtextoption.h>
QT_BEGIN_HEADER
@@ -79,6 +79,9 @@ public:
void setTextWidth(qreal textWidth);
qreal textWidth() const;
+ void setTextOption(const QTextOption &textOption);
+ QTextOption textOption() const;
+
QSizeF size() const;
void prepare(const QTransform &matrix = QTransform(), const QFont &font = QFont());
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 1a96291..cb60626 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -53,6 +53,8 @@
// We mean it.
//
+#include "qstatictext.h"
+
#include <private/qtextureglyphcache_p.h>
#include <QtGui/qcolor.h>
@@ -148,12 +150,14 @@ public:
QFixedPoint *positionPool; // 4 bytes per text
QChar *charPool; // 4 bytes per text
+ QTextOption textOption; // 28 bytes per text
+
unsigned char needsRelayout : 1; // 1 byte per text
unsigned char useBackendOptimizations : 1;
unsigned char textFormat : 2;
unsigned char untransformedCoordinates : 1;
// ================
- // 167 bytes per text
+ // 195 bytes per text
static QStaticTextPrivate *get(const QStaticText *q);
};