equal
deleted
inserted
replaced
87 if (!line.justified && line.width != QFIXED_MAX) { |
87 if (!line.justified && line.width != QFIXED_MAX) { |
88 int align = eng->option.alignment(); |
88 int align = eng->option.alignment(); |
89 if (align & Qt::AlignJustify && eng->option.textDirection() == Qt::RightToLeft) |
89 if (align & Qt::AlignJustify && eng->option.textDirection() == Qt::RightToLeft) |
90 align = Qt::AlignRight; |
90 align = Qt::AlignRight; |
91 if (align & Qt::AlignRight) |
91 if (align & Qt::AlignRight) |
92 x = line.width - (line.textAdvance + leadingSpaceWidth(eng, line)); |
92 x = line.width - (line.textWidth + leadingSpaceWidth(eng, line)); |
93 else if (align & Qt::AlignHCenter) |
93 else if (align & Qt::AlignHCenter) |
94 x = (line.width - line.textAdvance)/2; |
94 x = (line.width - line.textWidth)/2; |
95 } |
95 } |
96 return x; |
96 return x; |
97 } |
97 } |
98 |
98 |
99 /*! |
99 /*! |
303 QTextLayout can be used to create a sequence of QTextLine's with |
303 QTextLayout can be used to create a sequence of QTextLine's with |
304 given widths and can position them independently on the screen. |
304 given widths and can position them independently on the screen. |
305 Once the layout is done, these lines can be drawn on a paint |
305 Once the layout is done, these lines can be drawn on a paint |
306 device. |
306 device. |
307 |
307 |
308 Here's some pseudo code that presents the layout phase: |
308 Here's some code snippet that presents the layout phase: |
309 \snippet doc/src/snippets/code/src_gui_text_qtextlayout.cpp 0 |
309 \snippet doc/src/snippets/code/src_gui_text_qtextlayout.cpp 0 |
310 |
310 |
311 The text can be drawn by calling the layout's draw() function: |
311 The text can be drawn by calling the layout's draw() function: |
312 \snippet doc/src/snippets/code/src_gui_text_qtextlayout.cpp 1 |
312 \snippet doc/src/snippets/code/src_gui_text_qtextlayout.cpp 1 |
313 |
313 |
1566 by layout() without changing the line break position. |
1566 by layout() without changing the line break position. |
1567 */ |
1567 */ |
1568 qreal QTextLine::naturalTextWidth() const |
1568 qreal QTextLine::naturalTextWidth() const |
1569 { |
1569 { |
1570 return eng->lines[i].textWidth.toReal(); |
1570 return eng->lines[i].textWidth.toReal(); |
|
1571 } |
|
1572 |
|
1573 /*! \since 4.7 |
|
1574 Returns the horizontal advance of the text. The advance of the text |
|
1575 is the distance from its position to the next position at which |
|
1576 text would naturally be drawn. |
|
1577 |
|
1578 By adding the advance to the position of the text line and using this |
|
1579 as the position of a second text line, you will be able to position |
|
1580 the two lines side-by-side without gaps in-between. |
|
1581 */ |
|
1582 qreal QTextLine::horizontalAdvance() const |
|
1583 { |
|
1584 return eng->lines[i].textAdvance.toReal(); |
1571 } |
1585 } |
1572 |
1586 |
1573 /*! |
1587 /*! |
1574 Lays out the line with the given \a width. The line is filled from |
1588 Lays out the line with the given \a width. The line is filled from |
1575 its starting position with as many characters as will fit into |
1589 its starting position with as many characters as will fit into |