77 #include "qwidget.h" |
77 #include "qwidget.h" |
78 #include "qcolormap.h" |
78 #include "qcolormap.h" |
79 #include "qlayout.h" |
79 #include "qlayout.h" |
80 #include "qtooltip.h" |
80 #include "qtooltip.h" |
81 #include "qt_windows.h" |
81 #include "qt_windows.h" |
|
82 #include "qscrollbar.h" |
82 #if defined(QT_NON_COMMERCIAL) |
83 #if defined(QT_NON_COMMERCIAL) |
83 #include "qnc_win.h" |
84 #include "qnc_win.h" |
84 #endif |
85 #endif |
85 #include "private/qwininputcontext_p.h" |
86 #include "private/qwininputcontext_p.h" |
86 #include "private/qcursor_p.h" |
87 #include "private/qcursor_p.h" |
439 |
440 |
440 #if defined(Q_WS_WIN) |
441 #if defined(Q_WS_WIN) |
441 #define __export |
442 #define __export |
442 #endif |
443 #endif |
443 |
444 |
444 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); |
445 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); |
445 |
446 |
446 class QETWidget : public QWidget // event translator widget |
447 class QETWidget : public QWidget // event translator widget |
447 { |
448 { |
448 public: |
449 public: |
449 QWExtra *xtra() { return d_func()->extraData(); } |
450 QWExtra *xtra() { return d_func()->extraData(); } |
699 menu.setColor(QPalette::Inactive, QPalette::Button, menubar); |
700 menu.setColor(QPalette::Inactive, QPalette::Button, menubar); |
700 } |
701 } |
701 QApplication::setPalette(menu, "QMenuBar"); |
702 QApplication::setPalette(menu, "QMenuBar"); |
702 } |
703 } |
703 |
704 |
|
705 static void qt_set_windows_updateScrollBar(QWidget *widget) |
|
706 { |
|
707 QList<QObject*> children = widget->children(); |
|
708 for (int i = 0; i < children.size(); ++i) { |
|
709 QObject *o = children.at(i); |
|
710 if(!o->isWidgetType()) |
|
711 continue; |
|
712 if (QWidget *w = static_cast<QWidget *>(o)) |
|
713 qt_set_windows_updateScrollBar(w); |
|
714 } |
|
715 if (qobject_cast<QScrollBar*>(widget)) |
|
716 widget->updateGeometry(); |
|
717 } |
|
718 |
|
719 |
704 /***************************************************************************** |
720 /***************************************************************************** |
705 qt_init() - initializes Qt for Windows |
721 qt_init() - initializes Qt for Windows |
706 *****************************************************************************/ |
722 *****************************************************************************/ |
707 |
723 |
708 typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID); |
724 typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID); |
1398 || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK) |
1414 || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK) |
1399 #endif |
1415 #endif |
1400 ; |
1416 ; |
1401 } |
1417 } |
1402 |
1418 |
1403 extern "C" |
1419 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) |
1404 LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) |
|
1405 { |
1420 { |
1406 bool result = true; |
1421 bool result = true; |
1407 QEvent::Type evt_type = QEvent::None; |
1422 QEvent::Type evt_type = QEvent::None; |
1408 QETWidget *widget = 0; |
1423 QETWidget *widget = 0; |
1409 |
1424 |
1577 |
1592 |
1578 case WM_LBUTTONDOWN: |
1593 case WM_LBUTTONDOWN: |
1579 case WM_MBUTTONDOWN: |
1594 case WM_MBUTTONDOWN: |
1580 case WM_RBUTTONDOWN: |
1595 case WM_RBUTTONDOWN: |
1581 case WM_XBUTTONDOWN: |
1596 case WM_XBUTTONDOWN: |
|
1597 case WM_LBUTTONDBLCLK: |
|
1598 case WM_RBUTTONDBLCLK: |
|
1599 case WM_MBUTTONDBLCLK: |
|
1600 case WM_XBUTTONDBLCLK: |
1582 if (qt_win_ignoreNextMouseReleaseEvent) |
1601 if (qt_win_ignoreNextMouseReleaseEvent) |
1583 qt_win_ignoreNextMouseReleaseEvent = false; |
1602 qt_win_ignoreNextMouseReleaseEvent = false; |
1584 break; |
1603 break; |
1585 |
1604 |
1586 case WM_LBUTTONUP: |
1605 case WM_LBUTTONUP: |
1915 if (area == QLatin1String("intl")) { |
1934 if (area == QLatin1String("intl")) { |
1916 #endif |
1935 #endif |
1917 QLocalePrivate::updateSystemPrivate(); |
1936 QLocalePrivate::updateSystemPrivate(); |
1918 if (!widget->testAttribute(Qt::WA_SetLocale)) |
1937 if (!widget->testAttribute(Qt::WA_SetLocale)) |
1919 widget->dptr()->setLocale_helper(QLocale(), true); |
1938 widget->dptr()->setLocale_helper(QLocale(), true); |
|
1939 QEvent e(QEvent::LocaleChange); |
|
1940 QApplication::sendEvent(qApp, &e); |
1920 } |
1941 } |
1921 } |
1942 } |
1922 else if (msg.wParam == SPI_SETICONTITLELOGFONT) { |
1943 else if (msg.wParam == SPI_SETICONTITLELOGFONT) { |
1923 if (QApplication::desktopSettingsAware()) { |
1944 if (QApplication::desktopSettingsAware()) { |
1924 widget = (QETWidget*)QWidget::find(hwnd); |
1945 widget = (QETWidget*)QWidget::find(hwnd); |
1925 if (widget && !widget->parentWidget()) { |
1946 if (widget && !widget->parentWidget()) { |
1926 qt_set_windows_font_resources(); |
1947 qt_set_windows_font_resources(); |
1927 } |
1948 } |
1928 } |
1949 } |
1929 } |
1950 } |
|
1951 else if (msg.wParam == SPI_SETNONCLIENTMETRICS) { |
|
1952 widget = (QETWidget*)QWidget::find(hwnd); |
|
1953 if (widget && !widget->parentWidget()) { |
|
1954 qt_set_windows_updateScrollBar(widget); |
|
1955 QEvent e(QEvent::LayoutRequest); |
|
1956 QApplication::sendEvent(widget, &e); |
|
1957 } |
|
1958 } |
|
1959 |
1930 break; |
1960 break; |
1931 |
1961 |
1932 case WM_PAINT: // paint event |
1962 case WM_PAINT: // paint event |
1933 case WM_ERASEBKGND: // erase window background |
1963 case WM_ERASEBKGND: // erase window background |
1934 result = widget->translatePaintEvent(msg); |
1964 result = widget->translatePaintEvent(msg); |
2277 #endif //QT_NO_CLIPBOARD |
2307 #endif //QT_NO_CLIPBOARD |
2278 #ifndef QT_NO_ACCESSIBILITY |
2308 #ifndef QT_NO_ACCESSIBILITY |
2279 case WM_GETOBJECT: |
2309 case WM_GETOBJECT: |
2280 { |
2310 { |
2281 // Ignoring all requests while starting up |
2311 // Ignoring all requests while starting up |
2282 if (QApplication::startingUp() || QApplication::closingDown() || (DWORD)lParam != OBJID_CLIENT) { |
2312 if (QApplication::startingUp() || QApplication::closingDown() || (LONG)lParam != OBJID_CLIENT) { |
2283 result = false; |
2313 result = false; |
2284 break; |
2314 break; |
2285 } |
2315 } |
2286 |
2316 |
2287 typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN); |
2317 typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN); |
2445 QApplication::postEvent(widget, new QEvent(QEvent::OkRequest)); |
2475 QApplication::postEvent(widget, new QEvent(QEvent::OkRequest)); |
2446 if (CancelCommand) |
2476 if (CancelCommand) |
2447 QApplication::postEvent(widget, new QEvent(QEvent::Close)); |
2477 QApplication::postEvent(widget, new QEvent(QEvent::Close)); |
2448 else |
2478 else |
2449 #ifndef QT_NO_MENUBAR |
2479 #ifndef QT_NO_MENUBAR |
2450 QMenuBar::wceCommands(LOWORD(wParam), (HWND) lParam); |
2480 QMenuBar::wceCommands(LOWORD(wParam)); |
2451 #endif |
2481 #endif |
2452 result = true; |
2482 result = true; |
2453 } |
2483 } |
2454 break; |
2484 break; |
2455 case WM_HELP: |
2485 case WM_HELP: |
2980 MSG *msgPtr = (MSG *)(&msg); |
3021 MSG *msgPtr = (MSG *)(&msg); |
2981 // Update the passed in MSG structure with the |
3022 // Update the passed in MSG structure with the |
2982 // most recent one. |
3023 // most recent one. |
2983 msgPtr->lParam = mouseMsg.lParam; |
3024 msgPtr->lParam = mouseMsg.lParam; |
2984 msgPtr->wParam = mouseMsg.wParam; |
3025 msgPtr->wParam = mouseMsg.wParam; |
2985 msgPtr->pt = mouseMsg.pt; |
3026 // Extract the x,y coordinates from the lParam as we do in the WndProc |
|
3027 msgPtr->pt.x = GET_X_LPARAM(mouseMsg.lParam); |
|
3028 msgPtr->pt.y = GET_Y_LPARAM(mouseMsg.lParam); |
|
3029 ClientToScreen(msg.hwnd, &(msgPtr->pt)); |
2986 // Remove the mouse move message |
3030 // Remove the mouse move message |
2987 PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE, |
3031 PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE, |
2988 WM_MOUSEMOVE, PM_REMOVE); |
3032 WM_MOUSEMOVE, PM_REMOVE); |
2989 } else { |
3033 } else { |
2990 break; // there was no more WM_MOUSEMOVE event |
3034 break; // there was no more WM_MOUSEMOVE event |