Changeset 111 for trunk/src


Ignore:
Timestamp:
Aug 13, 2009, 9:16:52 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: More QCursor bits.

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

Legend:

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

    r108 r111  
    9494    HCURSOR hcurs;
    9595#elif defined (Q_WS_PM)
    96     HPOINTER hcurs;
     96    HPOINTER hptr;
     97    bool isSysPtr;
    9798#elif defined (Q_WS_X11)
    9899    XColor fg, bg;
  • trunk/src/gui/kernel/qcursor_pm.cpp

    r108 r111  
    4949
    5050#include <qimage.h>
     51#include <qapplication.h>
     52#include <qdesktopwidget.h>
    5153#include <qt_os2.h>
    5254
     
    6062
    6163QCursorData::QCursorData(Qt::CursorShape s)
    62   : cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(NULLHANDLE)
     64  : cshape(s), bm(0), bmm(0), hx(0), hy(0), hptr(NULLHANDLE), isSysPtr(false)
    6365{
    6466    ref = 1;
     
    6971    delete bm;
    7072    delete bmm;
    71     // @todo
    72 //  if (hcurs)
    73 //      delete it...
     73    if (hptr && !isSysPtr)
     74        WinDestroyPointer(hptr);
    7475}
    7576
     
    7778QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
    7879{
    79     // @todo implement
    80     return 0;
     80    if (!QCursorData::initialized)
     81        QCursorData::initialize();
     82    if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
     83        qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
     84        QCursorData *c = qt_cursorTable[0];
     85        c->ref.ref();
     86        return c;
     87    }
     88    QCursorData *d = new QCursorData;
     89    d->bm  = new QBitmap(bitmap);
     90    d->bmm = new QBitmap(mask);
     91    d->hptr = NULLHANDLE;
     92    d->cshape = Qt::BitmapCursor;
     93    d->hx = hotX >= 0 ? hotX : bitmap.width()/2;
     94    d->hy = hotY >= 0 ? hotY : bitmap.height()/2;
     95    return d;
    8196}
    8297
     
    85100    if (!QCursorData::initialized)
    86101        QCursorData::initialize();
    87     if (!d->hcurs)
     102    if (d->hptr == NULLHANDLE)
    88103        d->update();
    89     return d->hcurs;
     104    return d->hptr;
    90105}
    91106
     
    93108{
    94109    d = new QCursorData(Qt::CustomCursor);
    95     d->hcurs = handle;
     110    d->hptr = handle;
    96111}
    97112
     
    100115QPoint QCursor::pos()
    101116{
    102     // @todo implement
    103     return QPoint();
     117    POINTL p;
     118    WinQueryPointerPos(HWND_DESKTOP, &p);
     119    // flip y coordinate
     120    p.y = QApplication::desktop()->height() - (p.y + 1);
     121    return QPoint(p.x, p.y);
    104122}
    105123
    106124void QCursor::setPos(int x, int y)
    107125{
    108     // @todo implement
     126    // flip y coordinate
     127    y = QApplication::desktop()->height() - (y + 1);
     128    WinSetPointerPos(HWND_DESKTOP, x, y);
    109129}
    110130
     
    115135    if (!QCursorData::initialized)
    116136        QCursorData::initialize();
    117     // @todo implement
     137    // @todo we depend on QPixmap vs HBITMAP integration here
    118138}
    119139
     140#endif // QT_NO_CURSOR
     141
    120142QT_END_NAMESPACE
    121 #endif // QT_NO_CURSOR
Note: See TracChangeset for help on using the changeset viewer.