00001 #ifndef FAITH__SCROLLVIEW_H 00002 #define FAITH__SCROLLVIEW_H 00003 00004 #include <faith/scrollbar.h> 00005 #include <faith/ui.h> 00006 00007 namespace Faith 00008 { 00009 00010 namespace Internal 00011 { 00012 class ContentsWidget; 00013 class ClipperWidget; 00014 } 00015 00016 00017 class FAITH_UI_EXPORT ScrollView : public Widget 00018 { 00019 Q_OBJECT 00020 friend class Internal::ContentsWidget; 00021 friend class Internal::ClipperWidget; 00022 00023 struct ScrollViewPrivate; 00024 ScrollViewPrivate *d; 00025 00026 public: 00027 ScrollView(Widget *parent, const char *name=0); 00028 ~ScrollView(); 00029 00030 ScrollBar *horizontalScrollBar(); 00031 00032 ScrollBar *verticalScrollBar(); 00033 00038 Widget *cornerWidget(); 00039 00046 Widget *contents(); 00047 00053 Widget *clipper(); 00054 00061 Faith::Size contentsSize() const; 00062 00067 Faith::Size viewportSize() const; 00068 00069 void setContentsSize(const Faith::Size &size); 00070 void setContentsSize(int w, int h) { setContentsSize(Size(w,h)); } 00071 00075 Faith::Point contentsLocation() const; 00076 00077 signals: 00082 void scrolledTo(int x, int y); 00083 00088 void scrolledTo(const Faith::Point &pt); 00089 00090 public slots: 00098 void scrollTo(const Faith::Point &pt); 00099 00100 void scrollTo(int x, int y) { scrollTo(Point(x,y)); } 00101 00108 void ensureVisible(const Faith::Point &pt); 00109 00110 void ensureVisible(int x, int y) { ensureVisible(Point(x,y)); } 00111 00112 private slots: 00113 void faithReadScrollbars(); 00114 00115 protected: 00116 void resizeEvent(Faith::ResizeEvent *e); 00117 00118 void paintEvent(Faith::PaintEvent *e); 00119 00120 virtual void contentsMousePressEvent(Faith::MouseEvent *) { } 00121 virtual void contentsMouseReleaseEvent(Faith::MouseEvent *) { } 00122 virtual void contentsMouseMoveEvent(Faith::MouseEvent *) { } 00123 virtual void contentsKeyPressEvent(Faith::KeyPressEvent *) { } 00124 virtual void contentsPaintEvent(Faith::PaintEvent *) { } 00125 virtual void contentsFocusInEvent(Faith::FocusEvent *) { } 00126 virtual void contentsFocusOutEvent(Faith::FocusEvent *) { } 00127 virtual void contentsEnterEvent(Faith::Event *) { } 00128 virtual void contentsLeaveEvent(Faith::Event *) { } 00129 00130 virtual void viewportEnterEvent(Faith::Event *) { } 00131 virtual void viewportLeaveEvent(Faith::Event *) { } 00132 virtual void viewportResizeEvent(Faith::ResizeEvent *) { } 00133 00134 00135 private: 00140 Point normalizeLocation(const Point&); 00141 }; 00142 00143 } 00144 00145 #endif
1.4.7