Changeset 561 for trunk/src/gui/text/qtextdocumentlayout.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qtextdocumentlayout.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 199 199 return cellPadding; 200 200 } else { 201 Q_ASSERT(v. type() == QVariant::Double);202 return QFixed::fromReal(v.to Double() * deviceScale);201 Q_ASSERT(v.userType() == QVariant::Double || v.userType() == QMetaType::Float); 202 return QFixed::fromReal(v.toReal() * deviceScale); 203 203 } 204 204 } … … 856 856 void QTextDocumentLayoutPrivate::drawFrameDecoration(QPainter *painter, QTextFrame *frame, QTextFrameData *fd, const QRectF &clip, const QRectF &rect) const 857 857 { 858 859 const QBrush bg = frame->frameFormat().background(); 860 if (bg != Qt::NoBrush) { 861 QRectF bgRect = rect; 862 bgRect.adjust((fd->leftMargin + fd->border).toReal(), 863 (fd->topMargin + fd->border).toReal(), 864 - (fd->rightMargin + fd->border).toReal(), 865 - (fd->bottomMargin + fd->border).toReal()); 866 867 QRectF gradientRect; // invalid makes it default to bgRect 868 QPointF origin = bgRect.topLeft(); 869 if (!frame->parentFrame()) { 870 bgRect = clip; 871 gradientRect.setWidth(painter->device()->width()); 872 gradientRect.setHeight(painter->device()->height()); 873 } 874 fillBackground(painter, bgRect, bg, origin, gradientRect); 875 } 858 876 if (fd->border != 0) { 859 877 painter->save(); … … 875 893 876 894 painter->restore(); 877 }878 879 const QBrush bg = frame->frameFormat().background();880 if (bg != Qt::NoBrush) {881 QRectF bgRect = rect;882 bgRect.adjust((fd->leftMargin + fd->border).toReal(),883 (fd->topMargin + fd->border).toReal(),884 - (fd->rightMargin + fd->border).toReal(),885 - (fd->bottomMargin + fd->border).toReal());886 887 QRectF gradientRect; // invalid makes it default to bgRect888 QPointF origin = bgRect.topLeft();889 if (!frame->parentFrame()) {890 bgRect = clip;891 gradientRect.setWidth(painter->device()->width());892 gradientRect.setHeight(painter->device()->height());893 }894 fillBackground(painter, bgRect, bg, origin, gradientRect);895 895 } 896 896 } … … 1384 1384 case QTextListFormat::ListLowerAlpha: 1385 1385 case QTextListFormat::ListUpperAlpha: 1386 case QTextListFormat::ListLowerRoman: 1387 case QTextListFormat::ListUpperRoman: 1386 1388 itemText = static_cast<QTextList *>(object)->itemText(bl); 1387 1389 size.setWidth(fontMetrics.width(itemText)); … … 1427 1429 case QTextListFormat::ListDecimal: 1428 1430 case QTextListFormat::ListLowerAlpha: 1429 case QTextListFormat::ListUpperAlpha: { 1431 case QTextListFormat::ListUpperAlpha: 1432 case QTextListFormat::ListLowerRoman: 1433 case QTextListFormat::ListUpperRoman: { 1430 1434 QTextLayout layout(itemText, font, q->paintDevice()); 1431 1435 layout.setCacheEnabled(true); … … 1434 1438 layout.setTextOption(option); 1435 1439 layout.beginLayout(); 1436 layout.createLine(); 1440 QTextLine line = layout.createLine(); 1441 if (line.isValid()) 1442 line.setLeadingIncluded(true); 1437 1443 layout.endLayout(); 1438 1444 layout.draw(painter, QPointF(r.left(), pos.y())); … … 1443 1449 break; 1444 1450 case QTextListFormat::ListCircle: 1445 painter->drawEllipse(r); 1451 painter->setPen(QPen(brush, 0)); 1452 painter->drawEllipse(r.translated(0.5, 0.5)); // pixel align for sharper rendering 1446 1453 break; 1447 1454 case QTextListFormat::ListDisc: … … 1449 1456 painter->setPen(Qt::NoPen); 1450 1457 painter->drawEllipse(r); 1451 painter->setBrush(Qt::NoBrush);1452 1458 break; 1453 1459 case QTextListFormat::ListStyleUndefined: … … 1991 1997 } 1992 1998 1993 if (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom) { 1999 bool frameSpansIntoNextPage = (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom); 2000 if (frameSpansIntoNextPage && fd->size.height <= layoutStruct->pageHeight) { 1994 2001 layoutStruct->newPage(); 1995 2002 y = layoutStruct->y; 2003 2004 frameSpansIntoNextPage = false; 1996 2005 } 1997 2006 … … 2014 2023 // qDebug()<< "float positioned at " << fd->position.x << fd->position.y; 2015 2024 fd->layoutDirty = false; 2025 2026 // If the frame is a table, then positioning it will affect the size if it covers more than 2027 // one page, because of page breaks and repeating the header. 2028 if (qobject_cast<QTextTable *>(frame) != 0) 2029 fd->sizeDirty = frameSpansIntoNextPage; 2016 2030 } 2017 2031 … … 2345 2359 2346 2360 positionFloat(c); 2361 2362 // If the size was made dirty when the position was set, layout again 2363 if (cd->sizeDirty) 2364 updateRect = layoutFrame(c, layoutFrom, layoutTo); 2347 2365 2348 2366 QRectF frameRect(cd->position.toPointF(), cd->size.toSizeF()); … … 2501 2519 LDEBUG << "layoutBlock from=" << layoutFrom << "to=" << layoutTo; 2502 2520 2503 // qDebug() << "layoutBlock; width" << layoutStruct->x_right - layoutStruct->x_left << "(maxWidth is btw" << tl->maximumWidth() << ")";2521 // qDebug() << "layoutBlock; width" << layoutStruct->x_right - layoutStruct->x_left << "(maxWidth is btw" << tl->maximumWidth() << ')'; 2504 2522 2505 2523 if (previousBlockFormat) { … … 2564 2582 if (!line.isValid()) 2565 2583 break; 2584 line.setLeadingIncluded(true); 2566 2585 2567 2586 QFixed left, right; … … 2598 2617 layoutStruct->pendingFloats.clear(); 2599 2618 2600 if (haveWordOrAnyWrapMode) {2601 option.setWrapMode(QTextOption::WrapAnywhere);2602 tl->setTextOption(option);2603 }2604 2605 2619 line.setLineWidth((right-left).toReal()); 2606 2620 if (QFixed::fromReal(line.naturalTextWidth()) > right-left) { 2621 if (haveWordOrAnyWrapMode) { 2622 option.setWrapMode(QTextOption::WrapAnywhere); 2623 tl->setTextOption(option); 2624 } 2625 2607 2626 layoutStruct->pendingFloats.clear(); 2608 2627 // lines min width more than what we have … … 2616 2635 right -= text_indent; 2617 2636 line.setLineWidth(qMax<qreal>(line.naturalTextWidth(), (right-left).toReal())); 2637 2638 if (haveWordOrAnyWrapMode) { 2639 option.setWrapMode(QTextOption::WordWrap); 2640 tl->setTextOption(option); 2641 } 2618 2642 } 2619 2643 2620 if (haveWordOrAnyWrapMode) {2621 option.setWrapMode(QTextOption::WordWrap);2622 tl->setTextOption(option);2623 }2624 2644 } 2625 2645 … … 3206 3226 qreal QTextDocumentLayoutPrivate::scaleToDevice(qreal value) const 3207 3227 { 3208 QPaintDevice *dev = q_func()->paintDevice(); 3209 if (!dev) 3228 if (!paintDevice) 3210 3229 return value; 3211 return value * dev->logicalDpiY() / qreal(qt_defaultDpi());3230 return value * paintDevice->logicalDpiY() / qreal(qt_defaultDpi()); 3212 3231 } 3213 3232 3214 3233 QFixed QTextDocumentLayoutPrivate::scaleToDevice(QFixed value) const 3215 3234 { 3216 QPaintDevice *dev = q_func()->paintDevice(); 3217 if (!dev) 3235 if (!paintDevice) 3218 3236 return value; 3219 return value * QFixed( dev->logicalDpiY()) / QFixed(qt_defaultDpi());3237 return value * QFixed(paintDevice->logicalDpiY()) / QFixed(qt_defaultDpi()); 3220 3238 } 3221 3239
Note:
See TracChangeset
for help on using the changeset viewer.