void QCursor::setBitmap( const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY ) { if ( !initialized ) initialize(); if ( bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size() ) { #if defined(QT_CHECK_NULL) qWarning( "QCursor: Cannot create bitmap cursor; invalid bitmap(s)" ); #endif QCursor *c = &cursorTable[arrowCursorIdx]; c->data->ref(); data = c->data; return; } data = new QCursorData; Q_CHECK_PTR( data ); data->bm = new QBitmap( bitmap ); data->bmm = new QBitmap( mask ); data->hcurs = 0; data->cshape = BitmapCursor; data->hx = hotX >= 0 ? hotX : bitmap.width()/2; data->hy = hotY >= 0 ? hotY : bitmap.height()/2; data->fg.red = 0 << 8; data->fg.green = 0 << 8; data->fg.blue = 0 << 8; data->bg.red = 255 << 8; data->bg.green = 255 << 8; data->bg.blue = 255 << 8; update(); // Xcursor's backward compatibility hack needs the cursor to be created // right after the bitmaps are created and filled with data }
void QCursor::setBitmap( const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY ) { if ( !initialized ) initialize(); if ( bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size() ) { #if defined(QT_CHECK_NULL) qWarning( "QCursor: Cannot create bitmap cursor; invalid bitmap(s)" ); #endif QCursor *c = &cursorTable[arrowCursorIdx]; c->data->ref(); data = c->data; return; } data = new QCursorData; Q_CHECK_PTR( data ); data->bm = new QBitmap( bitmap ); data->bmm = new QBitmap( mask ); data->cshape = BitmapCursor; data->id = nextCursorId++; data->hx = hotX >= 0 ? hotX : bitmap.width()/2; data->hy = hotY >= 0 ? hotY : bitmap.height()/2; QPaintDevice::qwsDisplay()->defineCursor(data->id, *data->bm, *data->bmm, data->hx, data->hy); }