Changeset 480 for trunk/src


Ignore:
Timestamp:
Jan 27, 2010, 10:03:59 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: QCursor: Use a combination of the standard arrow and wait OS/2 cursors for Qt::BusyCursor to emphasize the difference from Qt::WaitCursor.

File:
1 edited

Legend:

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

    r479 r480  
    5656
    5757extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp
     58
     59extern HPS qt_alloc_mem_ps(int w, int h, HPS compat = 0); // qpixmap_pm.cpp
     60extern void qt_free_mem_ps(HPS hps); // qpixmap_pm.cpp
    5861
    5962/*****************************************************************************
     
    292295"                        "};
    293296
    294 enum { cursor_whatsthis_x = 9, cursor_whatsthis_y = 0 };
     297enum { cursor_whatsthis_x = 0, cursor_whatsthis_y = 0 };
    295298static char const * const cursor_whatsthis_xpm[] = {
    296299"24 24 3 1",
     
    368371"                ",
    369372"                "};
     373
     374static bool qt_alloc_ps_with_bitmap(int w, int h, bool isMono,
     375                                    HPS &hps, HBITMAP &hbm)
     376{
     377    hps = qt_alloc_mem_ps(32, 32);
     378    if (hps == NULLHANDLE)
     379        return false;
     380
     381    BITMAPINFOHEADER2 bmh;
     382    bmh.cbFix = sizeof(BITMAPINFOHEADER2);
     383    bmh.cx = w;
     384    bmh.cy = h;
     385    bmh.cPlanes = 1;
     386    bmh.cBitCount = isMono ? 1 : 32;
     387    hbm = GpiCreateBitmap(hps, &bmh, 0, 0, 0);
     388    if (hbm == NULLHANDLE) {
     389        qt_free_mem_ps(hps);
     390        return false;
     391    }
     392
     393    GpiSetBitmap(hps, hbm);
     394    return true;
     395}
     396
     397static void qt_free_ps_with_bitmap(HPS hps, HBITMAP hbm)
     398{
     399    GpiSetBitmap(hps, NULLHANDLE);
     400    GpiDeleteBitmap(hbm);
     401    qt_free_mem_ps(hps);
     402}
     403
     404static HPOINTER combineTwoCursors(LONG idOver, LONG idUnder)
     405{
     406    HPOINTER hptr = NULLHANDLE;
     407
     408    POINTERINFO piOver, piUnder;
     409    HPOINTER hOver = WinQuerySysPointer(HWND_DESKTOP, idOver, FALSE);
     410    WinQueryPointerInfo(hOver, &piOver);
     411    HPOINTER hUnder = WinQuerySysPointer(HWND_DESKTOP, idUnder, FALSE);
     412    WinQueryPointerInfo(hUnder, &piUnder);
     413    if (piOver.hbmColor) {
     414        HPS hpsPtr, hpsTmp, hpsMask;
     415        HBITMAP hbmPtr, hbmTmp, hbmMask;
     416        qt_alloc_ps_with_bitmap(32, 32, false, hpsPtr, hbmPtr);
     417        qt_alloc_ps_with_bitmap(32, 32, false, hpsTmp, hbmTmp);
     418        qt_alloc_ps_with_bitmap(32, 64, true, hpsMask, hbmMask);
     419        // copy the overlying pointer
     420        POINTL ptls[] = { { 0, 0 }, { 31, 31 }, { 0, 0 }, { 32, 32 } };
     421        GpiWCBitBlt(hpsTmp, piOver.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
     422        // make its transparent pixels black
     423        ptls[2].y += 32; ptls[3].y += 32;
     424        GpiSetColor(hpsTmp, CLR_TRUE);
     425        GpiSetBackColor(hpsTmp, CLR_FALSE);
     426        GpiWCBitBlt(hpsTmp, piOver.hbmPointer, 4, ptls, 0x22, BBO_IGNORE);
     427        // copy the underlying pointer
     428        ptls[2].y -= 32; ptls[3].y -= 32;
     429        GpiWCBitBlt(hpsPtr, piUnder.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
     430        // make non-transparent pixels from the overlying pointer black
     431        ptls[2].y += 32; ptls[3].y += 32;
     432        GpiSetColor(hpsPtr, CLR_TRUE);
     433        GpiSetBackColor(hpsPtr, CLR_FALSE);
     434        GpiWCBitBlt(hpsPtr, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
     435        // put the overlying pointer there
     436        ptls[2].y -= 32; ptls[3].y -= 32;
     437        ptls[1].x ++; ptls[1].y ++;
     438        GpiBitBlt(hpsPtr, hpsTmp, 4, ptls, ROP_SRCPAINT, BBO_IGNORE);
     439        // copy both underlying pointer's masks
     440        ptls[1].x --; ptls[1].y --;
     441        ptls[1].y += 32; ptls[3].y += 32;
     442        GpiWCBitBlt(hpsMask, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
     443        // add overlying pointer's XOR mask
     444        ptls[1].y -= 32; ptls[3].y -= 32;
     445        GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCPAINT, BBO_IGNORE);
     446        // add overlying pointer's AND mask
     447        ptls[0].y += 32; ptls[2].y += 32;
     448        ptls[1].y += 32; ptls[3].y += 32;
     449        GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
     450        // create the new pointer
     451        GpiSetBitmap(hpsPtr, NULLHANDLE);
     452        GpiSetBitmap(hpsMask, NULLHANDLE);
     453        piOver.hbmColor = hbmPtr;
     454        piOver.hbmPointer = hbmMask;
     455        piOver.hbmMiniColor = NULLHANDLE;
     456        piOver.hbmMiniPointer = NULLHANDLE;
     457        hptr = WinCreatePointerIndirect(HWND_DESKTOP, &piOver);
     458        qt_free_ps_with_bitmap(hpsMask,  hbmMask);
     459        qt_free_ps_with_bitmap(hpsTmp,  hbmTmp);
     460        qt_free_ps_with_bitmap(hpsPtr,  hbmPtr);
     461    } else {
     462        HPS hps;
     463        HBITMAP hbm;
     464        qt_alloc_ps_with_bitmap(32, 64, true, hps, hbm);
     465        POINTL ptls[] = { { 0, 0 }, { 31, 63 }, { 0, 0 }, { 32, 64 } };
     466        // make a copy of the underlying pointer
     467        GpiWCBitBlt(hps, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
     468        // combine AND masks
     469        ptls[0].y += 32; ptls[2].y += 32;
     470        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
     471        // apply the overlying AND mask to the underlying XOR mask
     472        ptls[0].y -= 32; ptls[1].y -= 32;
     473        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
     474        // apply the overlying XOR mask to the underlying XOR mask
     475        ptls[2].y -= 32; ptls[3].y -= 32;
     476        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCINVERT, BBO_IGNORE);
     477        // create the new pointer
     478        GpiSetBitmap(hps, 0);
     479        hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE,
     480                                piOver.xHotspot, piOver.yHotspot);
     481        qt_free_ps_with_bitmap(hps, hbm);
     482    }
     483
     484    Q_ASSERT(hptr);
     485    return hptr;
     486}
    370487
    371488void QCursorData::update()
     
    456573        break;
    457574    case Qt::BusyCursor:
    458         id = SPTR_WAIT;
    459         break;
     575        // we create a busy cursor below as a combination of the standard
     576        // arrow and wait cursors
     577        hptr = combineTwoCursors(SPTR_ARROW, SPTR_WAIT);
     578        isSysPtr = false;
     579        return;
    460580    case Qt::OpenHandCursor:
    461581        xpm = cursor_openhand_xpm;
Note: See TracChangeset for help on using the changeset viewer.