From 37333bf25ad9a4c538250f5af2f9f1d666362883 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ksysv/kscroller.h | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 ksysv/kscroller.h (limited to 'ksysv/kscroller.h') diff --git a/ksysv/kscroller.h b/ksysv/kscroller.h new file mode 100644 index 0000000..09329f1 --- /dev/null +++ b/ksysv/kscroller.h @@ -0,0 +1,150 @@ +// (c) 2000 Peter Putzer +#ifndef KSCROLLER_H +#define KSCROLLER_H + +#include + +class QScrollBar; + +/** + * A window that automatically enables scrollbars + * if it's smaller than the content. + * + * @author Peter Putzer + * @version $Id$ + */ +class KScroller : public QFrame +{ + Q_OBJECT + +public: + /** + * Constructor. + * + * @param parent the parent of this widget (passed on as ususal). + * @param name the name of this widget (as above). + */ + KScroller (QWidget* parent = 0L, const char* name = 0L); + + /** + * Destructor. + */ + virtual ~KScroller (); + + /** + * @return the vertical scrollbar. + */ + inline QScrollBar* verticalScrollBar () { return mVertical; } + + /** + * @return the horizontal scrollbar. + */ + inline QScrollBar* horizontalScrollBar () { return mHorizontal; } + + /** + * @return the current content, or 0L if none set. + */ + inline QWidget* content () { return mContent; } + + /** + * @return the current corner widget, or 0L if none set. + */ + QWidget* cornerWidget (); + +public slots: + /** + * Sets the content. Ownership is transfered to the scroller, any + * previously set content will be deleted! + * + * @param content has to be a child of the KScroller. + */ + void setContent (QWidget* content); + + /** + * Sets the corner widget (the small widget that's located where the vertical and horizontal scrollbars + * allmost meet). + * + * @param corner has to be a child of the KScroller. + */ + void setCornerWidget (QWidget* corner); + + /** + * Update the scrollbars. Call whenever you change the contents minimumSize. + */ + void updateScrollBars (); + +protected: + /** + * Reimplemented for internal reasons, the API is not affected. + */ + virtual void resizeEvent (QResizeEvent*); + + /** + * Reimplemented for internal reasons, the API is not affected. + */ + virtual QSize sizeHint() const; + + /** + * Reimplemented for internal reasons, the API is not affected. + */ + virtual QSize minimumSizeHint() const; + + +private slots: + /** + * Scroll vertically. + * + * @param value is the new slider value. + */ + void scrollVertical (int value); + + /** + * Scroll horizontally. + * + * @param value is the new slider value. + */ + void scrollHorizontal (int value); + +private: + /** + * Set up the horizontal scrollbar. + * + * @param cw is the width of the content. + * @param ch is the height of the content. + * @param w is the width of the scroller. + * @param h is the height of the scroller. + */ + void setupHorizontal (int cw, int ch, int w, int h); + + /** + * Set up the vertical scrollbar + * + * @param cw is the width of the content. + * @param ch is the height of the content. + * @param w is the width of the scroller. + * @param h is the height of the scroller. + */ + void setupVertical (int cw, int ch, int w, int h); + + /** + * Set up the corner widget. + * + * @param w is the width of the scroller. + * @param h is the height of the scroller. + */ + void setupCornerWidget (int w, int h); + + class KScrollerPrivate; + KScrollerPrivate* d; + + QScrollBar* mVertical; + QScrollBar* mHorizontal; + QWidget* mCornerWidget; + + QWidget* mContent; + + int mVerticalOld; + int mHorizontalOld; +}; + +#endif // KSCROLLER_H -- cgit v1.2.1