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

📄 qwsmanager_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        if (g.y() > maxWindowRect.bottom())            g.setY(maxWindowRect.bottom());    }    if (g == d->mousePos)        return;    if ( d->managed->isMaximized() )        return;    int x = d->managed->geometry().x();    int y = d->managed->geometry().y();    int w = d->managed->width();    int h = d->managed->height();    QRect geom(d->managed->geometry());    QPoint delta = g - d->mousePos;    d->mousePos = g;    if (d->activeRegion == QDecoration::Title) {        geom = QRect(x + delta.x(), y + delta.y(), w, h);    } else {        bool keepTop = true;        bool keepLeft = true;        switch (d->activeRegion) {        case QDecoration::Top:            geom.setTop(geom.top() + delta.y());            keepTop = false;            break;        case QDecoration::Bottom:            geom.setBottom(geom.bottom() + delta.y());            keepTop = true;            break;        case QDecoration::Left:            geom.setLeft(geom.left() + delta.x());            keepLeft = false;            break;        case QDecoration::Right:            geom.setRight(geom.right() + delta.x());            keepLeft = true;            break;        case QDecoration::TopRight:            geom.setTopRight(geom.topRight() + delta);            keepLeft = true;            keepTop = false;            break;        case QDecoration::TopLeft:            geom.setTopLeft(geom.topLeft() + delta);            keepLeft = false;            keepTop = false;            break;        case QDecoration::BottomLeft:            geom.setBottomLeft(geom.bottomLeft() + delta);            keepLeft = false;            keepTop = true;            break;        case QDecoration::BottomRight:            geom.setBottomRight(geom.bottomRight() + delta);            keepLeft = true;            keepTop = true;            break;        default:            return;        }        QSize newSize = QLayout::closestAcceptableSize(d->managed, geom.size());        int dx = newSize.width() - geom.width();        int dy = newSize.height() - geom.height();        if (keepTop) {            geom.setBottom(geom.bottom() + dy);            d->mousePos.ry() += dy;        } else {            geom.setTop(geom.top() - dy);            d->mousePos.ry() -= dy;        }        if (keepLeft) {            geom.setRight(geom.right() + dx);            d->mousePos.rx() += dx;        } else {            geom.setLeft(geom.left() - dx);            d->mousePos.rx() -= dx;        }    }    if (geom != d->managed->geometry()) {        QApplication::sendPostedEvents();        d->managed->setGeometry(geom);    }}void QWSManager::paintEvent(QPaintEvent *){     Q_D(QWSManager);     d->dirtyRegion(QDecoration::All, QDecoration::Normal);}void QWSManagerPrivate::dirtyRegion(int decorationRegion,                                    QDecoration::DecorationState state,                                    const QRegion &clip){    if (decorationRegion == QDecoration::All) {        dirtyRegions.clear();        dirtyStates.clear();    }    int i = dirtyRegions.indexOf(decorationRegion);    if (i >= 0) {        dirtyRegions.removeAt(i);        dirtyStates.removeAt(i);    }    dirtyRegions.append(decorationRegion);    dirtyStates.append(state);    QTLWExtra *topextra = managed->d_func()->extra->topextra;    QWidgetBackingStore *bs = topextra->backingStore;    const QRect clipRect = managed->rect().translated(bs->topLevelOffset());    QDecoration &dec = QApplication::qwsDecoration();    QRegion decRegion = dec.region(managed, clipRect, decorationRegion);    decRegion.translate(-bs->topLevelOffset());    if (!clip.isEmpty())        decRegion &= clip;    managed->d_func()->dirtyWidget_sys(decRegion);}/*!    \internal    Paints all the dirty regions into \a pixmap.    Returns the regions that have been repainted.*/void QWSManagerPrivate::paint(QPaintDevice *paintDevice, const QRegion &region){    if (dirtyRegions.empty() || !paintDevice || !paintDevice->paintEngine())        return;    QTLWExtra *topextra = managed->d_func()->extra->topextra;    Q_ASSERT(topextra && topextra->backingStore);    QWidgetBackingStore *bs = topextra->backingStore;    const QRect clipRect = managed->rect().translated(bs->topLevelOffset());    QDecoration &dec = QApplication::qwsDecoration();    QWSWindowSurface *surface;    surface = static_cast<QWSWindowSurface*>(bs->windowSurface);    const QRegion clippedRegion = region & surface->clipRegion();    const QRegion surfaceClip = clippedRegion.translated(bs->topLevelOffset());    paintDevice->paintEngine()->setSystemClip(surfaceClip);    QPainter *painter = 0;    const int numDirty = dirtyRegions.size();    for (int i = 0; i < numDirty; ++i) {        int r = dirtyRegions.at(i);        QDecoration::DecorationState state = dirtyStates.at(i);        QRegion clipRegion = dec.region(managed, clipRect, r);        if (!clipRegion.isEmpty()) {            if (!painter) {                painter = new QPainter(paintDevice);                painter->setFont(qApp->font());                painter->translate(bs->topLevelOffset());            }            clipRegion.translate(-bs->topLevelOffset());            painter->setClipRegion(clipRegion);            dec.paint(painter, managed, r, state);        }    }    dirtyRegions.clear();    dirtyStates.clear();    delete painter;}bool QWSManager::repaintRegion(int decorationRegion, QDecoration::DecorationState state){    Q_D(QWSManager);    d->dirtyRegion(decorationRegion, state);    return true;}void QWSManager::menu(const QPoint &pos){#ifdef QT_NO_MENU    Q_UNUSED(pos);#else    Q_D(QWSManager);    if (d->popup)        delete d->popup;    // Basic window operation menu    d->popup = new QMenu();    QApplication::qwsDecoration().buildSysMenu(d->managed, d->popup);    connect(d->popup, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*)));    d->popup->popup(pos);#endif // QT_NO_MENU}void QWSManager::menuTriggered(QAction *action){#ifdef QT_NO_MENU    Q_UNUSED(action);#else    Q_D(QWSManager);    QApplication::qwsDecoration().menuTriggered(d->managed, action);    d->popup->deleteLater();    d->popup = 0;#endif}void QWSManager::startMove(){    Q_D(QWSManager);    d->mousePos = QCursor::pos();    d->activeRegion = QDecoration::Title;    d->active = d->managed;    d->managed->grabMouse();}void QWSManager::startResize(){    Q_D(QWSManager);    d->activeRegion = QDecoration::BottomRight;    d->active = d->managed;    d->managed->grabMouse();}void QWSManager::maximize(){    Q_D(QWSManager);    // find out how much space the decoration needs    const int screen = QApplication::desktop()->screenNumber(d->managed);    const QRect desk = QApplication::desktop()->availableGeometry(screen);    QRect dummy(0, 0, 1, 1);    QRect nr;    QRegion r = QApplication::qwsDecoration().region(d->managed, dummy);    if (r.isEmpty()) {        nr = desk;    } else {        r += dummy; // make sure we get the full window region in case of 0 width borders        QRect rect = r.boundingRect();        nr = QRect(desk.x()-rect.x(), desk.y()-rect.y(),                desk.width() - (rect.width()==1 ? 0 : rect.width()-1), // ==1 -> dummy                desk.height() - (rect.height()==1 ? 0 : rect.height()-1));    }    d->managed->setGeometry(nr);}bool QWSManagerPrivate::newCachedRegion(const QPoint &pos){    // Check if anything has changed that would affect the region caching    if (managed->windowFlags() == cached_region.windowFlags        && managed->geometry() == cached_region.windowGeometry        && cached_region.region.contains(pos))        return false;    // Update the cached region    int reg = QApplication::qwsDecoration().regionAt(managed, pos);    if (QWidget::mouseGrabber())        reg = QDecoration::None;    previousRegionType = cached_region.regionType;    cached_region.regionType = reg;    cached_region.region = QApplication::qwsDecoration().region(managed, managed->geometry(),                                                                reg);    // Make room for borders around the widget, even if the decoration doesn't have a frame.    if (reg && !(reg & int(QDecoration::Borders))) {        cached_region.region -= QApplication::qwsDecoration().region(managed, managed->geometry(), QDecoration::Borders);    }    cached_region.windowFlags = managed->windowFlags();    cached_region.windowGeometry = managed->geometry();//    QRect rec = cached_region.region.boundingRect();//    qDebug("Updated cached region: 0x%04x (%d, %d)  (%d, %d,  %d, %d)",//           reg, pos.x(), pos.y(), rec.x(), rec.y(), rec.right(), rec.bottom());    return true;}#endif //QT_NO_QWS_MANAGER

⌨️ 快捷键说明

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