1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
190 , dirtyOpaqueChildren(1) |
190 , dirtyOpaqueChildren(1) |
191 , isOpaque(0) |
191 , isOpaque(0) |
192 , inDirtyList(0) |
192 , inDirtyList(0) |
193 , isScrolled(0) |
193 , isScrolled(0) |
194 , isMoved(0) |
194 , isMoved(0) |
|
195 , isGLWidget(0) |
195 , usesDoubleBufferedGLContext(0) |
196 , usesDoubleBufferedGLContext(0) |
196 #if defined(Q_WS_X11) |
197 #if defined(Q_WS_X11) |
197 , picture(0) |
198 , picture(0) |
198 #elif defined(Q_WS_WIN) |
199 #elif defined(Q_WS_WIN) |
199 , noPaintOnScreen(0) |
200 , noPaintOnScreen(0) |
200 , nativeGesturePanEnabled(0) |
201 , nativeGesturePanEnabled(0) |
201 #elif defined(Q_WS_MAC) |
202 #elif defined(Q_WS_MAC) |
202 , needWindowChange(0) |
203 , needWindowChange(0) |
203 , isGLWidget(0) |
|
204 , window_event(0) |
204 , window_event(0) |
205 , qd_hd(0) |
205 , qd_hd(0) |
206 #endif |
206 #endif |
207 { |
207 { |
208 if (!qApp) { |
208 if (!qApp) { |
1437 qApp->d_func()->sendSyntheticEnterLeave(this); |
1437 qApp->d_func()->sendSyntheticEnterLeave(this); |
1438 #endif |
1438 #endif |
1439 } |
1439 } |
1440 #endif |
1440 #endif |
1441 |
1441 |
|
1442 #ifdef Q_OS_SYMBIAN |
|
1443 if (d->extra && d->extra->topextra && d->extra->topextra->backingStore) { |
|
1444 // Okay, we are about to destroy the top-level window that owns |
|
1445 // the backing store. Make sure we delete the backing store right away |
|
1446 // before the window handle is invalid. This is important because |
|
1447 // the backing store will delete its window surface, which may or may |
|
1448 // not have a reference to this widget that will be used later to |
|
1449 // notify the window it no longer has a surface. |
|
1450 delete d->extra->topextra->backingStore; |
|
1451 d->extra->topextra->backingStore = 0; |
|
1452 } |
|
1453 #endif |
1442 if (QWidgetBackingStore *bs = d->maybeBackingStore()) { |
1454 if (QWidgetBackingStore *bs = d->maybeBackingStore()) { |
1443 bs->removeDirtyWidget(this); |
1455 bs->removeDirtyWidget(this); |
1444 if (testAttribute(Qt::WA_StaticContents)) |
1456 if (testAttribute(Qt::WA_StaticContents)) |
1445 bs->removeStaticWidget(this); |
1457 bs->removeStaticWidget(this); |
1446 } |
1458 } |
1658 { |
1670 { |
1659 if (paintOnScreen()) { |
1671 if (paintOnScreen()) { |
1660 repaint_sys(dirty); |
1672 repaint_sys(dirty); |
1661 dirty = QRegion(); |
1673 dirty = QRegion(); |
1662 } else if (QWidgetBackingStore *bs = maybeBackingStore()) { |
1674 } else if (QWidgetBackingStore *bs = maybeBackingStore()) { |
|
1675 #ifdef QT_MAC_USE_COCOA |
|
1676 Q_UNUSED(bs); |
|
1677 void qt_mac_set_needs_display(QWidget *, QRegion); |
|
1678 qt_mac_set_needs_display(q_func(), QRegion()); |
|
1679 #else |
1663 bs->sync(); |
1680 bs->sync(); |
|
1681 #endif |
1664 } |
1682 } |
1665 } |
1683 } |
1666 |
1684 |
1667 void QWidgetPrivate::syncBackingStore(const QRegion ®ion) |
1685 void QWidgetPrivate::syncBackingStore(const QRegion ®ion) |
1668 { |
1686 { |
1669 if (paintOnScreen()) |
1687 if (paintOnScreen()) |
1670 repaint_sys(region); |
1688 repaint_sys(region); |
1671 else if (QWidgetBackingStore *bs = maybeBackingStore()) |
1689 else if (QWidgetBackingStore *bs = maybeBackingStore()) { |
|
1690 #ifdef QT_MAC_USE_COCOA |
|
1691 Q_UNUSED(bs); |
|
1692 void qt_mac_set_needs_display(QWidget *, QRegion); |
|
1693 qt_mac_set_needs_display(q_func(), region); |
|
1694 #else |
1672 bs->sync(q_func(), region); |
1695 bs->sync(q_func(), region); |
|
1696 #endif |
|
1697 } |
1673 } |
1698 } |
1674 |
1699 |
1675 void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) |
1700 void QWidgetPrivate::setUpdatesEnabled_helper(bool enable) |
1676 { |
1701 { |
1677 Q_Q(QWidget); |
1702 Q_Q(QWidget); |
3086 #ifndef QT_NO_IM |
3119 #ifndef QT_NO_IM |
3087 if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { |
3120 if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { |
3088 QWidget *focusWidget = effectiveFocusWidget(); |
3121 QWidget *focusWidget = effectiveFocusWidget(); |
3089 QInputContext *qic = focusWidget->d_func()->inputContext(); |
3122 QInputContext *qic = focusWidget->d_func()->inputContext(); |
3090 if (enable) { |
3123 if (enable) { |
3091 qic->setFocusWidget(focusWidget); |
3124 if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) |
|
3125 qic->setFocusWidget(focusWidget); |
3092 } else { |
3126 } else { |
3093 qic->reset(); |
3127 qic->reset(); |
3094 qic->setFocusWidget(0); |
3128 qic->setFocusWidget(0); |
3095 } |
3129 } |
3096 } |
3130 } |
3341 lead to infinite recursion. |
3375 lead to infinite recursion. |
3342 |
3376 |
3343 \note Setting the size to \c{QSize(0, 0)} will cause the widget to not |
3377 \note Setting the size to \c{QSize(0, 0)} will cause the widget to not |
3344 appear on screen. This also applies to windows. |
3378 appear on screen. This also applies to windows. |
3345 |
3379 |
3346 \sa pos, geometry, minimumSize, maximumSize, resizeEvent() |
3380 \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize() |
3347 */ |
3381 */ |
3348 |
3382 |
3349 /*! |
3383 /*! |
3350 \property QWidget::width |
3384 \property QWidget::width |
3351 \brief the width of the widget excluding any window frame |
3385 \brief the width of the widget excluding any window frame |
9772 newBs->subSurfaces.append(windowSurface); |
9808 newBs->subSurfaces.append(windowSurface); |
9773 } |
9809 } |
9774 } |
9810 } |
9775 #endif |
9811 #endif |
9776 |
9812 |
9777 if (newParent) { |
9813 if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) { |
9778 if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) { |
9814 if (newParent) |
9779 oldBs->removeDirtyWidget(this); |
9815 oldBs->removeDirtyWidget(this); |
9780 // Move the widget and all its static children from |
9816 // Move the widget and all its static children from |
9781 // the old backing store to the new one. |
9817 // the old backing store to the new one. |
9782 oldBs->moveStaticWidgets(this); |
9818 oldBs->moveStaticWidgets(this); |
9783 } |
|
9784 } |
9819 } |
9785 |
9820 |
9786 if ((QApplicationPrivate::app_compile_version < 0x040200 |
9821 if ((QApplicationPrivate::app_compile_version < 0x040200 |
9787 || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation)) |
9822 || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation)) |
9788 && !testAttribute(Qt::WA_WState_Created)) |
9823 && !testAttribute(Qt::WA_WState_Created)) |
10356 break; } |
10391 break; } |
10357 case Qt::WA_NativeWindow: { |
10392 case Qt::WA_NativeWindow: { |
10358 #ifndef QT_NO_IM |
10393 #ifndef QT_NO_IM |
10359 QWidget *focusWidget = d->effectiveFocusWidget(); |
10394 QWidget *focusWidget = d->effectiveFocusWidget(); |
10360 QInputContext *ic = 0; |
10395 QInputContext *ic = 0; |
10361 if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) { |
10396 if (on && !internalWinId() && hasFocus() |
|
10397 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { |
10362 ic = focusWidget->d_func()->inputContext(); |
10398 ic = focusWidget->d_func()->inputContext(); |
10363 ic->reset(); |
10399 if (ic) { |
10364 ic->setFocusWidget(0); |
10400 ic->reset(); |
|
10401 ic->setFocusWidget(0); |
|
10402 } |
10365 } |
10403 } |
10366 if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) |
10404 if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) |
10367 parentWidget()->d_func()->enforceNativeChildren(); |
10405 parentWidget()->d_func()->enforceNativeChildren(); |
10368 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) |
10406 if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) |
10369 d->createWinId(); |
10407 d->createWinId(); |
10370 if (ic && isEnabled()) |
10408 if (ic && isEnabled() && focusWidget->isEnabled() |
|
10409 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { |
10371 ic->setFocusWidget(focusWidget); |
10410 ic->setFocusWidget(focusWidget); |
|
10411 } |
10372 #endif //QT_NO_IM |
10412 #endif //QT_NO_IM |
10373 break; |
10413 break; |
10374 } |
10414 } |
10375 case Qt::WA_PaintOnScreen: |
10415 case Qt::WA_PaintOnScreen: |
10376 d->updateIsOpaque(); |
10416 d->updateIsOpaque(); |
10403 QWidget *focusWidget = d->effectiveFocusWidget(); |
10443 QWidget *focusWidget = d->effectiveFocusWidget(); |
10404 QInputContext *ic = focusWidget->d_func()->ic; |
10444 QInputContext *ic = focusWidget->d_func()->ic; |
10405 if (!ic && (!on || hasFocus())) |
10445 if (!ic && (!on || hasFocus())) |
10406 ic = focusWidget->d_func()->inputContext(); |
10446 ic = focusWidget->d_func()->inputContext(); |
10407 if (ic) { |
10447 if (ic) { |
10408 if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()) { |
10448 if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled() |
|
10449 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { |
10409 ic->setFocusWidget(focusWidget); |
10450 ic->setFocusWidget(focusWidget); |
10410 } else if (!on && ic->focusWidget() == focusWidget) { |
10451 } else if (!on && ic->focusWidget() == focusWidget) { |
10411 ic->reset(); |
10452 ic->reset(); |
10412 ic->setFocusWidget(0); |
10453 ic->setFocusWidget(0); |
10413 } |
10454 } |
11870 It is almost never necessary to grab the mouse when using Qt, as |
11911 It is almost never necessary to grab the mouse when using Qt, as |
11871 Qt grabs and releases it sensibly. In particular, Qt grabs the |
11912 Qt grabs and releases it sensibly. In particular, Qt grabs the |
11872 mouse when a mouse button is pressed and keeps it until the last |
11913 mouse when a mouse button is pressed and keeps it until the last |
11873 button is released. |
11914 button is released. |
11874 |
11915 |
11875 Note that only visible widgets can grab mouse input. If |
11916 \note Only visible widgets can grab mouse input. If isVisible() |
11876 isVisible() returns false for a widget, that widget cannot call |
11917 returns false for a widget, that widget cannot call grabMouse(). |
11877 grabMouse(). |
11918 |
|
11919 \note \bold{(Mac OS X developers)} For \e Cocoa, calling |
|
11920 grabMouse() on a widget only works when the mouse is inside the |
|
11921 frame of that widget. For \e Carbon, it works outside the widget's |
|
11922 frame as well, like for Windows and X11. |
11878 |
11923 |
11879 \sa releaseMouse() grabKeyboard() releaseKeyboard() |
11924 \sa releaseMouse() grabKeyboard() releaseKeyboard() |
11880 */ |
11925 */ |
11881 |
11926 |
11882 /*! |
11927 /*! |
11883 \fn void QWidget::grabMouse(const QCursor &cursor) |
11928 \fn void QWidget::grabMouse(const QCursor &cursor) |
11884 \overload |
11929 \overload grabMouse() |
11885 |
11930 |
11886 Grabs the mouse input and changes the cursor shape. |
11931 Grabs the mouse input and changes the cursor shape. |
11887 |
11932 |
11888 The cursor will assume shape \a cursor (for as long as the mouse |
11933 The cursor will assume shape \a cursor (for as long as the mouse |
11889 focus is grabbed) and this widget will be the only one to receive |
11934 focus is grabbed) and this widget will be the only one to receive |
11890 mouse events until releaseMouse() is called(). |
11935 mouse events until releaseMouse() is called(). |
11891 |
11936 |
11892 \warning Grabbing the mouse might lock the terminal. |
11937 \warning Grabbing the mouse might lock the terminal. |
|
11938 |
|
11939 \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse(). |
11893 |
11940 |
11894 \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() |
11941 \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() |
11895 */ |
11942 */ |
11896 |
11943 |
11897 /*! |
11944 /*! |