Changeset 561 for trunk/src/gui/kernel/qwidget_win.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_win.cpp
r2 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 ** … … 57 57 #include "private/qwindowsurface_raster_p.h" 58 58 59 #ifndef QT_NO_DIRECT3D 60 #include "private/qpaintengine_d3d_p.h" 61 #include "private/qwindowsurface_d3d_p.h" 62 #endif 63 59 #include "qscrollbar.h" 60 #include "qabstractscrollarea.h" 61 #include <private/qabstractscrollarea_p.h> 64 62 65 63 #include <qdebug.h> … … 69 67 #include <private/qpaintengine_raster_p.h> 70 68 71 #if defined(Q_ OS_WINCE)69 #if defined(Q_WS_WINCE) 72 70 #include "qguifunctions_wince.h" 73 71 QT_USE_NAMESPACE … … 147 145 return; 148 146 QLibrary library(QLatin1String("wintab32")); 149 QT_WA({ 150 ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW"); 151 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); 152 } , { 153 ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenA"); 154 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA"); 155 }); 156 147 ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW"); 148 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); 157 149 ptrWTClose = (PtrWTClose)library.resolve("WTClose"); 158 150 ptrWTQueueSizeGet = (PtrWTQueueSizeGet)library.resolve("WTQueueSizeGet"); … … 170 162 qt_tablet_widget->createWinId(); 171 163 qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget")); 164 // We dont need this internal widget to appear in QApplication::topLevelWidgets() 165 if (QWidgetPrivate::allWidgets) 166 QWidgetPrivate::allWidgets->remove(qt_tablet_widget); 172 167 LOGCONTEXT lcMine; 173 168 qAddPostRoutine(qt_tablet_cleanup); … … 258 253 *****************************************************************************/ 259 254 260 #ifndef Q_ OS_WINCE255 #ifndef Q_WS_WINCE 261 256 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) 262 257 { … … 277 272 HINSTANCE appinst = qWinAppInst(); 278 273 HWND parentw, destroyw = 0; 279 WId id ;274 WId id = 0; 280 275 281 276 QString windowClassName = qt_reg_winclass(q); … … 294 289 if (desktop && !q->testAttribute(Qt::WA_DontShowOnScreen)) { // desktop widget 295 290 popup = false; // force this flags off 296 if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95) 297 data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN */), 291 data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN */), 298 292 GetSystemMetrics(78 /* SM_CXVIRTUALSCREEN */), GetSystemMetrics(79 /* SM_CYVIRTUALSCREEN */)); 299 else300 data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));301 293 } 302 294 303 295 parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0; 304 296 305 #ifdef UNICODE306 297 QString title; 307 const TCHAR *ttitle = 0;308 #endif309 QByteArray title95;310 298 int style = WS_CHILD; 311 299 int exsty = 0; 312 300 313 301 if (window) { 314 style = GetWindowLong A(window, GWL_STYLE);302 style = GetWindowLong(window, GWL_STYLE); 315 303 if (!style) 316 304 qErrnoWarning("QWidget::create: GetWindowLong failed"); … … 368 356 369 357 if (flags & Qt::WindowTitleHint) { 370 QT_WA({ 371 title = q->isWindow() ? qAppName() : q->objectName(); 372 ttitle = (TCHAR*)title.utf16(); 373 } , { 374 title95 = q->isWindow() ? qAppName().toLocal8Bit() : q->objectName().toLatin1(); 375 }); 358 title = q->isWindow() ? qAppName() : q->objectName(); 376 359 } 377 360 … … 386 369 id = window; 387 370 setWinId(window); 388 LONG res = SetWindowLong A(window, GWL_STYLE, style);371 LONG res = SetWindowLong(window, GWL_STYLE, style); 389 372 if (!res) 390 373 qErrnoWarning("QWidget::create: Failed to set window style"); 391 374 #ifdef _WIN64 392 res = SetWindowLongPtr A( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc );375 res = SetWindowLongPtr( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc ); 393 376 #else 394 res = SetWindowLong A( window, GWL_WNDPROC, (LONG)QtWndProc );377 res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc ); 395 378 #endif 396 379 if (!res) … … 443 426 } 444 427 445 QT_WA({ 446 const TCHAR *cname = (TCHAR*)windowClassName.utf16(); 447 id = CreateWindowEx(exsty, cname, ttitle, style, 448 x, y, w, h, 449 parentw, 0, appinst, 0); 450 } , { 451 id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style, 452 x, y, w, h, 453 parentw, 0, appinst, 0); 454 }); 428 id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()), 429 reinterpret_cast<const wchar_t *>(title.utf16()), style, 430 x, y, w, h, 431 parentw, NULL, appinst, NULL); 455 432 if (!id) 456 433 qErrnoWarning("QWidget::create: Failed to create window"); … … 464 441 winUpdateIsOpaque(); 465 442 } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget 466 QT_WA({ 467 const TCHAR *cname = (TCHAR*)windowClassName.utf16(); 468 id = CreateWindowEx(exsty, cname, ttitle, style, 469 data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(), 443 id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()), 444 reinterpret_cast<const wchar_t *>(title.utf16()), style, 445 data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(), 470 446 parentw, NULL, appinst, NULL); 471 } , {472 id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,473 data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),474 parentw, NULL, appinst, NULL);475 });476 447 if (!id) 477 448 qErrnoWarning("QWidget::create: Failed to create window"); … … 504 475 } 505 476 477 if (topLevel) { 478 if (data.window_flags & Qt::CustomizeWindowHint 479 && data.window_flags & Qt::WindowTitleHint) { 480 HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE); 481 if (data.window_flags & Qt::WindowCloseButtonHint) 482 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED); 483 else 484 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); 485 } 486 } 487 506 488 q->setAttribute(Qt::WA_WState_Created); // accept move/resize events 507 489 hd = 0; // no display context 490 491 if (q->testAttribute(Qt::WA_AcceptTouchEvents)) 492 registerTouchWindow(); 508 493 509 494 if (window) { // got window from outside … … 547 532 } 548 533 549 #endif //Q_ OS_WINCE534 #endif //Q_WS_WINCE 550 535 551 536 … … 554 539 Q_D(QWidget); 555 540 if (!isWindow() && parentWidget()) 556 parentWidget()->d_func()->invalidateBuffer( geometry());541 parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); 557 542 d->deactivateWidgetCleanup(); 558 543 if (testAttribute(Qt::WA_WState_Created)) { … … 575 560 DestroyWindow(internalWinId()); 576 561 } 577 #ifdef Q_ OS_WINCE562 #ifdef Q_WS_WINCE 578 563 if (destroyWindow && (windowType() == Qt::Desktop) && !GetDesktopWindow()) { 579 564 DestroyWindow(internalWinId()); … … 581 566 582 567 #endif 583 d->setWinId(0); 568 QT_TRY { 569 d->setWinId(0); 570 } QT_CATCH (const std::bad_alloc &) { 571 // swallow - destructors must not throw 572 } 584 573 } 585 574 } … … 616 605 bool wasCreated = q->testAttribute(Qt::WA_WState_Created); 617 606 if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) 618 q->parentWidget()->d_func()->invalidateBuffer( q->geometry());607 q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); 619 608 620 609 WId old_winid = data.winid; … … 672 661 q->setAttribute(Qt::WA_DropSiteRegistered, true); 673 662 674 675 if (data.window_flags & Qt::CustomizeWindowHint 676 && data.window_flags & Qt::WindowTitleHint) { 677 HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE); 678 if (data.window_flags & Qt::WindowCloseButtonHint) 679 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED); 680 else 681 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); 682 } 683 684 #ifdef Q_OS_WINCE 663 #ifdef Q_WS_WINCE 685 664 // Show borderless toplevel windows in tasklist & NavBar 686 665 if (!parent) { 687 666 QString txt = q->windowTitle().isEmpty()?qAppName():q->windowTitle(); 688 SetWindowText(q->internalWinId(), ( TCHAR*)txt.utf16());667 SetWindowText(q->internalWinId(), (wchar_t*)txt.utf16()); 689 668 } 690 669 #endif … … 699 678 QWExtra *extra = parentWindow->d_func()->extra; 700 679 if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId() 701 || (extra && extra->proxyWidget)) { 680 || (extra 681 #ifndef QT_NO_GRAPHICSVIEW 682 && extra->proxyWidget 683 #endif //QT_NO_GRAPHICSVIEW 684 )) { 702 685 if (extra && extra->topextra && extra->topextra->embedded) { 703 686 QPoint pt = mapTo(parentWindow, pos); … … 726 709 QWExtra *extra = parentWindow->d_func()->extra; 727 710 if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId() 728 || (extra && extra->proxyWidget)) { 711 || (extra 712 #ifndef QT_NO_GRAPHICSVIEW 713 && extra->proxyWidget 714 #endif //QT_NO_GRAPHICSVIEW 715 )) { 729 716 if (extra && extra->topextra && extra->topextra->embedded) { 730 717 POINT p = {pos.x(), pos.y()}; … … 747 734 void QWidgetPrivate::updateSystemBackground() {} 748 735 749 extern void qt_win_set_cursor(QWidget *, bool); // qapplication_win.cpp750 751 736 #ifndef QT_NO_CURSOR 752 737 void QWidgetPrivate::setCursor_sys(const QCursor &cursor) … … 771 756 772 757 Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); 773 QT_WA({ 774 SetWindowText(q->internalWinId(), (TCHAR*)caption.utf16()); 775 } , { 776 SetWindowTextA(q->internalWinId(), caption.toLocal8Bit()); 777 }); 778 } 779 780 /* 781 Create an icon mask the way Windows wants it using CreateBitmap. 782 */ 783 784 HBITMAP qt_createIconMask(const QBitmap &bitmap) 785 { 786 QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono); 787 int w = bm.width(); 788 int h = bm.height(); 789 int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment 790 uchar *bits = new uchar[bpl*h]; 791 bm.invertPixels(); 792 for (int y=0; y<h; y++) 793 memcpy(bits+y*bpl, bm.scanLine(y), bpl); 794 HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits); 795 delete [] bits; 796 return hbm; 758 SetWindowText(q->internalWinId(), (wchar_t*)caption.utf16()); 797 759 } 798 760 … … 806 768 return 0; 807 769 808 QBitmap mask = pm.mask(); 809 if (mask.isNull()) { 810 mask = QBitmap(pm.size()); 811 mask.fill(Qt::color1); 812 } 813 814 HBITMAP im = qt_createIconMask(mask); 815 ICONINFO ii; 816 ii.fIcon = true; 817 ii.hbmMask = im; 818 ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha); 819 ii.xHotspot = 0; 820 ii.yHotspot = 0; 821 result = CreateIconIndirect(&ii); 770 result = pm.toWinHICON(); 822 771 823 772 if (cache) { … … 825 774 *cache = new QPixmap(pm);; 826 775 } 827 DeleteObject(ii.hbmColor);828 DeleteObject(im);829 776 } 830 777 return result; … … 857 804 &(x->iconPixmap)); 858 805 if (x->winIconBig) { 859 SendMessage A(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);860 SendMessage A(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig);806 SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall); 807 SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig); 861 808 } else { 862 SendMessage A(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);863 SendMessage A(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall);809 SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall); 810 SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall); 864 811 } 865 812 } … … 878 825 879 826 // The procedure does nothing, but is required for mousegrabbing to work 880 #ifndef Q_ OS_WINCE827 #ifndef Q_WS_WINCE 881 828 LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) 882 829 { 883 830 return CallNextHookEx(journalRec, nCode, wParam, lParam); 884 831 } 885 #endif //Q_ OS_WINCE832 #endif //Q_WS_WINCE 886 833 887 834 /* Works only as long as pointer is inside the application's window, 888 835 which is good enough for QDockWidget. 889 836 890 Doesn't call SetWindowsHookEx A() - this function causes a system-wide837 Doesn't call SetWindowsHookEx() - this function causes a system-wide 891 838 freeze if any other app on the system installs a hook and fails to 892 839 process events. */ … … 906 853 } 907 854 908 #ifndef Q_ OS_WINCE855 #ifndef Q_WS_WINCE 909 856 void QWidget::grabMouse() 910 857 { … … 912 859 if (mouseGrb) 913 860 mouseGrb->releaseMouse(); 914 journalRec = SetWindowsHookEx A(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);861 journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0); 915 862 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); 916 863 SetCapture(effectiveWinId()); 917 864 mouseGrb = this; 865 #ifndef QT_NO_CURSOR 918 866 mouseGrbCur = new QCursor(mouseGrb->cursor()); 919 } 920 } 921 867 #endif 868 } 869 } 870 871 #ifndef QT_NO_CURSOR 922 872 void QWidget::grabMouse(const QCursor &cursor) 923 873 { … … 925 875 if (mouseGrb) 926 876 mouseGrb->releaseMouse(); 927 journalRec = SetWindowsHookEx A(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);877 journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0); 928 878 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); 929 879 SetCapture(effectiveWinId()); … … 933 883 } 934 884 } 885 #endif 935 886 936 887 void QWidget::releaseMouse() … … 983 934 } 984 935 985 #ifndef Q_ OS_WINCE936 #ifndef Q_WS_WINCE 986 937 void QWidget::setWindowState(Qt::WindowStates newstate) 987 938 { … … 1032 983 if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized)) 1033 984 d->topData()->normalGeometry = geometry(); 1034 d->topData()->savedFlags = GetWindowLongA(internalWinId(), GWL_STYLE);985 d->topData()->savedFlags = Qt::WindowFlags(GetWindowLong(internalWinId(), GWL_STYLE)); 1035 986 #ifndef Q_FLATTEN_EXPOSE 1036 987 UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP; … … 1038 989 UINT style = WS_POPUP; 1039 990 #endif 1040 if ( d->topData()->savedFlags& WS_SYSMENU)991 if (ulong(d->topData()->savedFlags) & WS_SYSMENU) 1041 992 style |= WS_SYSMENU; 1042 993 if (isVisible()) 1043 994 style |= WS_VISIBLE; 1044 SetWindowLong A(internalWinId(), GWL_STYLE, style);1045 QRect r = qApp->desktop()->screenGeometry(this);995 SetWindowLong(internalWinId(), GWL_STYLE, style); 996 QRect r = QApplication::desktop()->screenGeometry(this); 1046 997 UINT swpf = SWP_FRAMECHANGED; 1047 998 if (newstate & Qt::WindowActive) … … 1054 1005 if (isVisible()) 1055 1006 style |= WS_VISIBLE; 1056 SetWindowLong A(internalWinId(), GWL_STYLE, style);1007 SetWindowLong(internalWinId(), GWL_STYLE, style); 1057 1008 1058 1009 UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE; … … 1085 1036 QApplication::sendEvent(this, &e); 1086 1037 } 1087 #endif //Q_ OS_WINCE1038 #endif //Q_WS_WINCE 1088 1039 1089 1040 … … 1098 1049 deactivateWidgetCleanup(); 1099 1050 Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); 1100 #ifdef Q_ OS_WINCE1051 #ifdef Q_WS_WINCE 1101 1052 if (!qt_wince_is_mobile() && q->isFullScreen()) { 1102 1053 HWND handle = FindWindow(L"HHTaskBar", L""); … … 1127 1078 Platform-specific part of QWidget::show(). 1128 1079 */ 1129 #ifndef Q_ OS_WINCE1080 #ifndef Q_WS_WINCE 1130 1081 void QWidgetPrivate::show_sys() 1131 1082 { … … 1193 1144 } 1194 1145 1146 winSetupGestures(); 1147 1195 1148 invalidateBuffer(q->rect()); 1196 1149 } 1197 #endif //Q_ OS_WINCE1150 #endif //Q_WS_WINCE 1198 1151 1199 1152 void QWidgetPrivate::setFocus_sys() … … 1241 1194 */ 1242 1195 1243 void QWidgetPrivate::setWSGeometry(bool dontShow )1196 void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) 1244 1197 { 1245 1198 Q_Q(QWidget); … … 1387 1340 ValidateRgn(q->internalWinId(), 0); 1388 1341 1342 #ifdef Q_WS_WINCE 1343 // On Windows CE we can't just fiddle around with the window state. 1344 // Too much magic in setWindowState. 1345 if (isResize && q->isMaximized()) 1346 q->setWindowState(q->windowState() & ~Qt::WindowMaximized); 1347 #else 1389 1348 if (isResize) 1390 1349 data.window_state &= ~Qt::WindowMaximized; 1350 #endif 1391 1351 1392 1352 if (data.window_state & Qt::WindowFullScreen) { … … 1399 1359 if (q->isVisible()) 1400 1360 style |= WS_VISIBLE; 1401 SetWindowLong A(q->internalWinId(), GWL_STYLE, style);1361 SetWindowLong(q->internalWinId(), GWL_STYLE, style); 1402 1362 1403 1363 UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE; … … 1414 1374 const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false; 1415 1375 const bool isTranslucentWindow = !isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint) 1416 && GetWindowLong A(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED;1376 && GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED; 1417 1377 1418 1378 if (q->testAttribute(Qt::WA_WState_ConfigPending)) { // processing config event … … 1453 1413 } else if (!q->testAttribute(Qt::WA_DontShowOnScreen)) { 1454 1414 q->setAttribute(Qt::WA_OutsideWSRange, false); 1455 #ifndef Q_ OS_WINCE1415 #ifndef Q_WS_WINCE 1456 1416 // If the window is hidden and in maximized state or minimized, instead of moving the 1457 1417 // window, set the normal position of the window. … … 1465 1425 } else { 1466 1426 #else 1467 if (data.window_state _internal& Qt::WindowMaximized) {1427 if (data.window_state & Qt::WindowMaximized) { 1468 1428 qt_wince_maximize(q); 1469 1429 } else { 1470 1430 #endif 1471 if (!isTranslucentWindow) 1472 MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true); 1473 else if (isMove && !isResize) 1474 SetWindowPos(q->internalWinId(), 0, fs.x(), fs.y(), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); 1431 MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true); 1475 1432 } 1476 1433 if (!q->isVisible()) … … 1562 1519 if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint) 1563 1520 return false; 1521 // if the user explicitely asked for the maximize button, we try to add 1522 // it even if the window has fixed size. 1523 if (data.window_flags & Qt::CustomizeWindowHint && 1524 data.window_flags & Qt::WindowMaximizeButtonHint) 1525 return true; 1564 1526 if (extra) { 1565 1527 if ((extra->maxw && extra->maxw != QWIDGETSIZE_MAX && extra->maxw != QLAYOUTSIZE_MAX) … … 1572 1534 void QWidgetPrivate::winUpdateIsOpaque() 1573 1535 { 1574 #ifndef Q_ OS_WINCE1536 #ifndef Q_WS_WINCE 1575 1537 Q_Q(QWidget); 1576 1538 … … 1582 1544 1583 1545 if (!isOpaque && ptrUpdateLayeredWindowIndirect) { 1584 SetWindowLong A(q->internalWinId(), GWL_EXSTYLE,1585 GetWindowLong A(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED);1546 SetWindowLong(q->internalWinId(), GWL_EXSTYLE, 1547 GetWindowLong(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED); 1586 1548 } else { 1587 SetWindowLong A(q->internalWinId(), GWL_EXSTYLE,1588 GetWindowLong A(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);1549 SetWindowLong(q->internalWinId(), GWL_EXSTYLE, 1550 GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED); 1589 1551 } 1590 1552 #endif … … 1593 1555 void QWidgetPrivate::setConstraints_sys() 1594 1556 { 1595 #ifndef Q_ OS_WINCE_WM1557 #ifndef Q_WS_WINCE_WM 1596 1558 Q_Q(QWidget); 1597 1559 if (q->isWindow() && q->testAttribute(Qt::WA_WState_Created)) { 1598 int style = GetWindowLong A(q->internalWinId(), GWL_STYLE);1560 int style = GetWindowLong(q->internalWinId(), GWL_STYLE); 1599 1561 if (shouldShowMaximizeButton()) 1600 1562 style |= WS_MAXIMIZEBOX; 1601 1563 else 1602 1564 style &= ~WS_MAXIMIZEBOX; 1603 SetWindowLong A(q->internalWinId(), GWL_STYLE, style);1565 SetWindowLong(q->internalWinId(), GWL_STYLE, style); 1604 1566 } 1605 1567 #endif … … 1711 1673 } 1712 1674 1713 #ifndef Q_OS_WINCE1714 1675 void QWidgetPrivate::createSysExtra() 1715 1676 { … … 1717 1678 extra->dropTarget = 0; 1718 1679 #endif 1719 #ifndef QT_NO_DIRECT3D 1720 extra->had_auto_fill_bg = 0; 1721 extra->had_paint_on_screen = 0; 1722 extra->had_no_system_bg = 0; 1723 #endif 1724 } 1725 1680 } 1681 1682 #ifndef Q_WS_WINCE 1726 1683 void QWidgetPrivate::deleteSysExtra() 1727 1684 { 1728 1685 } 1729 #endif //Q_ OS_WINCE1686 #endif //Q_WS_WINCE 1730 1687 1731 1688 void QWidgetPrivate::createTLSysExtra() 1732 1689 { 1690 extra->topextra->savedFlags = 0; 1691 extra->topextra->winIconBig = 0; 1733 1692 extra->topextra->winIconSmall = 0; 1734 extra->topextra->winIconBig = 0;1735 1693 } 1736 1694 … … 1856 1814 1857 1815 Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); 1858 SetWindowRgn(data.winid, wr, true); 1816 if (!SetWindowRgn(data.winid, wr, true)) 1817 DeleteObject(wr); 1859 1818 } 1860 1819 … … 1874 1833 1875 1834 QTLWExtra *top = topData(); 1876 uint exstyle = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_EXSTYLE), 1877 GetWindowLongA(q->internalWinId(), GWL_EXSTYLE)); 1878 uint style = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_STYLE), 1879 GetWindowLongA(q->internalWinId(), GWL_STYLE)); 1880 #ifndef Q_OS_WINCE 1835 uint exstyle = GetWindowLong(q->internalWinId(), GWL_EXSTYLE); 1836 uint style = GetWindowLong(q->internalWinId(), GWL_STYLE); 1837 #ifndef Q_WS_WINCE 1881 1838 if (AdjustWindowRectEx(&rect, style & ~(WS_OVERLAPPED), FALSE, exstyle)) { 1882 1839 #else … … 1888 1845 } 1889 1846 1890 #ifndef Q_ OS_WINCE1847 #ifndef Q_WS_WINCE 1891 1848 void QWidgetPrivate::setWindowOpacity_sys(qreal level) 1892 1849 { 1893 1850 Q_Q(QWidget); 1894 1851 1895 if (!isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint)) { 1896 if (GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) { 1897 Q_BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), Q_AC_SRC_ALPHA}; 1898 Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA, NULL}; 1899 (*ptrUpdateLayeredWindowIndirect)(q->internalWinId(), &info); 1852 if (!isOpaque && ptrUpdateLayeredWindow && (data.window_flags & Qt::FramelessWindowHint)) { 1853 if (GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) { 1854 BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), AC_SRC_ALPHA}; 1855 ptrUpdateLayeredWindow(q->internalWinId(), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA); 1900 1856 } 1901 1857 return; … … 1913 1869 return; 1914 1870 1915 int wl = GetWindowLong A(q->internalWinId(), GWL_EXSTYLE);1871 int wl = GetWindowLong(q->internalWinId(), GWL_EXSTYLE); 1916 1872 1917 1873 if (level != 1.0) { 1918 1874 if ((wl&Q_WS_EX_LAYERED) == 0) 1919 SetWindowLong A(q->internalWinId(), GWL_EXSTYLE, wl|Q_WS_EX_LAYERED);1875 SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl | Q_WS_EX_LAYERED); 1920 1876 } else if (wl&Q_WS_EX_LAYERED) { 1921 SetWindowLong A(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED);1922 } 1923 (*ptrSetLayeredWindowAttributes)(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);1924 } 1925 #endif //Q_ OS_WINCE1877 SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED); 1878 } 1879 ptrSetLayeredWindowAttributes(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA); 1880 } 1881 #endif //Q_WS_WINCE 1926 1882 1927 1883 // class QGlobalRasterPaintEngine: public QRasterPaintEngine … … 1932 1888 // Q_GLOBAL_STATIC(QGlobalRasterPaintEngine, globalRasterPaintEngine) 1933 1889 1934 #ifndef QT_NO_DIRECT3D1935 static void cleanup_d3d_engine();1936 Q_GLOBAL_STATIC_WITH_INITIALIZER(QDirect3DPaintEngine, _qt_d3dEngine,1937 {1938 qAddPostRoutine(cleanup_d3d_engine);1939 })1940 static void cleanup_d3d_engine()1941 {1942 _qt_d3dEngine()->cleanup();1943 }1944 QDirect3DPaintEngine* qt_d3dEngine()1945 {1946 return _qt_d3dEngine();1947 }1948 #endif1949 1950 1890 1951 1891 #ifndef QT_NO_DIRECTDRAW … … 2003 1943 QOnScreenRasterPaintEngine() 2004 1944 : QRasterPaintEngine(new QImage(qt_primary_surface_bits, 2005 qApp->desktop()->width(),2006 qApp->desktop()->height(),1945 QApplication::desktop()->width(), 1946 QApplication::desktop()->height(), 2007 1947 qt_primary_surface_stride, 2008 1948 qt_primary_surface_format)) … … 2060 2000 QPaintEngine *QWidget::paintEngine() const 2061 2001 { 2062 #ifndef QT_NO_DIRECT3D2063 if ((qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault)2064 || testAttribute(Qt::WA_MSWindowsUseDirect3D))2065 && qt_d3dEngine()->hasDirect3DSupport())2066 {2067 QDirect3DPaintEngine *engine = qt_d3dEngine();2068 if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault))2069 engine->setFlushOnEnd(false);2070 else2071 engine->setFlushOnEnd(true);2072 return engine;2073 }2074 #endif2075 2002 #ifndef QT_NO_DIRECTDRAW 2076 2003 QOnScreenRasterPaintEngine *pe = onScreenPaintEngine(); … … 2101 2028 { 2102 2029 Q_Q(QWidget); 2103 #ifndef QT_NO_DIRECT3D2104 extern QDirect3DPaintEngine *qt_d3dEngine();2105 if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault) && (q->windowOpacity() == 1.0f)2106 && qt_d3dEngine()->hasDirect3DSupport()) {2107 return new QD3DWindowSurface(q);2108 }2109 #endif2110 2030 return new QRasterWindowSurface(q); 2111 2031 } … … 2115 2035 } 2116 2036 2117 2118 2037 void QWidgetPrivate::registerTouchWindow() 2038 { 2039 Q_Q(QWidget); 2040 2041 // enable WM_TOUCH* messages on our window 2042 if (q->testAttribute(Qt::WA_WState_Created) 2043 && QApplicationPrivate::RegisterTouchWindow 2044 && q->windowType() != Qt::Desktop) 2045 QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0); 2046 } 2047 2048 void QWidgetPrivate::winSetupGestures() 2049 { 2050 #if !defined(QT_NO_NATIVE_GESTURES) 2051 Q_Q(QWidget); 2052 if (!q || !q->isVisible() || !nativeGesturePanEnabled) 2053 return; 2054 2055 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); 2056 if (!qAppPriv->SetGestureConfig) 2057 return; 2058 WId winid = q->internalWinId(); 2059 2060 bool needh = false; 2061 bool needv = false; 2062 bool singleFingerPanEnabled = false; 2063 2064 #ifndef QT_NO_SCROLLAREA 2065 if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q->parent())) { 2066 QScrollBar *hbar = asa->horizontalScrollBar(); 2067 QScrollBar *vbar = asa->verticalScrollBar(); 2068 Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy(); 2069 Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy(); 2070 needh = (hbarpolicy == Qt::ScrollBarAlwaysOn || 2071 (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum())); 2072 needv = (vbarpolicy == Qt::ScrollBarAlwaysOn || 2073 (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); 2074 singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; 2075 if (!winid) { 2076 winid = q->winId(); // enforces the native winid on the viewport 2077 } 2078 } 2079 #endif //QT_NO_SCROLLAREA 2080 if (winid) { 2081 GESTURECONFIG gc[1]; 2082 memset(gc, 0, sizeof(gc)); 2083 gc[0].dwID = GID_PAN; 2084 if (nativeGesturePanEnabled) { 2085 gc[0].dwWant = GC_PAN; 2086 if (needv && singleFingerPanEnabled) 2087 gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; 2088 else 2089 gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; 2090 if (needh && singleFingerPanEnabled) 2091 gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; 2092 else 2093 gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; 2094 } else { 2095 gc[0].dwBlock = GC_PAN; 2096 } 2097 2098 qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0])); 2099 } 2100 #endif 2101 } 2119 2102 2120 2103 QT_END_NAMESPACE 2121 2104 2122 #ifdef Q_ OS_WINCE2105 #ifdef Q_WS_WINCE 2123 2106 # include "qwidget_wince.cpp" 2124 2107 #endif
Note:
See TracChangeset
for help on using the changeset viewer.