You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdeadmin/ksysv/kscroller.h

152 lines
3.2 KiB

// (c) 2000 Peter Putzer
#ifndef KSCROLLER_H
#define KSCROLLER_H
#include <tqframe.h>
class TQScrollBar;
/**
* A window that automatically enables scrollbars
* if it's smaller than the content.
*
* @author Peter Putzer <putzer@kde.org>
* @version $Id$
*/
class KScroller : public TQFrame
{
Q_OBJECT
TQ_OBJECT
public:
/**
* Constructor.
*
* @param parent the parent of this widget (passed on as ususal).
* @param name the name of this widget (as above).
*/
KScroller (TQWidget* parent = 0L, const char* name = 0L);
/**
* Destructor.
*/
virtual ~KScroller ();
/**
* @return the vertical scrollbar.
*/
inline TQScrollBar* verticalScrollBar () { return mVertical; }
/**
* @return the horizontal scrollbar.
*/
inline TQScrollBar* horizontalScrollBar () { return mHorizontal; }
/**
* @return the current content, or 0L if none set.
*/
inline TQWidget* content () { return mContent; }
/**
* @return the current corner widget, or 0L if none set.
*/
TQWidget* 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 (TQWidget* 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 (TQWidget* 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 (TQResizeEvent*);
/**
* Reimplemented for internal reasons, the API is not affected.
*/
virtual TQSize sizeHint() const;
/**
* Reimplemented for internal reasons, the API is not affected.
*/
virtual TQSize 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;
TQScrollBar* mVertical;
TQScrollBar* mHorizontal;
TQWidget* mCornerWidget;
TQWidget* mContent;
int mVerticalOld;
int mHorizontalOld;
};
#endif // KSCROLLER_H