Qt 4.8
Public Functions | Public Variables | List of all members
QTextLineItemIterator Struct Reference

#include <qtextengine_p.h>

Public Functions

bool atBeginning () const
 
bool atEnd () const
 
bool getSelectionBounds (QFixed *selectionX, QFixed *selectionWidth) const
 
bool isOutsideSelection () const
 
QScriptItemnext ()
 
 QTextLineItemIterator (QTextEngine *eng, int lineNum, const QPointF &pos=QPointF(), const QTextLayout::FormatRange *_selection=0)
 

Public Variables

QTextEngineeng
 
int firstItem
 
int glyphsEnd
 
int glyphsStart
 
int item
 
int itemEnd
 
int itemLength
 
int itemStart
 
QFixed itemWidth
 
int lastItem
 
QVarLengthArray< ucharlevels
 
const QScriptLineline
 
int lineEnd
 
int lineNum
 
int logicalItem
 
int nItems
 
QFixed pos_x
 
const QTextLayout::FormatRangeselection
 
QScriptItemsi
 
QVarLengthArray< int > visualOrder
 
QFixed x
 

Detailed Description

Definition at line 661 of file qtextengine_p.h.

Constructors and Destructors

◆ QTextLineItemIterator()

QTextLineItemIterator::QTextLineItemIterator ( QTextEngine eng,
int  lineNum,
const QPointF pos = QPointF(),
const QTextLayout::FormatRange _selection = 0 
)

Definition at line 3189 of file qtextengine.cpp.

3191  : eng(_eng),
3192  line(eng->lines[_lineNum]),
3193  si(0),
3194  lineNum(_lineNum),
3196  firstItem(eng->findItem(line.from)),
3197  lastItem(eng->findItem(lineEnd - 1)),
3198  nItems((firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0),
3199  logicalItem(-1),
3200  item(-1),
3202  levels(nItems),
3203  selection(_selection)
3204 {
3205  pos_x = x = QFixed::fromReal(pos.x());
3206 
3207  x += line.x;
3208 
3209  x += eng->alignLine(line);
3210 
3211  for (int i = 0; i < nItems; ++i)
3212  levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
3214 
3215  eng->shapeLine(line);
3216 }
QVarLengthArray< uchar > levels
int findItem(int strPos) const
QScriptItemArray items
LayoutData * layoutData
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
QVarLengthArray< int > visualOrder
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void shapeLine(const QScriptLine &line)
static void bidiReorder(int numRuns, const quint8 *levels, int *visualOrder)
const QTextLayout::FormatRange * selection
QScriptLineArray lines
QFixed alignLine(const QScriptLine &line)
signed int length
const QScriptLine & line

Functions

◆ atBeginning()

bool QTextLineItemIterator::atBeginning ( ) const
inline

Definition at line 667 of file qtextengine_p.h.

Referenced by QTextEngine::insertionPointsForLine().

667 { return logicalItem <= 0; }

◆ atEnd()

bool QTextLineItemIterator::atEnd ( ) const
inline

◆ getSelectionBounds()

bool QTextLineItemIterator::getSelectionBounds ( QFixed selectionX,
QFixed selectionWidth 
) const

Definition at line 3258 of file qtextengine.cpp.

Referenced by addSelectedRegionsToPath().

3259 {
3260  *selectionX = *selectionWidth = 0;
3261 
3262  if (!selection)
3263  return false;
3264 
3267  || si->position + itemLength <= selection->start)
3268  return false;
3269 
3270  *selectionX = x;
3271  *selectionWidth = itemWidth;
3272  } else {
3273  unsigned short *logClusters = eng->logClusters(si);
3274  QGlyphLayout glyphs = eng->shapedGlyphs(si);
3275 
3276  int from = qMax(itemStart, selection->start) - si->position;
3277  int to = qMin(itemEnd, selection->start + selection->length) - si->position;
3278  if (from >= to)
3279  return false;
3280 
3281  int start_glyph = logClusters[from];
3282  int end_glyph = (to == eng->length(item)) ? si->num_glyphs : logClusters[to];
3283  QFixed soff;
3284  QFixed swidth;
3285  if (si->analysis.bidiLevel %2) {
3286  for (int g = glyphsEnd - 1; g >= end_glyph; --g)
3287  soff += glyphs.effectiveAdvance(g);
3288  for (int g = end_glyph - 1; g >= start_glyph; --g)
3289  swidth += glyphs.effectiveAdvance(g);
3290  } else {
3291  for (int g = glyphsStart; g < start_glyph; ++g)
3292  soff += glyphs.effectiveAdvance(g);
3293  for (int g = start_glyph; g < end_glyph; ++g)
3294  swidth += glyphs.effectiveAdvance(g);
3295  }
3296 
3297  // If the starting character is in the middle of a ligature,
3298  // selection should only contain the right part of that ligature
3299  // glyph, so we need to get the width of the left part here and
3300  // add it to *selectionX
3301  QFixed leftOffsetInLigature = eng->offsetInLigature(si, from, to, start_glyph);
3302  *selectionX = x + soff + leftOffsetInLigature;
3303  *selectionWidth = swidth - leftOffsetInLigature;
3304  // If the ending character is also part of a ligature, swidth does
3305  // not contain that part yet, we also need to find out the width of
3306  // that left part
3307  *selectionWidth += eng->offsetInLigature(si, to, eng->length(item), end_glyph);
3308  }
3309  return true;
3310 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos)
int start
Specifies the beginning of the format range within the text layout&#39;s text.
Definition: qtextlayout.h:129
unsigned short * logClusters(const QScriptItem *si) const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QGlyphLayout shapedGlyphs(const QScriptItem *si) const
unsigned short bidiLevel
unsigned short num_glyphs
const QTextLayout::FormatRange * selection
unsigned short flags
int length(int item) const
if(void) toggleToolbarShown
QFixed effectiveAdvance(int item) const
int length
Specifies the numer of characters the format range spans.
Definition: qtextlayout.h:130
QScriptAnalysis analysis

◆ isOutsideSelection()

bool QTextLineItemIterator::isOutsideSelection ( ) const
inline

Definition at line 671 of file qtextengine_p.h.

Referenced by QTextLine::draw().

671  {
672  QFixed tmp1, tmp2;
673  return !getSelectionBounds(&tmp1, &tmp2);
674  }
bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const

◆ next()

QScriptItem & QTextLineItemIterator::next ( )

Definition at line 3218 of file qtextengine.cpp.

Referenced by addSelectedRegionsToPath(), QTextLine::draw(), QTextLine::glyphs(), and QTextEngine::insertionPointsForLine().

3219 {
3220  x += itemWidth;
3221 
3222  ++logicalItem;
3224  itemLength = eng->length(item);
3225  si = &eng->layoutData->items[item];
3226  if (!si->num_glyphs)
3227  eng->shape(item);
3228 
3230  itemWidth = si->width;
3231  return *si;
3232  }
3233 
3234  unsigned short *logClusters = eng->logClusters(si);
3235  QGlyphLayout glyphs = eng->shapedGlyphs(si);
3236 
3238  glyphsStart = logClusters[itemStart - si->position];
3239  if (lineEnd < si->position + itemLength) {
3240  itemEnd = lineEnd;
3241  glyphsEnd = logClusters[itemEnd-si->position];
3242  } else {
3244  glyphsEnd = si->num_glyphs;
3245  }
3246  // show soft-hyphen at line-break
3247  if (si->position + itemLength >= lineEnd
3248  && eng->layoutData->string.at(lineEnd - 1) == 0x00ad)
3249  glyphs.attributes[glyphsEnd - 1].dontPrint = false;
3250 
3251  itemWidth = 0;
3252  for (int g = glyphsStart; g < glyphsEnd; ++g)
3253  itemWidth += glyphs.effectiveAdvance(g);
3254 
3255  return *si;
3256 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QScriptItemArray items
LayoutData * layoutData
unsigned short * logClusters(const QScriptItem *si) const
QVarLengthArray< int > visualOrder
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
for(int ii=mo->methodOffset();ii< mo->methodCount();++ii)
QGlyphLayout shapedGlyphs(const QScriptItem *si) const
unsigned short num_glyphs
unsigned short flags
void shape(int item) const
int length(int item) const
QFixed effectiveAdvance(int item) const
HB_GlyphAttributes * attributes
const QScriptLine & line
QScriptAnalysis analysis

Properties

◆ eng

QTextEngine* QTextLineItemIterator::eng

Definition at line 676 of file qtextengine_p.h.

Referenced by getSelectionBounds(), next(), and QTextLineItemIterator().

◆ firstItem

int QTextLineItemIterator::firstItem

Definition at line 685 of file qtextengine_p.h.

Referenced by next(), and QTextLineItemIterator().

◆ glyphsEnd

int QTextLineItemIterator::glyphsEnd

Definition at line 693 of file qtextengine_p.h.

Referenced by QTextLine::draw(), getSelectionBounds(), QTextLine::glyphs(), and next().

◆ glyphsStart

int QTextLineItemIterator::glyphsStart

Definition at line 692 of file qtextengine_p.h.

Referenced by QTextLine::draw(), getSelectionBounds(), QTextLine::glyphs(), and next().

◆ item

int QTextLineItemIterator::item

◆ itemEnd

int QTextLineItemIterator::itemEnd

◆ itemLength

int QTextLineItemIterator::itemLength

Definition at line 690 of file qtextengine_p.h.

Referenced by next().

◆ itemStart

int QTextLineItemIterator::itemStart

◆ itemWidth

QFixed QTextLineItemIterator::itemWidth

Definition at line 697 of file qtextengine_p.h.

Referenced by QTextLine::draw(), getSelectionBounds(), and next().

◆ lastItem

int QTextLineItemIterator::lastItem

Definition at line 686 of file qtextengine_p.h.

◆ levels

QVarLengthArray<uchar> QTextLineItemIterator::levels

Definition at line 700 of file qtextengine_p.h.

Referenced by QTextLineItemIterator().

◆ line

const QScriptLine& QTextLineItemIterator::line

Definition at line 680 of file qtextengine_p.h.

Referenced by next(), and QTextLineItemIterator().

◆ lineEnd

int QTextLineItemIterator::lineEnd

Definition at line 684 of file qtextengine_p.h.

Referenced by next().

◆ lineNum

int QTextLineItemIterator::lineNum

Definition at line 683 of file qtextengine_p.h.

◆ logicalItem

int QTextLineItemIterator::logicalItem

Definition at line 688 of file qtextengine_p.h.

Referenced by next().

◆ nItems

int QTextLineItemIterator::nItems

Definition at line 687 of file qtextengine_p.h.

Referenced by QTextLineItemIterator().

◆ pos_x

QFixed QTextLineItemIterator::pos_x

Definition at line 679 of file qtextengine_p.h.

Referenced by QTextLineItemIterator().

◆ selection

const QTextLayout::FormatRange* QTextLineItemIterator::selection

Definition at line 702 of file qtextengine_p.h.

Referenced by getSelectionBounds().

◆ si

QScriptItem* QTextLineItemIterator::si

Definition at line 681 of file qtextengine_p.h.

Referenced by getSelectionBounds(), and next().

◆ visualOrder

QVarLengthArray<int> QTextLineItemIterator::visualOrder

Definition at line 699 of file qtextengine_p.h.

Referenced by next(), and QTextLineItemIterator().

◆ x

QFixed QTextLineItemIterator::x

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