Windows: Simplify cursor code.

Streamline code, remove unused arrays
(Qt::PointingHandCursor is handled in other switch-clause).

Task-number: QTBUG-36266

Change-Id: I533965ca4910230deefa8150d50b3ac677baaf1a
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Friedemann Kleint 2014-01-28 13:33:51 +01:00 committed by The Qt Project
parent 85fa39cf79
commit dbda292d2f

View File

@ -186,32 +186,6 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar phand_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00,
0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00,
0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00,
0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00,
0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00,
0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar phandm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00,
0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00,
0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00,
0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00,
0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00,
0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar openhand_bits[] = {
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
@ -229,11 +203,6 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
static const uchar * const cursor_bits32[] = {
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
phand_bits, phandm_bits
};
wchar_t *sh = 0;
switch (c.shape()) { // map to windows cursor
case Qt::ArrowCursor:
@ -300,23 +269,18 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
hx = hy = 8;
invb = invm = false;
} else if (cshape != Qt::BitmapCursor) {
int i = cshape - Qt::SplitVCursor;
QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]);
QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]);
bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
if (cshape == Qt::PointingHandCursor) {
hx = 7;
hy = 0;
} else
hx = hy = 16;
invb = invm = false;
} else {
} else if (cshape == Qt::BitmapCursor) {
bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono);
mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono);
invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
} else { // Qt::SplitVCursor, Qt::SplitHCursor
const QBitmap cb = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplit_bits : hsplit_bits);
const QBitmap cm = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplitm_bits : hsplitm_bits);
bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
hx = hy = 16;
invb = invm = false;
}
const int n = qMax(1, bbits.width() / 8);
const int h = bbits.height();