107 not automatically be used for clipping. To achieve clipping in addition to line breaks, use |
107 not automatically be used for clipping. To achieve clipping in addition to line breaks, use |
108 QPainter::setClipRect(). The position of the text is decided by the argument passed to |
108 QPainter::setClipRect(). The position of the text is decided by the argument passed to |
109 QPainter::drawStaticText() and can change from call to call with a minimal impact on |
109 QPainter::drawStaticText() and can change from call to call with a minimal impact on |
110 performance. |
110 performance. |
111 |
111 |
112 QStaticText will attempt to guess the format of the input text using Qt::mightBeRichText(). |
112 For extra convenience, it is possible to apply formatting to the text using the HTML subset |
113 To force QStaticText to display its contents as either plain text or rich text, use the |
113 supported by QTextDocument. QStaticText will attempt to guess the format of the input text using |
114 function QStaticText::setTextFormat() and pass in, respectively, Qt::PlainText and |
114 Qt::mightBeRichText(), and interpret it as rich text if this function returns true. To force |
115 Qt::RichText. |
115 QStaticText to display its contents as either plain text or rich text, use the function |
|
116 QStaticText::setTextFormat() and pass in, respectively, Qt::PlainText and Qt::RichText. |
|
117 |
|
118 QStaticText can only represent text, so only HTML tags which alter the layout or appearance of |
|
119 the text will be respected. Adding an image to the input HTML, for instance, will cause the |
|
120 image to be included as part of the layout, affecting the positions of the text glyphs, but it |
|
121 will not be displayed. The result will be an empty area the size of the image in the output. |
|
122 Similarly, using tables will cause the text to be laid out in table format, but the borders |
|
123 will not be drawn. |
116 |
124 |
117 If it's the first time the static text is drawn, or if the static text, or the painter's font |
125 If it's the first time the static text is drawn, or if the static text, or the painter's font |
118 has been altered since the last time it was drawn, the text's layout has to be |
126 has been altered since the last time it was drawn, the text's layout has to be |
119 recalculated. On some paint engines, changing the matrix of the painter will also cause the |
127 recalculated. On some paint engines, changing the matrix of the painter will also cause the |
120 layout to be recalculated. In particular, this will happen for any engine except for the |
128 layout to be recalculated. In particular, this will happen for any engine except for the |
390 { |
398 { |
391 } |
399 } |
392 |
400 |
393 QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) |
401 QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) |
394 : text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix), |
402 : text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix), |
395 items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0), needsRelayout(true), |
403 items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0), textOption(other.textOption), |
396 useBackendOptimizations(other.useBackendOptimizations), textFormat(other.textFormat), |
404 needsRelayout(true), useBackendOptimizations(other.useBackendOptimizations), |
397 untransformedCoordinates(other.untransformedCoordinates) |
405 textFormat(other.textFormat), untransformedCoordinates(other.untransformedCoordinates) |
398 { |
406 { |
399 } |
407 } |
400 |
408 |
401 QStaticTextPrivate::~QStaticTextPrivate() |
409 QStaticTextPrivate::~QStaticTextPrivate() |
402 { |
410 { |
470 |
478 |
471 QChar *charsDestination = m_chars.data() + currentItem.charOffset; |
479 QChar *charsDestination = m_chars.data() + currentItem.charOffset; |
472 memcpy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); |
480 memcpy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); |
473 |
481 |
474 m_items.append(currentItem); |
482 m_items.append(currentItem); |
475 } |
483 } |
|
484 |
|
485 virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ) |
|
486 { |
|
487 /* intentionally empty */ |
|
488 } |
476 |
489 |
477 virtual bool begin(QPaintDevice *) { return true; } |
490 virtual bool begin(QPaintDevice *) { return true; } |
478 virtual bool end() { return true; } |
491 virtual bool end() { return true; } |
479 virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {} |
492 virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {} |
480 virtual Type type() const |
493 virtual Type type() const |