Changeset 561 for trunk/src/gui/kernel/qwidget.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/kernel/qwidget.cpp
r467 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 ** … … 83 83 #include "private/qinputcontext_p.h" 84 84 #include "qfileinfo.h" 85 #include "private/qsoftkeymanager_p.h" 85 86 86 87 #if defined (Q_WS_WIN) … … 97 98 #endif 98 99 100 #include <private/qgraphicseffect_p.h> 99 101 #include <private/qwindowsurface_p.h> 100 102 #include <private/qbackingstore_p.h> … … 103 105 #endif 104 106 #include <private/qpaintengine_raster_p.h> 107 108 #if defined(Q_OS_SYMBIAN) 109 #include "private/qt_s60_p.h" 110 #endif 105 111 106 112 #include "qwidget_p.h" … … 112 118 #include "QtGui/qabstractscrollarea.h" 113 119 #include "private/qabstractscrollarea_p.h" 120 #include "private/qevent_p.h" 114 121 115 122 #include "private/qgraphicssystem_p.h" 123 #include "private/qgesturemanager_p.h" 116 124 117 125 // widget/widget data creation count … … 147 155 } 148 156 149 /*!150 \internal151 152 Returns true if \a p or any of its parents enable the153 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and154 QWidget::setParent() to determine whether it's necessary to embed the155 widget into a QGraphicsProxyWidget or not.156 */157 static inline bool bypassGraphicsProxyWidget(QWidget *p)158 {159 while (p) {160 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)161 return true;162 p = p->parentWidget();163 }164 return false;165 }166 167 157 #ifdef Q_WS_MAC 168 158 # define QT_NO_PAINT_DEBUG … … 172 162 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp 173 163 174 QWidgetPrivate::QWidgetPrivate(int version) : 175 QObjectPrivate(version), extra(0), focus_child(0) 176 ,layout(0), widgetItem(0) 177 ,leftmargin(0), topmargin(0), rightmargin(0), bottommargin(0) 178 ,leftLayoutItemMargin(0), topLayoutItemMargin(0), rightLayoutItemMargin(0) 179 ,bottomLayoutItemMargin(0) 180 ,fg_role(QPalette::NoRole) 181 ,bg_role(QPalette::NoRole) 182 ,hd(0) 183 ,dirty(0) 184 ,needsFlush(0) 185 ,dirtyOpaqueChildren(1) 186 ,isOpaque(0) 187 ,inDirtyList(0) 188 ,isScrolled(0) 189 ,isMoved(0) 190 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 191 ,noPaintOnScreen(0) 192 #endif 193 ,inheritedFontResolveMask(0) 194 ,inheritedPaletteResolveMask(0) 164 QWidgetPrivate::QWidgetPrivate(int version) 165 : QObjectPrivate(version) 166 , extra(0) 167 , focus_next(0) 168 , focus_prev(0) 169 , focus_child(0) 170 , layout(0) 171 , needsFlush(0) 172 , redirectDev(0) 173 , widgetItem(0) 174 , extraPaintEngine(0) 175 , polished(0) 176 , graphicsEffect(0) 177 #if !defined(QT_NO_IM) 178 , imHints(Qt::ImhNone) 179 #endif 180 , inheritedFontResolveMask(0) 181 , inheritedPaletteResolveMask(0) 182 , leftmargin(0) 183 , topmargin(0) 184 , rightmargin(0) 185 , bottommargin(0) 186 , leftLayoutItemMargin(0) 187 , topLayoutItemMargin(0) 188 , rightLayoutItemMargin(0) 189 , bottomLayoutItemMargin(0) 190 , hd(0) 191 , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) 192 , fg_role(QPalette::NoRole) 193 , bg_role(QPalette::NoRole) 194 , dirtyOpaqueChildren(1) 195 , isOpaque(0) 196 , inDirtyList(0) 197 , isScrolled(0) 198 , isMoved(0) 199 , usesDoubleBufferedGLContext(0) 195 200 #if defined(Q_WS_X11) 196 ,picture(0) 197 #endif 198 #ifdef Q_WS_MAC 199 ,needWindowChange(0) 200 ,isGLWidget(0) 201 #endif 202 ,polished(0) 203 204 , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) 205 , redirectDev(0) 201 , picture(0) 202 #elif defined(Q_WS_PM) 203 , noPaintOnScreen(0) 204 #elif defined(Q_WS_WIN) 205 , noPaintOnScreen(0) 206 , nativeGesturePanEnabled(0) 207 #elif defined(Q_WS_MAC) 208 , needWindowChange(0) 209 , isGLWidget(0) 210 , window_event(0) 211 , qd_hd(0) 212 #endif 206 213 { 207 214 if (!qApp) { … … 229 236 if (extra) 230 237 deleteExtra(); 238 239 #ifndef QT_NO_GRAPHICSEFFECT 240 delete graphicsEffect; 241 #endif //QT_NO_GRAPHICSEFFECT 231 242 } 232 243 … … 362 373 change focus. 363 374 364 This feature is only available in Qt for Embedded Linux. 375 This feature is only available in Qt for Embedded Linux and Qt 376 for Symbian. 365 377 366 378 \sa hasEditFocus(), QApplication::keypadNavigationEnabled() … … 446 458 447 459 \ingroup basicwidgets 448 \mainclass 460 449 461 450 462 The widget is the atom of the user interface: it receives mouse, keyboard … … 497 509 498 510 If you want to use a QWidget to hold child widgets you will usually want to 499 add a layout to the parent QWidget. See \l{Layout Classes} for more511 add a layout to the parent QWidget. See \l{Layout Management} for more 500 512 information. 501 513 … … 855 867 \o X11: This feature relies on the use of an X server that supports ARGB visuals 856 868 and a compositing window manager. 857 \o Windows: Th is feature requires Windows 2000 or later. The widget needs to have858 the Qt::FramelessWindowHint window flag setfor the translucency to work.869 \o Windows: The widget needs to have the Qt::FramelessWindowHint window flag set 870 for the translucency to work. 859 871 \endlist 860 872 … … 882 894 883 895 \sa QEvent, QPainter, QGridLayout, QBoxLayout 884 */ 885 886 QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid 887 QWidgetSet *QWidgetPrivate::uncreatedWidgets = 0; // widgets with no wid 896 897 \section1 Softkeys 898 899 Since Qt 4.6, Softkeys are usually physical keys on a device that have a corresponding label or 900 other visual representation on the screen that is generally located next to its 901 physical counterpart. They are most often found on mobile phone platforms. In 902 modern touch based user interfaces it is also possible to have softkeys that do 903 not correspond to any physical keys. Softkeys differ from other onscreen labels 904 in that they are contextual. 905 906 In Qt, contextual softkeys are added to a widget by calling addAction() and 907 passing a \c QAction with a softkey role set on it. When the widget 908 containing the softkey actions has focus, its softkeys should appear in 909 the user interface. Softkeys are discovered by traversing the widget 910 hierarchy so it is possible to define a single set of softkeys that are 911 present at all times by calling addAction() for a given top level widget. 912 913 On some platforms, this concept overlaps with \c QMenuBar such that if no 914 other softkeys are found and the top level widget is a QMainWindow containing 915 a QMenuBar, the menubar actions may appear on one of the softkeys. 916 917 Note: Currently softkeys are only supported on the Symbian Platform. 918 919 \sa addAction(), QAction, QMenuBar 920 921 */ 922 923 QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid 924 QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid 888 925 889 926 … … 925 962 */ 926 963 964 struct QWidgetExceptionCleaner 965 { 966 /* this cleans up when the constructor throws an exception */ 967 static inline void cleanup(QWidget *that, QWidgetPrivate *d) 968 { 969 #ifdef QT_NO_EXCEPTIONS 970 Q_UNUSED(that); 971 Q_UNUSED(d); 972 #else 973 QWidgetPrivate::allWidgets->remove(that); 974 if (d->focus_next != that) { 975 if (d->focus_next) 976 d->focus_next->d_func()->focus_prev = d->focus_prev; 977 if (d->focus_prev) 978 d->focus_prev->d_func()->focus_next = d->focus_next; 979 } 980 #endif 981 } 982 }; 983 927 984 /*! 928 985 Constructs a widget which is a child of \a parent, with widget … … 954 1011 : QObject(*new QWidgetPrivate, 0), QPaintDevice() 955 1012 { 956 d_func()->init(parent, f); 1013 QT_TRY { 1014 d_func()->init(parent, f); 1015 } QT_CATCH(...) { 1016 QWidgetExceptionCleaner::cleanup(this, d_func()); 1017 QT_RETHROW; 1018 } 957 1019 } 958 1020 … … 965 1027 : QObject(*new QWidgetPrivate, 0), QPaintDevice() 966 1028 { 967 d_func()->init(parent , f); 968 setObjectName(QString::fromAscii(name)); 1029 QT_TRY { 1030 d_func()->init(parent , f); 1031 setObjectName(QString::fromAscii(name)); 1032 } QT_CATCH(...) { 1033 QWidgetExceptionCleaner::cleanup(this, d_func()); 1034 QT_RETHROW; 1035 } 969 1036 } 970 1037 #endif … … 975 1042 : QObject(dd, 0), QPaintDevice() 976 1043 { 977 d_func()->init(parent, f); 1044 Q_D(QWidget); 1045 QT_TRY { 1046 d->init(parent, f); 1047 } QT_CATCH(...) { 1048 QWidgetExceptionCleaner::cleanup(this, d_func()); 1049 QT_RETHROW; 1050 } 978 1051 } 979 1052 … … 1031 1104 ; // don't modify window flags if the user explicitely set them. 1032 1105 else if (type == Qt::Dialog || type == Qt::Sheet) 1033 #ifndef Q_ OS_WINCE1106 #ifndef Q_WS_WINCE 1034 1107 flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; 1035 1108 #else … … 1047 1120 { 1048 1121 Q_Q(QWidget); 1049 if ( qApp->type() == QApplication::Tty)1122 if (QApplication::type() == QApplication::Tty) 1050 1123 qFatal("QWidget: Cannot create a QWidget when no GUI is being used"); 1051 1124 1052 Q_ASSERT( uncreatedWidgets);1053 uncreatedWidgets->insert(q);1125 Q_ASSERT(allWidgets); 1126 allWidgets->insert(q); 1054 1127 1055 1128 QWidget *desktopWidget = 0; … … 1062 1135 1063 1136 #ifndef QT_NO_THREAD 1064 if (! q->parent()) {1137 if (!parent) { 1065 1138 Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", 1066 1139 "Widgets must be created in the GUI thread."); … … 1097 1170 if (f & Qt::MSWindowsOwnDC) 1098 1171 q->setAttribute(Qt::WA_NativeWindow); 1099 1100 #ifdef Q_OS_WINCE1101 data.window_state_internal = 0;1102 #endif1103 1172 1104 1173 q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() … … 1257 1326 1258 1327 // a real toplevel window needs a backing store 1259 if (isWindow() ) {1328 if (isWindow() && windowType() != Qt::Desktop) { 1260 1329 delete d->topData()->backingStore; 1261 1330 // QWidgetBackingStore will check this variable, hence it must be 0 … … 1280 1349 if (isWindow() && !d->topData()->iconText.isEmpty()) 1281 1350 d->setWindowIconText_helper(d->topData()->iconText); 1351 if (isWindow() && !d->topData()->caption.isEmpty()) 1352 d->setWindowTitle_helper(d->topData()->caption); 1282 1353 if (windowType() != Qt::Desktop) { 1283 1354 d->updateSystemBackground(); … … 1340 1411 if (QApplicationPrivate::main_widget == this) { // reset main widget 1341 1412 QApplicationPrivate::main_widget = 0; 1342 qApp->quit(); 1343 } 1344 #endif 1345 1346 clearFocus(); 1413 QApplication::quit(); 1414 } 1415 #endif 1416 1417 QT_TRY { 1418 clearFocus(); 1419 } QT_CATCH(...) { 1420 // swallow this problem because we are in a destructor 1421 } 1347 1422 1348 1423 d->setDirtyOpaqueRegion(); 1349 1424 1350 if (isWindow() && isVisible() && internalWinId()) 1351 hide(); 1352 #if defined(Q_WS_WIN) || defined(Q_WS_PM) || defined(Q_WS_X11) 1353 else if (!internalWinId() && isVisible()) 1425 if (isWindow() && isVisible() && internalWinId()) { 1426 QT_TRY { 1427 d->close_helper(QWidgetPrivate::CloseNoEvent); 1428 } QT_CATCH(...) { 1429 // if we're out of memory, at least hide the window. 1430 QT_TRY { 1431 hide(); 1432 } QT_CATCH(...) { 1433 // and if that also doesn't work, then give up 1434 } 1435 } 1436 } 1437 1438 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 1439 else if (!internalWinId() && isVisible()) { 1354 1440 qApp->d_func()->sendSyntheticEnterLeave(this); 1441 #ifdef Q_WS_QWS 1442 } else if (isVisible()) { 1443 qApp->d_func()->sendSyntheticEnterLeave(this); 1444 #endif 1445 } 1355 1446 #endif 1356 1447 … … 1367 1458 QObjectPrivate::clearGuards(this); 1368 1459 1460 if (d->declarativeData) { 1461 d->declarativeData->destroyed(this); 1462 d->declarativeData = 0; // don't activate again in ~QObject 1463 } 1464 1369 1465 if (!d->children.isEmpty()) 1370 1466 d->deleteChildren(); … … 1372 1468 QApplication::removePostedEvents(this); 1373 1469 1374 destroy(); // platform-dependent cleanup 1375 1470 QT_TRY { 1471 destroy(); // platform-dependent cleanup 1472 } QT_CATCH(...) { 1473 // if this fails we can't do anything about it but at least we are not allowed to throw. 1474 } 1376 1475 --QWidgetPrivate::instanceCounter; 1377 1476 1378 if (QWidgetPrivate:: uncreatedWidgets) // might have been deleted by ~QApplication1379 QWidgetPrivate:: uncreatedWidgets->remove(this);1477 if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication 1478 QWidgetPrivate::allWidgets->remove(this); 1380 1479 1381 1480 QEvent e(QEvent::Destroy); … … 1397 1496 if (mapper && data.winid && !userDesktopWidget) { 1398 1497 mapper->remove(data.winid); 1399 uncreatedWidgets->insert(q); 1400 } 1498 } 1499 1500 const WId oldWinId = data.winid; 1401 1501 1402 1502 data.winid = id; … … 1406 1506 if (mapper && id && !userDesktopWidget) { 1407 1507 mapper->insert(data.winid, q); 1408 uncreatedWidgets->remove(q); 1508 } 1509 1510 if(oldWinId != id) { 1511 // Do not emit an event when the old winId is destroyed. This only 1512 // happens (a) during widget destruction, and (b) immediately prior 1513 // to creation of a new winId, for example as a result of re-parenting. 1514 if(id != 0) { 1515 QEvent e(QEvent::WinIdChange); 1516 QCoreApplication::sendEvent(q, &e); 1517 } 1409 1518 } 1410 1519 } … … 1416 1525 if (!extra->topextra) { 1417 1526 QTLWExtra* x = extra->topextra = new QTLWExtra; 1527 x->icon = 0; 1528 x->iconPixmap = 0; 1529 x->backingStore = 0; 1418 1530 x->windowSurface = 0; 1531 x->sharedPainter = 0; 1532 x->incw = x->inch = 0; 1533 x->basew = x->baseh = 0; 1534 x->frameStrut.setCoords(0, 0, 0, 0); 1535 x->normalGeometry = QRect(0,0,-1,-1); 1536 x->savedFlags = 0; 1419 1537 x->opacity = 255; 1420 1538 x->posFromMove = false; … … 1422 1540 x->inTopLevelResize = false; 1423 1541 x->inRepaint = false; 1424 x->backingStore = 0;1425 x->icon = 0;1426 x->iconPixmap = 0;1427 x->frameStrut.setCoords(0, 0, 0, 0);1428 x->incw = x->inch = 0;1429 x->basew = x->baseh = 0;1430 x->normalGeometry = QRect(0,0,-1,-1);1431 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)1432 1542 x->embedded = 0; 1433 #endif1434 #if defined(Q_WS_X11)1435 x->parentWinId = 0;1436 x->spont_unmapped = 0;1437 x->dnd = 0;1438 #endif1439 x->savedFlags = 0;1440 #if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)1441 x->qwsManager = 0;1442 #endif1443 x->sharedPainter = 0;1444 1543 createTLSysExtra(); 1445 1544 #ifdef QWIDGET_EXTRA_DEBUG 1446 static int count = 0;1447 qDebug() << "tlextra" << ++count;1545 static int count = 0; 1546 qDebug() << "tlextra" << ++count; 1448 1547 #endif 1449 1548 } … … 1459 1558 if (!extra) { // if not exists 1460 1559 extra = new QWExtra; 1461 extra->minw = extra->minh = 0; 1462 extra->maxw = extra->maxh = QWIDGETSIZE_MAX; 1560 extra->glContext = 0; 1561 extra->topextra = 0; 1562 #ifndef QT_NO_GRAPHICSVIEW 1563 extra->proxyWidget = 0; 1564 #endif 1565 #ifndef QT_NO_CURSOR 1566 extra->curs = 0; 1567 #endif 1568 extra->minw = 0; 1569 extra->minh = 0; 1570 extra->maxw = QWIDGETSIZE_MAX; 1571 extra->maxh = QWIDGETSIZE_MAX; 1572 extra->customDpiX = 0; 1573 extra->customDpiY = 0; 1463 1574 extra->explicitMinSize = 0; 1464 1575 extra->explicitMaxSize = 0; … … 1467 1578 extra->inRenderWithPainter = 0; 1468 1579 extra->hasMask = 0; 1469 #ifndef QT_NO_CURSOR1470 extra->curs = 0;1471 #endif1472 extra->style = 0;1473 extra->topextra = 0;1474 extra->proxyWidget = 0;1475 extra->glContext = 0;1476 extra->customDpiX = 0;1477 extra->customDpiY = 0;1478 1580 createSysExtra(); 1479 1581 #ifdef QWIDGET_EXTRA_DEBUG 1480 static int count = 0;1481 qDebug() << "extra" << ++count;1582 static int count = 0; 1583 qDebug() << "extra" << ++count; 1482 1584 #endif 1483 1585 } … … 1517 1619 extra = 0; 1518 1620 } 1519 }1520 1521 /*1522 Returns true if the background is inherited; otherwise returns1523 false.1524 1525 Mainly used in the paintOnScreen case.1526 */1527 1528 bool QWidgetPrivate::isBackgroundInherited() const1529 {1530 Q_Q(const QWidget);1531 1532 // windows do not inherit their background1533 if (q->isWindow() || q->windowType() == Qt::SubWindow)1534 return false;1535 1536 if (q->testAttribute(Qt::WA_NoSystemBackground) || q->testAttribute(Qt::WA_OpaquePaintEvent))1537 return false;1538 1539 const QPalette &pal = q->palette();1540 QPalette::ColorRole bg = q->backgroundRole();1541 QBrush brush = pal.brush(bg);1542 1543 // non opaque brushes leaves us no choice, we must inherit1544 if (!q->autoFillBackground() || !brush.isOpaque())1545 return true;1546 1547 if (brush.style() == Qt::SolidPattern) {1548 // the background is just a solid color. If there is no1549 // propagated contents, then we claim as performance1550 // optimization that it was not inheritet. This is the normal1551 // case in standard Windows or Motif style.1552 const QWidget *w = q->parentWidget();1553 if (!w->d_func()->isBackgroundInherited())1554 return false;1555 }1556 1557 return true;1558 1621 } 1559 1622 … … 1583 1646 } 1584 1647 1585 if (qRectIntersects(sibling->d ata->crect, r)) {1648 if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) { 1586 1649 const QWExtra *siblingExtra = sibling->d_func()->extra; 1587 if (siblingExtra && siblingExtra->hasMask 1650 if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect 1588 1651 && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) { 1589 1652 continue; … … 1649 1712 Q_Q(QWidget); 1650 1713 // Propagate a new inherited mask to all children. 1714 #ifndef QT_NO_GRAPHICSVIEW 1651 1715 if (!q->parentWidget() && extra && extra->proxyWidget) { 1652 #ifndef QT_NO_GRAPHICSVIEW1653 1716 QGraphicsProxyWidget *p = extra->proxyWidget; 1654 1717 inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve(); 1718 } else 1655 1719 #endif //QT_NO_GRAPHICSVIEW 1656 } elseif (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {1720 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { 1657 1721 inheritedPaletteResolveMask = 0; 1658 1722 } … … 1684 1748 if (!w->isVisible()) 1685 1749 return QRect(); 1686 QRect r = q->rect();1750 QRect r = effectiveRectFor(q->rect()); 1687 1751 int ox = 0; 1688 1752 int oy = 0; … … 1739 1803 } 1740 1804 1805 #ifndef QT_NO_GRAPHICSEFFECT 1806 void QWidgetPrivate::invalidateGraphicsEffectsRecursively() 1807 { 1808 Q_Q(QWidget); 1809 QWidget *w = q; 1810 do { 1811 if (w->graphicsEffect()) { 1812 QWidgetEffectSourcePrivate *sourced = 1813 static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func()); 1814 if (!sourced->updateDueToGraphicsEffect) 1815 w->graphicsEffect()->source()->d_func()->invalidateCache(); 1816 } 1817 w = w->parentWidget(); 1818 } while (w); 1819 } 1820 #endif //QT_NO_GRAPHICSEFFECT 1821 1741 1822 void QWidgetPrivate::setDirtyOpaqueRegion() 1742 1823 { … … 1744 1825 1745 1826 dirtyOpaqueChildren = true; 1827 1828 #ifndef QT_NO_GRAPHICSEFFECT 1829 invalidateGraphicsEffectsRecursively(); 1830 #endif //QT_NO_GRAPHICSEFFECT 1746 1831 1747 1832 if (q->isWindow()) … … 1758 1843 } 1759 1844 1760 QRegion QWidgetPrivate::getOpaqueRegion() const1761 {1762 Q_Q(const QWidget);1763 1764 QRegion r = isOpaque ? q->rect() : getOpaqueChildren();1765 if (extra && extra->hasMask)1766 r &= extra->mask;1767 if (r.isEmpty())1768 return r;1769 return r & clipRect();1770 }1771 1772 1845 const QRegion &QWidgetPrivate::getOpaqueChildren() const 1773 1846 { … … 1784 1857 1785 1858 const QPoint offset = child->geometry().topLeft(); 1786 that->opaqueChildren += child->d_func()->getOpaqueRegion().translated(offset); 1787 } 1788 1859 QWidgetPrivate *childd = child->d_func(); 1860 QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren(); 1861 if (childd->extra && childd->extra->hasMask) 1862 r &= childd->extra->mask; 1863 if (r.isEmpty()) 1864 continue; 1865 r.translate(offset); 1866 that->opaqueChildren += r; 1867 } 1868 1869 that->opaqueChildren &= q_func()->rect(); 1789 1870 that->dirtyOpaqueChildren = false; 1790 1871 … … 1826 1907 QWidgetPrivate *pd = w->parentWidget()->d_func(); 1827 1908 const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w)); 1909 const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect); 1828 1910 for (int i = myIndex + 1; i < pd->children.size(); ++i) { 1829 1911 QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i)); … … 1831 1913 continue; 1832 1914 1833 if (!qRectIntersects(sibling->data->crect, w->data->crect)) 1915 const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect); 1916 if (!qRectIntersects(siblingGeometry, widgetGeometry)) 1834 1917 continue; 1835 1918 … … 1839 1922 } 1840 1923 1841 if (!qRectIntersects(sibling ->data->crect, clipBoundingRect.translated(parentOffset)))1924 if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset))) 1842 1925 continue; 1843 1926 … … 1851 1934 QRegion siblingDirty(parentClip); 1852 1935 siblingDirty &= (siblingClipRect.translated(siblingPos)); 1853 const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask; 1936 const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask 1937 && !sibling->d_func()->graphicsEffect; 1854 1938 if (hasMask) 1855 1939 siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos); … … 1862 1946 sourceRegion -= siblingDirty; 1863 1947 } else { 1864 sourceRegion -= sibling ->data->crect.translated(-parentOffset);1948 sourceRegion -= siblingGeometry.translated(-parentOffset); 1865 1949 } 1866 1950 } else { … … 1893 1977 QPoint offset; 1894 1978 1979 #ifndef QT_NO_GRAPHICSEFFECT 1980 if (graphicsEffect) { 1981 w = q->parentWidget(); 1982 offset -= data.crect.topLeft(); 1983 } 1984 #endif //QT_NO_GRAPHICSEFFECT 1985 1895 1986 while (w) { 1896 1987 const QWidgetPrivate *wd = w->d_func(); … … 1902 1993 w = w->parentWidget(); 1903 1994 } 1904 }1905 1906 bool QWidgetPrivate::hasBackground() const1907 {1908 Q_Q(const QWidget);1909 if (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_PaintOnScreen))1910 return true;1911 if (q->testAttribute(Qt::WA_PaintOnScreen))1912 return true;1913 if (!q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {1914 const QPalette &pal = q->palette();1915 QPalette::ColorRole bg = q->backgroundRole();1916 QBrush bgBrush = pal.brush(bg);1917 return (bgBrush.style() != Qt::NoBrush &&1918 ((q->isWindow() || q->windowType() == Qt::SubWindow)1919 || (QPalette::ColorRole(bg_role) != QPalette::NoRole || (pal.resolve() & (1<<bg)))));1920 }1921 return false;1922 1995 } 1923 1996 … … 1944 2017 setDirtyOpaqueRegion(); 1945 2018 2019 #ifndef QT_NO_GRAPHICSEFFECT 2020 if (graphicsEffect) { 2021 // ### We should probably add QGraphicsEffect::isOpaque at some point. 2022 setOpaque(false); 2023 return; 2024 } 2025 #endif //QT_NO_GRAPHICSEFFECT 2026 1946 2027 Q_Q(QWidget); 1947 2028 #ifdef Q_WS_X11 … … 1991 2072 winUpdateIsOpaque(); 1992 2073 #endif 2074 #ifdef Q_OS_SYMBIAN 2075 s60UpdateIsOpaque(); 2076 #endif 1993 2077 } 1994 2078 … … 2003 2087 #ifdef Q_WS_WIN 2004 2088 winUpdateIsOpaque(); 2089 #endif 2090 #ifdef Q_OS_SYMBIAN 2091 s60UpdateIsOpaque(); 2005 2092 #endif 2006 2093 } … … 2024 2111 p.translate(-off); 2025 2112 widget->d_func()->paintBackground(&p, QRect(off, size())); 2026 2027 } 2028 2029 static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush) 2113 } 2114 2115 static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush) 2030 2116 { 2031 2117 Q_ASSERT(painter); … … 2036 2122 // when filling with the standard widget background. 2037 2123 // Defined in qmacstyle_mac.cpp 2038 extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const Q Point &offset, const QBrush &brush);2039 qt_mac_fill_background(painter, rgn, offset,brush);2124 extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); 2125 qt_mac_fill_background(painter, rgn, brush); 2040 2126 #else 2041 const QRegion translated = rgn.translated(offset); 2042 const QRect rect(translated.boundingRect()); 2043 painter->setClipRegion(translated); 2044 painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); 2045 #endif 2127 #if !defined(QT_NO_STYLE_S60) 2128 // Defined in qs60style.cpp 2129 extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush); 2130 if (!qt_s60_fill_background(painter, rgn, brush)) 2131 #endif // !defined(QT_NO_STYLE_S60) 2132 { 2133 const QRect rect(rgn.boundingRect()); 2134 painter->setClipRegion(rgn); 2135 painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); 2136 } 2137 #endif // Q_WS_MAC 2138 2139 } else if (brush.gradient() 2140 && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) { 2141 painter->save(); 2142 painter->setClipRegion(rgn); 2143 painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); 2144 painter->restore(); 2046 2145 } else { 2047 2146 const QVector<QRect> &rects = rgn.rects(); 2048 2147 for (int i = 0; i < rects.size(); ++i) 2049 painter->fillRect(rects.at(i).translated(offset), brush); 2050 } 2051 } 2052 2053 2054 void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, const QPoint &offset, int flags) const 2148 painter->fillRect(rects.at(i), brush); 2149 } 2150 } 2151 2152 void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const 2055 2153 { 2056 2154 Q_Q(const QWidget); 2155 2156 #ifndef QT_NO_SCROLLAREA 2157 bool resetBrushOrigin = false; 2158 QPointF oldBrushOrigin; 2159 //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture 2160 QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent); 2161 if (scrollArea && scrollArea->viewport() == q) { 2162 QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); 2163 QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); 2164 oldBrushOrigin = painter->brushOrigin(); 2165 resetBrushOrigin = true; 2166 painter->setBrushOrigin(-priv->contentsOffset()); 2167 2168 } 2169 #endif // QT_NO_SCROLLAREA 2057 2170 2058 2171 const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); … … 2064 2177 painter->setCompositionMode(QPainter::CompositionMode_Source); //copy alpha straight in 2065 2178 #endif 2066 fillRegion(painter, rgn, offset,bg);2179 fillRegion(painter, rgn, bg); 2067 2180 } 2068 2181 2069 2182 if (q->autoFillBackground()) 2070 fillRegion(painter, rgn, offset,autoFillBrush);2183 fillRegion(painter, rgn, autoFillBrush); 2071 2184 2072 2185 if (q->testAttribute(Qt::WA_StyledBackground)) { 2073 painter->setClipRegion(rgn .translated(offset));2186 painter->setClipRegion(rgn); 2074 2187 QStyleOption opt; 2075 2188 opt.initFrom(q); 2076 2189 q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); 2077 2190 } 2191 2192 #ifndef QT_NO_SCROLLAREA 2193 if (resetBrushOrigin) 2194 painter->setBrushOrigin(oldBrushOrigin); 2195 #endif // QT_NO_SCROLLAREA 2078 2196 } 2079 2197 … … 2095 2213 Q_Q(QWidget); 2096 2214 // If this was the active application window, reset it 2097 if ( qApp->activeWindow() == q)2098 qApp->setActiveWindow(0);2215 if (QApplication::activeWindow() == q) 2216 QApplication::setActiveWindow(0); 2099 2217 // If the is the active mouse press widget, reset it 2100 2218 if (q == qt_button_down) … … 2137 2255 will be provided a native handle. 2138 2256 2139 \note We recommend that you do not store this value as it is likely to 2140 change at run-time. 2257 On Mac OS X, the type returned depends on which framework Qt was linked 2258 against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt 2259 is using Cocoa, {WId} is a pointer to an NSView. 2260 2261 This value may change at run-time. An event with type QEvent::WinIdChange 2262 will be sent to the widget following a change in window system identifier. 2141 2263 2142 2264 \sa find() … … 2239 2361 widget's style, as described in the \l{Qt Style Sheets} document. 2240 2362 2241 \note Qt style sheets are currently not supported for QMacStyle 2242 (the default style on Mac OS X). We plan to address this in some future 2243 release. 2363 Since Qt 4.5, Qt style sheets fully supports Mac OS X. 2364 2365 \warning Qt style sheets are currently not supported for custom QStyle 2366 subclasses. We plan to address this in some future release. 2244 2367 2245 2368 \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets} … … 2292 2415 if (d->extra && d->extra->style) 2293 2416 return d->extra->style; 2294 return qApp->style();2417 return QApplication::style(); 2295 2418 } 2296 2419 … … 2342 2465 { 2343 2466 Q_Q(QWidget); 2344 createExtra();2345 2346 2467 QStyle *oldStyle = q->style(); 2347 2468 #ifndef QT_NO_STYLE_STYLESHEET 2348 QStyle *origStyle = extra->style; 2349 #endif 2350 extra->style = newStyle; 2469 QStyle *origStyle = 0; 2470 #endif 2471 2472 #ifdef Q_WS_MAC 2473 // the metalhack boolean allows Qt/Mac to do a proper re-polish depending 2474 // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever 2475 // set when changing that attribute and passes the widget's CURRENT style. 2476 // therefore no need to do a reassignment. 2477 if (!metalHack) 2478 #endif 2479 { 2480 createExtra(); 2481 2482 #ifndef QT_NO_STYLE_STYLESHEET 2483 origStyle = extra->style; 2484 #endif 2485 extra->style = newStyle; 2486 } 2351 2487 2352 2488 // repolish … … 2598 2734 Qt::WindowStates QWidget::windowState() const 2599 2735 { 2600 return (Qt::WindowStates)data->window_state;2736 return Qt::WindowStates(data->window_state); 2601 2737 } 2602 2738 … … 2610 2746 void QWidget::overrideWindowState(Qt::WindowStates newstate) 2611 2747 { 2612 QWindowStateChangeEvent e( (Qt::WindowStates)data->window_state, true);2748 QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); 2613 2749 data->window_state = newstate; 2614 2750 QApplication::sendEvent(this, &e); … … 2709 2845 2710 2846 On X11, this function may not work properly with certain window 2711 managers. See \l{geometry.html}{Window Geometry}for an explanation.2847 managers. See the \l{Window Geometry} documentation for an explanation. 2712 2848 2713 2849 \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible() … … 2764 2900 { 2765 2901 const QWidget * w = this; 2766 while ( w &&!w->testAttribute(Qt::WA_ForceDisabled)2902 while (!w->testAttribute(Qt::WA_ForceDisabled) 2767 2903 && !w->isWindow() 2768 2904 && w->parentWidget() … … 2948 3084 // enforce the windows behavior of clearing the cursor on 2949 3085 // disabled widgets 2950 extern void qt_x11_enforce_cursor(QWidget * w); // defined in qwidget_x11.cpp2951 3086 qt_x11_enforce_cursor(q); 2952 3087 } … … 2955 3090 setEnabled_helper_sys(enable); 2956 3091 #endif 2957 #if defined (Q_WS_WIN) 2958 if (q->hasFocus()) 2959 QInputContextPrivate::updateImeStatus(q, true); 2960 #endif 3092 #ifndef QT_NO_IM 3093 if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { 3094 QWidget *focusWidget = effectiveFocusWidget(); 3095 QInputContext *qic = focusWidget->d_func()->inputContext(); 3096 if (enable) { 3097 qic->setFocusWidget(focusWidget); 3098 } else { 3099 qic->reset(); 3100 qic->setFocusWidget(0); 3101 } 3102 } 3103 #endif //QT_NO_IM 2961 3104 QEvent e(QEvent::EnabledChange); 2962 3105 QApplication::sendEvent(q, &e); … … 3053 3196 window frame 3054 3197 3055 See the \l ink geometry.html Window Geometry documentation\endlink3056 for an overview of geometryissues with windows.3198 See the \l{Window Geometry} documentation for an overview of geometry 3199 issues with windows. 3057 3200 3058 3201 By default, this property contains a value that depends on the user's … … 3080 3223 any window frame 3081 3224 3082 See the \l ink geometry.html Window Geometry documentation\endlink3083 for an overview of window geometry.3225 See the \l{Window Geometry} documentation for an overview of geometry 3226 issues with windows. 3084 3227 3085 3228 By default, this property has a value of 0. … … 3100 3243 including any window frame 3101 3244 3102 See the \l ink geometry.html Window Geometry documentation\endlink3103 for an overview of window geometry.3245 See the \l{Window Geometry} documentation for an overview of geometry 3246 issues with windows. 3104 3247 3105 3248 By default, this property has a value of 0. … … 3133 3276 lead to infinite recursion. 3134 3277 3135 See the \l ink geometry.html Window Geometry documentation\endlink3136 for an overview of window geometry.3278 See the \l{Window Geometry} documentation for an overview of geometry 3279 issues with windows. 3137 3280 3138 3281 \sa frameGeometry, size x(), y() … … 3164 3307 can lead to infinite recursion. 3165 3308 3166 See the \l ink geometry.html Window Geometry documentation\endlink3167 for an overview of window geometry.3309 See the \l{Window Geometry} documentation for an overview of geometry 3310 issues with windows. 3168 3311 3169 3312 By default, this property contains a value that depends on the user's … … 3214 3357 \brief the width of the widget excluding any window frame 3215 3358 3216 See the \l ink geometry.html Window Geometry documentation\endlink3217 for an overview of window geometry.3359 See the \l{Window Geometry} documentation for an overview of geometry 3360 issues with windows. 3218 3361 3219 3362 \note Do not use this function to find the width of a screen on 3220 3363 a \l{QDesktopWidget}{multiple screen desktop}. Read 3221 \l{ multiple screens note}{this note} for details.3364 \l{QDesktopWidget#Screen Geometry}{this note} for details. 3222 3365 3223 3366 By default, this property contains a value that depends on the user's … … 3231 3374 \brief the height of the widget excluding any window frame 3232 3375 3233 See the \l ink geometry.html Window Geometry documentation\endlink3234 for an overview of window geometry.3376 See the \l{Window Geometry} documentation for an overview of geometry 3377 issues with windows. 3235 3378 3236 3379 \note Do not use this function to find the height of a screen 3237 on a \l {QDesktopWidget}{multiple screen desktop}. Read3238 \l {multiple screens note}{this note} for details.3380 on a \l{QDesktopWidget}{multiple screen desktop}. Read 3381 \l{QDesktopWidget#Screen Geometry}{this note} for details. 3239 3382 3240 3383 By default, this property contains a value that depends on the user's … … 3251 3394 The rect property equals QRect(0, 0, width(), height()). 3252 3395 3253 See the \l ink geometry.html Window Geometry documentation\endlink3254 for an overview of window geometry.3396 See the \l{Window Geometry} documentation for an overview of geometry 3397 issues with windows. 3255 3398 3256 3399 By default, this property contains a value that depends on the user's … … 3492 3635 } 3493 3636 #endif 3637 int mw = minw, mh = minh; 3638 if (mw == QWIDGETSIZE_MAX) 3639 mw = 0; 3640 if (mh == QWIDGETSIZE_MAX) 3641 mh = 0; 3494 3642 if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) { 3495 3643 qWarning("QWidget::setMinimumSize: (%s/%s) " … … 3497 3645 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, 3498 3646 QWIDGETSIZE_MAX); 3499 minw = qMin<int>(minw, QWIDGETSIZE_MAX);3500 minh = qMin<int>(minh, QWIDGETSIZE_MAX);3647 minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX); 3648 minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX); 3501 3649 } 3502 3650 if (minw < 0 || minh < 0) { … … 3504 3652 "are not possible", 3505 3653 q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); 3506 minw = qMax(minw, 0);3507 minh = qMax(minh, 0);3654 minw = mw = qMax(minw, 0); 3655 minh = mh = qMax(minh, 0); 3508 3656 } 3509 3657 createExtra(); 3510 if (extra->minw == m inw && extra->minh == minh)3658 if (extra->minw == mw && extra->minh == mh) 3511 3659 return false; 3512 extra->minw = m inw;3513 extra->minh = m inh;3514 extra->explicitMinSize = (m inw ? Qt::Horizontal : 0) | (minh ? Qt::Vertical : 0);3660 extra->minw = mw; 3661 extra->minh = mh; 3662 extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0); 3515 3663 return true; 3516 3664 } … … 3572 3720 extra->maxw = maxw; 3573 3721 extra->maxh = maxh; 3574 extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); 3722 extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) | 3723 (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0); 3575 3724 return true; 3576 3725 } … … 3651 3800 This will override the default size constraints set by QLayout. 3652 3801 3802 To remove constraints, set the size to QWIDGETSIZE_MAX. 3803 3653 3804 Alternatively, if you want the widget to have a 3654 3805 fixed size based on its contents, you can call … … 3692 3843 d->updateGeometry_helper(true); 3693 3844 3694 resize(w, h); 3845 if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX) 3846 resize(w, h); 3695 3847 } 3696 3848 … … 4065 4217 parent's background role. 4066 4218 4219 Note that styles are free to choose any color from the palette. 4220 You can modify the palette or set a style sheet if you don't 4221 achieve the result you want with setBackgroundRole(). 4222 4067 4223 \sa backgroundRole(), foregroundRole() 4068 4224 */ … … 4127 4283 that contrasts with the background role. 4128 4284 4285 Note that styles are free to choose any color from the palette. 4286 You can modify the palette or set a style sheet if you don't 4287 achieve the result you want with setForegroundRole(). 4288 4129 4289 \sa foregroundRole(), backgroundRole() 4130 4290 */ … … 4180 4340 appearance of the widget. Instead, you may choose to apply a \l 4181 4341 styleSheet. You can refer to our Knowledge Base article 4182 \l{http://qt software.com/developer/knowledgebase/22}{here} for more4342 \l{http://qt.nokia.com/developer/knowledgebase/22}{here} for more 4183 4343 information. 4184 4344 … … 4195 4355 data->pal.setCurrentColorGroup(QPalette::Disabled); 4196 4356 } else if ((!isVisible() || isActiveWindow()) 4197 #if defined(Q_OS_WIN) && !defined(Q_ OS_WINCE)4357 #if defined(Q_OS_WIN) && !defined(Q_WS_WINCE) 4198 4358 && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this)) 4199 4359 #endif … … 4240 4400 QPalette naturalPalette = QApplication::palette(q); 4241 4401 if (!q->testAttribute(Qt::WA_StyleSheet) 4242 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) || (extra && extra->proxyWidget))) { 4402 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) 4403 #ifndef QT_NO_GRAPHICSVIEW 4404 || (extra && extra->proxyWidget) 4405 #endif //QT_NO_GRAPHICSVIEW 4406 )) { 4243 4407 if (QWidget *p = q->parentWidget()) { 4244 4408 if (!p->testAttribute(Qt::WA_StyleSheet)) { … … 4251 4415 } 4252 4416 } 4253 } else if (extra && extra->proxyWidget) {4417 } 4254 4418 #ifndef QT_NO_GRAPHICSVIEW 4419 else if (extra && extra->proxyWidget) { 4255 4420 QPalette inheritedPalette = extra->proxyWidget->palette(); 4256 4421 inheritedPalette.resolve(inheritedMask); 4257 4422 naturalPalette = inheritedPalette.resolve(naturalPalette); 4423 } 4258 4424 #endif //QT_NO_GRAPHICSVIEW 4259 }4260 4425 } 4261 4426 naturalPalette.resolve(0); … … 4375 4540 QFont naturalFont = QApplication::font(q); 4376 4541 if (!q->testAttribute(Qt::WA_StyleSheet) 4377 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) || (extra && extra->proxyWidget))) { 4542 && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation) 4543 #ifndef QT_NO_GRAPHICSVIEW 4544 || (extra && extra->proxyWidget) 4545 #endif //QT_NO_GRAPHICSVIEW 4546 )) { 4378 4547 if (QWidget *p = q->parentWidget()) { 4379 4548 if (!p->testAttribute(Qt::WA_StyleSheet)) { … … 4386 4555 } 4387 4556 } 4388 } else if (extra && extra->proxyWidget) {4557 } 4389 4558 #ifndef QT_NO_GRAPHICSVIEW 4559 else if (extra && extra->proxyWidget) { 4390 4560 QFont inheritedFont = extra->proxyWidget->font(); 4391 4561 inheritedFont.resolve(inheritedMask); 4392 4562 naturalFont = inheritedFont.resolve(naturalFont); 4563 } 4393 4564 #endif //QT_NO_GRAPHICSVIEW 4394 }4395 4565 } 4396 4566 naturalFont.resolve(0); … … 4439 4609 #endif 4440 4610 // Combine new mask with natural mask and propagate to children. 4611 #ifndef QT_NO_GRAPHICSVIEW 4441 4612 if (!q->parentWidget() && extra && extra->proxyWidget) { 4442 #ifndef QT_NO_GRAPHICSVIEW4443 4613 QGraphicsProxyWidget *p = extra->proxyWidget; 4444 4614 inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); 4615 } else 4445 4616 #endif //QT_NO_GRAPHICSVIEW 4446 } elseif (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {4617 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { 4447 4618 inheritedFontResolveMask = 0; 4448 4619 } … … 4514 4685 4515 4686 When the layout direction is set on a widget, it will propagate to 4516 the widget's children. Children added after the call to \c 4517 setLayoutDirection() will not inherit the parent's layout 4687 the widget's children, but not to a child that is a window and not 4688 to a child for which setLayoutDirection() has been explicitly 4689 called. Also, child widgets added \e after setLayoutDirection() 4690 has been called for the parent do not inherit the parent's layout 4518 4691 direction. 4519 4692 … … 4575 4748 By default, this property contains a cursor with the Qt::ArrowCursor 4576 4749 shape. 4750 4751 Some underlying window implementations will reset the cursor if it 4752 leaves a widget even if the mouse is grabbed. If you want to have 4753 a cursor set for all widgets, even when outside the window, consider 4754 QApplication::setOverrideCursor(). 4577 4755 4578 4756 \sa QApplication::setOverrideCursor() … … 4602 4780 { 4603 4781 d->createExtra(); 4782 QCursor *newCursor = new QCursor(cursor); 4604 4783 delete d->extra->curs; 4605 d->extra->curs = new QCursor(cursor);4784 d->extra->curs = newCursor; 4606 4785 } 4607 4786 setAttribute(Qt::WA_SetCursor); … … 4713 4892 target = redirected; 4714 4893 offset -= redirectionOffset; 4715 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 4716 const QRegion redirectedSystemClip = redirected->paintEngine()->systemClip(); 4717 if (!redirectedSystemClip.isEmpty()) 4718 paintRegion &= redirectedSystemClip.translated(-offset); 4894 } 4895 4896 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 4897 if (QPaintEngine *targetEngine = target->paintEngine()) { 4898 const QRegion targetSystemClip = targetEngine->systemClip(); 4899 if (!targetSystemClip.isEmpty()) 4900 paintRegion &= targetSystemClip.translated(-offset); 4719 4901 } 4720 4902 } … … 4780 4962 4781 4963 const qreal opacity = painter->opacity(); 4782 if (qFuzzy Compare(opacity + 1, qreal(1.0)))4964 if (qFuzzyIsNull(opacity)) 4783 4965 return; // Fully transparent. 4784 4966 … … 4801 4983 QPaintEnginePrivate *enginePriv = engine->d_func(); 4802 4984 Q_ASSERT(enginePriv); 4803 QPaintDevice *target = painter->worldMatrixEnabled() ? engine->paintDevice() : painter->device();4985 QPaintDevice *target = engine->paintDevice(); 4804 4986 Q_ASSERT(target); 4805 4987 … … 4820 5002 const QRegion oldSystemViewport = enginePriv->systemViewport; 4821 5003 4822 // This ensures that transformed system clips are inside the current system clip. 4823 enginePriv->setSystemViewport(oldSystemClip); 5004 // This ensures that all painting triggered by render() is clipped to the current engine clip. 5005 if (painter->hasClipping()) { 5006 const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); 5007 enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); 5008 } else { 5009 enginePriv->setSystemViewport(oldSystemClip); 5010 } 4824 5011 4825 5012 render(target, targetOffset, toBePainted, renderFlags); … … 4836 5023 d->extra->inRenderWithPainter = false; 4837 5024 } 5025 5026 /*! 5027 \brief The graphicsEffect function returns a pointer to the 5028 widget's graphics effect. 5029 5030 If the widget has no graphics effect, 0 is returned. 5031 5032 \since 4.6 5033 5034 \sa setGraphicsEffect() 5035 */ 5036 #ifndef QT_NO_GRAPHICSEFFECT 5037 QGraphicsEffect *QWidget::graphicsEffect() const 5038 { 5039 Q_D(const QWidget); 5040 return d->graphicsEffect; 5041 } 5042 #endif //QT_NO_GRAPHICSEFFECT 5043 5044 /*! 5045 5046 \brief The setGraphicsEffect function is for setting the widget's graphics effect. 5047 5048 Sets \a effect as the widget's effect. If there already is an effect installed 5049 on this widget, QWidget will delete the existing effect before installing 5050 the new \a effect. 5051 5052 If \a effect is the installed on a different widget, setGraphicsEffect() will remove 5053 the effect from the widget and install it on this widget. 5054 5055 QWidget takes ownership of \a effect. 5056 5057 \note This function will apply the effect on itself and all its children. 5058 5059 \since 4.6 5060 5061 \sa graphicsEffect() 5062 */ 5063 #ifndef QT_NO_GRAPHICSEFFECT 5064 void QWidget::setGraphicsEffect(QGraphicsEffect *effect) 5065 { 5066 Q_D(QWidget); 5067 if (d->graphicsEffect == effect) 5068 return; 5069 5070 if (d->graphicsEffect) { 5071 d->invalidateBuffer(rect()); 5072 delete d->graphicsEffect; 5073 d->graphicsEffect = 0; 5074 } 5075 5076 if (effect) { 5077 // Set new effect. 5078 QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); 5079 QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); 5080 d->graphicsEffect = effect; 5081 effect->d_func()->setGraphicsEffectSource(source); 5082 update(); 5083 } 5084 5085 d->updateIsOpaque(); 5086 } 5087 #endif //QT_NO_GRAPHICSEFFECT 4838 5088 4839 5089 bool QWidgetPrivate::isAboutToShow() const … … 4928 5178 4929 5179 QPixmap pixmap(size); 4930 if (!(renderFlags & QWidget::DrawWindowBackground) )5180 if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque) 4931 5181 pixmap.fill(Qt::transparent); 4932 5182 q->render(&pixmap, QPoint(), toBePainted, renderFlags); … … 4981 5231 4982 5232 Q_Q(QWidget); 5233 #ifndef QT_NO_GRAPHICSEFFECT 5234 if (graphicsEffect && graphicsEffect->isEnabled()) { 5235 QGraphicsEffectSource *source = graphicsEffect->d_func()->source; 5236 QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> 5237 (source->d_func()); 5238 if (!sourced->context) { 5239 QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore); 5240 sourced->context = &context; 5241 if (!sharedPainter) { 5242 QPaintEngine *paintEngine = pdev->paintEngine(); 5243 paintEngine->d_func()->systemClip = rgn.translated(offset); 5244 QPainter p(pdev); 5245 p.translate(offset); 5246 context.painter = &p; 5247 graphicsEffect->draw(&p); 5248 paintEngine->d_func()->systemClip = QRegion(); 5249 } else { 5250 context.painter = sharedPainter; 5251 if (sharedPainter->worldTransform() != sourced->lastEffectTransform) { 5252 sourced->invalidateCache(); 5253 sourced->lastEffectTransform = sharedPainter->worldTransform(); 5254 } 5255 sharedPainter->save(); 5256 sharedPainter->translate(offset); 5257 graphicsEffect->draw(sharedPainter); 5258 sharedPainter->restore(); 5259 } 5260 sourced->context = 0; 5261 return; 5262 } 5263 } 5264 #endif //QT_NO_GRAFFICSEFFECT 5265 4983 5266 const bool asRoot = flags & DrawAsRoot; 4984 5267 const bool alsoOnScreen = flags & DrawPaintOnScreen; … … 5013 5296 paintEngine->d_func()->systemClip = toBePainted; 5014 5297 else 5015 paintEngine-> setSystemRect(q->data->crect);5298 paintEngine->d_func()->systemRect = q->data->crect; 5016 5299 5017 5300 //paint the background … … 5020 5303 5021 5304 QPainter p(q); 5022 QPoint scrollAreaOffset; 5023 5024 #ifndef QT_NO_SCROLLAREA 5025 QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(q->parent()); 5026 if (scrollArea && scrollArea->viewport() == q) { 5027 QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr; 5028 QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); 5029 scrollAreaOffset = priv->contentsOffset(); 5030 p.translate(-scrollAreaOffset); 5031 } 5032 #endif // QT_NO_SCROLLAREA 5033 5034 paintBackground(&p, toBePainted, scrollAreaOffset, (asRoot || onScreen) ? flags | DrawAsRoot : 0); 5305 paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0); 5035 5306 } 5036 5307 … … 5064 5335 restoreRedirected(); 5065 5336 if (!sharedPainter) 5066 paintEngine-> setSystemRect(QRect());5337 paintEngine->d_func()->systemRect = QRect(); 5067 5338 else 5068 5339 paintEngine->d_func()->currentClipWidget = 0; … … 5127 5398 } 5128 5399 5129 if (qRectIntersects(boundingRect, x->d ata->crect)) {5400 if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) { 5130 5401 #ifdef Q_BACKINGSTORE_SUBSURFACES 5131 5402 if (x->windowSurface() == currentSurface) … … 5145 5416 QWidgetPrivate *wd = w->d_func(); 5146 5417 const QPoint widgetPos(w->data->crect.topLeft()); 5147 const bool hasMask = wd->extra && wd->extra->hasMask; 5148 5418 const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect; 5149 5419 if (index > 0) { 5150 5420 QRegion wr(rgn); … … 5158 5428 } 5159 5429 5160 if (w->updatesEnabled() && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)) { 5430 if (w->updatesEnabled() 5431 #ifndef QT_NO_GRAPHICSVIEW 5432 && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget) 5433 #endif //QT_NO_GRAPHICSVIEW 5434 ) { 5161 5435 QRegion wRegion(rgn); 5162 wRegion &= w ->data->crect;5436 wRegion &= wd->effectiveRectFor(w->data->crect); 5163 5437 wRegion.translate(-widgetPos); 5164 5438 if (hasMask) … … 5168 5442 } 5169 5443 5444 #ifndef QT_NO_GRAPHICSEFFECT 5445 QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const 5446 { 5447 if (system != Qt::DeviceCoordinates) 5448 return m_widget->rect(); 5449 5450 if (!context) { 5451 // Device coordinates without context not yet supported. 5452 qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); 5453 return QRectF(); 5454 } 5455 5456 return context->painter->worldTransform().mapRect(m_widget->rect()); 5457 } 5458 5459 void QWidgetEffectSourcePrivate::draw(QPainter *painter) 5460 { 5461 if (!context || context->painter != painter) { 5462 m_widget->render(painter); 5463 return; 5464 } 5465 5466 // The region saved in the context is neither clipped to the rect 5467 // nor the mask, so we have to clip it here before calling drawWidget. 5468 QRegion toBePainted = context->rgn; 5469 toBePainted &= m_widget->rect(); 5470 QWidgetPrivate *wd = qt_widget_private(m_widget); 5471 if (wd->extra && wd->extra->hasMask) 5472 toBePainted &= wd->extra->mask; 5473 5474 wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags, 5475 context->sharedPainter, context->backingStore); 5476 } 5477 5478 QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, 5479 QGraphicsEffect::PixmapPadMode mode) const 5480 { 5481 const bool deviceCoordinates = (system == Qt::DeviceCoordinates); 5482 if (!context && deviceCoordinates) { 5483 // Device coordinates without context not yet supported. 5484 qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); 5485 return QPixmap(); 5486 } 5487 5488 QPoint pixmapOffset; 5489 QRectF sourceRect = m_widget->rect(); 5490 5491 if (deviceCoordinates) { 5492 const QTransform &painterTransform = context->painter->worldTransform(); 5493 sourceRect = painterTransform.mapRect(sourceRect); 5494 pixmapOffset = painterTransform.map(pixmapOffset); 5495 } 5496 5497 5498 QRect effectRect; 5499 5500 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { 5501 effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); 5502 5503 } else if (mode == QGraphicsEffect::PadToTransparentBorder) { 5504 effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); 5505 5506 } else { 5507 effectRect = sourceRect.toAlignedRect(); 5508 5509 } 5510 5511 if (offset) 5512 *offset = effectRect.topLeft(); 5513 5514 if (deviceCoordinates) { 5515 // Clip to device rect. 5516 int left, top, right, bottom; 5517 effectRect.getCoords(&left, &top, &right, &bottom); 5518 if (left < 0) { 5519 if (offset) 5520 offset->rx() += -left; 5521 effectRect.setX(0); 5522 } 5523 if (top < 0) { 5524 if (offset) 5525 offset->ry() += -top; 5526 effectRect.setY(0); 5527 } 5528 // NB! We use +-1 for historical reasons (see QRect documentation). 5529 QPaintDevice *device = context->painter->device(); 5530 const int deviceWidth = device->width(); 5531 const int deviceHeight = device->height(); 5532 if (right + 1 > deviceWidth) 5533 effectRect.setRight(deviceWidth - 1); 5534 if (bottom + 1 > deviceHeight) 5535 effectRect.setBottom(deviceHeight -1); 5536 } 5537 5538 pixmapOffset -= effectRect.topLeft(); 5539 5540 QPixmap pixmap(effectRect.size()); 5541 pixmap.fill(Qt::transparent); 5542 m_widget->render(&pixmap, pixmapOffset); 5543 return pixmap; 5544 } 5545 #endif //QT_NO_GRAPHICSEFFECT 5546 5547 #ifndef QT_NO_GRAPHICSVIEW 5170 5548 /*! 5171 5549 \internal … … 5176 5554 widget was found. 5177 5555 */ 5178 QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget( QWidget *origin)5556 QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) 5179 5557 { 5180 5558 if (origin) { … … 5186 5564 return 0; 5187 5565 } 5566 #endif 5188 5567 5189 5568 /*! … … 5266 5645 QString appName = QApplication::applicationName(); 5267 5646 if (!appName.isEmpty()) 5268 windowTitle += QLatin1 String(" ") + QChar(0x2014) + QLatin1String(" ") + appName;5647 windowTitle += QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appName; 5269 5648 #endif 5270 5649 return windowTitle; … … 5301 5680 } 5302 5681 5682 /*! 5683 Returns a modified window title with the [*] place holder 5684 replaced according to the rules described in QWidget::setWindowTitle 5685 5686 This function assumes that "[*]" can be quoted by another 5687 "[*]", so it will replace two place holders by one and 5688 a single last one by either "*" or nothing depending on 5689 the modified flag. 5690 5691 \internal 5692 */ 5303 5693 QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget) 5304 5694 { … … 5312 5702 #endif 5313 5703 5314 QString placeHolder(QLatin1String("[*]")); 5704 if (cap.isEmpty()) 5705 return cap; 5706 5707 QLatin1String placeHolder("[*]"); 5708 int placeHolderLength = 3; // QLatin1String doesn't have length() 5315 5709 5316 5710 int index = cap.indexOf(placeHolder); 5317 5711 5712 // here the magic begins 5318 5713 while (index != -1) { 5319 index += placeHolder .length();5714 index += placeHolderLength; 5320 5715 int count = 1; 5321 5716 while (cap.indexOf(placeHolder, index) == index) { 5322 5717 ++count; 5323 index += placeHolder .length();5718 index += placeHolderLength; 5324 5719 } 5325 5720 … … 5330 5725 cap.replace(lastIndex, 3, QWidget::tr("*")); 5331 5726 else 5332 cap.re place(lastIndex, 3, QLatin1String(""));5727 cap.remove(lastIndex, 3); 5333 5728 } 5334 5729 … … 5336 5731 } 5337 5732 5338 cap.replace(QLatin1String("[*][*]"), QLatin1String("[*]"));5733 cap.replace(QLatin1String("[*][*]"), placeHolder); 5339 5734 5340 5735 return cap; … … 5344 5739 { 5345 5740 Q_Q(QWidget); 5346 if (!q->testAttribute(Qt::WA_WState_Created)) 5347 createWinId(); 5348 setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); 5741 if (q->testAttribute(Qt::WA_WState_Created)) 5742 setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q)); 5349 5743 } 5350 5744 … … 5371 5765 void QWidget::setWindowTitle(const QString &title) 5372 5766 { 5373 if (QWidget::windowTitle() == title )5767 if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull()) 5374 5768 return; 5375 5769 … … 5402 5796 w = w->parentWidget(); 5403 5797 } 5404 return qApp->windowIcon();5798 return QApplication::windowIcon(); 5405 5799 } 5406 5800 … … 5465 5859 \list 5466 5860 \o The file name of the specified path, obtained using QFileInfo::fileName(). 5467 \o An optional \c{*} character, if the \l windowModified property is set,5468 as per the Apple Human Interface Guidelines.5469 5861 \endlist 5470 5862 … … 5515 5907 if (extra->topextra && extra->topextra->caption.isEmpty()) { 5516 5908 #ifdef Q_WS_MAC 5517 setWindowTitle_helper( filePath);5909 setWindowTitle_helper(QFileInfo(filePath).fileName()); 5518 5910 #else 5519 5911 Q_Q(QWidget); … … 5648 6040 be passed into any focus event sent from this function, it is used 5649 6041 to give an explanation of what caused the widget to get focus. 6042 If the window is not active, the widget will be given the focus when 6043 the window becomes active. 5650 6044 5651 6045 First, a focus out event is sent to the focus widget (if any) to … … 5655 6049 same.) 5656 6050 6051 \note On embedded platforms, setFocus() will not cause an input panel 6052 to be opened by the input method. If you want this to happen, you 6053 have to send a QEvent::RequestSoftwareInputPanel event to the 6054 widget yourself. 6055 5657 6056 setFocus() gives focus to a widget regardless of its focus policy, 5658 6057 but does not clear any keyboard grab (see grabKeyboard()). … … 5666 6065 5667 6066 \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(), 5668 setFocusPolicy(), QApplication::focusWidget(), grabKeyboard(),5669 grabMouse(), {Keyboard Focus} 6067 setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(), 6068 grabMouse(), {Keyboard Focus}, QEvent::RequestSoftwareInputPanel 5670 6069 */ 5671 6070 … … 5782 6181 { 5783 6182 QWidget *w = this; 5784 while (w && w->d_func()->focus_child == this) { 5785 w->d_func()->focus_child = 0; 6183 while (w) { 6184 if (w->d_func()->focus_child == this) 6185 w->d_func()->focus_child = 0; 5786 6186 w = w->parentWidget(); 5787 6187 } … … 5885 6285 /*! 5886 6286 Returns the next widget in this widget's focus chain. 6287 6288 \sa previousInFocusChain() 5887 6289 */ 5888 6290 QWidget *QWidget::nextInFocusChain() const 5889 6291 { 5890 6292 return const_cast<QWidget *>(d_func()->focus_next); 6293 } 6294 6295 /*! 6296 \brief The previousInFocusChain function returns the previous 6297 widget in this widget's focus chain. 6298 6299 \sa nextInFocusChain() 6300 6301 \since 4.6 6302 */ 6303 QWidget *QWidget::previousInFocusChain() const 6304 { 6305 return const_cast<QWidget *>(d_func()->focus_prev); 5891 6306 } 5892 6307 … … 5909 6324 { 5910 6325 QWidget *tlw = window(); 5911 if(tlw == qApp->activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))6326 if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup))) 5912 6327 return true; 5913 6328 … … 5924 6339 tlw->parentWidget() && tlw->parentWidget()->isActiveWindow()) 5925 6340 return true; 6341 6342 extern bool qt_mac_insideKeyWindow(const QWidget *); //qwidget_mac.cpp 6343 if (QApplication::testAttribute(Qt::AA_MacPluginApplication) && qt_mac_insideKeyWindow(tlw)) 6344 return true; 5926 6345 #endif 5927 6346 if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) { … … 5930 6349 (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) 5931 6350 return true; 5932 QWidget *w = qApp->activeWindow();6351 QWidget *w = QApplication::activeWindow(); 5933 6352 while(w && tlw->windowType() == Qt::Tool && 5934 6353 !w->isModal() && w->parentWidget()) { … … 6113 6532 This function is called from QDesktopwidget::screen(QPoint) to find the 6114 6533 closest screen for a point. 6534 In directional KeypadNavigation, it is called to find the closest 6535 widget to the current focus widget center. 6115 6536 */ 6116 6537 int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r) … … 6127 6548 dy = p.y() - r.bottom(); 6128 6549 return dx + dy; 6129 }6130 6131 QRect QWidgetPrivate::fromOrToLayoutItemRect(const QRect &rect, int sign) const6132 {6133 QRect r = rect;6134 r.adjust(-sign * leftLayoutItemMargin, -sign * topLayoutItemMargin,6135 +sign * rightLayoutItemMargin, +sign * bottomLayoutItemMargin);6136 return r;6137 6550 } 6138 6551 … … 6225 6638 \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 11 6226 6639 6227 See the \l ink geometry.html Window Geometry documentation\endlink6228 for an overview of geometryissues with windows.6640 See the \l{Window Geometry} documentation for an overview of geometry 6641 issues with windows. 6229 6642 6230 6643 Use QMainWindow::saveState() to save the geometry and the state of … … 6260 6673 6261 6674 If the restored geometry is off-screen, it will be modified to be 6262 inside the theavailable screen geometry.6675 inside the available screen geometry. 6263 6676 6264 6677 To restore geometry saved using QSettings, you can use code like … … 6267 6680 \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 12 6268 6681 6269 See the \l ink geometry.html Window Geometry documentation\endlink6270 for an overview of geometryissues with windows.6682 See the \l{Window Geometry} documentation for an overview of geometry 6683 issues with windows. 6271 6684 6272 6685 Use QMainWindow::restoreState() to restore the geometry and the … … 6385 6798 6386 6799 /*! 6387 Sets the margins around the contents of the widget to have the6388 sizes \a left, \a top, \a right, and \a bottom. The margins are6389 used by the layout system, and may be used by subclasses to6390 specify the areato draw in (e.g. excluding the frame).6391 6392 6393 6394 6800 Sets the margins around the contents of the widget to have the sizes 6801 \a left, \a top, \a right, and \a bottom. The margins are used by 6802 the layout system, and may be used by subclasses to specify the area 6803 to draw in (e.g. excluding the frame). 6804 6805 Changing the margins will trigger a resizeEvent(). 6806 6807 \sa contentsRect(), getContentsMargins() 6395 6808 */ 6396 6809 void QWidget::setContentsMargins(int left, int top, int right, int bottom) … … 6423 6836 } 6424 6837 6425 /*! Returns the widget's contents margins for \a left, \a top, \a 6838 /*! 6839 \overload 6840 \since 4.6 6841 6842 \brief The setContentsMargins function sets the margins around the 6843 widget's contents. 6844 6845 Sets the margins around the contents of the widget to have the 6846 sizes determined by \a margins. The margins are 6847 used by the layout system, and may be used by subclasses to 6848 specify the area to draw in (e.g. excluding the frame). 6849 6850 Changing the margins will trigger a resizeEvent(). 6851 6852 \sa contentsRect(), getContentsMargins() 6853 */ 6854 void QWidget::setContentsMargins(const QMargins &margins) 6855 { 6856 setContentsMargins(margins.left(), margins.top(), 6857 margins.right(), margins.bottom()); 6858 } 6859 6860 /*! 6861 Returns the widget's contents margins for \a left, \a top, \a 6426 6862 right, and \a bottom. 6427 6863 … … 6440 6876 *bottom = d->bottommargin; 6441 6877 } 6878 6879 /*! 6880 \since 4.6 6881 6882 \brief The contentsMargins function returns the widget's contents margins. 6883 6884 \sa getContentsMargins(), setContentsMargins(), contentsRect() 6885 */ 6886 QMargins QWidget::contentsMargins() const 6887 { 6888 Q_D(const QWidget); 6889 return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin); 6890 } 6891 6442 6892 6443 6893 /*! … … 6723 7173 // stores the correct old focus widget even if it's stolen in the 6724 7174 // showevent 6725 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) 7175 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 6726 7176 if (!isEmbedded && q->windowType() == Qt::Popup) 6727 7177 qApp->d_func()->openPopup(q); … … 6740 7190 show_sys(); 6741 7191 6742 #if !defined(Q_WS_WIN) && !defined(Q_WS_MAC) 7192 #if !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN) 6743 7193 if (!isEmbedded && q->windowType() == Qt::Popup) 6744 7194 qApp->d_func()->openPopup(q); … … 6822 7272 // hidden. 6823 7273 if (wasVisible) { 6824 #if defined(Q_WS_WIN) || defined(Q_WS_ PM) || defined(Q_WS_X11)7274 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 6825 7275 qApp->d_func()->sendSyntheticEnterLeave(q); 6826 7276 #endif … … 6860 7310 6861 7311 6862 Widgets are hidden if they were created as independent 6863 windows or as children of visible widgets, or if hide() or setVisible(false) was called. 6864 7312 Widgets are hidden if: 7313 \list 7314 \o they were created as independent windows, 7315 \o they were created as children of visible widgets, 7316 \o hide() or setVisible(false) was called. 7317 \endlist 6865 7318 */ 6866 7319 … … 6926 7379 parent = parent->parentWidget(); 6927 7380 } 6928 if (parent && !d->getOpaqueRegion().isEmpty())7381 if (parent) 6929 7382 parent->d_func()->setDirtyOpaqueRegion(); 6930 7383 } … … 6951 7404 d->show_helper(); 6952 7405 6953 #if defined(Q_WS_WIN) || defined(Q_WS_ PM) || defined(Q_WS_X11)7406 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 6954 7407 qApp->d_func()->sendSyntheticEnterLeave(this); 6955 7408 #endif … … 7066 7519 } 7067 7520 } 7068 #if defined(Q_WS_WIN) || defined(Q_WS_ PM) || defined(Q_WS_X11)7521 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 7069 7522 qApp->d_func()->sendSyntheticEnterLeave(widget); 7070 7523 #endif … … 7108 7561 #ifdef QT3_SUPPORT 7109 7562 if (isMain) 7110 qApp->quit();7563 QApplication::quit(); 7111 7564 #endif 7112 7565 // Attempt to close the application only if this widget has the … … 7233 7686 return isVisible(); 7234 7687 const QWidget * w = this; 7235 while (w 7236 && !w->isHidden() 7688 while (!w->isHidden() 7237 7689 && !w->isWindow() 7238 7690 && w->parentWidget() … … 7291 7743 if (q->isWindow()) { 7292 7744 Qt::Orientations exp; 7293 if ( QLayout *l = q->layout()) {7294 if (l ->hasHeightForWidth())7295 s.setHeight(l ->totalHeightForWidth(s.width()));7296 exp = l ->expandingDirections();7745 if (layout) { 7746 if (layout->hasHeightForWidth()) 7747 s.setHeight(layout->totalHeightForWidth(s.width())); 7748 exp = layout->expandingDirections(); 7297 7749 } else 7298 7750 { … … 7310 7762 QRect screen = QApplication::desktop()->screenGeometry(q->pos()); 7311 7763 #endif 7312 #if defined (Q_ OS_WINCE)7764 #if defined (Q_WS_WINCE) || defined (Q_OS_SYMBIAN) 7313 7765 s.setWidth(qMin(s.width(), screen.width())); 7314 7766 s.setHeight(qMin(s.height(), screen.height())); … … 7352 7804 ensurePolished(); 7353 7805 QSize s = d->adjustedSize(); 7806 7807 if (d->layout) 7808 d->layout->activate(); 7809 7354 7810 if (s.isValid()) 7355 7811 resize(s); … … 7497 7953 case QEvent::MouseButtonDblClick: 7498 7954 case QEvent::MouseMove: 7955 case QEvent::TouchBegin: 7956 case QEvent::TouchUpdate: 7957 case QEvent::TouchEnd: 7499 7958 case QEvent::ContextMenu: 7500 7959 #ifndef QT_NO_WHEELEVENT … … 7562 8021 if (!k->isAccepted() && QApplication::keypadNavigationEnabled() 7563 8022 && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) { 7564 if (k->key() == Qt::Key_Up) 7565 res = focusNextPrevChild(false); 7566 else if (k->key() == Qt::Key_Down) 7567 res = focusNextPrevChild(true); 8023 if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) { 8024 if (k->key() == Qt::Key_Up) 8025 res = focusNextPrevChild(false); 8026 else if (k->key() == Qt::Key_Down) 8027 res = focusNextPrevChild(true); 8028 } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { 8029 if (k->key() == Qt::Key_Up) 8030 res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth); 8031 else if (k->key() == Qt::Key_Right) 8032 res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast); 8033 else if (k->key() == Qt::Key_Down) 8034 res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth); 8035 else if (k->key() == Qt::Key_Left) 8036 res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest); 8037 } 7568 8038 if (res) { 7569 8039 k->accept(); … … 7618 8088 break; 7619 8089 case QEvent::FocusIn: 7620 #if defined(Q_WS_WIN)7621 Q InputContextPrivate::updateImeStatus(this, true);8090 #ifdef QT_SOFTKEYS_ENABLED 8091 QSoftKeyManager::updateSoftKeys(); 7622 8092 #endif 7623 8093 focusInEvent((QFocusEvent*)event); … … 7625 8095 7626 8096 case QEvent::FocusOut: 7627 #if defined(Q_WS_WIN)7628 QInputContextPrivate::updateImeStatus(this, false);7629 #endif7630 8097 focusOutEvent((QFocusEvent*)event); 7631 8098 break; … … 7773 8240 QApplication::sendEvent(w, event); 7774 8241 } 8242 8243 #ifdef QT_SOFTKEYS_ENABLED 8244 if (isWindow() && isActiveWindow()) 8245 QSoftKeyManager::updateSoftKeys(); 8246 #endif 8247 7775 8248 break; } 7776 8249 … … 7784 8257 for (int i = 0; i < childList.size(); ++i) { 7785 8258 QObject *o = childList.at(i); 7786 QApplication::sendEvent(o, event); 8259 if (o) 8260 QApplication::sendEvent(o, event); 7787 8261 } 7788 8262 } … … 7813 8287 for (int i = 0; i < childList.size(); ++i) { 7814 8288 QObject *o = childList.at(i); 7815 if (o != qApp->activeModalWidget()) {8289 if (o && o != QApplication::activeModalWidget()) { 7816 8290 if (qobject_cast<QWidget *>(o) && static_cast<QWidget *>(o)->isWindow()) { 7817 8291 // do not forward the event to child windows, … … 7880 8354 case QEvent::ActionRemoved: 7881 8355 case QEvent::ActionChanged: 8356 #ifdef QT_SOFTKEYS_ENABLED 8357 QSoftKeyManager::updateSoftKeys(); 8358 #endif 7882 8359 actionEvent((QActionEvent*)event); 7883 8360 break; … … 7902 8379 break; 7903 8380 #endif 8381 case QEvent::TouchBegin: 8382 case QEvent::TouchUpdate: 8383 case QEvent::TouchEnd: 8384 { 8385 #ifndef Q_WS_MAC 8386 QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); 8387 const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first(); 8388 if (touchPoint.isPrimary() || touchEvent->deviceType() == QTouchEvent::TouchPad) 8389 break; 8390 8391 // fake a mouse event! 8392 QEvent::Type eventType = QEvent::None; 8393 switch (touchEvent->type()) { 8394 case QEvent::TouchBegin: 8395 eventType = QEvent::MouseButtonPress; 8396 break; 8397 case QEvent::TouchUpdate: 8398 eventType = QEvent::MouseMove; 8399 break; 8400 case QEvent::TouchEnd: 8401 eventType = QEvent::MouseButtonRelease; 8402 break; 8403 default: 8404 Q_ASSERT(!true); 8405 break; 8406 } 8407 if (eventType == QEvent::None) 8408 break; 8409 8410 QMouseEvent mouseEvent(eventType, 8411 touchPoint.pos().toPoint(), 8412 touchPoint.screenPos().toPoint(), 8413 Qt::LeftButton, 8414 Qt::LeftButton, 8415 touchEvent->modifiers()); 8416 (void) QApplication::sendEvent(this, &mouseEvent); 8417 #endif // Q_WS_MAC 8418 break; 8419 } 8420 case QEvent::Gesture: 8421 event->ignore(); 8422 break; 7904 8423 #ifndef QT_NO_PROPERTIES 7905 8424 case QEvent::DynamicPropertyChange: { … … 7953 8472 case QEvent::FontChange: 7954 8473 case QEvent::StyleChange: { 8474 Q_D(QWidget); 7955 8475 update(); 7956 8476 updateGeometry(); 8477 if (d->layout) 8478 d->layout->invalidate(); 7957 8479 #ifdef Q_WS_QWS 7958 Q_D(QWidget);7959 8480 if (isWindow()) 7960 8481 d->data.fstrut_dirty = true; … … 8036 8557 event->accept(); 8037 8558 QWidget* w; 8038 while ((w = qApp->activePopupWidget()) && w != this){8559 while ((w = QApplication::activePopupWidget()) && w != this){ 8039 8560 w->close(); 8040 if ( qApp->activePopupWidget() == w) // widget does not want to dissappear8561 if (QApplication::activePopupWidget() == w) // widget does not want to dissappear 8041 8562 w->hide(); // hide at least 8042 8563 } … … 8066 8587 The default implementation generates a normal mouse press event. 8067 8588 8068 Note that the widgets gets a mousePressEvent() and a 8069 mouseReleaseEvent() before the mouseDoubleClickEvent(). 8589 \note The widget will also receive mouse press and mouse release 8590 events in addition to the double click event. It is up to the 8591 developer to ensure that the application interprets these events 8592 correctly. 8070 8593 8071 8594 \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), … … 8448 8971 \a query specifies which property is queried. 8449 8972 8450 \sa inputMethodEvent(), QInputMethodEvent, QInputContext 8973 \sa inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints 8451 8974 */ 8452 8975 QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const … … 8457 8980 case Qt::ImFont: 8458 8981 return font(); 8982 case Qt::ImAnchorPosition: 8983 // Fallback. 8984 return inputMethodQuery(Qt::ImCursorPosition); 8459 8985 default: 8460 8986 return QVariant(); 8461 8987 } 8462 8988 } 8989 8990 /*! 8991 \property QWidget::inputMethodHints 8992 \brief What input method specific hints the widget has. 8993 8994 This is only relevant for input widgets. It is used by 8995 the input method to retrieve hints as to how the input method 8996 should operate. For example, if the Qt::ImhFormattedNumbersOnly flag 8997 is set, the input method may change its visual components to reflect 8998 that only numbers can be entered. 8999 9000 \note The flags are only hints, so the particular input method 9001 implementation is free to ignore them. If you want to be 9002 sure that a certain type of characters are entered, 9003 you should also set a QValidator on the widget. 9004 9005 The default value is Qt::ImhNone. 9006 9007 \since 4.6 9008 9009 \sa inputMethodQuery(), QInputContext 9010 */ 9011 Qt::InputMethodHints QWidget::inputMethodHints() const 9012 { 9013 Q_D(const QWidget); 9014 #ifndef QT_NO_IM 9015 return d->imHints; 9016 #else //QT_NO_IM 9017 return 0; 9018 #endif //QT_NO_IM 9019 } 9020 9021 void QWidget::setInputMethodHints(Qt::InputMethodHints hints) 9022 { 9023 #ifndef QT_NO_IM 9024 Q_D(QWidget); 9025 d->imHints = hints; 9026 // Optimisation to update input context only it has already been created. 9027 if (d->ic || qApp->d_func()->inputContext) { 9028 QInputContext *ic = inputContext(); 9029 if (ic) 9030 ic->update(); 9031 } 9032 #endif //QT_NO_IM 9033 } 9034 8463 9035 8464 9036 #ifndef QT_NO_DRAGANDDROP … … 8803 9375 that have been added to the layout. 8804 9376 8805 \sa setLayout(), sizePolicy(), {Layout Classes}9377 \sa setLayout(), sizePolicy(), {Layout Management} 8806 9378 */ 8807 9379 QLayout *QWidget::layout() const … … 8833 9405 The QWidget will take ownership of \a layout. 8834 9406 8835 \sa layout(), {Layout Classes}9407 \sa layout(), {Layout Management} 8836 9408 */ 8837 9409 … … 9234 9806 #endif 9235 9807 9236 if ( newParent) {9237 if ( QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {9808 if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) { 9809 if (newParent) 9238 9810 oldBs->removeDirtyWidget(this); 9239 // Move the widget and all its static children from 9240 // the old backing store to the new one. 9241 oldBs->moveStaticWidgets(this); 9242 } 9811 // Move the widget and all its static children from 9812 // the old backing store to the new one. 9813 oldBs->moveStaticWidgets(this); 9243 9814 } 9244 9815 … … 9268 9839 d->resolveLocale(); 9269 9840 9270 // Note: GL widgets under Windows will always need a ParentChange 9271 // event to handle recreation/rebinding of the GL context, hence 9272 // the (f & Qt::MSWindowsOwnDC) clause 9841 // Note: GL widgets under WGL or EGL will always need a ParentChange 9842 // event to handle recreation/rebinding of the GL context, hence the 9843 // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all 9844 // platforms). 9273 9845 if (newParent 9274 #if def Q_WS_WIN9846 #if defined(Q_WS_WIN) || defined(QT_OPENGL_ES) 9275 9847 || (f & Qt::MSWindowsOwnDC) 9276 9848 #endif … … 9370 9942 #ifndef QT_NO_GRAPHICSVIEW 9371 9943 if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { 9372 9373 9374 9375 9376 9377 9378 9944 // Graphics View maintains its own dirty region as a list of rects; 9945 // until we can connect item updates directly to the view, we must 9946 // separately add a translated dirty region. 9947 if (!d->dirty.isEmpty()) { 9948 foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) 9949 proxy->update(rect); 9950 } 9379 9951 proxy->scroll(dx, dy, proxy->subWidgetRect(this)); 9380 9952 return; … … 9405 9977 #ifndef QT_NO_GRAPHICSVIEW 9406 9978 if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { 9407 9408 9409 9410 9411 9412 9413 9979 // Graphics View maintains its own dirty region as a list of rects; 9980 // until we can connect item updates directly to the view, we must 9981 // separately add a translated dirty region. 9982 if (!d->dirty.isEmpty()) { 9983 foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) 9984 proxy->update(rect); 9985 } 9414 9986 proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); 9415 9987 return; … … 9477 10049 return; 9478 10050 9479 QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0; 9480 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { 9481 tlwExtra->inRepaint = true; 9482 tlwExtra->backingStore->markDirty(rect, this, true); 9483 tlwExtra->inRepaint = false; 10051 if (hasBackingStoreSupport()) { 10052 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); 10053 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { 10054 tlwExtra->inRepaint = true; 10055 tlwExtra->backingStore->markDirty(rect, this, true); 10056 tlwExtra->inRepaint = false; 10057 } 9484 10058 } else { 9485 10059 d->repaint_sys(rect); … … 9504 10078 return; 9505 10079 9506 QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0; 9507 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { 9508 tlwExtra->inRepaint = true; 9509 tlwExtra->backingStore->markDirty(rgn, this, true); 9510 tlwExtra->inRepaint = false; 10080 if (hasBackingStoreSupport()) { 10081 QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); 10082 if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { 10083 tlwExtra->inRepaint = true; 10084 tlwExtra->backingStore->markDirty(rgn, this, true); 10085 tlwExtra->inRepaint = false; 10086 } 9511 10087 } else { 9512 10088 d->repaint_sys(rgn); … … 9690 10266 9691 10267 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 9692 if (attribute == Qt::WA_PaintOnScreen && on) { 10268 // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 10269 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { 9693 10270 // see qwidget_[win|pm].cpp, ::paintEngine for details 9694 10271 paintEngine(); … … 9804 10381 ? Qt::WindowModal 9805 10382 : Qt::ApplicationModal; 10383 // Some window managers does not allow us to enter modal after the 10384 // window is showing. Therefore, to be consistent, we cannot call 10385 // QApplicationPrivate::enterModal(this) here. The window must be 10386 // hidden before changing modality. 9806 10387 } 9807 10388 if (testAttribute(Qt::WA_WState_Created)) { … … 9814 10395 QApplication::sendEvent(this, &e); 9815 10396 break; } 9816 #if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN)9817 case Qt::WA_MSWindowsUseDirect3D:9818 if (!qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault)) {9819 if (on) {9820 if (!d->extra)9821 d->createExtra();9822 d->extra->had_auto_fill_bg = d->extra->autoFillBackground;9823 d->extra->had_no_system_bg = testAttribute(Qt::WA_NoSystemBackground);9824 d->extra->had_paint_on_screen = testAttribute(Qt::WA_PaintOnScreen);9825 // enforce the opaque widget state D3D needs9826 d->extra->autoFillBackground = true;9827 setAttribute(Qt::WA_PaintOnScreen);9828 setAttribute(Qt::WA_NoSystemBackground);9829 } else if (d->extra) {9830 d->extra->autoFillBackground = d->extra->had_auto_fill_bg;9831 setAttribute(Qt::WA_PaintOnScreen, d->extra->had_paint_on_screen);9832 setAttribute(Qt::WA_NoSystemBackground, d->extra->had_no_system_bg);9833 }9834 }9835 break;9836 #endif9837 10397 case Qt::WA_NativeWindow: { 9838 10398 #ifndef QT_NO_IM 10399 QWidget *focusWidget = d->effectiveFocusWidget(); 9839 10400 QInputContext *ic = 0; 9840 10401 if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) { 9841 ic = d->inputContext();10402 ic = focusWidget->d_func()->inputContext(); 9842 10403 ic->reset(); 9843 10404 ic->setFocusWidget(0); … … 9848 10409 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) 9849 10410 d->createWinId(); 9850 #ifndef QT_NO_IM 9851 if (ic) 9852 ic->setFocusWidget(this); 9853 #endif 10411 if (ic && isEnabled()) 10412 ic->setFocusWidget(focusWidget); 10413 #endif //QT_NO_IM 9854 10414 break; 9855 10415 } … … 9881 10441 break; 9882 10442 case Qt::WA_InputMethodEnabled: { 9883 #if defined(Q_WS_WIN) || (defined(Q_WS_QWS) && !defined(QT_NO_QWS_INPUTMETHODS))9884 if (hasFocus())9885 QInputContextPrivate::updateImeStatus(this, true);9886 #endif9887 10443 #ifndef QT_NO_IM 9888 QInputContext *ic = d->ic; 9889 if (!ic) { 9890 // implicitly create input context only if we have a focus 9891 if (hasFocus()) 9892 ic = d->inputContext(); 9893 } 10444 QWidget *focusWidget = d->effectiveFocusWidget(); 10445 QInputContext *ic = focusWidget->d_func()->ic; 10446 if (!ic && (!on || hasFocus())) 10447 ic = focusWidget->d_func()->inputContext(); 9894 10448 if (ic) { 9895 if (on && hasFocus() && ic->focusWidget() != this) {9896 ic->setFocusWidget( this);9897 } else if (!on && ic->focusWidget() == this) {10449 if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()) { 10450 ic->setFocusWidget(focusWidget); 10451 } else if (!on && ic->focusWidget() == focusWidget) { 9898 10452 ic->reset(); 9899 10453 ic->setFocusWidget(0); 9900 10454 } 9901 10455 } 9902 #endif 10456 #endif //QT_NO_IM 9903 10457 break; 9904 10458 } … … 9971 10525 9972 10526 break; 10527 case Qt::WA_AcceptTouchEvents: 10528 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_S60) 10529 if (on) 10530 d->registerTouchWindow(); 10531 #endif 10532 break; 9973 10533 default: 9974 10534 break; … … 10001 10561 By default the value of this property is 1.0. 10002 10562 10003 This feature is available on Embedded Linux, Mac OS X, X11 platforms that10004 support the Composite extension, and Windows 2000 and later.10563 This feature is available on Embedded Linux, Mac OS X, Windows, 10564 and X11 platforms that support the Composite extension. 10005 10565 10006 10566 This feature is not available on Windows CE. … … 10326 10886 void QWidget::updateMicroFocus() 10327 10887 { 10328 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) )10888 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) 10329 10889 Q_D(QWidget); 10330 10890 // and optimisation to update input context only it has already been created. … … 11033 11593 */ 11034 11594 11595 /*! 11596 \fn QWidget::setupUi(QWidget *widget) 11597 11598 Sets up the user interface for the specified \a widget. 11599 11600 \note This function is available with widgets that derive from user 11601 interface descriptions created using \l{uic}. 11602 11603 \sa {Using a Designer UI File in Your Application} 11604 */ 11605 11035 11606 QRect QWidgetPrivate::frameStrut() const 11036 11607 { … … 11051 11622 return maybeTopData() ? maybeTopData()->frameStrut : QRect(); 11052 11623 } 11624 11625 #ifdef QT_KEYPAD_NAVIGATION 11626 /*! 11627 \internal 11628 11629 Changes the focus from the current focusWidget to a widget in 11630 the \a direction. 11631 11632 Returns true, if there was a widget in that direction 11633 */ 11634 bool QWidgetPrivate::navigateToDirection(Direction direction) 11635 { 11636 QWidget *targetWidget = widgetInNavigationDirection(direction); 11637 if (targetWidget) 11638 targetWidget->setFocus(); 11639 return (targetWidget != 0); 11640 } 11641 11642 /*! 11643 \internal 11644 11645 Searches for a widget that is positioned in the \a direction, starting 11646 from the current focusWidget. 11647 11648 Returns the pointer to a found widget or 0, if there was no widget in 11649 that direction. 11650 */ 11651 QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) 11652 { 11653 const QWidget *sourceWidget = QApplication::focusWidget(); 11654 if (!sourceWidget) 11655 return 0; 11656 const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint())); 11657 const int sourceX = 11658 (direction == DirectionNorth || direction == DirectionSouth) ? 11659 (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2) 11660 :(direction == DirectionEast ? sourceRect.right() : sourceRect.left()); 11661 const int sourceY = 11662 (direction == DirectionEast || direction == DirectionWest) ? 11663 (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2) 11664 :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top()); 11665 const QPoint sourcePoint(sourceX, sourceY); 11666 const QPoint sourceCenter = sourceRect.center(); 11667 const QWidget *sourceWindow = sourceWidget->window(); 11668 11669 QWidget *targetWidget = 0; 11670 int shortestDistance = INT_MAX; 11671 foreach(QWidget *targetCandidate, QApplication::allWidgets()) { 11672 11673 const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); 11674 11675 // For focus proxies, the child widget handling the focus can have keypad navigation focus, 11676 // but the owner of the proxy cannot. 11677 // Additionally, empty widgets should be ignored. 11678 if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty()) 11679 continue; 11680 11681 // Only navigate to a target widget that... 11682 if ( targetCandidate != sourceWidget 11683 // ...takes the focus, 11684 && targetCandidate->focusPolicy() & Qt::TabFocus 11685 // ...is above if DirectionNorth, 11686 && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top()) 11687 // ...is on the right if DirectionEast, 11688 && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right()) 11689 // ...is below if DirectionSouth, 11690 && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom()) 11691 // ...is on the left if DirectionWest, 11692 && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left()) 11693 // ...is enabled, 11694 && targetCandidate->isEnabled() 11695 // ...is visible, 11696 && targetCandidate->isVisible() 11697 // ...is in the same window, 11698 && targetCandidate->window() == sourceWindow) { 11699 const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect); 11700 if (targetCandidateDistance < shortestDistance) { 11701 shortestDistance = targetCandidateDistance; 11702 targetWidget = targetCandidate; 11703 } 11704 } 11705 } 11706 return targetWidget; 11707 } 11708 #endif 11053 11709 11054 11710 /*! … … 11210 11866 11211 11867 11212 11213 11214 11868 #ifndef QT_NO_GRAPHICSVIEW 11215 11869 /*! … … 11240 11894 */ 11241 11895 11242 QT_END_NAMESPACE 11243 11244 #include "moc_qwidget.cpp" 11896 /*! 11897 Subscribes the widget to a given \a gesture with specific \a flags. 11898 11899 \sa ungrabGesture(), QGestureEvent 11900 \since 4.6 11901 */ 11902 void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) 11903 { 11904 Q_D(QWidget); 11905 d->gestureContext.insert(gesture, flags); 11906 (void)QGestureManager::instance(); // create a gesture manager 11907 } 11908 11909 /*! 11910 Unsubscribes the widget from a given \a gesture type 11911 11912 \sa grabGesture(), QGestureEvent 11913 \since 4.6 11914 */ 11915 void QWidget::ungrabGesture(Qt::GestureType gesture) 11916 { 11917 Q_D(QWidget); 11918 if (d->gestureContext.remove(gesture)) { 11919 QGestureManager *manager = QGestureManager::instance(); 11920 manager->cleanupCachedGestures(this, gesture); 11921 } 11922 } 11923 11245 11924 11246 11925 /*! … … 11314 11993 button is released. 11315 11994 11316 Note that only visible widgets can grab mouse input. If 11317 isVisible() returns false for a widget, that widget cannot call 11318 grabMouse(). 11319 11320 \sa releaseMouse() grabKeyboard() releaseKeyboard() grabKeyboard() 11321 focusWidget() 11995 \note Only visible widgets can grab mouse input. If isVisible() 11996 returns false for a widget, that widget cannot call grabMouse(). 11997 11998 \note \bold{(Mac OS X developers)} For \e Cocoa, calling 11999 grabMouse() on a widget only works when the mouse is inside the 12000 frame of that widget. For \e Carbon, it works outside the widget's 12001 frame as well, like for Windows and X11. 12002 12003 \sa releaseMouse() grabKeyboard() releaseKeyboard() 11322 12004 */ 11323 12005 11324 12006 /*! 11325 12007 \fn void QWidget::grabMouse(const QCursor &cursor) 11326 \overload 12008 \overload grabMouse() 11327 12009 11328 12010 Grabs the mouse input and changes the cursor shape. … … 11333 12015 11334 12016 \warning Grabbing the mouse might lock the terminal. 12017 12018 \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse(). 11335 12019 11336 12020 \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() … … 11539 12223 } 11540 12224 12225 /*! \fn const QX11Info &QWidget::x11Info() const 12226 Returns information about the configuration of the X display used to display 12227 the widget. 12228 12229 \warning This function is only available on X11. 12230 */ 12231 12232 /*! \fn Qt::HANDLE QWidget::x11PictureHandle() const 12233 Returns the X11 Picture handle of the widget for XRender 12234 support. Use of this function is not portable. This function will 12235 return 0 if XRender support is not compiled into Qt, if the 12236 XRender extension is not supported on the X11 display, or if the 12237 handle could not be created. 12238 */ 12239 12240 #ifdef Q_OS_SYMBIAN 12241 void QWidgetPrivate::_q_delayedDestroy(WId winId) 12242 { 12243 delete winId; 12244 } 12245 #endif 12246 12247 QT_END_NAMESPACE 12248 12249 #include "moc_qwidget.cpp" 12250
Note:
See TracChangeset
for help on using the changeset viewer.