当前位置: 首页>>代码示例>>C++>>正文


C++ QCursor::mask方法代码示例

本文整理汇总了C++中QCursor::mask方法的典型用法代码示例。如果您正苦于以下问题:C++ QCursor::mask方法的具体用法?C++ QCursor::mask怎么用?C++ QCursor::mask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCursor的用法示例。


在下文中一共展示了QCursor::mask方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shape

QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
    : shape(c.shape()), bitmapCacheKey(0), maskCacheKey(0)
{
    if (shape == Qt::BitmapCursor) {
        const qint64 pixmapCacheKey = c.pixmap().cacheKey();
        if (pixmapCacheKey) {
            bitmapCacheKey = pixmapCacheKey;
        } else {
            Q_ASSERT(c.bitmap());
            Q_ASSERT(c.mask());
            bitmapCacheKey = c.bitmap()->cacheKey();
            maskCacheKey = c.mask()->cacheKey();
        }
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:15,代码来源:qxcbcursor.cpp

示例2: qt_createPixmapCursor

static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot )
{
    QSize size;

    /* calculate size of cursor */
    QPoint pt = hotspot - cursor.hotSpot();
    QPoint pixmap_point( 0, 0 );
    QPoint cursor_point( 0, 0 );

    if ( qWinVersion() <= Qt::WV_95 ) {
        /* Win95 can only fixed size */
        size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) );
        size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) );
    } else {
        /* calculate size (enlarge if needed) */
        const QBitmap *tmp = cursor.bitmap();

        /* Only bitmap cursors allowed... */
        if ( tmp ) {
            QPoint point;

            // curent size
            size = pixmap.size();

            // calc position of lower right cursor pos
            point.setX( pt.x() + tmp->size().width() );
            point.setY( pt.y() + tmp->size().height() );
            // resize when cursor to large
            if ( point.x() > pixmap.width() )
                size.setWidth( point.x() );
            if ( point.y() > pixmap.height() )
                size.setHeight( point.y() );

            // calc upper left corner where both pixmaps have to be drawn
            if ( pt.x() >= 0 ) {
                cursor_point.setX( pt.x() );
            } else {
                pixmap_point.setX( -pt.x() );
                // negative position -> resize
                size.setWidth( size.width() - pt.x() );
            }
            if ( pt.y() >= 0 ) {
                cursor_point.setX( pt.x() );
            } else {
                pixmap_point.setY( -pt.y() );
                // negative position -> resize
                size.setHeight( size.height() - pt.y() );
            }

        }
    }

    /* Mask */
    QBitmap andMask( size );
    BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS );
    if ( pixmap.mask() )
        BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND );
    else
        BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS );
    const QBitmap *curMsk = cursor.mask();
    if ( curMsk )
        BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND );

    /* create Pixmap */
    QPixmap xorMask( size );
    xorMask.fill ( Qt::color1 );
    QPainter paint2( &xorMask );
    paint2.drawPixmap( pixmap_point, pixmap );

    QPixmap pm;
    pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) );
    pm.setMask( *cursor.mask() );
    paint2.drawPixmap ( cursor_point, pm );
    paint2.end();

#ifdef DEBUG_QDND_SRC

    andMask.save ( "pand.png", "PNG" );
    xorMask.save ( "pxor.png", "PNG" );
#endif

    HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size );

    if ( !cur ) {
        qWarning( "Error creating cursor: %d", GetLastError() );
    }
    return cur;
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:88,代码来源:qdnd_win.cpp

示例3: createSystemCursor


//.........这里部分代码省略.........
    case Qt::WhatsThisCursor:
        sh = IDC_HELP;
        break;
    case Qt::BusyCursor:
        sh = IDC_APPSTARTING;
        break;
    case Qt::PointingHandCursor:
        sh = IDC_HAND;
        break;
    case Qt::BlankCursor:
    case Qt::SplitVCursor:
    case Qt::SplitHCursor:
    case Qt::OpenHandCursor:
    case Qt::ClosedHandCursor:
    case Qt::BitmapCursor: {
        QImage bbits, mbits;
        bool invb, invm;
        if (cshape == Qt::BlankCursor) {
            bbits = QImage(32, 32, QImage::Format_Mono);
            bbits.fill(0);                // ignore color table
            mbits = bbits.copy();
            hx = hy = 16;
            invb = invm = false;
        } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
            bool open = cshape == Qt::OpenHandCursor;
            QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
            QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            hx = hy = 8;
            invb = invm = false;
        } 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();
#if !defined(Q_OS_WINCE)
        QScopedArrayPointer<uchar> xBits(new uchar[h * n]);
        QScopedArrayPointer<uchar> xMask(new uchar[h * n]);
        int x = 0;
        for (int i = 0; i < h; ++i) {
            uchar *bits = bbits.scanLine(i);
            uchar *mask = mbits.scanLine(i);
            for (int j = 0; j < n; ++j) {
                uchar b = bits[j];
                uchar m = mask[j];
                if (invb)
                    b ^= 0xff;
                if (invm)
                    m ^= 0xff;
                xBits[x] = ~m;
                xMask[x] = b ^ m;
                ++x;
            }
        }
        return CreateCursor(GetModuleHandle(0), hx, hy, bbits.width(), bbits.height(),
开发者ID:3163504123,项目名称:phantomjs,代码行数:67,代码来源:qwindowscursor.cpp


注:本文中的QCursor::mask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。