[Kde-cygwin-cvs] CVS: qt-3/src/kernel qapplication_win.cpp,1.1.2.30.2.87,1.1.2.30.2.88 qdnd_win.cpp,
Status: Inactive
Brought to you by:
habacker
From: Christian E. <che...@us...> - 2005-08-01 17:44:57
|
Update of /cvsroot/kde-cygwin/qt-3/src/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9720/src/kernel Modified Files: Tag: QT_WIN32_3_3_BRANCH qapplication_win.cpp qdnd_win.cpp qfont_win.cpp qwidget_win.cpp Log Message: huge update from qt4 Index: qapplication_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qapplication_win.cpp,v retrieving revision 1.1.2.30.2.87 retrieving revision 1.1.2.30.2.88 diff -u -r1.1.2.30.2.87 -r1.1.2.30.2.88 --- qapplication_win.cpp 22 Jul 2005 15:41:00 -0000 1.1.2.30.2.87 +++ qapplication_win.cpp 1 Aug 2005 17:44:44 -0000 1.1.2.30.2.88 @@ -226,10 +226,6 @@ extern void qt_dispatchEnterLeave( QWidget*, QWidget* ); // qapplication.cpp -// Palette handling -extern QPalette *qt_std_pal; -extern void qt_create_std_palette(); - // Keyboard handling static bool bInTranslateMessage = false; static bool bChar = true; @@ -280,22 +276,15 @@ }; -// read the _QT_INPUT_ENCODING property and apply the settings to -// the application -static void qt_set_input_encoding() -{ -#ifdef DEBUG_QAPPLICATION - qDebug( "TODO: qapplication_win.cpp: qt_set_input_encoding" ); -#endif -} - static const QColor getQColorFromSys( int syscolor ) { COLORREF c = GetSysColor( syscolor ); return QColor( GetRValue( c ), GetGValue( c ), GetBValue( c ) ); } -void qt_win_update_os_settings() +extern QFont qt_LOGFONTtoQFont(LOGFONT& lf,bool scale); + +static void qt_set_windows_resources() { if ( !qApp ) return ; @@ -505,60 +494,119 @@ if ( pal != QApplication::palette() ) QApplication::setPalette( pal, TRUE, "QTipLabel" ); +#ifndef Q_OS_TEMP + QFont menuFont; + QFont messageFont; + QFont statusFont; + QFont titleFont; + QFont smallTitleFont; + + QT_WA({ + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(ncm); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0); + menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont,true); + messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont,true); + statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont,true); + titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont,true); + smallTitleFont = qt_LOGFONTtoQFont(ncm.lfSmCaptionFont,true); + } , { + // A version + NONCLIENTMETRICSA ncm; + ncm.cbSize = sizeof(ncm); + SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0); + menuFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMenuFont,true); + messageFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMessageFont,true); + statusFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfStatusFont,true); + titleFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfCaptionFont,true); + smallTitleFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfSmCaptionFont,true); + }); - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof( NONCLIENTMETRICS ); - QT_WA( - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 );, - SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0 ); - ) - HDC hDC = qt_display_dc(); /* better than GetDC(0) */ + QApplication::setFont(menuFont, true, "QMenu"); + QApplication::setFont(menuFont, true, "QMenuBar"); + QApplication::setFont(menuFont, true, "QPopupMenu"); + QApplication::setFont(menuFont, true, "QPushButton"); + QApplication::setFont(messageFont, true, "QMessageBox"); + QApplication::setFont(messageFont, true, "QMessageBoxLabel"); + QApplication::setFont(statusFont, true, "QTipLabel"); + QApplication::setFont(statusFont, true, "QStatusBar"); + QApplication::setFont(titleFont, true, "QTitleBar"); + QApplication::setFont(smallTitleFont, true, "QDockWidgetTitle"); +#else LOGFONT lf; - QT_WA( - GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof( LOGFONT ), &lf );, - GetObjectA( GetStockObject( DEFAULT_GUI_FONT ), sizeof( LOGFONT ), &lf ); - ) + HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT); + GetObject(stockFont, sizeof(lf), &lf); + QApplication::setFont(qt_LOGFONTtoQFont(lf, true)); +#endif// Q_OS_TEMP +} -#ifdef DEBUG_QAPPLICATION +// need to get default font? +extern bool qt_app_has_font; + +static void qt_init_gui() +{ + QT_WA_INLINE( qt_register_window_classes_w (), + qt_register_window_classes_a () ); + + // Get the application name/instance if qWinMain() was not invoked +#ifndef Q_OS_TEMP + // No message boxes but important ones + SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); +#endif + + if (appInst == 0) { + QT_WA({ + appInst = GetModuleHandleW(0); + }, { + appInst = GetModuleHandleA(0); + }); + } + +#ifndef Q_OS_TEMP + // Initialize OLE/COM + // S_OK means success and S_FALSE means that it has already + // been initialized + HRESULT r; + r = OleInitialize(0); + if (r != S_OK && r != S_FALSE) { + qWarning("Qt: Could not initialize OLE (error %x)", (unsigned int)r); + } +#endif + + // Misc. initialization +#if defined(QT_DEBUG) + GdiSetBatchLimit(1); +#endif + + QColor::initialize(); + QFont::initialize(); + QCursor::initialize(); + QPainter::initialize(); + QWindowsMime::initialize(); - qDebug( "qapplication_win.cpp: qt_init_internal default font: %s, lfHeight%d, fsize=%d, GetDeviceCaps(hDC, LOGPIXELSY)=%d", lf.lfFaceName, lf.lfHeight, GetPointSize( hDC, lf.lfHeight ), ( int ) GetDeviceCaps( hDC, LOGPIXELSY ) ); -#endif - - QFont fmenu( qt_winQString( ncm.lfMenuFont.lfFaceName ), - GetPointSize( hDC, ncm.lfMenuFont.lfHeight ), - ncm.lfMenuFont.lfWeight == FW_BOLD ? QFont::Bold : QFont::Normal, - ( bool ) ncm.lfMenuFont.lfItalic - ); - QFont fstatus( qt_winQString( ncm.lfStatusFont.lfFaceName ), - GetPointSize( hDC, ncm.lfStatusFont.lfHeight ), - ncm.lfStatusFont.lfWeight == FW_BOLD ? QFont::Bold : QFont::Normal, - ( bool ) ncm.lfStatusFont.lfItalic - ); - QFont fmsg( qt_winQString( ncm.lfMessageFont.lfFaceName ), - GetPointSize( hDC, ncm.lfMessageFont.lfHeight ), - ncm.lfMessageFont.lfWeight == FW_BOLD ? QFont::Bold : QFont::Normal, - ( bool ) ncm.lfMessageFont.lfItalic - ); - QFont ftitle( qt_winQString( ncm.lfCaptionFont.lfFaceName ), - GetPointSize( hDC, ncm.lfCaptionFont.lfHeight ), - ncm.lfCaptionFont.lfWeight == FW_BOLD ? QFont::Bold : QFont::Normal, - ( bool ) ncm.lfCaptionFont.lfItalic - ); - QFont fdef( qt_winQString( lf.lfFaceName ), - GetPointSize( hDC, lf.lfHeight ), - lf.lfWeight == FW_BOLD ? QFont::Bold : QFont::Normal, - ( bool ) lf.lfItalic - ); - - QApplication::setFont( fdef ); - - QApplication::setFont( fmenu, TRUE, "QMenuBar" ); - QApplication::setFont( fmenu, TRUE, "QPopupMenu" ); - QApplication::setFont( fmenu, TRUE, "QPushButton" ); - QApplication::setFont( fstatus, TRUE, "QTipLabel" ); - QApplication::setFont( fmsg, TRUE, "QMessageBoxLabel" ); - QApplication::setFont( ftitle, TRUE, "QTitleBar" ); + qApp->setName( appName ); + // default font + if (!qt_app_has_font) { + HFONT hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + QFont f; + QT_WA({ + LOGFONT lf; + if (GetObject(hfont, sizeof(lf), &lf)) + f = qt_LOGFONTtoQFont((LOGFONT&)lf,true); + } , { + LOGFONTA lf; + if (GetObjectA(hfont, sizeof(lf), &lf)) + f = qt_LOGFONTtoQFont((LOGFONT&)lf,true); + }); + QApplication::setFont(f); + } + qt_set_windows_resources(); + QT_WA({ + WM95_MOUSEWHEEL = RegisterWindowMessage(L"MSWHEEL_ROLLMSG"); + } , { + WM95_MOUSEWHEEL = RegisterWindowMessageA("MSWHEEL_ROLLMSG"); + }); } static void qt_init_internal( int *argcptr, char **argv ) @@ -647,35 +695,9 @@ } *argcptr = j; - - if ( qt_is_gui_used ) { - QT_WA_INLINE( qt_register_window_classes_w (), - qt_register_window_classes_a () ); - -#ifdef DEBUG_QAPPLICATION - - qDebug( "qapplication_win.cpp: qt_init_internal: after registerclass" ); -#endif - -#ifndef Q_OS_TEMP - // Initialize OLE/COM - // S_OK means success and S_FALSE means that it has already - // been initialized - HRESULT r; - r = OleInitialize(0); - if (r != S_OK && r != S_FALSE) { - qWarning("Qt: Could not initialize OLE (error %x)", (unsigned int)r); - } -#endif - - QColor::initialize(); - QFont::initialize(); - QCursor::initialize(); - QPainter::initialize(); - QWindowsMime::initialize(); - - qApp->setName( appName ); - } + + if ( qt_is_gui_used ) + qt_init_gui(); setlocale( LC_ALL, "" ); // use correct char set mapping @@ -686,18 +708,6 @@ setlocale( LC_NUMERIC, "C" ); // make sprintf()/scanf() work - if ( qt_is_gui_used ) { - extern void qt_init_dnd(); - - qt_init_dnd(); - qt_set_input_encoding(); - qt_win_update_os_settings(); - QT_WA({ - WM95_MOUSEWHEEL = RegisterWindowMessage(L"MSWHEEL_ROLLMSG"); - } , { - WM95_MOUSEWHEEL = RegisterWindowMessageA("MSWHEEL_ROLLMSG"); - }); - } /* we can't call something like qt_init_dir() in qdir_win.cpp since link_includes and configure.exe will fail linking because of missing qAddPostRoutine */ #if !defined(Q_CYGWIN_WIN) @@ -2287,7 +2297,9 @@ QPixmap *pm = ( extra ) ? extra->bg_pix : NULL; HDC hdcOld = hdc; hdc = ( HDC ) msg.wParam; + setWState( WState_InPaintEvent ); qt_erase_region( this, pm, backgroundOffset(), rgn ); + clearWState ( WState_InPaintEvent ); hdc = hdcOld; /* An application should return nonzero in response to WM_ERASEBKGND if it processes the message and erases the background */ @@ -2311,17 +2323,7 @@ qDebug( "painting region %d,%d-%d,%d", ps.rcPaint.top, ps.rcPaint.left, ps.rcPaint.bottom, ps.rcPaint.right ); qDebug( "QETWidget::translatePaintEvent crect %d,%d-%d,%d", crect.left(), crect.top(), crect.right(), crect.bottom() ); #endif - if ( ps.fErase ) { - /* We should never get into here since this is handled in QETWidget::translateEraseEvent */ - QPixmap *pm = ( extra ) ? extra->bg_pix : NULL; - qt_erase_region( this, pm, backgroundOffset(), paintRegion ); - } - // There is no need to set a clipRegion since the hdc we get from beginPaint already - // has the correct clip regions set - QPaintEvent e( paintRegion, ps.fErase ); - setWState( WState_InPaintEvent ); - QApplication::sendSpontaneousEvent( this, &e ); - clearWState ( WState_InPaintEvent ); + repaint( paintRegion ); EndPaint( winid, &ps ); hdc = hdcOld; Index: qdnd_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qdnd_win.cpp,v retrieving revision 1.1.2.5.2.23 retrieving revision 1.1.2.5.2.24 diff -u -r1.1.2.5.2.23 -r1.1.2.5.2.24 --- qdnd_win.cpp 31 Jul 2005 17:43:25 -0000 1.1.2.5.2.23 +++ qdnd_win.cpp 1 Aug 2005 17:44:46 -0000 1.1.2.5.2.24 @@ -66,8 +66,6 @@ static IDataObject *pIDataObject = NULL; -class QOleDropTarget; -QPtrList<QOleDropTarget> dnd_widgets; static QDragObject *global_src = 0; static QDragObject::DragMode drag_mode; @@ -264,6 +262,10 @@ { return widget; } + void releaseQt() + { + widget = 0; + } /* IDropTarget methods */ STDMETHOD( DragEnter ) ( LPDATAOBJECT, DWORD, POINTL, LPDWORD ); @@ -1245,73 +1247,24 @@ /*********************************************** Enables / disables drag and drop for widget w ************************************************/ -bool qt_dnd_enable( QWidget * w, bool on ) +void qt_olednd_unregister( QWidget* widget, QOleDropTarget *dst ) { - if ( on ) { - for ( QOleDropTarget * tgt = dnd_widgets.first(); tgt; tgt = dnd_widgets.next() ) { - if ( tgt->getWidget() == w ) - return true; - } - QOleDropTarget *dst = new QOleDropTarget( w ); - dst->AddRef(); -#ifndef Q_OS_TEMP - - int ret = RegisterDragDrop( w->winId(), dst ); - if ( ret != S_OK ) { -#ifdef DEBUG_QDND_WIN - qDebug( "RegisterDragDrop failed with error %d", ret ); -#endif - - dst->Release(); - return false; - } - CoLockObjectExternal( dst, true, true ); -#endif - - dnd_widgets.append( dst ); - return true; - } - /* on == false */ - for ( QOleDropTarget * dst = dnd_widgets.first(); dst; dst = dnd_widgets.next() ) { - if ( dst->getWidget() == w ) { + dst->releaseQt(); + dst->Release(); #ifndef Q_OS_TEMP - CoLockObjectExternal( dst, false, true ); - RevokeDragDrop( dst->getWidget() ->winId() ); + CoLockObjectExternal(dst, false, true); + RevokeDragDrop(widget->winId()); #endif - - dnd_widgets.remove( dst ); - dst->Release(); - return true; - } - } - return false; } -void qt_cleanup_dnd() +QOleDropTarget* qt_olednd_register( QWidget* widget ) { - for ( QOleDropTarget * dst = dnd_widgets.last(); dst; dst = dnd_widgets.prev() ) { + QOleDropTarget* dst = new QOleDropTarget(widget); #ifndef Q_OS_TEMP - CoLockObjectExternal( dst, false, true ); - RevokeDragDrop( dst->getWidget() ->winId() ); + RegisterDragDrop(widget->winId(), dst); + CoLockObjectExternal(dst, true, true); #endif - - dst->Release(); - } - dnd_widgets.clear(); - delete noDropCursor; - delete copyCursor; - delete moveCursor; - delete linkCursor; - delete stdNoDropCursor; - delete stdCopyCursor; - delete stdMoveCursor; - delete stdLinkCursor; + return dst; } -void qt_init_dnd() -{ - qAddPostRoutine( qt_cleanup_dnd ); -} - -#endif // QT_NO_DRAGANDDROP - +#endif // QT_NO_DRAGANDDROP \ No newline at end of file Index: qfont_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfont_win.cpp,v retrieving revision 1.1.2.16.2.10 retrieving revision 1.1.2.16.2.11 diff -u -r1.1.2.16.2.10 -r1.1.2.16.2.11 --- qfont_win.cpp 17 Oct 2004 17:26:54 -0000 1.1.2.16.2.10 +++ qfont_win.cpp 1 Aug 2005 17:44:46 -0000 1.1.2.16.2.11 @@ -76,6 +76,36 @@ #define QT_CHECK_STATE +// ### maybe move to qapplication_win +QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/) +{ + QString family = QT_WA_INLINE(QString::fromUcs2((ushort*)lf.lfFaceName), + QString::fromLocal8Bit((char*)lf.lfFaceName)); + QFont qf(family); + qf.setItalic(lf.lfItalic); + if (lf.lfWeight != FW_DONTCARE) { + int weight; + if (lf.lfWeight < 400) + weight = QFont::Light; + else if (lf.lfWeight < 600) + weight = QFont::Normal; + else if (lf.lfWeight < 700) + weight = QFont::DemiBold; + else if (lf.lfWeight < 800) + weight = QFont::Bold; + else + weight = QFont::Black; + qf.setWeight(weight); + } + int lfh = QABS(lf.lfHeight); + Q_ASSERT(qt_display_dc()); + qf.setPointSize(lfh * 72.0 / GetDeviceCaps(qt_display_dc(),LOGPIXELSY)); + qf.setUnderline(false); + qf.setOverline(false); + qf.setStrikeOut(false); + return qf; +} + //333 double qt_pixelSize( double pointSize, QPaintDevice *paintdevice, int scr ) { Index: qwidget_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qwidget_win.cpp,v retrieving revision 1.1.2.15.2.53 retrieving revision 1.1.2.15.2.54 diff -u -r1.1.2.15.2.53 -r1.1.2.15.2.54 --- qwidget_win.cpp 18 Jul 2005 15:05:59 -0000 1.1.2.15.2.53 +++ qwidget_win.cpp 1 Aug 2005 17:44:46 -0000 1.1.2.15.2.54 @@ -55,7 +55,8 @@ // defined in qregion_win.cpp HRGN QBitmapToHRGN( const QBitmap& bm ); // QWidget::setMask( QBitmap ) // defined in qdnd_win.cpp -bool qt_dnd_enable( QWidget* w, bool on ); // QWidget::setAcceptDrops() +void qt_olednd_unregister(QWidget* widget, QOleDropTarget *dst); +QOleDropTarget* qt_olednd_register(QWidget* widget); // defined in qapplication_x11.cpp void qt_leave_modal( QWidget * ); // QWidget::destroy() @@ -1081,7 +1082,7 @@ void QWidget::update() { if ( isVisible() && isUpdatesEnabled() ) { - InvalidateRect( winId(), 0, true ); + InvalidateRect( winId(), 0, false ); } } @@ -1122,7 +1123,7 @@ r.bottom = crect.height(); else r.bottom = y + h; - InvalidateRect( winId(), &r, true ); + InvalidateRect( winId(), &r, false ); } } @@ -1200,24 +1201,28 @@ \sa update(), paintEvent(), setUpdatesEnabled(), erase() */ -void QWidget::repaint( const QRegion& reg, bool erase ) +void QWidget::repaint( const QRegion& rgn, bool erase ) { #ifdef DEBUG_QWIDGET qDebug( "QWidget::repaint( QRegion& reg, bool erase=%d)", erase ); qDebug( " this is: %s %s", className(), name() ); - QRect rect = reg.boundingRect(); + QRect rect = rgn.boundingRect(); qDebug( "rect: %d,%d - %d,%d", rect.left(), rect.top(), rect.right(), rect.bottom() ); #endif - if ( !isVisible() || !isUpdatesEnabled() || reg.isEmpty() ) + if ( !isVisible() || !isUpdatesEnabled() || rgn.isEmpty() ) return; - ValidateRgn( winId(), reg.handle() ); + if ( testWState( Qt::WState_InPaintEvent ) ) + qWarning( "QWidget::repaint: recursive repaint detected." ); - QPaintEvent e( reg, erase ); - if ( erase ) - this->erase( reg ); - QApplication::sendEvent( this, &e ); + ValidateRgn( winId(), rgn.handle() ); + setWState( Qt::WState_InPaintEvent ); + + QPaintEvent e( rgn ); + this->erase( rgn ); + QApplication::sendSpontaneousEvent( this, &e ); + clearWState ( Qt::WState_InPaintEvent ); } /*! @@ -1373,7 +1378,7 @@ void QWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove ) { #ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: %s internalSetGeometry called: x=%d, y=%d, w=%d, h=%d, isMove=%d", className(), x, y, w, h, isMove ); + qDebug( "QWidget::internalSetGeometry( x=%d, y=%d, w=%d, h=%d, isMove=%d )", x, y, w, h, isMove ); #endif if ( isTopLevel() && isMove ) { @@ -1741,10 +1746,17 @@ void QWidget::scroll( int dx, int dy ) { #ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: scroll(%d, %d)", dx, dy ); + qDebug( "QWidget::scroll( %d, %d )", dx, dy ); #endif + if ( testWState( WState_BlockUpdates ) ) + return; + + UINT flags = SW_INVALIDATE | SW_SCROLLCHILDREN; + if ( backgroundMode() != NoBackground ) + flags |= SW_ERASE; - scroll( dx, dy, QRect() ); + ScrollWindowEx( winId(), dx, dy, 0, 0, 0, 0, flags ); + UpdateWindow( winId() ); } /*! Scrolls \a r \a dx pixels to the right and \a dy downwards. Both @@ -1761,26 +1773,25 @@ \sa QScrollView erase() bitBlt() */ -void QWidget::scroll( int dx, int dy, const QRect& ) +void QWidget::scroll( int dx, int dy, const QRect& r ) { #ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: scroll( %d, %d )", dx, dy ); + qDebug( "QWidget::scroll( %d, %d, %d/%d - %d/%d )", dx, dy, r.left(), r.top(), r.bottom(), r.right() ); #endif - if ( testWState( WState_BlockUpdates ) || !isVisible() ) - return ; - bool just_update = QABS( dx ) > width() || QABS( dy ) > height(); - if ( just_update ) - update(); - - if ( dx == 0 && dy == 0 ) - return ; + if ( testWState( WState_BlockUpdates ) ) + return; - /* CE: I first only scrolled visibleRect() or r but we have to scroll the entire client - area - otherwise we'll loose children which are completly outside our rect... - there is still a lot of flicker when resizing a QListView! - */ - ScrollWindowEx( winId(), dx, dy, 0, 0, NULL, NULL, SW_ERASE | SW_INVALIDATE | SW_SCROLLCHILDREN ); + UINT flags = SW_INVALIDATE; + if ( backgroundMode() != NoBackground ) + flags |= SW_ERASE; + + RECT wr; + wr.top = r.top(); + wr.left = r.left(); + wr.bottom = r.bottom() + 1; + wr.right = r.right() + 1; + ScrollWindowEx( winId(), dx, dy, &wr, &wr, 0, 0, flags ); UpdateWindow( winId() ); } @@ -1876,38 +1887,23 @@ void QWidget::createSysExtra() { -#ifdef DEBUG_QWIDGET - qDebug( "QWidget::createSysExtra()" ); -#endif + extra->dropTarget = 0; } void QWidget::deleteSysExtra() { -#ifdef DEBUG_QWIDGET - qDebug( "QWidget::deleteSysExtra()" ); -#endif + setAcceptDrops( false ); } void QWidget::createTLSysExtra() { -#ifdef DEBUG_QWIDGET - qDebug( "QWidget::createTLSysExtra()" ); -#endif - extra->topextra->winIcon = 0; } void QWidget::deleteTLSysExtra() { -#ifdef DEBUG_QWIDGET - qDebug( "QWidget::deleteTLSysExtra()" ); -#endif - - if ( extra->topextra->winIcon ) { - SendMessage( winid, WM_SETICON, ICON_BIG, 0 ); + if ( extra->topextra->winIcon ) DestroyIcon( extra->topextra->winIcon ); - extra->topextra->winIcon = 0; - } } @@ -1919,10 +1915,6 @@ bool QWidget::acceptDrops() const { -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: acceptDrops" ); -#endif - return testWState( WState_DND ); } @@ -1939,16 +1931,35 @@ void QWidget::setAcceptDrops( bool on ) { -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: setAcceptDrops" ); -#endif + if ( testWState( WState_DND ) == ( Qt::WState )on ) + return; - if ( testWState( WState_DND ) != (Qt::WState)on ) { - if ( qt_dnd_enable( this, on ) ) { - if ( on ) - setWState( WState_DND ); - else - clearWState( WState_DND ); + // Enablement is defined by d->extra->dropTarget != 0. + if ( on ) { + // Turn on. + createExtra(); + QWExtra *extra = extraData(); + if ( !extra->dropTarget ) { + extra->dropTarget = qt_olednd_register( this ); + setWState( Qt::WState_DND ); + } + } else { + // Turn off. + QWExtra *extra = extraData(); + if ( extra && extra->dropTarget ) { + qt_olednd_unregister( this, extra->dropTarget ); + extra->dropTarget = 0; + clearWState( Qt::WState_DND ); + } + } + + if ( children() ) { + QObjectListIt it( *children() ); + register QObject *obj; + while ( ( obj = it.current() ) ) { + ++it; + if ( obj->isWidgetType() ) + ( ( QWidget* ) obj ) ->setAcceptDrops( on ); } } } @@ -1971,7 +1982,12 @@ qDebug( "qwidget_win.cpp: setMask %s", className() ); #endif - SetWindowRgn( winId(), region.handle(), true ); + // Since SetWindowRegion takes ownership, and we need to translate, + // we take a copy. + HRGN wr = CreateRectRgn( 0, 0, 0, 0 ); + CombineRgn( wr, region.handle(), 0, RGN_COPY ); + + SetWindowRgn( winId(), wr, true ); } /*! @@ -1989,20 +2005,8 @@ void QWidget::setMask( const QBitmap &bitmap ) { -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: setMask" ); -#endif - - HRGN hRgn = QBitmapToHRGN( bitmap ); // qregion_win.cpp - if ( !hRgn ) { -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: setMask(QBitmap) failed" ); -#endif - - return; - } - SetWindowRgn( winId(), hRgn, TRUE ); - // hRgn is deleted by windows + QRegion region( bitmap ); + setMask( region ); } /*! @@ -2013,11 +2017,7 @@ void QWidget::clearMask() { -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp: clearMask, %s", className() ); -#endif - - SetWindowRgn( winId(), ( HRGN ) NULL, true ); + SetWindowRgn( winId(), 0, true ); } /*!\reimp @@ -2040,27 +2040,32 @@ qDebug( "qwidget_win.cpp updateFrameStrut()" ); #endif - QWidget *that = ( QWidget * ) this; + QWidget *q = ( QWidget * ) this; - if ( isDesktop() ) { - that->fstrut_dirty = false; - return ; + if ( !isVisible() || isDesktop() ) { + q->fstrut_dirty = isVisible(); + return; } - QTLWExtra *top = that->topData(); - - int capWidth, xBdrWidth, yBdrWidth; - getWndBorderInfo( winId(), capWidth, xBdrWidth, yBdrWidth ); - - top->fleft = xBdrWidth; - top->fright = xBdrWidth; - top->ftop = capWidth; - top->fbottom = yBdrWidth; -#ifdef DEBUG_QWIDGET - qDebug( "qwidget_win.cpp updateFrameStrut(%ld, %ld, %ld, %ld)", top->fleft, top->ftop, top->fright, top->fbottom ); -#endif + RECT fr, cr; + GetWindowRect( q->winId(), &fr ); + GetClientRect( q->winId(), &cr ); + + POINT pt; + pt.x = 0; + pt.y = 0; + + ClientToScreen( q->winId(), &pt ); + q->crect = QRect( QPoint( pt.x, pt.y ), + QPoint( pt.x + cr.right, pt.y + cr.bottom ) ); + + QTLWExtra *top = q->topData(); + top->ftop = crect.top() - fr.top; + top->fleft = crect.left() - fr.left; + top->fbottom = fr.bottom - crect.bottom(); + top->fright = fr.right - crect.right(); - that->fstrut_dirty = false; + q->fstrut_dirty = false; } |