Changeset 182 for trunk/src


Ignore:
Timestamp:
Sep 15, 2009, 3:21:22 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented standard cursor shapes (#54).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication.cpp

    r95 r182  
    25062506#if defined(Q_WS_WIN)
    25072507  extern void qt_win_set_cursor(QWidget *, bool);
     2508#elif defined(Q_WS_PM)
     2509  extern void qt_pm_set_cursor(QWidget *, bool);
    25082510#elif defined(Q_WS_X11)
    25092511  extern void qt_x11_enforce_cursor(QWidget *, bool);
     
    26572659#if defined(Q_WS_WIN)
    26582660            qt_win_set_cursor(cursorWidget, true);
     2661#elif defined(Q_WS_PM)
     2662            qt_pm_set_cursor(cursorWidget, true);
    26592663#elif defined(Q_WS_X11)
    26602664            qt_x11_enforce_cursor(cursorWidget, true);
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r169 r182  
    423423void QApplication::setOverrideCursor(const QCursor &cursor)
    424424{
    425     // @todo implement
     425    qApp->d_func()->cursor_list.prepend(cursor);
     426    WinSetPointer(HWND_DESKTOP, qApp->d_func()->cursor_list.first().handle());
    426427}
    427428
    428429void QApplication::restoreOverrideCursor()
    429430{
    430     // @todo implement
    431 }
    432 
    433 #endif
     431    if (qApp->d_func()->cursor_list.isEmpty())
     432        return;
     433    qApp->d_func()->cursor_list.removeFirst();
     434
     435    if (!qApp->d_func()->cursor_list.isEmpty()) {
     436        WinSetPointer(HWND_DESKTOP, qApp->d_func()->cursor_list.first().handle());
     437    } else {
     438        QWidget *w = QWidget::find(curWin);
     439        if (w)
     440            WinSetPointer(HWND_DESKTOP, w->cursor().handle());
     441        else
     442            WinSetPointer(HWND_DESKTOP, QCursor(Qt::ArrowCursor).handle());
     443    }
     444}
     445
     446/*
     447  Internal function called from QWidget::setCursor()
     448   force is true if this function is called from dispatchEnterLeave, it means that the
     449   mouse is actually directly under this widget.
     450*/
     451void qt_pm_set_cursor(QWidget *w, bool force)
     452{
     453    static QPointer<QWidget> lastUnderMouse = 0;
     454    if (force) {
     455        lastUnderMouse = w;
     456    } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
     457               && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
     458        w = lastUnderMouse;
     459    }
     460
     461    if (!curWin && w && w->internalWinId())
     462        return;
     463    QWidget* cW = w && !w->internalWinId() ? w : QWidget::find(curWin);
     464    if (!cW || cW->window() != w->window() ||
     465         !cW->isVisible() || !cW->underMouse() || QApplication::overrideCursor())
     466        return;
     467
     468    WinSetPointer(HWND_DESKTOP, cW->cursor().handle());
     469}
     470
     471#endif // QT_NO_CURSOR
    434472
    435473/*****************************************************************************
  • trunk/src/gui/kernel/qcursor_pm.cpp

    r111 r182  
    136136        QCursorData::initialize();
    137137    // @todo we depend on QPixmap vs HBITMAP integration here
     138
     139    LONG id = 0;
     140    const uchar *bits = 0;
     141    const uchar *mask = 0;
     142    bool isbitmap = false;
     143
     144    switch (cshape) { // map to OS/2 cursor
     145    case Qt::ArrowCursor:
     146    case Qt::UpArrowCursor: // @todo what's this?
     147    case Qt::CrossCursor: // @todo what's this?
     148        id = SPTR_ARROW;
     149            break;
     150    case Qt::WaitCursor:
     151        id = SPTR_WAIT;
     152            break;
     153    case Qt::IBeamCursor:
     154        id = SPTR_TEXT;
     155        break;
     156    case Qt::SizeVerCursor:
     157        id = SPTR_SIZENS;
     158        break;
     159    case Qt::SizeHorCursor:
     160        id = SPTR_SIZEWE;
     161        break;
     162    case Qt::SizeBDiagCursor:
     163        id = SPTR_SIZENESW;
     164        break;
     165    case Qt::SizeFDiagCursor:
     166        id = SPTR_SIZENWSE;
     167        break;
     168    case Qt::SizeAllCursor:
     169        id = SPTR_MOVE;
     170        break;
     171    case Qt::ForbiddenCursor:
     172        id = SPTR_ILLEGAL;
     173        break;
     174    default:
     175        // @temporary
     176        id = SPTR_ARROW;
     177        break;
     178        // @todo later here will be this:
     179//      qWarning("QCursor::update: Invalid cursor shape %d", cshape);
     180//      return;
     181    }
     182
     183
     184    if ((bits && mask) || isbitmap) {
     185        // @todo later
     186        hptr = 0;
     187        isSysPtr = false;
     188    } else {
     189        hptr = WinQuerySysPointer(HWND_DESKTOP, id, FALSE);
     190        isSysPtr = true;
     191    }
    138192}
    139193
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r169 r182  
    14021402
    14031403#ifndef QT_NO_CURSOR
     1404
     1405extern void qt_pm_set_cursor(QWidget *, bool); // qapplication_pm.cpp
     1406
    14041407void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
    14051408{
    1406     // @todo implement, depends on #29
     1409    Q_UNUSED(cursor);
     1410    Q_Q(QWidget);
     1411    qt_pm_set_cursor(q, false);
    14071412}
    14081413
    14091414void QWidgetPrivate::unsetCursor_sys()
    14101415{
    1411     // @todo implement, depends on #29
     1416    Q_Q(QWidget);
     1417    qt_pm_set_cursor(q, false);
    14121418}
    14131419#endif
Note: See TracChangeset for help on using the changeset viewer.