Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QWidget::scroll ( int  dx,
int  dy,
const QRect r 
) [inherited]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version only scrolls r and does not move the children of the widget.

If r is empty or invalid, the result is undefined.

See also:
QScrollArea bitBlt()

Definition at line 2153 of file qwidget_x11.cpp.

References QObject::children(), QWidget::height(), QRect::height(), QWidget::internalWinId(), QRect::isValid(), QObject::isWidgetType(), QWidget::isWindow(), QWidget::move(), QWidget::pos, QWidget::repaint(), QWidget::testAttribute(), QWidget::update(), QWidget::updatesEnabled, QRect::width(), QWidget::width(), QRect::x(), and QRect::y().

{

    Q_D(QWidget);
    if (!updatesEnabled() && children().size() == 0 || !isVisible())
        return;
    if (dx == 0 && dy == 0)
        return;
    if (!QWidgetBackingStore::paintOnScreen(this)) {
        d->scrollRect(r, dx, dy);
        d->dirtyWidget_sys(r);
        return;
    }
    bool valid_rect = r.isValid();
    bool just_update = qAbs(dx) > width() || qAbs(dy) > height();
    QRect sr = valid_rect ? r : d->clipRect();
    if (just_update) {
        update();
    } else if (!valid_rect){
        d->dirtyOnScreen.translate(dx,dy);
    }

    int x1, y1, x2, y2, w = sr.width(), h = sr.height();
    if (dx > 0) {
        x1 = sr.x();
        x2 = x1+dx;
        w -= dx;
    } else {
        x2 = sr.x();
        x1 = x2-dx;
        w += dx;
    }
    if (dy > 0) {
        y1 = sr.y();
        y2 = y1+dy;
        h -= dy;
    } else {
        y2 = sr.y();
        y1 = y2-dy;
        h += dy;
    }

    if (dx == 0 && dy == 0)
        return;

    Display *dpy = X11->display;
    // Want expose events
    if (w > 0 && h > 0 && !just_update) {
        GC gc = XCreateGC(dpy, internalWinId(), 0, 0);
        XSetGraphicsExposures(dpy, gc, True);
        XCopyArea(dpy, internalWinId(), internalWinId(), gc, x1, y1, w, h, x2, y2);
        XFreeGC(dpy, gc);
    }

    if (!valid_rect && !d->children.isEmpty()) {        // scroll children
        QPoint pd(dx, dy);
        for (int i = 0; i < d->children.size(); ++i) { // move all children
            register QObject *object = d->children.at(i);
            if (object->isWidgetType()) {
                QWidget *w = static_cast<QWidget *>(object);
                if (!w->isWindow())
                    w->move(w->pos() + pd);
            }
        }
    }

    if (just_update)
        return;

    // Don't let the server be bogged-down with repaint events
    bool repaint_immediately = (qt_sip_count(this) < 3 && !testAttribute(Qt::WA_WState_InPaintEvent));

    if (dx) {
        int x = x2 == sr.x() ? sr.x()+w : sr.x();
        if (repaint_immediately)
            repaint(x, sr.y(), qAbs(dx), sr.height());
        else
            XClearArea(dpy, data->winid, x, sr.y(), qAbs(dx), sr.height(), True);
    }
    if (dy) {
        int y = y2 == sr.y() ? sr.y()+h : sr.y();
        if (repaint_immediately)
            repaint(sr.x(), y, sr.width(), qAbs(dy));
        else
            XClearArea(dpy, data->winid, sr.x(), y, sr.width(), qAbs(dy), True);
    }

    qt_insert_sip(this, dx, dy); // #### ignores r
}


Generated by  Doxygen 1.6.0   Back to index