Changeset 469 for trunk/src/gui/kernel


Ignore:
Timestamp:
Jan 22, 2010, 8:50:23 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: DnD: Implemented support for setting the drag pixmap.

File:
1 edited

Legend:

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

    r466 r469  
    12191219#endif
    12201220
    1221     // @todo custom drag pixmap?
    1222 
    12231221    DRAGIMAGE img;
    12241222    img.cb = sizeof(DRAGIMAGE);
    1225     img.hImage = WinQuerySysPointer(HWND_DESKTOP, SPTR_FILE, FALSE);
    1226     img.fl = DRG_ICON;
    1227     img.cxOffset = 0;
    1228     img.cyOffset = 0;
     1223
     1224    QPixmap pm = dragPrivate()->pixmap;
     1225    if (!pm.isNull()) {
     1226        if (pm.hasAlpha()) {
     1227            // replace the black pixels with the neutral default window
     1228            // background color
     1229            QPixmap pm2(pm.width(), pm.height());
     1230            pm2.fill(QApplication::palette().color(QPalette::Window));
     1231            QPainter p(&pm2);
     1232            p.drawPixmap(0, 0, pm);
     1233            p.end();
     1234            pm = pm2;
     1235        }
     1236        QPoint hot = dragPrivate()->hotspot;
     1237        img.fl = DRG_BITMAP;
     1238        img.hImage = pm.toPmHBITMAP();
     1239        img.cxOffset = -hot.x();
     1240        img.cyOffset = -(pm.height() - hot.y() - 1);
     1241    } else {
     1242        img.fl = DRG_ICON;
     1243        img.hImage = WinQuerySysPointer(HWND_DESKTOP, SPTR_FILE, FALSE);
     1244        img.cxOffset = 0;
     1245        img.cyOffset = 0;
     1246    }
    12291247
    12301248    // the mouse is most likely captured by Qt at this point, uncapture it
Note: See TracChangeset for help on using the changeset viewer.