⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwscursor_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,    0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,    0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};#endifvoid QWSServerPrivate::initializeCursor(){    Q_Q(QWSServer);    // setup system cursors#ifndef QT_NO_QWS_CURSOR//    qt_screen->initCursor(sharedram + ramlen,true);    // default cursor    cursor = 0;    setCursor(QWSCursor::systemCursor(Qt::ArrowCursor));#endif    q->sendMouseEvent(QPoint(swidth/2, sheight/2), 0);}void QWSServerPrivate::setCursor(QWSCursor *curs){#ifdef QT_NO_QWS_CURSOR    Q_UNUSED(curs);#else    if (cursor == curs)        return;    cursor = curs;    if (!haveviscurs || !curs)        curs = QWSCursor::systemCursor(Qt::BlankCursor);    qt_screencursor->set(curs->image(),                         curs->hotSpot().x(),                         curs->hotSpot().y());#endif}#ifndef QT_NO_QWS_CURSORstatic void cleanupSystemCursorTable(){    for (int i = 0; i <= Qt::LastCursor; i++)        if (systemCursorTable[i]) {            delete systemCursorTable[i];            systemCursorTable[i] = 0;        }}#endifvoid QWSCursor::createSystemCursor(int id){#ifdef QT_NO_QWS_CURSOR    Q_UNUSED(id);#else    if (!systemCursorTableInit) {        for (int i = 0; i <= Qt::LastCursor; i++)            systemCursorTable[i] = 0;        qAddPostRoutine(cleanupSystemCursorTable);        systemCursorTableInit = true;    }    switch (id) {        // 16x16 cursors        case Qt::ArrowCursor:            systemCursorTable[Qt::ArrowCursor] =                new QWSCursor(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);            break;        case Qt::UpArrowCursor:            systemCursorTable[Qt::UpArrowCursor] =                new QWSCursor(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);            break;        case Qt::CrossCursor:            systemCursorTable[Qt::CrossCursor] =                new QWSCursor(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);            break;        case Qt::IBeamCursor:            systemCursorTable[Qt::IBeamCursor] =                new QWSCursor(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);            break;        case Qt::SizeVerCursor:            systemCursorTable[Qt::SizeVerCursor] =                new QWSCursor(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);            break;        case Qt::SizeHorCursor:            systemCursorTable[Qt::SizeHorCursor] =                new QWSCursor(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);            break;        case Qt::SizeBDiagCursor:            systemCursorTable[Qt::SizeBDiagCursor] =                new QWSCursor(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);            break;        case Qt::SizeFDiagCursor:            systemCursorTable[Qt::SizeFDiagCursor] =                new QWSCursor(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);            break;        case Qt::BlankCursor:            systemCursorTable[Qt::BlankCursor] =                new QWSCursor(0, 0, 0, 0, 0, 0);            break;        // 20x20 cursors        case Qt::ForbiddenCursor:            systemCursorTable[Qt::ForbiddenCursor] =                new QWSCursor(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);            break;        // 32x32 cursors        case Qt::WaitCursor:            systemCursorTable[Qt::WaitCursor] =                new QWSCursor(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);            break;        case Qt::SplitVCursor:            systemCursorTable[Qt::SplitVCursor] =                new QWSCursor(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);            break;        case Qt::SplitHCursor:            systemCursorTable[Qt::SplitHCursor] =                new QWSCursor(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);            break;        case Qt::SizeAllCursor:            systemCursorTable[Qt::SizeAllCursor] =                new QWSCursor(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);            break;        case Qt::PointingHandCursor:            systemCursorTable[Qt::PointingHandCursor] =                new QWSCursor(phand_bits, phandm_bits, 32, 32, 0, 0);            break;        case Qt::WhatsThisCursor:            systemCursorTable[Qt::WhatsThisCursor] =                new QWSCursor(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);            break;        case Qt::BusyCursor:            systemCursorTable[Qt::BusyCursor] =                new QWSCursor(busy_bits, busym_bits, 32, 32, 0, 0);            break;        case Qt::OpenHandCursor:            systemCursorTable[Qt::OpenHandCursor] =                new QWSCursor(openhand_bits, openhandm_bits, 16, 16, 8, 8);            break;        case Qt::ClosedHandCursor:            systemCursorTable[Qt::ClosedHandCursor] =                new QWSCursor(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);            break;        default:            qWarning("Unknown system cursor %d", id);    }#endif}QWSCursor *QWSCursor::systemCursor(int id){    QWSCursor *cursor = 0;#ifdef QT_NO_QWS_CURSOR    Q_UNUSED(id);#else    if (id >= 0 && id <= Qt::LastCursor) {        if (!systemCursorTable[id])            createSystemCursor(id);        cursor = systemCursorTable[id];    }    if (cursor == 0) {        if (!systemCursorTable[Qt::ArrowCursor])            createSystemCursor(Qt::ArrowCursor);        cursor = systemCursorTable[Qt::ArrowCursor];    }#endif    return cursor;}void QWSCursor::set(const uchar *data, const uchar *mask,                    int width, int height, int hx, int hy){#ifdef QT_NO_QWS_CURSOR    Q_UNUSED(data);    Q_UNUSED(mask);    Q_UNUSED(width);    Q_UNUSED(height);    Q_UNUSED(hx);    Q_UNUSED(hy);#else    hot.setX(hx);    hot.setY(hy);    cursor = QImage(width,height, QImage::Format_Indexed8);    if (!width || !height || !data || !mask)        return;    cursor.setNumColors(3);    cursor.setColor(0, 0xff000000);    cursor.setColor(1, 0xffffffff);    cursor.setColor(2, 0x00000000);    int bytesPerLine = (width + 7) / 8;    int p = 0;    int d, m;    int x = -1, w = 0;    uchar *cursor_data = cursor.bits();    int bpl = cursor.bytesPerLine();    for (int i = 0; i < height; i++)    {        for (int j = 0; j < bytesPerLine; j++, data++, mask++)        {            for (int b = 0; b < 8 && j*8+b < width; b++)            {                d = *data & (1 << b);                m = *mask & (1 << b);                if (d && m) p = 0;                else if (!d && m) p = 1;                else p = 2;                cursor_data[j*8+b] = p;                // calc region                if (x < 0 && m)                    x = j*8+b;                else if (x >= 0 && !m) {                    x = -1;                    w = 0;                }                if (m)                    w++;            }        }        if (x >= 0) {            x = -1;            w = 0;        }        cursor_data += bpl;    }    if (qt_screencursor) {        if (qt_screencursor->supportsAlphaCursor()) {            createDropShadow(5, 2);        }    }#endif}// now we're really sillyvoid QWSCursor::createDropShadow(int dropx, int dropy){    //#####if 1 || defined(QT_NO_QWS_CURSOR) || defined(QT_NO_QWS_ALHPA_CURSOR)    Q_UNUSED(dropx);    Q_UNUSED(dropy);#else    if (cursor.width() + dropx > 64 || cursor.height() + dropy > 64)        return;    if (!cursor.hasAlphaBuffer()) {        cursor.setAlphaBuffer(true);        const int nblur=4;        const int darkness=140;        QImage drop(cursor.width()+dropx+nblur, cursor.height()+dropy+nblur, 8, 18);        drop.setColor(0, 0xff000000); // bg (black)        drop.setColor(1, 0xffffffff); // fg (white)        for (int i=0; i<16; i++) {            drop.setColor(2+i, (darkness*i/16)<<24);        }        drop.fill(2); // all trans        QImage drop2 = drop.copy();        int cp;        // made solid shadow        for (int row = 0; row < cursor.height(); row++) {            for (int col = 0; col < cursor.width(); col++) {                cp = cursor.pixelIndex(col, row);                if (cp != 2)                    drop.setPixel(col+dropx, row+dropy, 17);            }        }        // blur shadow        for (int blur=0; blur<nblur; blur++) {            QImage& to((blur&1)?drop:drop2);            QImage& from((blur&1)?drop2:drop);            for (int row = 1; row < drop.height()-1; row++) {                for (int col = 1; col < drop.width()-1; col++) {                    int t=0;                    for (int dx=-1; dx<=1; dx++) {                        for (int dy=-1; dy<=1; dy++) {                            t += from.pixelIndex(col+dx,row+dy)-2;                        }                    }                    to.setPixel(col,row,2+t/9);                }            }        }        // copy cursor        for (int row = 0; row < cursor.height(); row++) {            for (int col = 0; col < cursor.width(); col++) {                cp = cursor.pixelIndex(col, row);                if (cp != 2)                    drop.setPixel(col, row, cp);            }        }        cursor = drop;    }#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -