src/gui/kernel/qwidget.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     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 **
  3086 #ifndef QT_NO_IM
  3086 #ifndef QT_NO_IM
  3087     if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
  3087     if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
  3088         QWidget *focusWidget = effectiveFocusWidget();
  3088         QWidget *focusWidget = effectiveFocusWidget();
  3089         QInputContext *qic = focusWidget->d_func()->inputContext();
  3089         QInputContext *qic = focusWidget->d_func()->inputContext();
  3090         if (enable) {
  3090         if (enable) {
  3091             qic->setFocusWidget(focusWidget);
  3091             if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
       
  3092                 qic->setFocusWidget(focusWidget);
  3092         } else {
  3093         } else {
  3093             qic->reset();
  3094             qic->reset();
  3094             qic->setFocusWidget(0);
  3095             qic->setFocusWidget(0);
  3095         }
  3096         }
  3096     }
  3097     }
  9772                 newBs->subSurfaces.append(windowSurface);
  9773                 newBs->subSurfaces.append(windowSurface);
  9773         }
  9774         }
  9774     }
  9775     }
  9775 #endif
  9776 #endif
  9776 
  9777 
  9777     if (newParent) {
  9778     if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
  9778         if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
  9779         if (newParent)
  9779             oldBs->removeDirtyWidget(this);
  9780             oldBs->removeDirtyWidget(this);
  9780             // Move the widget and all its static children from
  9781         // Move the widget and all its static children from
  9781             // the old backing store to the new one.
  9782         // the old backing store to the new one.
  9782             oldBs->moveStaticWidgets(this);
  9783         oldBs->moveStaticWidgets(this);
  9783         }
       
  9784     }
  9784     }
  9785 
  9785 
  9786     if ((QApplicationPrivate::app_compile_version < 0x040200
  9786     if ((QApplicationPrivate::app_compile_version < 0x040200
  9787          || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
  9787          || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
  9788         && !testAttribute(Qt::WA_WState_Created))
  9788         && !testAttribute(Qt::WA_WState_Created))
 10356         break; }
 10356         break; }
 10357     case Qt::WA_NativeWindow: {
 10357     case Qt::WA_NativeWindow: {
 10358 #ifndef QT_NO_IM
 10358 #ifndef QT_NO_IM
 10359         QWidget *focusWidget = d->effectiveFocusWidget();
 10359         QWidget *focusWidget = d->effectiveFocusWidget();
 10360         QInputContext *ic = 0;
 10360         QInputContext *ic = 0;
 10361         if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) {
 10361         if (on && !internalWinId() && hasFocus()
       
 10362             && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
 10362             ic = focusWidget->d_func()->inputContext();
 10363             ic = focusWidget->d_func()->inputContext();
 10363             ic->reset();
 10364             if (ic) {
 10364             ic->setFocusWidget(0);
 10365                 ic->reset();
       
 10366                 ic->setFocusWidget(0);
       
 10367             }
 10365         }
 10368         }
 10366         if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
 10369         if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
 10367             parentWidget()->d_func()->enforceNativeChildren();
 10370             parentWidget()->d_func()->enforceNativeChildren();
 10368         if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
 10371         if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
 10369             d->createWinId();
 10372             d->createWinId();
 10370         if (ic && isEnabled())
 10373         if (ic && isEnabled() && focusWidget->isEnabled()
       
 10374             && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
 10371             ic->setFocusWidget(focusWidget);
 10375             ic->setFocusWidget(focusWidget);
       
 10376         }
 10372 #endif //QT_NO_IM
 10377 #endif //QT_NO_IM
 10373         break;
 10378         break;
 10374     }
 10379     }
 10375     case Qt::WA_PaintOnScreen:
 10380     case Qt::WA_PaintOnScreen:
 10376         d->updateIsOpaque();
 10381         d->updateIsOpaque();
 10403         QWidget *focusWidget = d->effectiveFocusWidget();
 10408         QWidget *focusWidget = d->effectiveFocusWidget();
 10404         QInputContext *ic = focusWidget->d_func()->ic;
 10409         QInputContext *ic = focusWidget->d_func()->ic;
 10405         if (!ic && (!on || hasFocus()))
 10410         if (!ic && (!on || hasFocus()))
 10406             ic = focusWidget->d_func()->inputContext();
 10411             ic = focusWidget->d_func()->inputContext();
 10407         if (ic) {
 10412         if (ic) {
 10408             if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()) {
 10413             if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()
       
 10414                 && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
 10409                 ic->setFocusWidget(focusWidget);
 10415                 ic->setFocusWidget(focusWidget);
 10410             } else if (!on && ic->focusWidget() == focusWidget) {
 10416             } else if (!on && ic->focusWidget() == focusWidget) {
 10411                 ic->reset();
 10417                 ic->reset();
 10412                 ic->setFocusWidget(0);
 10418                 ic->setFocusWidget(0);
 10413             }
 10419             }
 11870     It is almost never necessary to grab the mouse when using Qt, as
 11876     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
 11877     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
 11878     mouse when a mouse button is pressed and keeps it until the last
 11873     button is released.
 11879     button is released.
 11874 
 11880 
 11875     Note that only visible widgets can grab mouse input. If
 11881     \note Only visible widgets can grab mouse input. If isVisible()
 11876     isVisible() returns false for a widget, that widget cannot call
 11882     returns false for a widget, that widget cannot call grabMouse().
 11877     grabMouse().
 11883 
       
 11884     \note \bold{(Mac OS X developers)} For \e Cocoa, calling
       
 11885     grabMouse() on a widget only works when the mouse is inside the
       
 11886     frame of that widget.  For \e Carbon, it works outside the widget's
       
 11887     frame as well, like for Windows and X11.
 11878 
 11888 
 11879     \sa releaseMouse() grabKeyboard() releaseKeyboard()
 11889     \sa releaseMouse() grabKeyboard() releaseKeyboard()
 11880 */
 11890 */
 11881 
 11891 
 11882 /*!
 11892 /*!
 11883     \fn void QWidget::grabMouse(const QCursor &cursor)
 11893     \fn void QWidget::grabMouse(const QCursor &cursor)
 11884     \overload
 11894     \overload grabMouse()
 11885 
 11895 
 11886     Grabs the mouse input and changes the cursor shape.
 11896     Grabs the mouse input and changes the cursor shape.
 11887 
 11897 
 11888     The cursor will assume shape \a cursor (for as long as the mouse
 11898     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
 11899     focus is grabbed) and this widget will be the only one to receive
 11890     mouse events until releaseMouse() is called().
 11900     mouse events until releaseMouse() is called().
 11891 
 11901 
 11892     \warning Grabbing the mouse might lock the terminal.
 11902     \warning Grabbing the mouse might lock the terminal.
       
 11903 
       
 11904     \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse().
 11893 
 11905 
 11894     \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
 11906     \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
 11895 */
 11907 */
 11896 
 11908 
 11897 /*!
 11909 /*!