10#if QT_CONFIG(cssparser)
11#include "private/qcssutil_p.h"
13#include "private/qguiapplication_p.h"
26#include "private/qfunctions_p.h"
80 currentLayoutStruct(
nullptr), sizeDirty(true), layoutDirty(true)
124#ifndef QT_NO_CSSPARSER
154 return other < *
this;
217 Q_ASSERT(
v.userType() == QMetaType::Double ||
v.userType() == QMetaType::Float);
222#ifndef QT_NO_CSSPARSER
234#ifdef QT_NO_CSSPARSER
238#ifndef QT_NO_CSSPARSER
246#ifdef QT_NO_CSSPARSER
250#ifndef QT_NO_CSSPARSER
258#ifdef QT_NO_CSSPARSER
262#ifndef QT_NO_CSSPARSER
270#ifdef QT_NO_CSSPARSER
274#ifndef QT_NO_CSSPARSER
295 if (qobject_cast<QTextTable *>(
f))
299 f->setLayoutData(
data);
313 return f->firstPosition() >
f->lastPosition();
330 const int row = cell.
row();
331 const int rowSpan = cell.
rowSpan();
343 return !nextIt.
atEnd()
356 if (
it.currentFrame())
364 return qobject_cast<const QTextTable *>(previousFrame)
373 return qobject_cast<const QTextTable *>(previousFrame)
449 return checkPoint.
y <
y;
461 if (!gradientRect.isNull()) {
463 m.translate(gradientRect.left(), gradientRect.top());
464 m.scale(gradientRect.width(), gradientRect.height());
469 p->setBrushOrigin(origin);
511 const QTextBlock &bl,
bool inRootFrame)
const;
536 bool withPageBreaks);
571 : fixedColumnWidth(-1),
573 currentLazyLayoutPosition(-1),
574 lazyLayoutStepSize(1000),
588 || y < 0 || y >
data(rootFrame)->
size.height)
589 return rootFrame->
begin();
593 return rootFrame->
begin();
611 const int blockPos =
map.position(block);
616 if (containingFrame != rootFrame) {
617 while (containingFrame->
parentFrame() != rootFrame) {
622 it.cf = containingFrame;
638 const QFixedPoint relativePoint(point.
x -
fd->position.x, point.
y -
fd->position.y);
643 <<
"position" <<
fd->position.toPointF() <<
"size" <<
fd->size.toSizeF();
644 if (
frame != rootFrame) {
645 if (relativePoint.
y < 0 || relativePoint.
x < 0) {
649 }
else if (relativePoint.
y >
fd->size.height || relativePoint.
x >
fd->size.width) {
662 const int rows =
table->rows();
663 const int columns =
table->columns();
667 for (
int r = 0;
r < rows; ++
r) {
668 for (
int c = 0;
c < columns; ++
c) {
675 const QFixedPoint pointInCell = relativePoint - cellPos;
678 for (
int i = 0;
i < childFrames.
size(); ++
i) {
695 for (
int i = 0;
i < childFrames.
size(); ++
i) {
707 if (
frame == rootFrame) {
713 if (
it.currentFrame())
714 *
position =
it.currentFrame()->firstPosition();
725 for (; !
it.atEnd(); ++
it) {
900#ifndef QT_NO_CSSPARSER
914#ifndef QT_NO_CSSPARSER
930 if (turn_off_antialiasing)
937 const QBrush bg =
frame->frameFormat().background();
940 bgRect.
adjust((
fd->leftMargin +
fd->border).toReal(),
941 (
fd->topMargin +
fd->border).toReal(),
942 - (
fd->rightMargin +
fd->border).toReal(),
943 - (
fd->bottomMargin +
fd->border).toReal());
947 if (!
frame->parentFrame()) {
954 if (
fd->border != 0) {
959 const qreal leftEdge =
rect.left() +
fd->leftMargin.toReal();
961 const qreal topMargin =
fd->topMargin.toReal();
962 const qreal leftMargin =
fd->leftMargin.toReal();
963 const qreal bottomMargin =
fd->bottomMargin.toReal();
964 const qreal rightMargin =
fd->rightMargin.toReal();
969 fd->effectiveTopMargin.toReal(),
fd->effectiveBottomMargin.toReal(),
970 border,
frame->frameFormat().borderBrush(),
frame->frameFormat().borderStyle());
979 const int *selectedTableCells)
982 int row_start = selectedTableCells[
i * 4];
983 int col_start = selectedTableCells[
i * 4 + 1];
984 int num_rows = selectedTableCells[
i * 4 + 2];
985 int num_cols = selectedTableCells[
i * 4 + 3];
987 if (row_start != -1) {
988 if (
r >= row_start &&
r < row_start + num_rows
989 &&
c >= col_start &&
c < col_start + num_cols)
995 if (firstPosition == lastPosition)
998 cell_context.
selections[
i].cursor.setPosition(firstPosition);
1001 cell_context.
selections[
i].cursor.clearSelection();
1015#ifdef QT_NO_CSSPARSER
1025#ifndef QT_NO_CSSPARSER
1048 if (
fd->layoutDirty)
1058 && (off.
y() >
context.clip.bottom() || off.
y() +
fd->size.height.toReal() <
context.clip.top()
1059 || off.
x() >
context.clip.right() || off.
x() +
fd->size.width.toReal() <
context.clip.left()))
1067 QPointF offsetOfRepaintedCursorBlock = off;
1070 const QRectF frameRect(off,
fd->size.toSizeF());
1073 const int rows =
table->rows();
1074 const int columns =
table->columns();
1078 for (
int i = 0;
i <
context.selections.size(); ++
i) {
1080 int row_start = -1, col_start = -1, num_rows = -1, num_cols = -1;
1082 if (
s.cursor.currentTable() ==
table)
1083 s.cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
1085 selectedTableCells[
i * 4] = row_start;
1086 selectedTableCells[
i * 4 + 1] = col_start;
1087 selectedTableCells[
i * 4 + 2] = num_rows;
1088 selectedTableCells[
i * 4 + 3] = num_cols;
1092 if (pageHeight <= 0)
1097 while (parentFrame) {
1098 absYPos +=
data(parentFrame)->position.y;
1101 const int tableStartPage = (absYPos / pageHeight).truncate();
1102 const int tableEndPage = ((absYPos + td->
size.
height) / pageHeight).truncate();
1110 const int headerRowCount =
qMin(
table->format().headerRowCount(), rows - 1);
1111 int page = tableStartPage + 1;
1112 while (
page <= tableEndPage) {
1115 for (
int r = 0;
r < headerRowCount; ++
r) {
1116 for (
int c = 0;
c < columns; ++
c) {
1127 &offsetOfRepaintedCursorBlock);
1150 for (
int c = 0;
c < columns; ++
c) {
1152 firstRow =
qMin(firstRow, cell.
row());
1155 for (
int r = firstRow;
r < lastRow; ++
r) {
1156 for (
int c = 0;
c < columns; ++
c) {
1167 &offsetOfRepaintedCursorBlock);
1180 const int numFloats =
fd->floats.
size();
1182 for (
int i = 0;
i < numFloats; ++
i)
1188 if (cursorBlockNeedingRepaint.
isValid()) {
1191 const int cursorPos =
context.cursorPosition - cursorBlockNeedingRepaint.
position();
1200#ifndef QT_NO_CSSPARSER
1285 int col = cell.
column() + dc;
1286 int row = cell.
row() + dr;
1288 if (col < 0 || row < 0 || col >=
table->columns() ||
row >=
table->rows())
1313 return cell.
row() ==
1325 Q_UNREACHABLE_RETURN(
false);
1348 const bool outermost =
1382 bool mustCheckThirdCell =
false;
1414 if (mustCheckThirdCell)
1425 bool couldHaveContinuation,
1431 if (competingEdgeData > edgeData) {
1432 *maxCompetingEdgeData = competingEdgeData;
1433 }
else if (competingEdgeData.
width == edgeData.
width) {
1434 if ((
isSameAxis(edgeData.
edge, competingEdge) && couldHaveContinuation)
1436 *maxCompetingEdgeData = competingEdgeData;
1440 if (maxOrthogonalEdgeData && competingEdgeData.
width > maxOrthogonalEdgeData->
width)
1441 *maxOrthogonalEdgeData = competingEdgeData;
1447 return p->scaleToDevice(
w.width) / 2.0;
1492 bool couldHaveContinuation,
1493 bool ignoreEdgesAbove)
1511 &maxCompetingEdgeData, &maxOrthogonalEdgeData);
1517 if (competingCell.
isValid()) {
1519 &maxCompetingEdgeData,
nullptr);
1526 if (competingCell.
isValid() &&
sharesAxis(cell, orthogonalEdge, competingCell, orthogonalEdge)) {
1528 &maxCompetingEdgeData, &maxOrthogonalEdgeData);
1534 bool hasPriority = edgeData > maxCompetingEdgeData;
1541 return hasPriority ? 0 :
p->scaleToDevice(maxOrthogonalEdgeData.
width);
1564 int forceHeaderRow,
bool adjustTopAnchor,
bool adjustBottomAnchor,
1565 bool ignoreEdgesAbove)
1572 if (edgeData.
width == 0)
1580 borderStyle =
table->format().borderStyle();
1584 switch (edgeData.
edge) {
1587 borderStyle =
fmt.topBorderStyle();
1591 borderStyle =
fmt.bottomBorderStyle();
1595 borderStyle =
fmt.leftBorderStyle();
1599 borderStyle =
fmt.rightBorderStyle();
1615 if (forceHeaderRow != -1)
1616 cellOrHeader =
table->cellAt(forceHeaderRow, cell.
column());
1621 wv =
p->scaleToDevice(edgeData.
width);
1628 wv =
p->scaleToDevice(edgeData.
width);
1635 wh =
p->scaleToDevice(edgeData.
width);
1639 false, ignoreEdgesAbove))
1646 wh =
p->scaleToDevice(edgeData.
width);
1650 false, ignoreEdgesAbove))
1686#ifdef COLLAPSE_DEBUG
1700#ifndef QT_NO_CSSPARSER
1704 const int headerRowCount =
qMin(
table->format().headerRowCount(),
table->rows() - 1);
1705 if (headerRowCount > 0 && cell.
row() >= headerRowCount)
1720 const int lastHeaderRow =
table->format().headerRowCount() - 1;
1721 const bool tableHasHeader =
table->format().headerRowCount() > 0;
1722 const bool isHeaderRow = cell.
row() <
table->format().headerRowCount();
1723 const bool isFirstRow = cell.
row() == lastHeaderRow + 1;
1725 const bool previousRowOnPreviousPage = !isFirstRow
1729 topMarginAfterPageBreak,
1732 const bool nextRowOnNextPage = !isLastRow
1735 topMarginAfterPageBreak,
1738 const bool rowStartsOnPage =
page == paginator.
topPage;
1740 const bool rowStartsOnPageTop = !tableHasHeader
1742 && previousRowOnPreviousPage;
1743 const bool rowStartsOnPageBelowHeader = tableHasHeader
1745 && previousRowOnPreviousPage;
1748 ? !isHeaderRow && (!rowStartsOnPage || rowStartsOnPageBelowHeader)
1751 ? !isHeaderRow && (!rowEndsOnPage || nextRowOnNextPage)
1754 ? !tableHasHeader && !rowStartsOnPage
1756 const bool doNotAdjustBottomAnchor = suppressBottomBorder;
1758 if (!suppressTopBorder) {
1760 -1,
true,
true, rowStartsOnPageTop);
1764 suppressTopBorder ? lastHeaderRow : -1,
1765 !doNotAdjustTopAnchor,
1766 !doNotAdjustBottomAnchor,
1767 rowStartsOnPageTop);
1769 suppressTopBorder ? lastHeaderRow : -1,
1770 !doNotAdjustTopAnchor,
1771 !doNotAdjustBottomAnchor,
1772 rowStartsOnPageTop);
1774 if (!suppressBottomBorder) {
1776 -1,
true,
true,
false);
1780 if (turn_off_antialiasing)
1800 int cr = cell.
row();
1816 const int headerRowCount =
qMin(
table->format().headerRowCount(),
table->rows() - 1);
1817 if (
r >= headerRowCount)
1830 switch (cellBorder) {
1848 border,
table->format().borderBrush(), cellBorder);
1858 const int topPage = pageHeight > 0 ?
static_cast<int>(cellRect.
top() / pageHeight) : 0;
1859 const int bottomPage = pageHeight > 0 ?
static_cast<int>((cellRect.
bottom()) / pageHeight) : 0;
1861 if (topPage == bottomPage)
1864 for (
int i = topPage;
i <= bottomPage; ++
i) {
1867 if (topPage != bottomPage) {
1892 cellRect.
top() + (topPadding + verticalOffset).toReal());
1899 *cursorBlockNeedingRepaint = repaintBlock;
1900 *cursorBlockOffset = cellPos;
1911 const bool inRootFrame = (!
it.atEnd() &&
it.parentFrame() &&
it.parentFrame()->parentFrame() ==
nullptr);
1914 if (inRootFrame &&
context.clip.isValid()) {
1921 for (; !
it.atEnd(); ++
it) {
1925 int currentPosInDoc;
1927 currentPosInDoc =
c->firstPosition();
1929 currentPosInDoc =
it.currentBlock().position();
1938 && currentPosInDoc >= lastVisibleCheckPoint->positionInFrame
1961 *cursorBlockNeedingRepaint = previousBlock;
1964 previousBlock =
it.currentBlock();
1968 for (
int i = 0;
i < floats.
size(); ++
i) {
1974 const int pos =
frame->firstPosition() - 1;
1986 const QTextBlock &bl,
bool inRootFrame)
const
2006 rect.setRight((
fd->size.width -
fd->rightMargin).toReal());
2018 for (
int i = 0;
i <
context.selections.size(); ++
i) {
2020 const int selStart =
range.cursor.selectionStart() - blpos;
2021 const int selEnd =
range.cursor.selectionEnd() - blpos;
2022 if (selStart < bllen && selEnd > 0
2023 && selEnd > selStart) {
2026 o.length = selEnd - selStart;
2037 if (
o.start +
o.length == bllen - 1)
2042 if (selStart < 0 && selEnd >= 1)
2043 selFormat = &
range.format;
2059 && ((
context.cursorPosition >= blpos &&
context.cursorPosition < blpos + bllen)
2061 int cpos =
context.cursorPosition;
2077 y =
r.top() +
r.height() / 2;
2079 const qreal middleX =
r.left() +
r.width() / 2;
2095 if (
q->paintDevice())
2101 int style = lf.
style();
2109 if (
layout->lineCount() == 0)
2149 xoff = -xoff -
size.width();
2157 if (selectionFormat) {
2172 r.adjust(-adj, 0, -adj, 0);
2174 if (selectionFormat)
2194 layout.setCacheEnabled(
true);
2201 line.setLeadingIncluded(
true);
2237 if (
it.currentFrame()) {
2238 return data(
it.currentFrame())->position.y;
2242 if (
layout->lineCount() == 0)
2256 QFixed absoluteTableY,
bool withPageBreaks)
2258 qCDebug(lcTable) <<
"layoutCell";
2266 if (withPageBreaks) {
2280 if (layoutStruct.
pageHeight < 0 || !withPageBreaks)
2282 const int currentPage = layoutStruct.
currentPage();
2289#ifndef QT_NO_CSSPARSER
2290 const int headerRowCount =
t->format().headerRowCount();
2304 layoutStruct.
y =
qMax(layoutStruct.
y, pageTop);
2307 for (
int i = 0;
i < childFrames.
size(); ++
i) {
2321 for (
int i = 0;
i < childFrames.
size(); ++
i) {
2338 data(
t)->floats.clear();
2342 return layoutStruct;
2345#ifndef QT_NO_CSSPARSER
2348 qreal *outerBorders)
2351 if (
w.width > outerBorders[edge])
2352 outerBorders[edge] =
w.width;
2358 qCDebug(lcTable) <<
"layoutTable from" << layoutFrom <<
"to" << layoutTo <<
"parentY" << parentY;
2361 const int rows =
table->rows();
2362 const int columns =
table->columns();
2377 if (columnWidthConstraints.
size() != columns)
2378 columnWidthConstraints.
resize(columns);
2393#ifndef QT_NO_CSSPARSER
2398 outerBorders[
i] = 0;
2400 for (
int r = 0;
r < rows; ++
r) {
2402 for (
int c = 0;
c < columns; ++
c)
2405 if (
r == rows - 1) {
2406 for (
int c = 0;
c < columns; ++
c)
2429recalc_minmax_widths:
2433 remainingWidth -= columns * 2 * td->
borderCell;
2435 remainingWidth -= (columns - 1) * cellSpacing;
2437 remainingWidth -= 2 * cellSpacing;
2445 const QFixed initialTotalWidth = remainingWidth;
2460 for (
int i = 0;
i < columns; ++
i) {
2465 if (cspan > 1 &&
i != cell.
column())
2470 const QFixed widthPadding = leftPadding + rightPadding;
2476 layoutTo, td, absoluteTableY,
2481 for (
int n = 0;
n < cspan; ++
n) {
2482 const int col =
i +
n;
2483 QFixed w = widthToDistribute / (cspan -
n);
2487 if (widthToDistribute <= 0)
2507 widthToDistribute =
maxW;
2508 for (
int n = 0;
n < cspan; ++
n) {
2509 const int col =
i +
n;
2510 QFixed w = widthToDistribute / (cspan -
n);
2515 if (widthToDistribute <= 0)
2524 int variableCols = 0;
2525 QFixed totalMinWidth = 0;
2526 for (
int i = 0;
i < columns; ++
i) {
2531 qCDebug(lcTable) <<
"column" <<
i <<
"has width constraint" << td->
minWidths.
at(
i) <<
"px, remaining width now" << remainingWidth;
2539 qCDebug(lcTable) <<
"column" <<
i <<
"has variable width, min" << td->
minWidths.
at(
i) <<
"remaining width now" << remainingWidth;
2546 const QFixed totalPercentagedWidth = initialTotalWidth * totalPercentage / 100;
2547 QFixed remainingMinWidths = totalMinWidth;
2548 for (
int i = 0;
i < columns; ++
i) {
2553 const QFixed percentWidth = totalPercentagedWidth * allottedPercentage / totalPercentage;
2554 QFixed maxWidth = remainingWidth - remainingMinWidths;
2560 qCDebug(lcTable) <<
"column" <<
i <<
"has width constraint" << columnWidthConstraints.
at(
i).rawValue()
2561 <<
"%, allocated width" << td->
widths[
i] <<
"remaining width now" << remainingWidth;
2568 if (variableCols > 0 && remainingWidth > 0) {
2570 for (
int i = 0;
i < columns; ++
i)
2573 columnsWithProperMaxSize.
append(
i);
2575 QFixed lastRemainingWidth = remainingWidth;
2576 while (remainingWidth > 0) {
2577 for (
int k = 0; k < columnsWithProperMaxSize.
size(); ++k) {
2578 const int col = columnsWithProperMaxSize[k];
2579 const int colsLeft = columnsWithProperMaxSize.
size() - k;
2582 remainingWidth -=
w;
2584 if (remainingWidth == lastRemainingWidth)
2586 lastRemainingWidth = remainingWidth;
2589 if (remainingWidth > 0
2592 const QFixed widthPerAnySizedCol = remainingWidth / variableCols;
2593 for (
int col = 0; col < columns; ++col) {
2595 td->
widths[col] += widthPerAnySizedCol;
2606 for (
int i = 0;
i < columns; ++
i) {
2615 for (
int i = 1;
i < columns; ++
i)
2627 goto recalc_minmax_widths;
2640 bool haveRowSpannedCells =
false;
2644 cellHeights.
reserve(rows * columns);
2647 if (pageHeight <= 0)
2651 heightToDistribute.
resize(columns);
2654 const int headerRowCount =
qMin(
table->format().headerRowCount(), rows - 1);
2656 bool hasDroppedTable =
false;
2662 for (
int r = 0;
r < rows; ++
r) {
2665 const int tableStartPage = (absoluteTableY / pageHeight).truncate();
2666 const int currentPage = ((td->
rowPositions.
at(
r) + absoluteTableY) / pageHeight).truncate();
2669 const QFixed nextPageTop = pageTop + pageHeight;
2676 bool dropRowToNextPage =
true;
2677 int cellCountBeforeRow = cellHeights.
size();
2687 if (r <= headerRowCount && rowStartPage > tableStartPage && !hasDroppedTable) {
2689 cellHeights.
clear();
2691 hasDroppedTable =
true;
2696 int rowCellCount = 0;
2697 for (
int c = 0;
c < columns; ++
c) {
2699 const int rspan = cell.
rowSpan();
2702 if (cspan > 1 && cell.
column() !=
c)
2706 haveRowSpannedCells =
true;
2708 const int cellRow = cell.
row();
2711 if (cellRow + rspan - 1 ==
r)
2721 const QFixed widthPadding = leftPadding + rightPadding;
2727 layoutFrom, layoutTo,
2731 const QFixed height = (layoutStruct.
y + bottomPadding + topPadding).round();
2734 heightToDistribute[
c] =
height + dropDistance;
2738 cellHeights.
append(layoutStruct.
y);
2741 if (childPos < pageBottom)
2742 dropRowToNextPage =
false;
2745 if (rowCellCount > 0 && dropRowToNextPage) {
2749 dropRowToNextPage =
false;
2750 cellHeights.
resize(cellCountBeforeRow);
2751 if (
r > headerRowCount)
2756 if (haveRowSpannedCells) {
2758 for (
int c = 0;
c < columns; ++
c)
2759 heightToDistribute[
c] =
qMax(heightToDistribute.
at(
c) - effectiveHeight - dropDistance,
QFixed(0));
2762 if (
r == headerRowCount - 1) {
2775 for (
int r = 0;
r < rows; ++
r) {
2776 for (
int c = 0;
c < columns; ++
c) {
2781 const int rowSpan = cell.
rowSpan();
2790 offset = (availableHeight - cellHeight) / 2;
2793 offset = availableHeight - cellHeight;
2800 for (
int cd = 0; cd < cell.
columnSpan(); ++cd) {
2801 const int index = (
c + cd) + (
r +
rd) * columns;
2809 for (
int i = 0;
i < columns; ++
i) {
2815 for (
int i = 0;
i < columns; ++
i) {
2841 fd->layoutDirty =
true;
2857 bool frameSpansIntoNextPage = (
y + layoutStruct->
frameY +
fd->size.height > layoutStruct->
pageBottom);
2858 if (frameSpansIntoNextPage &&
fd->size.height <= layoutStruct->
pageHeight) {
2860 y = layoutStruct->
y;
2862 frameSpansIntoNextPage =
false;
2865 y =
findY(
y, layoutStruct,
fd->size.width);
2874 fd->position.x =
right -
fd->size.width;
2882 fd->layoutDirty =
false;
2886 if (qobject_cast<QTextTable *>(
frame) !=
nullptr)
2887 fd->sizeDirty = frameSpansIntoNextPage;
2892 qCDebug(lcLayout,
"layoutFrame (%d--%d), parent=%p",
f->firstPosition(),
f->lastPosition(),
f->parentFrame());
2915 qCDebug(lcLayout,
"layoutFrame (%d--%d), parent=%p",
f->firstPosition(),
f->lastPosition(),
f->parentFrame());
2921 bool fullLayout =
false;
2926 if (tm !=
fd->topMargin) {
2931 if (bm !=
fd->bottomMargin) {
2932 fd->bottomMargin = bm;
2938 if (
b !=
fd->border) {
2943 if (
p !=
fd->padding) {
2956 if (qobject_cast<QTextTable *>(
parent)) {
2962 fd->effectiveTopMargin =
fd->topMargin +
fd->border +
fd->padding;
2963 fd->effectiveBottomMargin =
fd->bottomMargin +
fd->border +
fd->padding;
2966 newContentsWidth = frameWidth - 2*(
fd->border +
fd->padding)
2967 -
fd->leftMargin -
fd->rightMargin;
2969 if (frameHeight != -1) {
2970 fd->contentsHeight = frameHeight - 2*(
fd->border +
fd->padding)
2971 -
fd->topMargin -
fd->bottomMargin;
2973 fd->contentsHeight = frameHeight;
2983 fd->contentsWidth = newContentsWidth;
2990 fd->contentsWidth = newContentsWidth;
2994 layoutStruct.
x_left =
fd->leftMargin +
fd->border +
fd->padding;
2995 layoutStruct.
x_right = layoutStruct.
x_left + newContentsWidth;
2996 layoutStruct.
y =
fd->topMargin +
fd->border +
fd->padding;
2997 layoutStruct.
frameY = parentY +
fd->position.y;
3001 layoutStruct.
fullLayout = fullLayout || (
fd->oldContentsWidth != newContentsWidth);
3003 qCDebug(lcLayout) <<
"layoutStruct: x_left" << layoutStruct.
x_left <<
"x_right" << layoutStruct.
x_right
3005 fd->oldContentsWidth = newContentsWidth;
3016 if (!
f->parentFrame())
3022 QFixed maxChildFrameWidth = 0;
3027 maxChildFrameWidth =
qMax(maxChildFrameWidth, cd->
size.
width);
3030 const QFixed marginWidth = 2*(
fd->border +
fd->padding) +
fd->leftMargin +
fd->rightMargin;
3031 if (!
f->parentFrame()) {
3037 fd->contentsWidth = actualWidth;
3038 if (newContentsWidth <= 0) {
3039 fd->contentsWidth = newContentsWidth;
3045 fd->size.height =
fd->contentsHeight == -1
3046 ? layoutStruct.
y +
fd->border +
fd->padding +
fd->bottomMargin
3047 :
fd->contentsHeight + 2*(
fd->border +
fd->padding) +
fd->topMargin +
fd->bottomMargin;
3048 fd->size.width = actualWidth + marginWidth;
3049 fd->sizeDirty =
false;
3058 qCDebug(lcLayout) <<
"layoutFlow from=" << layoutFrom <<
"to=" << layoutTo;
3061 fd->currentLayoutStruct = layoutStruct;
3069 if (!redoCheckPoints) {
3075 layoutStruct->
y = checkPoint->y;
3076 layoutStruct->
frameY = checkPoint->frameY;
3094 redoCheckPoints =
true;
3098 if (redoCheckPoints) {
3101 cp.
y = layoutStruct->
y;
3113 QFixed maximumBlockWidth = 0;
3118 if (
it.currentFrame())
3119 docPos =
it.currentFrame()->firstPosition();
3121 docPos =
it.currentBlock().position();
3129 p.y = layoutStruct->
y;
3130 p.frameY = layoutStruct->
frameY;
3131 p.positionInFrame = docPos;
3191 absoluteChildPos += layoutStruct->
frameY;
3194 if (absoluteChildPos > layoutStruct->
pageBottom) {
3196 pos.y = layoutStruct->
y;
3241 if (frameRect == oldFrameRect && updateRect.
isValid())
3244 updateRect = frameRect;
3258 if (!previousIt.
atEnd() && previousIt !=
it)
3259 lastIt = previousIt;
3269 const QFixed origY = layoutStruct->
y;
3276 previousBlockFormatPtr = &previousBlockFormat;
3279 layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr);
3303 layoutStruct->
y = origY;
3314 if (layoutStruct->
pageBottom == origPageBottom) {
3319 layoutStruct->
y = origY -
height;
3321 layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr);
3324 if (
layout->lineCount() > 0) {
3328 layout->lineAt(0).setPosition(linePos -
layout->position());
3338 previousBlockFormat = blockFormat;
3349 if (!qobject_cast<QTextTable *>(layoutStruct->
frame)) {
3354 layoutStruct->
y =
qMax(layoutStruct->
y,
fd->position.y +
fd->size.height);
3361 if (!
fd->floats.isEmpty())
3368 cp.
y = layoutStruct->
y;
3383 fd->currentLayoutStruct =
nullptr;
3396 *lineBreakHeight = *lineBottom;
3404 *lineAdjustment = 0;
3416 const int blockLength = bl.
length();
3418 qCDebug(lcLayout) <<
"layoutBlock from=" << layoutFrom <<
"to=" << layoutTo
3421 if (previousBlockFormat) {
3423 if (margin > 0 &&
q->paintDevice()) {
3447 || (blockPosition + blockLength > layoutFrom && blockPosition <= layoutTo)
3451 qCDebug(lcLayout) <<
"do layout";
3470 const QFixed cy = layoutStruct->
y;
3471 const QFixed l = layoutStruct->
x_left + totalLeftMargin;
3476 bool firstLine =
true;
3479 if (!
line.isValid())
3481 line.setLeadingIncluded(
true);
3491 left += text_indent;
3493 right -= text_indent;
3508 left += text_indent;
3510 right -= text_indent;
3518 if (haveWordOrAnyWrapMode) {
3530 left += text_indent;
3532 right -= text_indent;
3535 if (haveWordOrAnyWrapMode) {
3543 QFixed lineBreakHeight, lineHeight, lineAdjustment, lineBottom;
3561 left += text_indent;
3563 right -= text_indent;
3566 line.setPosition(
QPointF((
left - layoutStruct->
x_left).toReal(), (layoutStruct->
y - cy - lineAdjustment).toReal()));
3567 bottom = layoutStruct->
y + lineBottom;
3568 layoutStruct->
y += lineHeight;
3584 for (
int i = 0;
i < cnt; ++
i) {
3585 qCDebug(lcLayout) <<
"going to move text line" <<
i;
3590 QFixed lineBreakHeight, lineHeight, lineAdjustment, lineBottom;
3600 bottom = layoutStruct->
y + lineBottom;
3601 layoutStruct->
y += lineHeight;
3605 && blockLength > 1) {
3606 if (layoutFrom >= blockPosition + blockLength) {
3611 }
else if (layoutTo < blockPosition) {
3625 const QFixed margins = totalLeftMargin + totalRightMargin;
3647 if (!
fd->layoutDirty) {
3648 if (
fd->position.y <=
y &&
fd->position.y +
fd->size.height >
y) {
3663 requiredWidth =
qMin(requiredWidth, layoutStruct->
x_right - layoutStruct->
x_left);
3677 if (!
fd->layoutDirty) {
3678 if (
fd->position.y <= yFrom &&
fd->position.y +
fd->size.height > yFrom)
3679 newY =
qMin(newY,
fd->position.y +
fd->size.height);
3708 d->ensureLayoutFinished();
3712 if (
d->document->pageSize().width() == 0 &&
d->viewportRect.isValid()) {
3719 d->clipRect =
QRectF(
fd->position.toPointF(),
fd->size.toSizeF()).
adjusted(
fd->leftMargin.toReal(), 0, -
fd->rightMargin.toReal(), 0);
3739 fd->floats.removeAll(
nullptr);
3741 fd->layoutDirty =
true;
3742 fd->sizeDirty =
true;
3746 for (
int i = 0;
i < children.
size(); ++
i)
3757 endIt = endIt.
next();
3758 for (; blockIt.
isValid() && blockIt != endIt; blockIt = blockIt.
next())
3761 if (!
d->docPrivate->canLayout())
3766 d->lazyLayoutStepSize = 1000;
3767 d->sizeChangedTimer.stop();
3768 d->insideDocumentChange =
true;
3770 const int documentLength =
d->docPrivate->length();
3771 const bool fullLayout = (oldLength == 0 &&
length == documentLength);
3772 const bool smallChange = documentLength > 0
3773 && (
qMax(
length, oldLength) * 100 / documentLength) < 5;
3780 && (
d->currentLazyLayoutPosition == -1 ||
d->showLayoutProgress ==
false))
3781 d->showLayoutProgress =
false;
3783 d->showLayoutProgress =
true;
3786 d->contentHasAlignment =
false;
3787 d->currentLazyLayoutPosition = 0;
3788 d->checkPoints.clear();
3791 d->ensureLayoutedByPosition(from);
3792 updateRect = doLayout(from, oldLength,
length);
3795 if (!
d->layoutTimer.isActive() &&
d->currentLazyLayoutPosition != -1)
3796 d->layoutTimer.start(10,
this);
3798 d->insideDocumentChange =
false;
3800 if (
d->showLayoutProgress) {
3802 if (newSize !=
d->lastReportedSize) {
3803 d->lastReportedSize = newSize;
3816QRectF QTextDocumentLayout::doLayout(
int from,
int oldLength,
int length)
3828 if (
data(root)->sizeDirty)
3829 updateRect =
d->layoutFrame(root, from, from +
length);
3830 data(root)->layoutDirty =
false;
3832 if (
d->currentLazyLayoutPosition == -1)
3834 else if (
d->showLayoutProgress)
3835 d->sizeChangedTimer.start(0,
this);
3855 int lastPos =
f->lastPosition();
3878 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3880 pos =
frame->frameFormat().position();
3882 fd->sizeDirty =
false;
3884 fd->minimumWidth =
fd->maximumWidth =
fd->size.width;
3892 qreal halfX =
m.xHeight()/2.;
3893 item.setAscent((inlineSize.
height() + halfX) / 2.);
3894 item.setDescent((inlineSize.
height() - halfX) / 2.);
3905 if (
item.width() != 0)
3915 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3921 if (
b.position() <=
frame->firstPosition() &&
b.position() +
b.length() >
frame->lastPosition())
3922 line =
b.layout()->lineAt(
b.layout()->lineCount()-1);
3934 QTextFrame *
frame = qobject_cast<QTextFrame *>(
d->document->objectForFormat(
f));
3945 const QSizeF pgSize =
d->document->pageSize();
3954 return data(
d->docPrivate->rootFrame())->size.toSizeF();
3960 d->ensureLayoutFinished();
3967 d->ensureLayoutFinished();
3976 const QSizeF oldSize =
q->dynamicDocumentSize();
4014 return d->cursorWidth;
4020 d->fixedColumnWidth =
width;
4039 if (!
d->docPrivate->canLayout())
4041 d->ensureLayoutFinished();
4044 const int framePos =
table->firstPosition();
4048 pos +=
fd->position.toPointF();
4058 f =
f->parentFrame();
4066 if (!
d->docPrivate->canLayout())
4068 d->ensureLayoutFinished();
4069 return d->frameBoundingRectInternal(
frame);
4075 const int framePos =
frame->firstPosition();
4079 pos +=
fd->position.toPointF();
4087 f =
f->parentFrame();
4100 const int blockPos = block.
position();
4124 int pos =
d->currentLazyLayoutPosition;
4133 if (
e->timerId() ==
d->layoutTimer.timerId()) {
4134 if (
d->currentLazyLayoutPosition != -1)
4136 }
else if (
e->timerId() ==
d->sizeChangedTimer.timerId()) {
4139 d->sizeChangedTimer.stop();
4141 if (
d->currentLazyLayoutPosition == -1) {
4143 if (newCount !=
d->lastPageCount) {
4144 d->lastPageCount = newCount;
4153void QTextDocumentLayout::layoutFinished()
4156 d->layoutTimer.stop();
4157 if (!
d->insideDocumentChange)
4158 d->sizeChangedTimer.start(0,
this);
4160 d->showLayoutProgress =
true;
4171 d->ensureLayoutFinished();
4172 return d->idealWidth;
4178 return d->contentHasAlignment;
4197#include "moc_qtextdocumentlayout_p.cpp"
QPaintDevice * paintDevice
QTextDocumentPrivate * docPrivate
void pageCountChanged(int newPages)
This signal is emitted when the number of pages in the layout changes; newPages is the updated page c...
virtual void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format)
This function is called to draw the inline object, object, with the given painter within the rectangl...
void documentSizeChanged(const QSizeF &newSize)
This signal is emitted when the size of the document layout changes to newSize.
QTextDocument * document() const
Returns the text document that this layout is operating on.
void registerHandler(int objectType, QObject *component)
Registers the given component as a handler for items of the given objectType.
void update(const QRectF &=QRectF(0., 0., 1000000000., 1000000000.))
This signal is emitted when the rectangle rect has been updated.
Qt::BrushStyle style() const
Returns the brush style.
The QColor class provides colors based on RGB, HSV or CMYK values.
\reentrant \inmodule QtGui
qreal horizontalAdvance(const QString &string, int length=-1) const
Returns the horizontal advance in pixels of the first length characters of text.
\reentrant \inmodule QtGui
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
qsizetype size() const noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
bool isEmpty() const noexcept
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
const_iterator constBegin() const noexcept
void reserve(qsizetype size)
void resize(qsizetype size)
void append(parameter_type t)
const_iterator constEnd() const noexcept
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool isEmpty() const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
The QPainter class performs low-level painting on widgets and other paint devices.
const QPen & pen() const
Returns the painter's current pen.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void restore()
Restores the current painter state (pops a saved state off the stack).
const QBrush & brush() const
Returns the painter's current brush.
void save()
Saves the current painter state (pushes the state onto a stack).
QPoint brushOrigin() const
Returns the currently set brush origin.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
QColor color() const
Returns the color of this pen's brush.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setBottom(qreal pos) noexcept
Sets the bottom edge of the rectangle to the given finite y coordinate.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr void setTop(qreal pos) noexcept
Sets the top edge of the rectangle to the given finite y coordinate.
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
bool intersects(const QRectF &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e.
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
constexpr void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void translate(qreal dx, qreal dy) noexcept
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
qreal bottomMargin() const
Returns the paragraph's bottom margin.
qreal topMargin() const
Returns the paragraph's top margin.
Qt::Alignment alignment() const
Returns the paragraph's alignment.
MarkerType marker() const
QList< QTextOption::Tab > tabPositions() const
PageBreakFlags pageBreakPolicy() const
bool nonBreakableLines() const
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
int indent() const
Returns the paragraph's indent.
qreal leftMargin() const
Returns the paragraph's left margin.
qreal textIndent() const
Returns the paragraph's text indent.
qreal lineHeight(qreal scriptLineHeight, qreal scaling) const
qreal rightMargin() const
Returns the paragraph's right margin.
int lineHeightType() const
int length() const
Returns the length of the block in characters.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
bool contains(int position) const
Returns true if the given position is located within the text block; otherwise returns false.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
QString text() const
Returns the block's contents as plain text.
Qt::LayoutDirection textDirection() const
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block's character format.
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
QFont font() const
Returns the font for this character format.
void setCellPosition(QTextTable *t, const QTextTableCell &cell, const QPointF &pos)
QBasicTimer sizeChangedTimer
int currentLazyLayoutPosition
QFixed findY(QFixed yFrom, const QTextLayoutStruct *layoutStruct, QFixed requiredWidth) const
uint insideDocumentChange
void layoutBlock(const QTextBlock &bl, int blockPosition, const QTextBlockFormat &blockFormat, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, const QTextBlockFormat *previousBlockFormat)
QTextOption::WrapMode wordWrapMode
void floatMargins(QFixed y, const QTextLayoutStruct *layoutStruct, QFixed *left, QFixed *right) const
void ensureLayoutedByPosition(int position) const
QTextLayoutStruct layoutCell(QTextTable *t, const QTextTableCell &cell, QFixed width, int layoutFrom, int layoutTo, QTextTableData *tableData, QFixed absoluteTableY, bool withPageBreaks)
HitPoint hitTest(QTextFrame *frame, const QFixedPoint &point, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const
void drawBlock(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, const QTextBlock &bl, bool inRootFrame) const
QList< QCheckPoint > checkPoints
QFixed blockIndent(const QTextBlockFormat &blockFormat) const
QTextFrame::Iterator frameIteratorForTextPosition(int position) const
QRectF layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY=0)
void drawTableCellBorder(const QRectF &cellRect, QPainter *painter, QTextTable *table, QTextTableData *td, const QTextTableCell &cell) const
QTextDocumentLayoutPrivate()
void drawBorder(QPainter *painter, const QRectF &rect, qreal topMargin, qreal bottomMargin, qreal border, const QBrush &brush, QTextFrameFormat::BorderStyle style) const
void drawFrame(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, QTextFrame *f) const
void layoutFlow(QTextFrame::Iterator it, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, QFixed width=0)
qreal scaleToDevice(qreal value) const
QRectF layoutTable(QTextTable *t, int layoutFrom, int layoutTo, QFixed parentY)
void ensureLayoutFinished() const
void positionFloat(QTextFrame *frame, QTextLine *currentLine=nullptr)
void drawFrameDecoration(QPainter *painter, QTextFrame *frame, QTextFrameData *fd, const QRectF &clip, const QRectF &rect) const
QTextFrame::Iterator frameIteratorForYPosition(QFixed y) const
void drawListItem(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, const QTextBlock &bl, const QTextCharFormat *selectionFormat) const
void drawFlow(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context, QTextFrame::Iterator it, const QList< QTextFrame * > &floats, QTextBlock *cursorBlockNeedingRepaint) const
void ensureLayouted(QFixed y) const
QRectF frameBoundingRectInternal(QTextFrame *frame) const
void drawTableCell(const QRectF &cellRect, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &cell_context, QTextTable *table, QTextTableData *td, int r, int c, QTextBlock *cursorBlockNeedingRepaint, QPointF *cursorBlockOffset) const
void setFixedColumnWidth(int width)
QSizeF documentSize() const override
Returns the total size of the document's layout.
QRectF tableCellBoundingRect(QTextTable *table, const QTextTableCell &cell) const
void documentChanged(int from, int oldLength, int length) override
This function is called whenever the contents of the document change.
virtual QRectF blockBoundingRect(const QTextBlock &block) const override
Returns the bounding rectangle of block.
void draw(QPainter *painter, const PaintContext &context) override
Draws the layout with the given painter using the given context.
void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, int posInDocument, const QTextFormat &format) override
This function is called to draw the inline object, object, with the given painter within the rectangl...
QTextDocumentLayout(QTextDocument *doc)
int pageCount() const override
Returns the number of pages contained in the layout.
void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override
Sets the size of the inline object item corresponding to the text format.
virtual QRectF frameBoundingRect(QTextFrame *frame) const override
Returns the bounding rectangle of frame.
void setViewport(const QRectF &viewport)
int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const override
Returns the cursor position for the given point with the specified accuracy.
QRectF tableBoundingRect(QTextTable *table) const
void setCursorWidth(int width)
void ensureLayouted(qreal)
QSizeF dynamicDocumentSize() const
virtual void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
int dynamicPageCount() const
void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override
Lays out the inline object item using the given text format.
const BlockMap & blockMap() const
QTextFrame * frameAt(int pos) const
QTextFrame * rootFrame() const
static const QTextDocumentPrivate * get(const QTextDocument *document)
QTextOption defaultTextOption
\reentrant \inmodule QtGui
QSizeF pageSize
the page size that should be used for laying out the document
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
QTextFrame * rootFrame() const
Returns the document's root frame.
QTextCharFormat toCharFormat() const
Returns this format as a character format.
QBrush background() const
Returns the brush used to paint the document's background.
Property
This enum describes the different properties a format can have.
@ TableCellBottomBorderStyle
@ TableCellTopBorderStyle
@ TableCellRightBorderStyle
@ BlockTrailingHorizontalRulerWidth
@ TableCellLeftBorderStyle
QTextLength lengthProperty(int propertyId) const
Returns the value of the property given by propertyId.
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.
QTextTableCellFormat toTableCellFormat() const
QTextListFormat toListFormat() const
Returns this format as a list format.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines,...
QFixed effectiveBottomMargin
QList< QPointer< QTextFrame > > floats
QFixed effectiveTopMargin
QTextLayoutStruct * currentLayoutStruct
Position position() const
Returns the positioning policy for frames with this frame format.
QTextLength width() const
Returns the width of the frame's border rectangle.
QTextLength height() const
Returns the height of the frame's border rectangle.
qreal border() const
Returns the width of the border in pixels.
qreal bottomMargin() const
Position
This enum describes how a frame is located relative to the surrounding text.
qreal rightMargin() const
qreal padding() const
Returns the width of the frame's internal padding in pixels.
PageBreakFlags pageBreakPolicy() const
QTextFrame * currentFrame() const
Returns the current frame pointed to by the iterator, or \nullptr if the iterator currently points to...
bool atEnd() const
Returns true if the current item is the last item in the text frame.
Q_GUI_EXPORT QTextBlock currentBlock() const
Returns the current block the iterator points to.
int lastPosition() const
Returns the last document position inside the frame.
QList< QTextFrame * > childFrames() const
Returns a (possibly empty) list of the frame's child frames.
QTextFrameFormat frameFormat() const
Returns the frame's format.
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
QTextFrame * parentFrame() const
Returns the frame's parent frame.
int firstPosition() const
Returns the first document position inside the frame.
const QTextOption & textOption() const
Returns the current text option used to control the layout process.
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
qreal minimumWidth() const
The minimum width the layout needs.
void setPosition(const QPointF &p)
Moves the text layout to point p.
int lineCount() const
Returns the number of lines in this text layout.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs.
qreal maximumWidth() const
The maximum width the layout could expand to; this is essentially the width of the entire text.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
void draw(QPainter *p, const QPointF &pos, const QList< FormatRange > &selections=QList< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
void endLayout()
Ends the layout process.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
qreal value(qreal maximumLength) const
Returns the effective length, constrained by the type of the length object and the specified maximumL...
Type type() const
Returns the type of this length object.
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
QRectF naturalTextRect() const
Returns the rectangle covered by the line.
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
@ CursorBetweenCharacters
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
int textLength() const
Returns the length of the text in the line.
Style
This enum describes the symbols used to decorate list items:
Style style() const
Returns the list format's style.
int indent() const
Returns the list format's indentation.
The QTextObjectInterface class allows drawing of custom text objects in \l{QTextDocument}s.
virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format)=0
Draws this text object using the specified painter.
virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format)=0
The intrinsicSize() function returns the size of the text object represented by format in the given d...
QTextFormat format() const
Returns the text object's format.
void setTextDirection(Qt::LayoutDirection aDirection)
Sets the direction of the text layout defined by the option to the given direction.
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
Flags flags() const
Returns the flags associated with the option.
@ AddSpaceForLineAndParagraphSeparators
WrapMode
This enum describes how text is wrapped in a document.
@ WrapAtWordBoundaryOrAnywhere
QTextCharFormat format() const
Returns the cell's character format.
int columnSpan() const
Returns the number of columns this cell spans.
int firstPosition() const
int row() const
Returns the number of the row in the table that contains this cell.
int rowSpan() const
Returns the number of rows this cell spans.
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
int column() const
Returns the number of the column in the table that contains this cell.
QTextFrame::iterator begin() const
Returns a frame iterator pointing to the beginning of the table's cell.
void calcRowPosition(int row)
QList< QFixed > maxWidths
QFixedPoint cellPosition(QTextTable *table, const QTextTableCell &cell) const
QFixed rightPadding(QTextTable *table, const QTextTableCell &cell) const
QList< QFixed > rowPositions
QFixed effectiveBottomBorder
QFixed effectiveRightBorder
QList< QFixed > cellVerticalOffsets
QList< QFixed > columnPositions
QRectF cellRect(const QTextTableCell &cell) const
QFixed topPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed effectiveLeftBorder
QFixed cellWidth(int column, int colspan) const
QFixed bottomPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed cellBorderWidth(QTextTable *table, const QTextTableCell &cell, QCss::Edge edge) const
QFixed leftPadding(QTextTable *table, const QTextTableCell &cell) const
QFixed effectiveTopBorder
QList< QFixed > minWidths
QFixed paddingProperty(const QTextFormat &format, QTextFormat::Property property) const
QMultiHash< int, QTextFrame * > childFrameMap
constexpr size_type size() const noexcept
double toDouble(bool *ok=nullptr) const
Returns the variant as a double if the variant has userType() \l QMetaType::Double,...
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, qreal dw2, QCss::Edge edge, QCss::BorderStyle style, QBrush c)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qIsNull(qfloat16 f) noexcept
Q_GUI_EXPORT int qt_defaultDpi()
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxW
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLenum GLenum GLenum scale
GLenum GLenum GLsizei void * table
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static void drawCellBorder(const QTextDocumentLayoutPrivate *p, QPainter *painter, QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, const QRectF &borderRect, QCss::Edge edge, int forceHeaderRow, bool adjustTopAnchor, bool adjustBottomAnchor, bool ignoreEdgesAbove)
static bool sharesAxis(const QTextTableCell &cell, QCss::Edge edge, const QTextTableCell &competingCell, QCss::Edge competingCellEdge)
static bool isSameAxis(QCss::Edge e1, QCss::Edge e2)
static EdgeData axisEdgeData(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge)
static QTextFormat::Property borderStylePropertyForEdge(QCss::Edge edge)
static bool isLineSeparatorBlockAfterTable(const QTextBlock &block, const QTextFrame *previousFrame)
static void adjustContextSelectionsForCell(QAbstractTextDocumentLayout::PaintContext &cell_context, const QTextTableCell &cell, int r, int c, const int *selectedTableCells)
static QTextFormat::Property borderPropertyForEdge(QCss::Edge edge)
static EdgeData cellEdgeData(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge)
static bool cellClipTest(QTextTable *table, QTextTableData *td, const QAbstractTextDocumentLayout::PaintContext &cell_context, const QTextTableCell &cell, QRectF cellRect)
static bool isEmptyBlockBeforeTable(const QTextBlock &block, const QTextBlockFormat &format, const QTextFrame::Iterator &nextIt)
static void checkJoinedEdge(QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, QCss::Edge competingEdge, const EdgeData &edgeData, bool couldHaveContinuation, EdgeData *maxCompetingEdgeData, EdgeData *maxOrthogonalEdgeData)
static bool operator<(const QCheckPoint &checkPoint, QFixed y)
static QTextTableCell adjacentCell(QTextTable *table, const QTextTableCell &cell, QCss::Edge edge)
static QFixed firstChildPos(const QTextFrame *f)
static void findWidestOutermostBorder(QTextTable *table, QTextTableData *td, const QTextTableCell &cell, QCss::Edge edge, qreal *outerBorders)
static QFixed flowPosition(const QTextFrame::iterator &it)
static bool isEmptyBlockAfterTable(const QTextBlock &block, const QTextFrame *previousFrame)
static QTextFrameData * createData(QTextFrame *f)
static bool isVerticalAxis(QCss::Edge e)
static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect=QRectF())
static qreal collapseOffset(const QTextDocumentLayoutPrivate *p, const EdgeData &w)
static void markFrames(QTextFrame *current, int from, int oldLength, int length)
static bool isFrameFromInlineObject(QTextFrame *f)
static double prioritizedEdgeAnchorOffset(const QTextDocumentLayoutPrivate *p, QTextTable *table, const QTextTableData *td, const QTextTableCell &cell, const EdgeData &edgeData, QCss::Edge orthogonalEdge, bool couldHaveContinuation, bool ignoreEdgesAbove)
static QCss::Edge adjacentEdge(QCss::Edge edge)
static void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling, QFixed *lineAdjustment, QFixed *lineBreakHeight, QFixed *lineHeight, QFixed *lineBottom)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
QVideoFrameFormat::PixelFormat fmt
QRandomGenerator64 rd
[10]
view viewport() -> scroll(dx, dy, deviceRect)
QRectF clipRect(int page) const
BorderPaginator(QTextDocument *document, const QRectF &rect, qreal topMarginAfterPageBreak, qreal bottomMargin, qreal border)
qreal topMarginAfterPageBreak
EdgeData(qreal width, const QTextTableCell &cell, QCss::Edge edge, EdgeClass edgeClass)
bool operator>(const EdgeData &other) const
bool operator<(const EdgeData &other) const
\reentrant \inmodule QtGui
QList< Selection > selections
\variable QAbstractTextDocumentLayout::PaintContext::cursorPosition
constexpr QPointF toPointF() const
static constexpr QFixedPoint fromPointF(const QPointF &p)
static constexpr QFixedSize fromSizeF(const QSizeF &s)
constexpr QSizeF toSizeF() const
static constexpr QFixed fromReal(qreal r)
constexpr QFixed round() const
constexpr qreal toReal() const
constexpr int truncate() const
bool contains(const AT &t) const noexcept
QList< QTextFrame * > pendingFloats
QRectF updateRectForFloats
QFixed contentHeight() const
void addUpdateRectForFloat(const QRectF &rect)
QPointer< QObject > component
QTextObjectInterface * iface