Changeset 130


Ignore:
Timestamp:
Aug 26, 2009, 9:37:08 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented QWidget::grabMouse/Keyboard(), releaseMouse/Keyboard(), activateWindow().

Location:
trunk/src/gui/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qwidget_p.h

    r128 r130  
    473473    { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
    474474             maybeTopData()->fId : data.winid; }
     475    HWND effectiveFrameWinId() const;
    475476#endif
    476477
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r129 r130  
    14501450void QWidget::grabMouse()
    14511451{
    1452     // @todo implement
     1452    Q_D(QWidget);
     1453    if (!qt_nograb()) {
     1454        if (mouseGrb)
     1455            mouseGrb->releaseMouse();
     1456        Q_ASSERT(testAttribute(Qt::WA_WState_Created));
     1457        WinSetCapture(HWND_DESKTOP, d->effectiveFrameWinId());
     1458        mouseGrb = this;
     1459#ifndef QT_NO_CURSOR
     1460        mouseGrbCur = new QCursor(mouseGrb->cursor());
     1461#endif
     1462    }
    14531463}
    14541464
    14551465void QWidget::grabMouse(const QCursor &cursor)
    14561466{
    1457     // @todo implement
     1467    Q_D(QWidget);
     1468    if (!qt_nograb()) {
     1469        if (mouseGrb)
     1470            mouseGrb->releaseMouse();
     1471        Q_ASSERT(testAttribute(Qt::WA_WState_Created));
     1472        WinSetCapture(HWND_DESKTOP, d->effectiveFrameWinId());
     1473        mouseGrbCur = new QCursor(cursor);
     1474        WinSetPointer(HWND_DESKTOP, mouseGrbCur->handle());
     1475        mouseGrb = this;
     1476    }
    14581477}
    14591478
    14601479void QWidget::releaseMouse()
    14611480{
    1462     // @todo implement
     1481    if (!qt_nograb() && mouseGrb == this) {
     1482        WinSetCapture(HWND_DESKTOP, 0);
     1483        if (mouseGrbCur) {
     1484            delete mouseGrbCur;
     1485            mouseGrbCur = 0;
     1486        }
     1487        mouseGrb = 0;
     1488    }
    14631489}
    14641490
    14651491void QWidget::grabKeyboard()
    14661492{
    1467     // @todo implement
     1493    if (!qt_nograb()) {
     1494        if (keyboardGrb)
     1495            keyboardGrb->releaseKeyboard();
     1496        keyboardGrb = this;
     1497    }
    14681498}
    14691499
    14701500void QWidget::releaseKeyboard()
    14711501{
    1472     // @todo implement
     1502    if (!qt_nograb() && keyboardGrb == this)
     1503        keyboardGrb = 0;
    14731504}
    14741505
    14751506QWidget *QWidget::mouseGrabber()
    14761507{
    1477     // @todo implement
    1478     return 0;
     1508    return mouseGrb;
    14791509}
    14801510
    14811511QWidget *QWidget::keyboardGrabber()
    14821512{
    1483     // @todo implement
    1484     return 0;
     1513    return keyboardGrb;
    14851514}
    14861515
    14871516void QWidget::activateWindow()
    14881517{
    1489     // @todo implement
     1518    window()->createWinId();
     1519    WinSetActiveWindow(HWND_DESKTOP, window()->d_func()->frameWinId());
    14901520}
    14911521
     
    20202050{
    20212051    // @todo implement
     2052}
     2053
     2054HWND QWidgetPrivate::effectiveFrameWinId() const
     2055{
     2056    Q_Q(const QWidget);
     2057    HWND fid = frameWinId();
     2058    if (fid != NULLHANDLE || !q->testAttribute(Qt::WA_WState_Created))
     2059        return fid;
     2060    QWidget *realParent = q->nativeParentWidget();
     2061    Q_ASSERT(realParent);
     2062    Q_ASSERT(realParent->d_func()->frameWinId());
     2063    return realParent->d_func()->frameWinId();
    20222064}
    20232065
Note: See TracChangeset for help on using the changeset viewer.