Qt 4.8
Public Functions | Properties | Friends | List of all members
QTextInlineObject Class Reference

The QTextInlineObject class represents an inline object in a QTextLayout. More...

#include <qtextlayout.h>

Public Functions

qreal ascent () const
 Returns the inline object's ascent. More...
 
qreal descent () const
 Returns the inline object's descent. More...
 
QTextFormat format () const
 Returns format of the inline object within the text layout. More...
 
int formatIndex () const
 Returns an integer describing the format of the inline object within the text layout. More...
 
qreal height () const
 Returns the inline object's total height. More...
 
bool isValid () const
 Returns true if this inline object is valid; otherwise returns false. More...
 
 QTextInlineObject (int i, QTextEngine *e)
 Creates a new inline object for the item at position i in the text engine e. More...
 
 QTextInlineObject ()
 
QRectF rect () const
 Returns the inline object's rectangle. More...
 
void setAscent (qreal a)
 Sets the inline object's ascent to a. More...
 
void setDescent (qreal d)
 Sets the inline object's decent to d. More...
 
void setWidth (qreal w)
 Sets the inline object's width to w. More...
 
Qt::LayoutDirection textDirection () const
 Returns if the object should be laid out right-to-left or left-to-right. More...
 
int textPosition () const
 The position of the inline object within the text layout. More...
 
qreal width () const
 Returns the inline object's width. More...
 

Properties

QTextEngineeng
 
int itm
 

Friends

class QTextLayout
 

Detailed Description

The QTextInlineObject class represents an inline object in a QTextLayout.

Note
This class or function is reentrant.

This class is only used if the text layout is used to lay out parts of a QTextDocument.

The inline object has various attributes that can be set, for example using, setWidth(), setAscent(), and setDescent(). The rectangle it occupies is given by rect(), and its direction by isRightToLeft(). Its position in the text layout is given by at(), and its format is given by format().

Definition at line 69 of file qtextlayout.h.

Constructors and Destructors

◆ QTextInlineObject() [1/2]

QTextInlineObject::QTextInlineObject ( int  i,
QTextEngine e 
)
inline

Creates a new inline object for the item at position i in the text engine e.

Definition at line 72 of file qtextlayout.h.

72 : itm(i), eng(e) {}
QTextEngine * eng
Definition: qtextlayout.h:96

◆ QTextInlineObject() [2/2]

QTextInlineObject::QTextInlineObject ( )
inline
Warning
This function is not part of the public interface.

Definition at line 73 of file qtextlayout.h.

Referenced by QTextLine::draw(), and QTextLine::layout_helper().

73 : itm(0), eng(0) {}
QTextEngine * eng
Definition: qtextlayout.h:96

Functions

◆ ascent()

qreal QTextInlineObject::ascent ( ) const

Returns the inline object's ascent.

See also
descent(), width(), rect()

Definition at line 184 of file qtextlayout.cpp.

185 {
186  return eng->layoutData->items[itm].ascent.toReal();
187 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

◆ descent()

qreal QTextInlineObject::descent ( ) const

Returns the inline object's descent.

See also
ascent(), width(), rect()

Definition at line 194 of file qtextlayout.cpp.

Referenced by QTextLayout::drawCursor().

195 {
196  return eng->layoutData->items[itm].descent.toReal();
197 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

◆ format()

QTextFormat QTextInlineObject::format ( ) const

Returns format of the inline object within the text layout.

Definition at line 260 of file qtextlayout.cpp.

Referenced by QTextLine::draw(), and QTextLine::layout_helper().

261 {
262  if (!eng->block.docHandle())
263  return QTextFormat();
264  return eng->formats()->format(eng->formatIndex(&eng->layoutData->items[itm]));
265 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
QTextFormat format(int idx) const
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
QTextBlock block
int formatIndex(const QScriptItem *si) const
QTextDocumentPrivate * docHandle() const
Definition: qtextobject.h:283
QTextFormatCollection * formats() const

◆ formatIndex()

int QTextInlineObject::formatIndex ( ) const

Returns an integer describing the format of the inline object within the text layout.

Definition at line 252 of file qtextlayout.cpp.

253 {
254  return eng->formatIndex(&eng->layoutData->items[itm]);
255 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
int formatIndex(const QScriptItem *si) const

◆ height()

qreal QTextInlineObject::height ( ) const

Returns the inline object's total height.

This is equal to ascent() + descent() + 1.

See also
ascent(), descent(), width(), rect()

Definition at line 205 of file qtextlayout.cpp.

Referenced by QTextLine::draw().

206 {
207  return eng->layoutData->items[itm].height().toReal();
208 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

◆ isValid()

bool QTextInlineObject::isValid ( ) const
inline

Returns true if this inline object is valid; otherwise returns false.

Definition at line 74 of file qtextlayout.h.

74 { return eng; }
QTextEngine * eng
Definition: qtextlayout.h:96

◆ rect()

QRectF QTextInlineObject::rect ( ) const

Returns the inline object's rectangle.

See also
ascent(), descent(), width()

Definition at line 163 of file qtextlayout.cpp.

Referenced by addSelectedRegionsToPath().

164 {
166  return QRectF(0, -si.ascent.toReal(), si.width.toReal(), si.height().toReal());
167 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QFixed height() const
qreal toReal() const
Definition: qfixed_p.h:77

◆ setAscent()

void QTextInlineObject::setAscent ( qreal  a)

Sets the inline object's ascent to a.

See also
ascent(), setDescent(), width(), rect()

Definition at line 225 of file qtextlayout.cpp.

Referenced by QTextDocumentLayout::resizeInlineObject(), and QAbstractTextDocumentLayout::resizeInlineObject().

226 {
227  eng->layoutData->items[itm].ascent = QFixed::fromReal(a);
228 }
QScriptItemArray items
long ASN1_INTEGER_get ASN1_INTEGER * a
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70

◆ setDescent()

void QTextInlineObject::setDescent ( qreal  d)

Sets the inline object's decent to d.

See also
descent(), setAscent(), width(), rect()

Definition at line 235 of file qtextlayout.cpp.

Referenced by QTextDocumentLayout::resizeInlineObject(), and QAbstractTextDocumentLayout::resizeInlineObject().

236 {
237  eng->layoutData->items[itm].descent = QFixed::fromReal(d);
238 }
double d
Definition: qnumeric_p.h:62
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70

◆ setWidth()

void QTextInlineObject::setWidth ( qreal  w)

Sets the inline object's width to w.

See also
width(), ascent(), descent(), rect()

Definition at line 215 of file qtextlayout.cpp.

Referenced by QTextDocumentLayout::resizeInlineObject(), and QAbstractTextDocumentLayout::resizeInlineObject().

216 {
217  eng->layoutData->items[itm].width = QFixed::fromReal(w);
218 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70

◆ textDirection()

Qt::LayoutDirection QTextInlineObject::textDirection ( ) const

Returns if the object should be laid out right-to-left or left-to-right.

Definition at line 270 of file qtextlayout.cpp.

271 {
272  return (eng->layoutData->items[itm].analysis.bidiLevel % 2 ? Qt::RightToLeft : Qt::LeftToRight);
273 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

◆ textPosition()

int QTextInlineObject::textPosition ( ) const

The position of the inline object within the text layout.

Definition at line 243 of file qtextlayout.cpp.

244 {
245  return eng->layoutData->items[itm].position;
246 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

◆ width()

qreal QTextInlineObject::width ( ) const

Returns the inline object's width.

See also
ascent(), descent(), rect()

Definition at line 174 of file qtextlayout.cpp.

Referenced by QTextLine::draw(), QTextLine::naturalTextRect(), and QTextDocumentLayout::positionInlineObject().

175 {
176  return eng->layoutData->items[itm].width.toReal();
177 }
QScriptItemArray items
QTextEngine * eng
Definition: qtextlayout.h:96
LayoutData * layoutData

Friends and Related Functions

◆ QTextLayout

friend class QTextLayout
friend

Definition at line 94 of file qtextlayout.h.

Properties

◆ eng

QTextEngine* QTextInlineObject::eng
private

◆ itm

int QTextInlineObject::itm
private

The documentation for this class was generated from the following files: