summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget_win.cpp
diff options
context:
space:
mode:
authorminiak <milan.burda@gmail.com>2009-09-22 08:33:27 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-09-22 08:33:27 (GMT)
commitac7fca3606d1a7dd5985b6fc284c40c0f2682fe5 (patch)
tree986d53bf15469aa9207e301b8a1c7c401218dc36 /src/gui/kernel/qwidget_win.cpp
parentc0f1055fe809e6f4c90ea7ba3c369b2c01aaae07 (diff)
downloadQt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.zip
Qt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.tar.gz
Qt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.tar.bz2
* QPixmap: Add toWinHICON() & fromWinHICON() method
Duplicate QPixmap <-> HICON conversion code removed from qwidget_win.cpp & qsystemtrayicon_win.cpp. Task-number: 218533 Merge-request: 1570 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/kernel/qwidget_win.cpp')
-rw-r--r--src/gui/kernel/qwidget_win.cpp36
1 files changed, 1 insertions, 35 deletions
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 211e9d4..c705e2a 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -747,25 +747,6 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
SetWindowText(q->internalWinId(), (wchar_t*)caption.utf16());
}
-/*
- Create an icon mask the way Windows wants it using CreateBitmap.
-*/
-
-HBITMAP qt_createIconMask(const QBitmap &bitmap)
-{
- QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
- int w = bm.width();
- int h = bm.height();
- int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
- uchar *bits = new uchar[bpl*h];
- bm.invertPixels();
- for (int y=0; y<h; y++)
- memcpy(bits+y*bpl, bm.scanLine(y), bpl);
- HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
- delete [] bits;
- return hbm;
-}
-
HICON qt_createIcon(QIcon icon, int xSize, int ySize, QPixmap **cache)
{
HICON result = 0;
@@ -775,27 +756,12 @@ HICON qt_createIcon(QIcon icon, int xSize, int ySize, QPixmap **cache)
if (pm.isNull())
return 0;
- QBitmap mask = pm.mask();
- if (mask.isNull()) {
- mask = QBitmap(pm.size());
- mask.fill(Qt::color1);
- }
-
- HBITMAP im = qt_createIconMask(mask);
- ICONINFO ii;
- ii.fIcon = true;
- ii.hbmMask = im;
- ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha);
- ii.xHotspot = 0;
- ii.yHotspot = 0;
- result = CreateIconIndirect(&ii);
+ result = pm.toWinHICON();
if (cache) {
delete *cache;
*cache = new QPixmap(pm);;
}
- DeleteObject(ii.hbmColor);
- DeleteObject(im);
}
return result;
}