115 #include "private/qabstractscrollarea_p.h" |
115 #include "private/qabstractscrollarea_p.h" |
116 #include "private/qevent_p.h" |
116 #include "private/qevent_p.h" |
117 |
117 |
118 #include "private/qgraphicssystem_p.h" |
118 #include "private/qgraphicssystem_p.h" |
119 #include "private/qgesturemanager_p.h" |
119 #include "private/qgesturemanager_p.h" |
|
120 |
|
121 #ifdef QT_KEYPAD_NAVIGATION |
|
122 #include "qtabwidget.h" // Needed in inTabWidget() |
|
123 #endif // QT_KEYPAD_NAVIGATION |
120 |
124 |
121 // widget/widget data creation count |
125 // widget/widget data creation count |
122 //#define QWIDGET_EXTRA_DEBUG |
126 //#define QWIDGET_EXTRA_DEBUG |
123 //#define ALIEN_DEBUG |
127 //#define ALIEN_DEBUG |
124 |
128 |
6117 if (QWExtra *topData = window()->d_func()->extra) { |
6121 if (QWExtra *topData = window()->d_func()->extra) { |
6118 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) { |
6122 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) { |
6119 previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); |
6123 previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); |
6120 if (previousProxyFocus && previousProxyFocus->focusProxy()) |
6124 if (previousProxyFocus && previousProxyFocus->focusProxy()) |
6121 previousProxyFocus = previousProxyFocus->focusProxy(); |
6125 previousProxyFocus = previousProxyFocus->focusProxy(); |
|
6126 if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus) |
|
6127 return; |
6122 } |
6128 } |
6123 } |
6129 } |
6124 #endif |
6130 #endif |
6125 |
6131 |
6126 QWidget *w = f; |
6132 QWidget *w = f; |
7529 QList<QObject*> childList = children; |
7535 QList<QObject*> childList = children; |
7530 for (int i = 0; i < childList.size(); ++i) { |
7536 for (int i = 0; i < childList.size(); ++i) { |
7531 QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); |
7537 QWidget *widget = qobject_cast<QWidget*>(childList.at(i)); |
7532 if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden)) |
7538 if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden)) |
7533 continue; |
7539 continue; |
|
7540 #ifdef QT_MAC_USE_COCOA |
|
7541 // Before doing anything we need to make sure that we don't leave anything in a non-consistent state. |
|
7542 // When hiding a widget we need to make sure that no mouse_down events are active, because |
|
7543 // the mouse_up event will never be received by a hidden widget or one of its descendants. |
|
7544 // The solution is simple, before going through with this we check if there are any mouse_down events in |
|
7545 // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and |
|
7546 // then we continue. |
|
7547 // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already |
|
7548 // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the |
|
7549 // mouse release event. There are two ways to interpret this: |
|
7550 // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it |
|
7551 // might be waiting for a release event that will never arrive. |
|
7552 // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not |
|
7553 // supposed to trigger because it is not visible. |
|
7554 if(widget == qt_button_down) |
|
7555 qt_button_down = 0; |
|
7556 #endif // QT_MAC_USE_COCOA |
7534 if (spontaneous) |
7557 if (spontaneous) |
7535 widget->setAttribute(Qt::WA_Mapped, false); |
7558 widget->setAttribute(Qt::WA_Mapped, false); |
7536 else |
7559 else |
7537 widget->setAttribute(Qt::WA_WState_Visible, false); |
7560 widget->setAttribute(Qt::WA_WState_Visible, false); |
7538 widget->d_func()->hideChildren(spontaneous); |
7561 widget->d_func()->hideChildren(spontaneous); |
7923 inline void setDisabledStyle(QWidget *w, bool setStyle) |
7946 inline void setDisabledStyle(QWidget *w, bool setStyle) |
7924 { |
7947 { |
7925 // set/reset WS_DISABLED style. |
7948 // set/reset WS_DISABLED style. |
7926 if(w && w->isWindow() && w->isVisible() && w->isEnabled()) { |
7949 if(w && w->isWindow() && w->isVisible() && w->isEnabled()) { |
7927 LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE); |
7950 LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE); |
|
7951 LONG newStyle = dwStyle; |
7928 if (setStyle) |
7952 if (setStyle) |
7929 dwStyle |= WS_DISABLED; |
7953 newStyle |= WS_DISABLED; |
7930 else |
7954 else |
7931 dwStyle &= ~WS_DISABLED; |
7955 newStyle &= ~WS_DISABLED; |
7932 SetWindowLong(w->winId(), GWL_STYLE, dwStyle); |
7956 if (newStyle != dwStyle) { |
7933 // we might need to repaint in some situations (eg. menu) |
7957 SetWindowLong(w->winId(), GWL_STYLE, newStyle); |
7934 w->repaint(); |
7958 // we might need to repaint in some situations (eg. menu) |
|
7959 w->repaint(); |
|
7960 } |
7935 } |
7961 } |
7936 } |
7962 } |
7937 #endif |
7963 #endif |
7938 |
7964 |
7939 /***************************************************************************** |
7965 /***************************************************************************** |
11624 } |
11650 } |
11625 } |
11651 } |
11626 } |
11652 } |
11627 return targetWidget; |
11653 return targetWidget; |
11628 } |
11654 } |
|
11655 |
|
11656 /*! |
|
11657 \internal |
|
11658 |
|
11659 Tells us if it there is currently a reachable widget by keypad navigation in |
|
11660 a certain \a orientation. |
|
11661 If no navigation is possible, occuring key events in that \a orientation may |
|
11662 be used to interact with the value in the focussed widget, even though it |
|
11663 currently has not the editFocus. |
|
11664 |
|
11665 \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus() |
|
11666 */ |
|
11667 bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation) |
|
11668 { |
|
11669 return orientation == Qt::Horizontal? |
|
11670 (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast) |
|
11671 || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest)) |
|
11672 :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth) |
|
11673 || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth)); |
|
11674 } |
|
11675 /*! |
|
11676 \internal |
|
11677 |
|
11678 Checks, if the \a widget is inside a QTabWidget. If is is inside |
|
11679 one, left/right key events will be used to switch between tabs in keypad |
|
11680 navigation. If there is no QTabWidget, the horizontal key events can be used |
|
11681 to |
|
11682 interact with the value in the focussed widget, even though it currently has |
|
11683 not the editFocus. |
|
11684 |
|
11685 \sa QWidget::hasEditFocus() |
|
11686 */ |
|
11687 bool QWidgetPrivate::inTabWidget(QWidget *widget) |
|
11688 { |
|
11689 for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget()) |
|
11690 if (qobject_cast<const QTabWidget*>(tabWidget)) |
|
11691 return true; |
|
11692 return false; |
|
11693 } |
11629 #endif |
11694 #endif |
11630 |
11695 |
11631 /*! |
11696 /*! |
11632 \preliminary |
11697 \preliminary |
11633 \since 4.2 |
11698 \since 4.2 |