Source Code (Use browser search to find items of interest.)

Class Index

qt'QScrollView (./qt-2.1.0/src/widgets/qscrollview.h:35)

class Q_EXPORT QScrollView : public QFrame
{
    Q_OBJECT
    Q_ENUMS( ResizePolicy ScrollBarMode )
    Q_PROPERTY( ResizePolicy resizePolicy READ resizePolicy WRITE setResizePolicy )
    Q_PROPERTY( ScrollBarMode vScrollBarMode READ vScrollBarMode WRITE setVScrollBarMode )
    Q_PROPERTY( ScrollBarMode hScrollBarMode READ hScrollBarMode WRITE setHScrollBarMode )
    Q_PROPERTY( int visibleWidth READ visibleWidth )
    Q_PROPERTY( int visibleHeight READ visibleHeight )
    Q_PROPERTY( int contentsWidth READ contentsWidth )
    Q_PROPERTY( int contentsHeight READ contentsHeight )
    Q_PROPERTY( int contentsX READ contentsX )
    Q_PROPERTY( int contentsY READ contentsY )
    Q_PROPERTY( bool dragAutoScroll READ dragAutoScroll WRITE setDragAutoScroll )

public:
    QScrollView(QWidget *parent=0, const char *name=0, WFlags f=0);
    ~QScrollView();

    enum ResizePolicy { Default, Manual, AutoOne };
    virtual void setResizePolicy( ResizePolicy );
    ResizePolicy resizePolicy() const;

    void removeChild(QWidget* child);
    virtual void addChild( QWidget* child, int x=0, int y=0 );
    virtual void moveChild( QWidget* child, int x, int y );
    int childX(QWidget* child);
    int childY(QWidget* child);
    bool childIsVisible(QWidget* child);
    void showChild(QWidget* child, bool yes=TRUE);

    enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn };

    ScrollBarMode vScrollBarMode() const;
    virtual void  setVScrollBarMode( ScrollBarMode );

    ScrollBarMode hScrollBarMode() const;
    virtual void  setHScrollBarMode( ScrollBarMode );

    QWidget*     cornerWidget() const;
    virtual void setCornerWidget(QWidget*);

    QScrollBar*  horizontalScrollBar() const;
    QScrollBar*  verticalScrollBar() const;
    QWidget*	 viewport() const;
    QWidget*	 clipper() const;

    int		visibleWidth() const;
    int		visibleHeight() const;

    int		contentsWidth() const;
    int		contentsHeight() const;
    int		contentsX() const;
    int		contentsY() const;

    void	resize( int w, int h );
    void	resize( const QSize& );
    void	show();

    void	updateContents( int x, int y, int w, int h );
    void	updateContents( const QRect& r );
    void	repaintContents( int x, int y, int w, int h, bool erase=TRUE );
    void	repaintContents( const QRect& r, bool erase=TRUE );

    void	contentsToViewport(int x, int y, int& vx, int& vy);
    void	viewportToContents(int vx, int vy, int& x, int& y);
    QPoint	contentsToViewport(const QPoint&);
    QPoint	viewportToContents(const QPoint&);
    void	enableClipper(bool y);

    QSize	viewportSize( int, int ) const;
    QSizePolicy sizePolicy() const;
    QSize	sizeHint() const;
    QSize	minimumSizeHint() const;

    void	removeChild(QObject* child);

    void	setDragAutoScroll( bool b ); // #### virtual in 3.0
    bool	dragAutoScroll() const;

signals:
    void	contentsMoving(int x, int y);

public slots:
    virtual void resizeContents( int w, int h );
    void	scrollBy( int dx, int dy );
    virtual void        setContentsPos( int x, int y );
    void	ensureVisible(int x, int y);
    void	ensureVisible(int x, int y, int xmargin, int ymargin);
    void	center(int x, int y);
    void	center(int x, int y, float xmargin, float ymargin);

    void	updateScrollBars();
    void	setEnabled( bool enable );

protected:
    void	resizeEvent(QResizeEvent*);
    void 	wheelEvent( QWheelEvent * );
    bool	eventFilter( QObject *, QEvent *e );

    virtual void contentsMousePressEvent( QMouseEvent* );
    virtual void contentsMouseReleaseEvent( QMouseEvent* );
    virtual void contentsMouseDoubleClickEvent( QMouseEvent* );
    virtual void contentsMouseMoveEvent( QMouseEvent* );
    virtual void contentsDragEnterEvent( QDragEnterEvent * );
    virtual void contentsDragMoveEvent( QDragMoveEvent * );
    virtual void contentsDragLeaveEvent( QDragLeaveEvent * );
    virtual void contentsDropEvent( QDropEvent * );
    virtual void contentsWheelEvent( QWheelEvent * );

    virtual void viewportPaintEvent( QPaintEvent* );
    virtual void viewportResizeEvent( QResizeEvent* );
    virtual void viewportMousePressEvent( QMouseEvent* );
    virtual void viewportMouseReleaseEvent( QMouseEvent* );
    virtual void viewportMouseDoubleClickEvent( QMouseEvent* );
    virtual void viewportMouseMoveEvent( QMouseEvent* );
    virtual void viewportDragEnterEvent( QDragEnterEvent * );
    virtual void viewportDragMoveEvent( QDragMoveEvent * );
    virtual void viewportDragLeaveEvent( QDragLeaveEvent * );
    virtual void viewportDropEvent( QDropEvent * );
    virtual void viewportWheelEvent( QWheelEvent * );

    virtual void drawContentsOffset(QPainter*, int ox, int oy,
		    int cx, int cy, int cw, int ch);
    virtual void drawContents(QPainter*, int cx, int cy, int cw, int ch);
    void	frameChanged();

    virtual void setMargins(int left, int top, int right, int bottom);
    int leftMargin() const;
    int topMargin() const;
    int rightMargin() const;
    int bottomMargin() const;

    bool focusNextPrevChild( bool next );

    virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h);
    virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h);

private:
    virtual void drawContents( QPainter* );
    void moveContents(int x, int y);

    QScrollViewData* d;

private slots:
    void hslide(int);
    void vslide(int);
    void doDragAutoScroll();
    void startDragAutoScroll();
    void stopDragAutoScroll();

private:	// Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
    QScrollView( const QScrollView & );
    QScrollView &operator=( const QScrollView & );
#endif
    void changeFrameRect(const QRect&);
};

qt'QScrollView::QScrollView() (./qt-2.1.0/src/widgets/qscrollview.cpp:443)

QScrollView::QScrollView( QWidget *parent, const char *name, WFlags f ) :
    QFrame( parent, name, f & (~WNorthWestGravity) & (~WRepaintNoErase), FALSE )
{
    d = new QScrollViewData(this,WResizeNoErase |
	    (f&WPaintClever) | (f&WRepaintNoErase) | (f&WNorthWestGravity) );
    connect( &d->autoscroll_timer, SIGNAL( timeout() ),
	     this, SLOT( doDragAutoScroll() ) );

    connect( &d->hbar, SIGNAL( valueChanged( int ) ),
	this, SLOT( hslide( int ) ) );
    connect( &d->vbar, SIGNAL( valueChanged( int ) ),
	this, SLOT( vslide( int ) ) );
    d->viewport.installEventFilter( this );

    setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
    setLineWidth( style().defaultFrameWidth() );
}

/*! Destructs the QScrollView.  Any children added with addChild()
  will be destructed. */


qt'QScrollView::~QScrollView() (./qt-2.1.0/src/widgets/qscrollview.cpp:464)

QScrollView::~QScrollView()
{
    // Be careful not to get all those useless events...
    if ( d->clipped_viewport )
	d->clipped_viewport->removeEventFilter( this );
    else
	d->viewport.removeEventFilter( this );
    delete d;
}



qt'QScrollView::hslide() (./qt-2.1.0/src/widgets/qscrollview.cpp:475)

void QScrollView::hslide( int pos )
{
    if ( !d->signal_choke ) {
	moveContents( -pos, -contentsY() );
	QApplication::syncX();
    }
}


qt'QScrollView::vslide() (./qt-2.1.0/src/widgets/qscrollview.cpp:483)

void QScrollView::vslide( int pos )
{
    if ( !d->signal_choke ) {
	moveContents( -contentsX(), -pos );
	QApplication::syncX();
    }
}

/*!
  Called when the horizontal scrollbar geometry changes.  This is provided
  as a protected function so that subclasses can do interesting things
  like providing extra buttons in some of the space normally used by the
  scrollbars.

  The default implementation simply gives all the space to \a hbar.

  \sa setVBarGeometry()
*/

qt'QScrollView::setHBarGeometry() (./qt-2.1.0/src/widgets/qscrollview.cpp:501)

void QScrollView::setHBarGeometry(QScrollBar& hbar,
    int x, int y, int w, int h)
{
    hbar.setGeometry( x, y, w, h );
}

/*!
  Called when the vertical scrollbar geometry changes.  This is provided
  as a protected function so that subclasses can do interesting things
  like providing extra buttons in some of the space normally used by the
  scrollbars.

  The default implementation simply gives all the space to \a vbar.

  \sa setHBarGeometry()
*/

qt'QScrollView::setVBarGeometry() (./qt-2.1.0/src/widgets/qscrollview.cpp:517)

void QScrollView::setVBarGeometry( QScrollBar& vbar,
    int x, int y, int w, int h)
{
    vbar.setGeometry( x, y, w, h );
}


/*! Returns the viewport size for size (\a x, \a y).

  The viewport size depends on \a x,y (the size of the contents), the
  size of this widget, the modes of the horizontal and vertical scroll
  bars.

  This function permits widgets that can trade vertical and horizontal
  space for each other to control scroll bar appearance better.  For
  example, a word processor or web browser can control the width of
  the right margin accurately, whether there needs to be a vertical
  scroll bar or not.
*/



qt'QScrollView::viewportSize() (./qt-2.1.0/src/widgets/qscrollview.cpp:538)

QSize QScrollView::viewportSize( int x, int y ) const
{
    int fw = frameWidth();
    int lmarg = fw+d->l_marg;
    int rmarg = fw+d->r_marg;
    int tmarg = fw+d->t_marg;
    int bmarg = fw+d->b_marg;

    int w = width();
    int h = height();

    bool needh, needv;
    bool showh, showv;
    int hsbExt = horizontalScrollBar()->sizeHint().height();
    int vsbExt = verticalScrollBar()->sizeHint().width();

    if ( d->policy != AutoOne || d->anyVisibleChildren() ) {
	// Do we definitely need the scrollbar?
	needh = w-lmarg-rmarg < x;
	needv = h-tmarg-bmarg < y;

	// Do we intend to show the scrollbar?
	if (d->hMode == AlwaysOn)
	    showh = TRUE;
	else if (d->hMode == AlwaysOff)
	    showh = FALSE;
	else
	    showh = needh;

	if (d->vMode == AlwaysOn)
	    showv = TRUE;
	else if (d->vMode == AlwaysOff)
	    showv = FALSE;
	else
	    showv = needv;

	// Given other scrollbar will be shown, NOW do we need one?
	if ( showh && h-vsbExt-tmarg-bmarg < y ) {
	    if (d->vMode == Auto)
		showv=TRUE;
	}
	if ( showv && w-hsbExt-lmarg-rmarg < x ) {
	    if (d->hMode == Auto)
		showh=TRUE;
	}
    } else {
	// Scrollbars not needed, only show scrollbar that are always on.
	showh = d->hMode == AlwaysOn;
	showv = d->vMode == AlwaysOn;
    }

    return QSize( w-lmarg-rmarg - (showv ? vsbExt : 0),
		  h-tmarg-bmarg - (showh ? hsbExt : 0) );
}


/*!
  Updates scrollbars - all possibilities considered.  You should never
  need to call this in your code.
*/

qt'QScrollView::updateScrollBars() (./qt-2.1.0/src/widgets/qscrollview.cpp:598)

void QScrollView::updateScrollBars()
{
    // I support this should use viewportSize()... but it needs
    // so many of the temporary variables from viewportSize.  hm.
    int fw = frameWidth();
    int lmarg = fw+d->l_marg;
    int rmarg = fw+d->r_marg;
    int tmarg = fw+d->t_marg;
    int bmarg = fw+d->b_marg;

    int w = width();
    int h = height();

    int portw, porth;

    bool needh;
    bool needv;
    bool showh;
    bool showv;

    int hsbExt = horizontalScrollBar()->sizeHint().height();
    int vsbExt = verticalScrollBar()->sizeHint().width();

    if ( d->policy != AutoOne || d->anyVisibleChildren() ) {
	// Do we definitely need the scrollbar?
	needh = w-lmarg-rmarg < contentsWidth();
	needv = h-tmarg-bmarg < contentsHeight();

	// Do we intend to show the scrollbar?
	if (d->hMode == AlwaysOn)
	    showh = TRUE;
	else if (d->hMode == AlwaysOff)
	    showh = FALSE;
	else
	    showh = needh;

	if (d->vMode == AlwaysOn)
	    showv = TRUE;
	else if (d->vMode == AlwaysOff)
	    showv = FALSE;
	else
	    showv = needv;

	// Given other scrollbar will be shown, NOW do we need one?
	if ( showh && h-vsbExt-tmarg-bmarg < contentsHeight() ) {
	    needv=TRUE;
	    if (d->vMode == Auto)
		showv=TRUE;
	}
	if ( showv && w-hsbExt-lmarg-rmarg < contentsWidth() ) {
	    needh=TRUE;
	    if (d->hMode == Auto)
		showh=TRUE;
	}
    } else {
	// Scrollbars not needed, only show scrollbar that are always on.
	needh = needv = FALSE;
	showh = d->hMode == AlwaysOn;
	showv = d->vMode == AlwaysOn;
    }

    bool sc = d->signal_choke;
    d->signal_choke=TRUE;

    // Hide unneeded scrollbar, calculate viewport size
    if ( showh ) {
        porth=h-hsbExt-tmarg-bmarg;
    } else {
	if (!needh)
	    d->hbar.setValue(0);
	d->hbar.hide();
	porth=h-tmarg-bmarg;
    }
    if ( showv ) {
	portw=w-vsbExt-lmarg-rmarg;
    } else {
	if (!needv)
	    d->vbar.setValue(0);
	d->vbar.hide();
	portw=w-lmarg-rmarg;
    }

    // Configure scrollbars that we will show
    if ( showv ) {
	if ( needv ) {
	    d->vbar.setRange( 0, contentsHeight()-porth );
	    d->vbar.setSteps( QScrollView::d->vbar.lineStep(), porth );
	} else {
	    d->vbar.setRange( 0, 0 );
	}
    }
    if ( showh ) {
	if ( needh ) {
	    d->hbar.setRange( 0, contentsWidth()-portw );
	    d->hbar.setSteps( QScrollView::d->hbar.lineStep(), portw );
	} else {
	    d->hbar.setRange( 0, 0 );
	}
    }

    // Position the scrollbars, viewport, and corner widget.
    int bottom;
    if ( showh ) {
	int right = ( showv || cornerWidget() ) ? w-vsbExt : w;
	if ( style() == WindowsStyle )
            setHBarGeometry(d->hbar, fw, h-hsbExt-fw,
                            right-fw-fw, hsbExt );
	else
            setHBarGeometry(d->hbar, 0, h-hsbExt, right,
                            hsbExt );
	bottom=h-hsbExt;
    } else {
        bottom=h;
    }
    if ( showv ) {
	clipper()->setGeometry( lmarg, tmarg,
                                w-vsbExt-lmarg-rmarg,
                                bottom-tmarg-bmarg );
	if ( style() == WindowsStyle )
	    changeFrameRect(QRect(0, 0, w, h) );
	else
	    changeFrameRect(QRect(0, 0, w-vsbExt, bottom));
	if (cornerWidget()) {
	    if ( style() == WindowsStyle )
                setVBarGeometry( d->vbar, w-vsbExt-fw,
                                 fw, vsbExt,
                                 h-hsbExt-fw-fw );
	    else
                setVBarGeometry( d->vbar, w-vsbExt, 0,
                                 vsbExt,
                                 h-hsbExt );
	}
	else {
	    if ( style() == WindowsStyle )
                setVBarGeometry( d->vbar, w-vsbExt-fw,
                                 fw, vsbExt,
                                 bottom-fw-fw );
	    else
                setVBarGeometry( d->vbar, w-vsbExt, 0,
                                 vsbExt, bottom );
	}
    } else {
	if ( style() == WindowsStyle )
	    changeFrameRect(QRect(0, 0, w, h));
	else
	    changeFrameRect(QRect(0, 0, w, bottom));
	clipper()->setGeometry( lmarg, tmarg,
				 w-lmarg-rmarg, bottom-tmarg-bmarg );
    }
    if ( d->corner ) {
	if ( style() == WindowsStyle )
            d->corner->setGeometry( w-vsbExt-fw,
                                    h-hsbExt-fw,
                                    vsbExt,
                                    hsbExt );
	else
            d->corner->setGeometry( w-vsbExt,
                                    h-hsbExt,
                                    vsbExt,
                                    hsbExt );
    }

    d->signal_choke=sc;

    if ( contentsX()+visibleWidth() > contentsWidth() ) {
	int x=QMAX(0,contentsWidth()-visibleWidth());
	d->hbar.setValue(x);
	// Do it even if it is recursive
	moveContents( -x, -contentsY() );
    }
    if ( contentsY()+visibleHeight() > contentsHeight() ) {
	int y=QMAX(0,contentsHeight()-visibleHeight());
	d->vbar.setValue(y);
	// Do it even if it is recursive
	moveContents( -contentsX(), -y );
    }

    // Finally, show the scrollbars.
    if ( showh )
	d->hbar.show();
    if ( showv )
	d->vbar.show();
}


/*! \reimp
*/

qt'QScrollView::show() (./qt-2.1.0/src/widgets/qscrollview.cpp:785)

void QScrollView::show()
{
    //     Ensures that scrollbars have the correct size when the
    //     widget is shown.
    if (isVisible()) return;
    QWidget::show();
    updateScrollBars();
    d->hideOrShowAll(this);
}

/*! \reimp
 */

qt'QScrollView::resize() (./qt-2.1.0/src/widgets/qscrollview.cpp:797)

void QScrollView::resize( int w, int h )
{
    //   Ensures that scrollbars have the correct size when the widget is
    //   resized.
    QWidget::resize( w, h );
}

/*! \reimp
*/

qt'QScrollView::resize() (./qt-2.1.0/src/widgets/qscrollview.cpp:806)

void QScrollView::resize( const QSize& s )
{
    //   Ensures that scrollbars have the correct size when the widget is
    //   resized.
    resize(s.width(),s.height());
}

/*! \reimp
*/

qt'QScrollView::resizeEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:815)

void QScrollView::resizeEvent( QResizeEvent* event )
{
    // Ensures that scrollbars have the correct size when the widget
    // is resized.
    bool u = isUpdatesEnabled();
    setUpdatesEnabled( FALSE );
    QFrame::resizeEvent( event );

    // do _not_ update the scrollbars when updates have been
    // disabled. This makes it possible for subclasses to implement
    // dynamic wrapping without a horizontal scrollbar showing up all
    // the time when making a window smaller.
    if ( u )
	updateScrollBars();
    d->hideOrShowAll(this);
    setUpdatesEnabled( u );
}


/*! \reimp
*/

qt'QScrollView::wheelEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:836)

void QScrollView::wheelEvent( QWheelEvent *e ){
    QWheelEvent ce( viewport()->mapFromGlobal( e->globalPos() ),
		    e->globalPos(), e->delta(), e->state());
    viewportWheelEvent(&ce);
    if ( !ce.isAccepted() ) {
	if (verticalScrollBar())
	    QApplication::sendEvent( verticalScrollBar(), e);
    }
}

/*!
  Returns the currently set mode for the vertical scrollbar.

  \sa setVScrollBarMode()
*/
QScrollView::ScrollBarMode QScrollView::vScrollBarMode() const
{
    return d->vMode;
}


/*! \enum QScrollView::ScrollBarMode

  This enum type describes the various modes of QScrollView's scroll
  bars.  The defined modes are: <ul>

   <li> \c Auto - QScrollView shows a scrollbar when the content is
   too tall to fit and not else.  This is the default.

   <li> \c AlwaysOff - QScrollView never shows a scrollbar.

   <li> \c AlwaysOn - QScrollView always shows a scrollbar.

   </ul>

   (The modes for the horizontal and vertical scroll bars are independent.)
*/


/*!
  Sets the mode for the vertical scrollbar.

  \sa vScrollBarMode(), setHScrollBarMode()
*/

qt'QScrollView::setVScrollBarMode() (./qt-2.1.0/src/widgets/qscrollview.cpp:880)

void  QScrollView::setVScrollBarMode( ScrollBarMode mode )
{
    if (d->vMode != mode) {
	d->vMode = mode;
	updateScrollBars();
    }
}


/*!
  Returns the currently set mode for the horizontal scrollbar.

  \sa setHScrollBarMode()
*/
QScrollView::ScrollBarMode QScrollView::hScrollBarMode() const
{
    return d->hMode;
}

/*!
  Sets the mode for the horizontal scrollbar.
  <ul>
   <li> \c Auto (the default) shows a scrollbar when the content is too wide to fit.
   <li> \c AlwaysOff never shows a scrollbar.
   <li> \c AlwaysOn always shows a scrollbar.
  </ul>

  \sa hScrollBarMode(), setVScrollBarMode()
*/

qt'QScrollView::setHScrollBarMode() (./qt-2.1.0/src/widgets/qscrollview.cpp:909)

void  QScrollView::setHScrollBarMode( ScrollBarMode mode )
{
    if (d->hMode != mode) {
	d->hMode = mode;
	updateScrollBars();
    }
}


/*!
Returns the widget in the corner between the two scrollbars.

By default, no corner widget is present.
*/

qt'QScrollView::cornerWidget() (./qt-2.1.0/src/widgets/qscrollview.cpp:923)

QWidget* QScrollView::cornerWidget() const
{
    return d->corner;
}

/*!
  Sets the widget in the corner between the two scrollbars.

  You will probably also want to
  set at least one of the scrollbar modes to AlwaysOn.

  Passing 0 shows no widget in the corner.

  Any previous corner widget is hidden.

  You may call setCornerWidget() with the same widget at different times.

  All widgets set here will be deleted by the QScrollView when it destructs
  unless you separately
  reparent the widget after setting some other corner widget (or 0).

  Any \e newly set widget should have no current parent.

  By default, no corner widget is present.

  \sa setVScrollBarMode(), setHScrollBarMode()
*/

qt'QScrollView::setCornerWidget() (./qt-2.1.0/src/widgets/qscrollview.cpp:950)

void QScrollView::setCornerWidget(QWidget* corner)
{
    QWidget* oldcorner = d->corner;
    if (oldcorner != corner) {
	if (oldcorner) oldcorner->hide();
	d->corner = corner;

	if ( corner && corner->parentWidget() != this ) {
	    // #### No clean way to get current WFlags
	    corner->reparent( this, (((QScrollView*)corner))->getWFlags(),
			      QPoint(0,0), FALSE );
	}

	updateScrollBars();
	if ( corner ) corner->show();
    }
}


/*!
  Sets the resize policy to \a r.

  \sa resizePolicy() ResizePolicy
*/

qt'QScrollView::setResizePolicy() (./qt-2.1.0/src/widgets/qscrollview.cpp:974)

void QScrollView::setResizePolicy( ResizePolicy r )
{
    d->policy = r;
}

/*!
  Returns the currently set ResizePolicy.

  \sa setResizePolicy() ResizePolicy
*/
QScrollView::ResizePolicy QScrollView::resizePolicy() const
{
    return d->policy;
}

/*! \reimp
*/

qt'QScrollView::setEnabled() (./qt-2.1.0/src/widgets/qscrollview.cpp:991)

void QScrollView::setEnabled( bool enable )
{
    QFrame::setEnabled( enable );
}

/*!
  Removes a child from the scrolled area.  Note that this happens
  automatically if the child is deleted.
*/

qt'QScrollView::removeChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:1000)

void QScrollView::removeChild(QWidget* child)
{
    if ( !d ) // In case we are destructing
	return;

    QSVChildRec *r = d->rec(child);
    if ( r ) d->deleteChildRec( r );
}

/*! \reimp
*/

qt'QScrollView::removeChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:1011)

void QScrollView::removeChild(QObject* child)
{
    QFrame::removeChild(child);
}

/*!
  Inserts \a child into the scrolled area positioned at (\a x, \a y).
  The position defaults to (0,0). If the child is already in the view,
  it is just moved.

  You may want to call enableClipper(TRUE) if you add a large number
  of widgets.
*/

qt'QScrollView::addChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:1024)

void QScrollView::addChild(QWidget* child, int x, int y)
{
    if ( child->parentWidget() == viewport() ) {
	// May already be there
	QSVChildRec *r = d->rec(child);
	if (r) {
	    r->moveTo(this,x,y,d->clipped_viewport);
	    if ( d->policy > Manual ) {
		d->autoResizeHint();
		d->autoResize(this); // #### better to just deal with this one widget!
	    }
	    return;
	}
    }

    if ( d->children.isEmpty() && d->policy == Default ) {
	setResizePolicy( AutoOne );
	child->installEventFilter( this );
    } else if ( d->policy == AutoOne ) {
	child->removeEventFilter( this );
    }
    if ( child->parentWidget() != viewport() ) {
	child->reparent( viewport(), 0, QPoint(0,0), FALSE );
    }
    d->addChildRec(child,x,y)->hideOrShow(this, d->clipped_viewport);

    if ( d->policy > Manual ) {
	d->autoResizeHint();
	d->autoResize(this); // #### better to just deal with this one widget!
    }
}

/*!
  Repositions \a child to (\a x, \a y).
  This functions the same as addChild().
*/

qt'QScrollView::moveChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:1060)

void QScrollView::moveChild(QWidget* child, int x, int y)
{
    addChild(child,x,y);
}

/*!
  Returns the X position of the given child widget.
  Use this rather than QWidget::x() for widgets added to the view.
*/

qt'QScrollView::childX() (./qt-2.1.0/src/widgets/qscrollview.cpp:1069)

int QScrollView::childX(QWidget* child)
{
    return d->rec(child)->x;
}

/*!
  Returns the Y position of the given child widget.
  Use this rather than QWidget::y() for widgets added to the view.
*/

qt'QScrollView::childY() (./qt-2.1.0/src/widgets/qscrollview.cpp:1078)

int QScrollView::childY(QWidget* child)
{
    return d->rec(child)->y;
}

/*!
  \obsolete

  Returns TRUE if \a child is visible.  This is equivalent
  to child->isVisible().
*/

qt'QScrollView::childIsVisible() (./qt-2.1.0/src/widgets/qscrollview.cpp:1089)

bool QScrollView::childIsVisible(QWidget* child)
{
    return child->isVisible();
}

/*!
  \obsolete

  Sets the visibility of \a child. Equivalent to
  QWidget::show() or QWidget::hide().
*/

qt'QScrollView::showChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:1100)

void QScrollView::showChild(QWidget* child, bool y)
{
    if ( y )
	child->show();
    else
	child->hide();
}


/*!
  This event filter ensures the scrollbars are updated when a single
  contents widget is resized, shown, hidden, or destroyed, and passes
  mouse events to the QScrollView.
*/


qt'QScrollView::eventFilter() (./qt-2.1.0/src/widgets/qscrollview.cpp:1115)

bool QScrollView::eventFilter( QObject *obj, QEvent *e )
{
    if (!d) return FALSE; // we are destructing
    if ( obj == &d->viewport || obj == d->clipped_viewport ) {
	switch ( e->type() ) {

	/* Forward many events to viewport...() functions */
	case QEvent::Paint:
	    viewportPaintEvent( (QPaintEvent*)e );
	    break;
	case QEvent::Resize:
	    viewportResizeEvent( (QResizeEvent*)e );
	    break;
	case QEvent::MouseButtonPress:
	    viewportMousePressEvent( (QMouseEvent*)e );
	    break;
	case QEvent::MouseButtonRelease:
	    viewportMouseReleaseEvent( (QMouseEvent*)e );
	    break;
	case QEvent::MouseButtonDblClick:
	    viewportMouseDoubleClickEvent( (QMouseEvent*)e );
	    break;
	case QEvent::MouseMove:
	    viewportMouseMoveEvent( (QMouseEvent*)e );
	    break;
	case QEvent::DragEnter:
	    viewportDragEnterEvent( (QDragEnterEvent*)e );
	    break;
	case QEvent::DragMove: {
	    if ( d->drag_autoscroll ) {
		QPoint vp = contentsToViewport( ( (QDragMoveEvent*)e )->pos() );
		QRect inside_margin( autoscroll_margin, autoscroll_margin,
				     visibleWidth() - autoscroll_margin * 2,
				     visibleHeight() - autoscroll_margin * 2 );
		if ( !inside_margin.contains( vp ) ) {
		    startDragAutoScroll();
		    ( (QDragMoveEvent*)e )->accept( QRect(0,0,0,0) ); // Keep sending move events
		}
	    }
	    viewportDragMoveEvent( (QDragMoveEvent*)e );
	} break;
	case QEvent::DragLeave:
	    stopDragAutoScroll();
	    viewportDragLeaveEvent( (QDragLeaveEvent*)e );
	    break;
	case QEvent::Drop:
	    stopDragAutoScroll();
	    viewportDropEvent( (QDropEvent*)e );
	    break;
	case QEvent::Wheel:
	    viewportWheelEvent( (QWheelEvent*)e );
	    break;


	case QEvent::ChildRemoved:
	    removeChild((QWidget*)((QChildEvent*)e)->child());
	    break;
	case QEvent::LayoutHint:
	    d->autoResizeHint();
	    break;
	default:
	    break;
	}
    } else {
	// must be a child
	QSVChildRec* r = d->rec((QWidget*)obj);
	if (!r) return FALSE; // spurious
	if ( e->type() == QEvent::Resize )
	    d->autoResize(this);
	else if ( e->type() == QEvent::Move )
	    d->autoMove(this);
    }
    return FALSE;  // always continue with standard event processing
}

/*!
  This event handler is called whenever the QScrollView receives a
  mousePressEvent() - the press position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsMousePressEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1195)

void QScrollView::contentsMousePressEvent( QMouseEvent* )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  mouseReleaseEvent() - the release position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsMouseReleaseEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1204)

void QScrollView::contentsMouseReleaseEvent( QMouseEvent* )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  mouseDoubleClickEvent() - the click position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsMouseDoubleClickEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1213)

void QScrollView::contentsMouseDoubleClickEvent( QMouseEvent* )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  mouseMoveEvent() - the mouse position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsMouseMoveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1222)

void QScrollView::contentsMouseMoveEvent( QMouseEvent* )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  dragEnterEvent() - the drag position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsDragEnterEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1231)

void QScrollView::contentsDragEnterEvent( QDragEnterEvent * )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  dragMoveEvent() - the drag position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsDragMoveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1240)

void QScrollView::contentsDragMoveEvent( QDragMoveEvent * )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  dragLeaveEvent() - the drag position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsDragLeaveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1249)

void QScrollView::contentsDragLeaveEvent( QDragLeaveEvent * )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  dropEvent() - the drop position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsDropEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1258)

void QScrollView::contentsDropEvent( QDropEvent * )
{
}

/*!
  This event handler is called whenever the QScrollView receives a
  wheelEvent() - the mouse position is translated to be a
  point on the contents.
*/

qt'QScrollView::contentsWheelEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1267)

void QScrollView::contentsWheelEvent( QWheelEvent * e )
{
    e->ignore();
}


/*!
  This is a low-level painting routine that draws the viewport
  contents.  Reimplement this if drawContents() is too high-level.
  (for example, if you don't want to open a QPainter on the viewport).
*/

qt'QScrollView::viewportPaintEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1278)

void QScrollView::viewportPaintEvent( QPaintEvent* pe )
{
    QWidget* vp = viewport();
    QPainter p(vp);
    QRect r = pe->rect();
    if ( d->clipped_viewport ) {
	QRect rr(
	    -d->clipped_viewport->x(), -d->clipped_viewport->y(),
	    d->viewport.width(), d->viewport.height()
	);
	r &= rr;
	int ex = r.x() + d->clipped_viewport->x() + contentsX();
	int ey = r.y() + d->clipped_viewport->y() + contentsY();
	int ew = r.width();
	int eh = r.height();
	drawContentsOffset(&p,
	    contentsX()+d->clipped_viewport->x(),
	    contentsY()+d->clipped_viewport->y(),
	    ex, ey, ew, eh);
    } else {
	r &= d->viewport.rect();
	int ex = r.x() + contentsX();
	int ey = r.y() + contentsY();
	int ew = r.width();
	int eh = r.height();
	drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh);
    }
}


/*!
  To provide simple processing of events on the contents, this method
  receives all resize events sent to the viewport.

  \sa QWidget::resizeEvent()
*/

qt'QScrollView::viewportResizeEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1314)

void QScrollView::viewportResizeEvent( QResizeEvent* )
{
}

/*!
  To provide simple processing of events on the contents, this method receives all mouse
  press events sent to the viewport.

  The default implementation translates the event and calls
  contentsMousePressEvent().

  \sa contentsMousePressEvent(), QWidget::mousePressEvent()
*/

qt'QScrollView::viewportMousePressEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1327)

void QScrollView::viewportMousePressEvent( QMouseEvent* e )
{
    QMouseEvent ce(e->type(), viewportToContents(e->pos()),
	e->globalPos(), e->button(), e->state());
    contentsMousePressEvent(&ce);
}

/*!
  To provide simple processing of events on the contents,
  this method receives all mouse
  release events sent to the viewport.

  The default implementation translates the event and calls
  contentsMouseReleaseEvent().

  \sa QWidget::mouseReleaseEvent()
*/

qt'QScrollView::viewportMouseReleaseEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1344)

void QScrollView::viewportMouseReleaseEvent( QMouseEvent* e )
{
    QMouseEvent ce(e->type(), viewportToContents(e->pos()),
	e->globalPos(), e->button(), e->state());
    contentsMouseReleaseEvent(&ce);
}

/*!
  To provide simple processing of events on the contents,
  this method receives all mouse
  double click events sent to the viewport.

  The default implementation translates the event and calls
  contentsMouseDoubleClickEvent().

  \sa QWidget::mouseDoubleClickEvent()
*/

qt'QScrollView::viewportMouseDoubleClickEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1361)

void QScrollView::viewportMouseDoubleClickEvent( QMouseEvent* e )
{
    QMouseEvent ce(e->type(), viewportToContents(e->pos()),
	e->globalPos(), e->button(), e->state());
    contentsMouseDoubleClickEvent(&ce);
}

/*!
  To provide simple processing of events on the contents,
  this method receives all mouse
  move events sent to the viewport.

  The default implementation translates the event and calls
  contentsMouseMoveEvent().

  \sa QWidget::mouseMoveEvent()
*/

qt'QScrollView::viewportMouseMoveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1378)

void QScrollView::viewportMouseMoveEvent( QMouseEvent* e )
{
    QMouseEvent ce(e->type(), viewportToContents(e->pos()),
	e->globalPos(), e->button(), e->state());
    contentsMouseMoveEvent(&ce);
}

/*!
  To provide simple processing of events on the contents,
  this method receives all drag enter
  events sent to the viewport.

  The default implementation translates the event and calls
  contentsDragEnterEvent().

  \sa QWidget::dragEnterEvent()
*/

qt'QScrollView::viewportDragEnterEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1395)

void QScrollView::viewportDragEnterEvent( QDragEnterEvent* e )
{
    e->setPoint(viewportToContents(e->pos()));
    contentsDragEnterEvent(e);
    e->setPoint(contentsToViewport(e->pos()));
}

/*!
  To provide simple processing of events on the contents,
  this method receives all drag move
  events sent to the viewport.

  The default implementation translates the event and calls
  contentsDragMoveEvent().

  \sa QWidget::dragMoveEvent()
*/

qt'QScrollView::viewportDragMoveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1412)

void QScrollView::viewportDragMoveEvent( QDragMoveEvent* e )
{
    e->setPoint(viewportToContents(e->pos()));
    contentsDragMoveEvent(e);
    e->setPoint(contentsToViewport(e->pos()));
}

/*!
  To provide simple processing of events on the contents,
  this method receives all drag leave
  events sent to the viewport.

  The default implementation calls contentsDragLeaveEvent().

  \sa QWidget::dragLeaveEvent()
*/

qt'QScrollView::viewportDragLeaveEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1428)

void QScrollView::viewportDragLeaveEvent( QDragLeaveEvent* e )
{
    contentsDragLeaveEvent(e);
}

/*!
  To provide simple processing of events on the contents,
  this method receives all drop
  events sent to the viewport.

  The default implementation translates the event and calls
  contentsDropEvent().

  \sa QWidget::dropEvent()
*/

qt'QScrollView::viewportDropEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1443)

void QScrollView::viewportDropEvent( QDropEvent* e )
{
    e->setPoint(viewportToContents(e->pos()));
    contentsDropEvent(e);
    e->setPoint(contentsToViewport(e->pos()));
}

/*!
  To provide simple processing of events on the contents,
  this method receives all wheel
  events sent to the viewport.

  The default implementation translates the event and calls
  contentsWheelEvent().

  \sa QWidget::wheelEvent()
*/

qt'QScrollView::viewportWheelEvent() (./qt-2.1.0/src/widgets/qscrollview.cpp:1460)

void QScrollView::viewportWheelEvent( QWheelEvent* e )
{
    QWheelEvent ce( viewportToContents(e->pos()),
	e->globalPos(), e->delta(), e->state());
    contentsWheelEvent(&ce);
    if ( ce.isAccepted() )
	e->accept();
    else
	e->ignore();
}

/*!
 Returns the component horizontal scrollbar.  It is made available to allow
 accelerators, autoscrolling, etc., and to allow changing
 of arrow scroll rates: bar->setSteps( rate, bar->pageStep() ).

 It should not be otherwise manipulated.

 This function never returns 0.
*/

qt'QScrollView::horizontalScrollBar() (./qt-2.1.0/src/widgets/qscrollview.cpp:1480)

QScrollBar* QScrollView::horizontalScrollBar() const
{
    return &d->hbar;
}

/*!
 Returns the component vertical scrollbar.  It is made available to allow
 accelerators, autoscrolling, etc., and to allow changing
 of arrow scroll rates: bar->setSteps( rate, bar->pageStep() ).

 It should not be otherwise manipulated.

 This function never returns 0.
*/

qt'QScrollView::verticalScrollBar() (./qt-2.1.0/src/widgets/qscrollview.cpp:1494)

QScrollBar* QScrollView::verticalScrollBar() const {
    return &d->vbar;
}


/*!
 Scrolls the content so that the point (x, y) is visible
 with at least 50-pixel margins (if possible, otherwise centered).
*/

qt'QScrollView::ensureVisible() (./qt-2.1.0/src/widgets/qscrollview.cpp:1503)

void QScrollView::ensureVisible( int x, int y )
{
    ensureVisible(x, y, 50, 50);
}

/*!
 Scrolls the content so that the point (x, y) is visible
 with at least the given pixel margins (if possible, otherwise centered).
*/

qt'QScrollView::ensureVisible() (./qt-2.1.0/src/widgets/qscrollview.cpp:1512)

void QScrollView::ensureVisible( int x, int y, int xmargin, int ymargin )
{
    int pw=visibleWidth();
    int ph=visibleHeight();

    int cx=-contentsX();
    int cy=-contentsY();
    int cw=contentsWidth();
    int ch=contentsHeight();

    if ( pw < xmargin*2 )
	xmargin=pw/2;
    if ( ph < ymargin*2 )
	ymargin=ph/2;

    if ( cw <= pw ) {
	xmargin=0;
	cx=0;
    }
    if ( ch <= ph ) {
	ymargin=0;
	cy=0;
    }

    if ( x < -cx+xmargin )
	cx = -x+xmargin;
    else if ( x >= -cx+pw-xmargin )
	cx = -x+pw-xmargin;

    if ( y < -cy+ymargin )
	cy = -y+ymargin;
    else if ( y >= -cy+ph-ymargin )
	cy = -y+ph-ymargin;

    if ( cx > 0 )
	cx=0;
    else if ( cx < pw-cw && cw>pw )
	cx=pw-cw;

    if ( cy > 0 )
	cy=0;
    else if ( cy < ph-ch && ch>ph )
	cy=ph-ch;

    setContentsPos( -cx, -cy );
}

/*!
 Scrolls the content so that the point (x, y) is in the top-left corner.
*/

qt'QScrollView::setContentsPos() (./qt-2.1.0/src/widgets/qscrollview.cpp:1562)

void QScrollView::setContentsPos( int x, int y )
{
    if ( x < 0 ) x = 0;
    if ( y < 0 ) y = 0;
    // Choke signal handling while we update BOTH sliders.
    d->signal_choke=TRUE;
    moveContents( -x, -y );
    d->vbar.setValue( y );
    d->hbar.setValue( x );
//     updateScrollBars(); // ### warwick, why should we need that???
    d->signal_choke=FALSE;
//     updateScrollBars(); // ### warwick, why should we need that???
}

/*!
 Scrolls the content by \a x to the left and \a y upwards.
*/

qt'QScrollView::scrollBy() (./qt-2.1.0/src/widgets/qscrollview.cpp:1579)

void QScrollView::scrollBy( int dx, int dy )
{
    setContentsPos( contentsX()+dx, contentsY()+dy );
}

/*!
 Scrolls the content so that the point (x,y) is in the
 center of visible area.
*/

qt'QScrollView::center() (./qt-2.1.0/src/widgets/qscrollview.cpp:1588)

void QScrollView::center( int x, int y )
{
    ensureVisible( x, y, 32000, 32000 );
}

/*!
 Scrolls the content so that the point (x,y) is visible,
 with the given margins (as fractions of visible area).

 eg.
 <ul>
   <li>Margin 0.0 allows (x,y) to be on edge of visible area.
   <li>Margin 0.5 ensures (x,y) is in middle 50% of visible area.
   <li>Margin 1.0 ensures (x,y) is in the center of the visible area.
 </ul>
*/

qt'QScrollView::center() (./qt-2.1.0/src/widgets/qscrollview.cpp:1604)

void QScrollView::center( int x, int y, float xmargin, float ymargin )
{
    int pw=visibleWidth();
    int ph=visibleHeight();
    ensureVisible( x, y, int( xmargin/2.0*pw+0.5 ), int( ymargin/2.0*ph+0.5 ) );
}


/*!
  \fn void QScrollView::contentsMoving(int x, int y)

  This signal is emitted just before the contents is moved
  to the given position.

  \sa contentsX(), contentsY()
*/

/*!
  Moves the contents.
*/

qt'QScrollView::moveContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1624)

void QScrollView::moveContents(int x, int y)
{
    if ( -x+visibleWidth() > contentsWidth() )
	x=QMIN(0,-contentsWidth()+visibleWidth());
    if ( -y+visibleHeight() > contentsHeight() )
	y=QMIN(0,-contentsHeight()+visibleHeight());

    int dx = x - d->vx;
    int dy = y - d->vy;

    if (!dx && !dy)
	return; // Nothing to do

    emit contentsMoving( -x, -y );

    d->vx = x;
    d->vy = y;

    if ( d->clipped_viewport ) {
	// Cheap move (usually)
	d->moveAllBy(dx,dy);
    } else if ( /*dx && dy ||*/
	 ( QABS(dy) * 5 > visibleHeight() * 4 ) ||
	 ( QABS(dx) * 5 > visibleWidth() * 4 )
	)
    {
	// Big move
	if ( viewport()->isUpdatesEnabled() )
	    viewport()->update();
	d->moveAllBy(dx,dy);
    } else {
	// Small move
	clipper()->scroll(dx,dy);
    }
    d->hideOrShowAll(this, TRUE );
}

/*!
  Returns the X coordinate of the contents which is at the left
  edge of the viewport.
*/

qt'QScrollView::contentsX() (./qt-2.1.0/src/widgets/qscrollview.cpp:1665)

int QScrollView::contentsX() const
{
    return -d->vx;
}

/*!
  Returns the Y coordinate of the contents which is at the top
  edge of the viewport.
*/

qt'QScrollView::contentsY() (./qt-2.1.0/src/widgets/qscrollview.cpp:1674)

int QScrollView::contentsY() const
{
    return -d->vy;
}

/*!
  Returns the width of the contents area.
*/

qt'QScrollView::contentsWidth() (./qt-2.1.0/src/widgets/qscrollview.cpp:1682)

int QScrollView::contentsWidth() const
{
    return d->vwidth;
}

/*!
  Returns the height of the contents area.
*/

qt'QScrollView::contentsHeight() (./qt-2.1.0/src/widgets/qscrollview.cpp:1690)

int QScrollView::contentsHeight() const
{
    return d->vheight;
}

/*!
  Set the size of the contents area to \a w pixels wide and \a h
  pixels high, and updates the viewport accordingly.
*/

qt'QScrollView::resizeContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1699)

void QScrollView::resizeContents( int w, int h )
{
    int ow = d->vwidth;
    int oh = d->vheight;
    d->vwidth = w;
    d->vheight = h;

    // Could more efficiently scroll if shrinking, repaint if growing, etc.
    updateScrollBars();

    if ( d->children.isEmpty() && d->policy == Default )
	setResizePolicy( Manual );

    if ( ow > w ) {
	// Swap
	int t=w;
	w=ow;
	ow=t;
    }
    // Refresh area ow..w
    if ( ow < visibleWidth() && w >= 0 ) {
	if ( ow < 0 )
	    ow = 0;
	if ( w > visibleWidth() )
	    w = visibleWidth();
	clipper()->update( contentsX()+ow, 0, w-ow, visibleHeight() );
    }

    if ( oh > h ) {
	// Swap
	int t=h;
	h=oh;
	oh=t;
    }
    // Refresh area oh..h
    if ( oh < visibleHeight() && h >= 0 ) {
	if ( oh < 0 )
	    oh = 0;
	if ( h > visibleHeight() )
	    h = visibleHeight();
	clipper()->update( 0, contentsY()+oh, visibleWidth(), h-oh);
    }
}

/*!
  Calls update() on rectangle defined by \a x, \a y, \a w, \a h,
  translated appropriately.  If the rectangle in not visible,
  nothing is repainted.

  \sa repaintContents()
*/

qt'QScrollView::updateContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1750)

void QScrollView::updateContents( int x, int y, int w, int h )
{
    QWidget* vp = viewport();

    // Translate
    x -= contentsX();
    y -= contentsY();

    // Clip to QCOORD space
    if ( x < 0 ) {
	w += x;
	x = 0;
    }
    if ( y < 0 ) {
	h += y;
	y = 0;
    }

    if ( w < 0 || h < 0 )
	return;
    if ( w > visibleWidth() )
	w = visibleWidth();
    if ( h > visibleHeight() )
	h = visibleHeight();

    if ( d->clipped_viewport ) {
	// Translate clipper() to viewport()
	x -= d->clipped_viewport->x();
	y -= d->clipped_viewport->y();
    }

    vp->update( x, y, w, h );
}

/*!
  \overload
*/

qt'QScrollView::updateContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1787)

void QScrollView::updateContents( const QRect& r )
{
    updateContents(r.x(), r.y(), r.width(), r.height());
}

/*!
  \overload
*/

qt'QScrollView::repaintContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1795)

void QScrollView::repaintContents( const QRect& r, bool erase )
{
    repaintContents(r.x(), r.y(), r.width(), r.height(), erase);
}



/*!
  Calls repaint() on rectangle defined by \a x, \a y, \a w, \a h,
  translated appropriately.  If the rectangle in not visible,
  nothing is repainted.

  \sa updateContents()
*/

qt'QScrollView::repaintContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1809)

void QScrollView::repaintContents( int x, int y, int w, int h, bool erase )
{
    QWidget* vp = viewport();

    // Translate logical to clipper()
    x -= contentsX();
    y -= contentsY();

    // Clip to QCOORD space
    if ( x < 0 ) {
	w += x;
	x = 0;
    }
    if ( y < 0 ) {
	h += y;
	y = 0;
    }

    if ( w < 0 || h < 0 )
	return;
    if ( w > visibleWidth() )
	w = visibleWidth();
    if ( h > visibleHeight() )
	h = visibleHeight();

    if ( d->clipped_viewport ) {
	// Translate clipper() to viewport()
	x -= d->clipped_viewport->x();
	y -= d->clipped_viewport->y();
    }

    vp->repaint( x, y, w, h, erase );
}


/*!
  For backward compatibility only.
  It is easier to use drawContents(QPainter*,int,int,int,int).

  The default implementation translates the painter appropriately
  and calls drawContents(QPainter*,int,int,int,int).
*/

qt'QScrollView::drawContentsOffset() (./qt-2.1.0/src/widgets/qscrollview.cpp:1851)

void QScrollView::drawContentsOffset(QPainter* p, int offsetx, int offsety, int clipx, int clipy, int clipw, int cliph)
{
    p->translate(-offsetx,-offsety);
    drawContents(p, clipx, clipy, clipw, cliph);
}

/*!
  \fn void QScrollView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)

  Reimplement this method if you are viewing a drawing area rather
  than a widget.

  The function should draw the rectangle (\a clipx, \a clipy, \a clipw, \a
  cliph ) of the contents, using painter \a p.  The clip rectangle is
  in the scroll views's coordinates.

  For example:
  \code
  {
    // Fill a 40000 by 50000 rectangle at (100000,150000)

    // Calculate the coordinates...
    int x1 = 100000, y1 = 150000;
    int x2 = x1+40000-1, y2 = y1+50000-1;

    // Clip the coordinates so X/Windows will not have problems...
    if (x1 < clipx) x1=clipx;
    if (y1 < clipy) y1=clipy;
    if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
    if (y2 > clipy+cliph-1) y2=clipy+cliph-1;

    // Paint using the small coordinates...
    if ( x2 >= x1 && y2 >= y1 )
	p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
  }
  \endcode

  The clip rectangle and translation of the painter \a p is already set
  appropriately.
*/

qt'QScrollView::drawContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:1891)

void QScrollView::drawContents(QPainter*, int, int, int, int)
{
}

/*! \reimp
*/

qt'QScrollView::frameChanged() (./qt-2.1.0/src/widgets/qscrollview.cpp:1897)

void QScrollView::frameChanged()
{
    // Ensures that scrollbars have the correct size when the frame
    // style changes.
    updateScrollBars();
}


/*!
  Returns the viewport widget of the scrollview.  This is the widget
  containing the contents widget or which is the drawing area.
*/

qt'QScrollView::viewport() (./qt-2.1.0/src/widgets/qscrollview.cpp:1909)

QWidget* QScrollView::viewport() const
{
    return d->clipped_viewport ? d->clipped_viewport : &d->viewport;
}

/*!
  Returns the clipper widget.
  Contents in the scrollview is ultimately clipped to be inside
  the clipper widget.

  You should not need to access this.

  \sa visibleWidth(), visibleHeight()
*/

qt'QScrollView::clipper() (./qt-2.1.0/src/widgets/qscrollview.cpp:1923)

QWidget* QScrollView::clipper() const
{
    return &d->viewport;
}

/*!
  Returns the horizontal amount of the content that is visible.
*/

qt'QScrollView::visibleWidth() (./qt-2.1.0/src/widgets/qscrollview.cpp:1931)

int QScrollView::visibleWidth() const
{
    return clipper()->width();
}

/*!
  Returns the vertical amount of the content that is visible.
*/

qt'QScrollView::visibleHeight() (./qt-2.1.0/src/widgets/qscrollview.cpp:1939)

int QScrollView::visibleHeight() const
{
    return clipper()->height();
}



qt'QScrollView::changeFrameRect() (./qt-2.1.0/src/widgets/qscrollview.cpp:1945)

void QScrollView::changeFrameRect(const QRect& r)
{
    QRect oldr = frameRect();
    if (oldr != r) {
	QRect cr = contentsRect();
	QRegion fr( frameRect() );
	fr = fr.subtract( contentsRect() );
	setFrameRect( r );
	if ( isVisible() ) {
	    cr = cr.intersect( contentsRect() );
	    fr = fr.unite( frameRect() );
	    fr = fr.subtract( cr );
	    if ( !fr.isEmpty() )
		QApplication::postEvent( this, new QPaintEvent( fr, FALSE ) );
	}
    }
}


/*!
  Sets the margins around the scrolling area.  This is useful for
  applications such as spreadsheets with `locked' rows and columns.
  The marginal space is \e inside the frameRect() and is left blank -
  reimplement drawContents() or put widgets in the unused area.

  By default all margins are zero.

  \sa frameChanged()
*/

qt'QScrollView::setMargins() (./qt-2.1.0/src/widgets/qscrollview.cpp:1974)

void QScrollView::setMargins(int left, int top, int right, int bottom)
{
    if ( left == d->l_marg &&
	 top == d->t_marg &&
	 right == d->r_marg &&
	 bottom == d->b_marg )
	return;

    d->l_marg = left;
    d->t_marg = top;
    d->r_marg = right;
    d->b_marg = bottom;
    updateScrollBars();
}


/*!
  Returns the current left margin.
  \sa setMargins()
*/

qt'QScrollView::leftMargin() (./qt-2.1.0/src/widgets/qscrollview.cpp:1994)

int QScrollView::leftMargin() const
{
    return d->l_marg;
}


/*!
  Returns the current top margin.
  \sa setMargins()
*/

qt'QScrollView::topMargin() (./qt-2.1.0/src/widgets/qscrollview.cpp:2004)

int QScrollView::topMargin() const
{
    return d->t_marg;
}


/*!
  Returns the current right margin.
  \sa setMargins()
*/

qt'QScrollView::rightMargin() (./qt-2.1.0/src/widgets/qscrollview.cpp:2014)

int QScrollView::rightMargin() const
{
    return d->r_marg;
}


/*!
  Returns the current bottom margin.
  \sa setMargins()
*/

qt'QScrollView::bottomMargin() (./qt-2.1.0/src/widgets/qscrollview.cpp:2024)

int QScrollView::bottomMargin() const
{
    return d->b_marg;
}

/*! \reimp
*/

qt'QScrollView::focusNextPrevChild() (./qt-2.1.0/src/widgets/qscrollview.cpp:2031)

bool QScrollView::focusNextPrevChild( bool next )
{
    //  Makes sure that the new focus widget is on-screen, if
    //  necessary by scrolling the scroll view.

    // first set things up for the scan
    QFocusData *f = focusData();
    QWidget *startingPoint = f->home();
    QWidget *candidate = 0;
    QWidget *w = next ? f->next() : f->prev();
    QSVChildRec *r;

    // then scan for a possible focus widget candidate
    while( !candidate && w != startingPoint ) {
	if ( w != startingPoint &&
	     (w->focusPolicy() & TabFocus) == TabFocus
	     && w->isEnabled() &&!w->focusProxy() && w->isVisible() )
	    candidate = w;
	w = next ? f->next() : f->prev();
    }

    // if we could not find one, maybe super or parentWidget() can?
    if ( !candidate )
	return QFrame::focusNextPrevChild( next );

    // we've found one.
    r = d->ancestorRec( candidate );
    if ( r && ( r->child == candidate ||
		candidate->isVisibleTo( r->child ) ) ) {
	QPoint cp = r->child->mapToGlobal(QPoint(0,0));
	QPoint cr = candidate->mapToGlobal(QPoint(0,0)) - cp;
	ensureVisible( r->x+cr.x()+candidate->width()/2,
		       r->y+cr.y()+candidate->height()/2,
		       candidate->width()/2,
		       candidate->height()/2 );
    }

    candidate->setFocus();
    return TRUE;
}



/*!
  When large numbers of child widgets are in a scrollview, especially
  if they are close together, the scrolling performance can suffer
  greatly.  If you call enableClipper(TRUE), the scrollview will
  use an extra widget to group child widgets.

  Note that you may only call enableClipper() prior to adding widgets.

  For a full discussion, see the overview documentation of this
  class.
*/

qt'QScrollView::enableClipper() (./qt-2.1.0/src/widgets/qscrollview.cpp:2085)

void QScrollView::enableClipper(bool y)
{
    if ( !d->clipped_viewport == !y )
	return;
    if ( d->children.count() )
	qFatal("May only call QScrollView::enableClipper() before adding widgets");
    if ( y ) {
	d->clipped_viewport = new QClipperWidget(clipper(), "qt_clipped_viewport", d->flags);
	d->clipped_viewport->setGeometry(-coord_limit/2,-coord_limit/2,
					coord_limit,coord_limit);
	d->viewport.setBackgroundMode(NoBackground); // no exposures for this
	d->viewport.removeEventFilter( this );
	d->clipped_viewport->installEventFilter( this );
    } else {
	delete d->clipped_viewport;
	d->clipped_viewport = 0;
    }
}

/*!
  Returns the
    point \a p
  translated to
    a point on the viewport() widget.
*/

qt'QScrollView::contentsToViewport() (./qt-2.1.0/src/widgets/qscrollview.cpp:2110)

QPoint QScrollView::contentsToViewport(const QPoint& p)
{
    if ( d->clipped_viewport ) {
	return QPoint( p.x() - contentsX() - d->clipped_viewport->x(),
		       p.y() - contentsY() - d->clipped_viewport->y() );
    } else {
	return QPoint( p.x() - contentsX(),
		       p.y() - contentsY() );
    }
}

/*!
  Returns the
    point on the viewport \a vp
  translated to
    a point in the contents.
*/

qt'QScrollView::viewportToContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:2127)

QPoint QScrollView::viewportToContents(const QPoint& vp)
{
    if ( d->clipped_viewport ) {
	return QPoint( vp.x() + contentsX() + d->clipped_viewport->x(),
		       vp.y() + contentsY() + d->clipped_viewport->y() );
    } else {
	return QPoint( vp.x() + contentsX(),
		       vp.y() + contentsY() );
    }
}


/*!
  Translates
    a point (\a x, \a y) in the contents
  to
    a point (\a vx, \a vy) on the viewport() widget.
*/

qt'QScrollView::contentsToViewport() (./qt-2.1.0/src/widgets/qscrollview.cpp:2145)

void QScrollView::contentsToViewport(int x, int y, int& vx, int& vy)
{
    const QPoint v = contentsToViewport(QPoint(x,y));
    vx = v.x();
    vy = v.y();
}

/*!
  Translates
    a point (\a vx, \a vy) on the viewport() widget
  to
    a point (\a x, \a y) in the contents.
*/

qt'QScrollView::viewportToContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:2158)

void QScrollView::viewportToContents(int vx, int vy, int& x, int& y)
{
    const QPoint c = viewportToContents(QPoint(vx,vy));
    x = c.x();
    y = c.y();
}


/*!\reimp
*/

qt'QScrollView::sizePolicy() (./qt-2.1.0/src/widgets/qscrollview.cpp:2168)

QSizePolicy QScrollView::sizePolicy() const
{
    return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
}


/*!
  \reimp
*/

qt'QScrollView::sizeHint() (./qt-2.1.0/src/widgets/qscrollview.cpp:2177)

QSize QScrollView::sizeHint() const
{
    constPolish();
    QSize result = QSize(frameWidth()*2, frameWidth()*2);
    if ( d->policy == QScrollView::AutoOne ) {
	QSVChildRec* r = d->children.first();
	QSize cs = r->child->sizeHint();
	if ( cs.isValid() )
	    result += cs;
	else
	    result += r->child->size();
    } else {
	result += QSize(contentsWidth(),contentsHeight());
    }
    return result;
}


/*!
  \reimp
*/

qt'QScrollView::minimumSizeHint() (./qt-2.1.0/src/widgets/qscrollview.cpp:2198)

QSize QScrollView::minimumSizeHint() const
{
    return QSize(100+frameWidth()*2,
		 100+frameWidth()*2);
}


/*!
  \reimp

  (Implemented to get rid of a compiler warning.)
*/

qt'QScrollView::drawContents() (./qt-2.1.0/src/widgets/qscrollview.cpp:2210)

void QScrollView::drawContents( QPainter * )
{
}

/*!
  \internal
*/

qt'QScrollView::startDragAutoScroll() (./qt-2.1.0/src/widgets/qscrollview.cpp:2217)

void QScrollView::startDragAutoScroll()
{
    if ( !d->autoscroll_timer.isActive() ) {
	d->autoscroll_time = initialScrollTime;
	d->autoscroll_accel = initialScrollAccel;
	d->autoscroll_timer.start( d->autoscroll_time );
    }
}

/*!
  \internal
*/


qt'QScrollView::stopDragAutoScroll() (./qt-2.1.0/src/widgets/qscrollview.cpp:2230)

void QScrollView::stopDragAutoScroll()
{
    d->autoscroll_timer.stop();
}

/*!
  \internal
*/


qt'QScrollView::doDragAutoScroll() (./qt-2.1.0/src/widgets/qscrollview.cpp:2239)

void QScrollView::doDragAutoScroll()
{
    QPoint p = viewport()->mapFromGlobal( QCursor::pos() );

    if ( d->autoscroll_accel-- <= 0 && d->autoscroll_time ) {
	d->autoscroll_accel = initialScrollAccel;
	d->autoscroll_time--;
	d->autoscroll_timer.start( d->autoscroll_time );
    }
    int l = QMAX( 1, ( initialScrollTime- d->autoscroll_time ) );

    int dx = 0, dy = 0;
    if ( p.y() < autoscroll_margin ) {
	dy = -l;
    } else if ( p.y() > visibleHeight() - autoscroll_margin ) {
	dy = +l;
    }
    if ( p.x() < autoscroll_margin ) {
	dx = -l;
    } else if ( p.x() > visibleWidth() - autoscroll_margin ) {
	dx = +l;
    }
    if ( dx || dy ) {
	scrollBy(dx,dy);
    } else {
	stopDragAutoScroll();
    }
}

/*!
  If \a b is set to TRUE, the QScrollView automatically scrolles the contents
  in drag move events if the user moves the cursor close to a border of the
  view. This of course only works id the viewport accepts drops!.
  Specifying FALSE here disables this autscroll feature.
*/


qt'QScrollView::setDragAutoScroll() (./qt-2.1.0/src/widgets/qscrollview.cpp:2275)

void QScrollView::setDragAutoScroll( bool b )
{
    d->drag_autoscroll = b;
}

/*!
  Returns TRUE if autoscrolling in drag move events is enabled, else
  FALSE.

  \sa setDragAutoScroll()
*/


qt'QScrollView::dragAutoScroll() (./qt-2.1.0/src/widgets/qscrollview.cpp:2287)

bool QScrollView::dragAutoScroll() const
{
    return d->drag_autoscroll;
}