|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt3Support module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef Q3SCROLLVIEW_H |
|
43 #define Q3SCROLLVIEW_H |
|
44 |
|
45 #include <Qt3Support/q3frame.h> |
|
46 #include <QtGui/qscrollbar.h> |
|
47 |
|
48 QT_BEGIN_HEADER |
|
49 |
|
50 QT_BEGIN_NAMESPACE |
|
51 |
|
52 QT_MODULE(Qt3SupportLight) |
|
53 |
|
54 class Q3ScrollViewData; |
|
55 |
|
56 class Q_COMPAT_EXPORT Q3ScrollView : public Q3Frame |
|
57 { |
|
58 Q_OBJECT |
|
59 Q_ENUMS( ResizePolicy ScrollBarMode ) |
|
60 Q_PROPERTY( ResizePolicy resizePolicy READ resizePolicy WRITE setResizePolicy ) |
|
61 Q_PROPERTY( ScrollBarMode vScrollBarMode READ vScrollBarMode WRITE setVScrollBarMode ) |
|
62 Q_PROPERTY( ScrollBarMode hScrollBarMode READ hScrollBarMode WRITE setHScrollBarMode ) |
|
63 Q_PROPERTY( int visibleWidth READ visibleWidth ) |
|
64 Q_PROPERTY( int visibleHeight READ visibleHeight ) |
|
65 Q_PROPERTY( int contentsWidth READ contentsWidth ) |
|
66 Q_PROPERTY( int contentsHeight READ contentsHeight ) |
|
67 Q_PROPERTY( int contentsX READ contentsX ) |
|
68 Q_PROPERTY( int contentsY READ contentsY ) |
|
69 Q_PROPERTY( bool dragAutoScroll READ dragAutoScroll WRITE setDragAutoScroll ) |
|
70 |
|
71 public: |
|
72 Q3ScrollView(QWidget* parent=0, const char* name=0, Qt::WindowFlags f=0); |
|
73 ~Q3ScrollView(); |
|
74 |
|
75 enum ResizePolicy { Default, Manual, AutoOne, AutoOneFit }; |
|
76 virtual void setResizePolicy( ResizePolicy ); |
|
77 ResizePolicy resizePolicy() const; |
|
78 |
|
79 void styleChange( QStyle & ); |
|
80 void removeChild(QWidget* child); |
|
81 virtual void addChild( QWidget* child, int x=0, int y=0 ); |
|
82 virtual void moveChild( QWidget* child, int x, int y ); |
|
83 int childX(QWidget* child); |
|
84 int childY(QWidget* child); |
|
85 bool childIsVisible(QWidget* child) { return child->isVisible(); } // obsolete functions |
|
86 void showChild(QWidget* child, bool yes=true) { child->setVisible(yes); } |
|
87 |
|
88 enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn }; |
|
89 |
|
90 ScrollBarMode vScrollBarMode() const; |
|
91 virtual void setVScrollBarMode( ScrollBarMode ); |
|
92 |
|
93 ScrollBarMode hScrollBarMode() const; |
|
94 virtual void setHScrollBarMode( ScrollBarMode ); |
|
95 |
|
96 QWidget* cornerWidget() const; |
|
97 virtual void setCornerWidget(QWidget*); |
|
98 |
|
99 // ### 4.0: Consider providing a factory function for scrollbars |
|
100 // (e.g. make the two following functions virtual) |
|
101 QScrollBar* horizontalScrollBar() const; |
|
102 QScrollBar* verticalScrollBar() const; |
|
103 QWidget* viewport() const; |
|
104 QWidget* clipper() const; |
|
105 |
|
106 int visibleWidth() const; |
|
107 int visibleHeight() const; |
|
108 |
|
109 int contentsWidth() const; |
|
110 int contentsHeight() const; |
|
111 int contentsX() const; |
|
112 int contentsY() const; |
|
113 |
|
114 void resize( int w, int h ); |
|
115 void resize( const QSize& ); |
|
116 void setVisible(bool visible); |
|
117 |
|
118 void updateContents( int x, int y, int w, int h ); |
|
119 void updateContents( const QRect& r ); |
|
120 void updateContents(); |
|
121 void repaintContents( int x, int y, int w, int h, bool erase=true ); |
|
122 void repaintContents( const QRect& r, bool erase=true ); |
|
123 void repaintContents( bool erase=true ); |
|
124 void contentsToViewport( int x, int y, int& vx, int& vy ) const; |
|
125 void viewportToContents( int vx, int vy, int& x, int& y ) const; |
|
126 QPoint contentsToViewport( const QPoint& ) const; |
|
127 QPoint viewportToContents( const QPoint& ) const; |
|
128 void enableClipper( bool y ); |
|
129 |
|
130 void setStaticBackground( bool y ); |
|
131 bool hasStaticBackground() const; |
|
132 |
|
133 QSize viewportSize( int, int ) const; |
|
134 QSize sizeHint() const; |
|
135 QSize minimumSizeHint() const; |
|
136 |
|
137 void removeChild(QObject* child); |
|
138 |
|
139 bool isHorizontalSliderPressed(); |
|
140 bool isVerticalSliderPressed(); |
|
141 |
|
142 virtual void setDragAutoScroll( bool b ); |
|
143 bool dragAutoScroll() const; |
|
144 |
|
145 Q_SIGNALS: |
|
146 void contentsMoving(int x, int y); |
|
147 void horizontalSliderPressed(); |
|
148 void horizontalSliderReleased(); |
|
149 void verticalSliderPressed(); |
|
150 void verticalSliderReleased(); |
|
151 |
|
152 public Q_SLOTS: |
|
153 virtual void resizeContents( int w, int h ); |
|
154 void scrollBy( int dx, int dy ); |
|
155 virtual void setContentsPos( int x, int y ); |
|
156 void ensureVisible(int x, int y); |
|
157 void ensureVisible(int x, int y, int xmargin, int ymargin); |
|
158 void center(int x, int y); |
|
159 void center(int x, int y, float xmargin, float ymargin); |
|
160 |
|
161 void updateScrollBars(); // ### virtual in 4.0 |
|
162 void setEnabled( bool enable ); |
|
163 |
|
164 protected: |
|
165 virtual void drawContents(QPainter*, int cx, int cy, int cw, int ch); |
|
166 virtual void drawContentsOffset(QPainter*, int ox, int oy, |
|
167 int cx, int cy, int cw, int ch); |
|
168 |
|
169 |
|
170 virtual void contentsMousePressEvent( QMouseEvent* ); |
|
171 virtual void contentsMouseReleaseEvent( QMouseEvent* ); |
|
172 virtual void contentsMouseDoubleClickEvent( QMouseEvent* ); |
|
173 virtual void contentsMouseMoveEvent( QMouseEvent* ); |
|
174 virtual void contentsDragEnterEvent( QDragEnterEvent * ); |
|
175 virtual void contentsDragMoveEvent( QDragMoveEvent * ); |
|
176 virtual void contentsDragLeaveEvent( QDragLeaveEvent * ); |
|
177 virtual void contentsDropEvent( QDropEvent * ); |
|
178 virtual void contentsWheelEvent( QWheelEvent * ); |
|
179 virtual void contentsContextMenuEvent( QContextMenuEvent * ); |
|
180 |
|
181 |
|
182 virtual void viewportPaintEvent( QPaintEvent* ); |
|
183 virtual void viewportResizeEvent( QResizeEvent* ); |
|
184 virtual void viewportMousePressEvent( QMouseEvent* ); |
|
185 virtual void viewportMouseReleaseEvent( QMouseEvent* ); |
|
186 virtual void viewportMouseDoubleClickEvent( QMouseEvent* ); |
|
187 virtual void viewportMouseMoveEvent( QMouseEvent* ); |
|
188 virtual void viewportDragEnterEvent( QDragEnterEvent * ); |
|
189 virtual void viewportDragMoveEvent( QDragMoveEvent * ); |
|
190 virtual void viewportDragLeaveEvent( QDragLeaveEvent * ); |
|
191 virtual void viewportDropEvent( QDropEvent * ); |
|
192 virtual void viewportWheelEvent( QWheelEvent * ); |
|
193 virtual void viewportContextMenuEvent( QContextMenuEvent * ); |
|
194 |
|
195 void frameChanged(); |
|
196 |
|
197 public: |
|
198 virtual void setMargins(int left, int top, int right, int bottom); |
|
199 int leftMargin() const; |
|
200 int topMargin() const; |
|
201 int rightMargin() const; |
|
202 int bottomMargin() const; |
|
203 protected: |
|
204 |
|
205 bool focusNextPrevChild( bool next ); |
|
206 |
|
207 virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h); |
|
208 virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h); |
|
209 |
|
210 void resizeEvent(QResizeEvent*); |
|
211 void mousePressEvent( QMouseEvent * ); |
|
212 void mouseReleaseEvent( QMouseEvent * ); |
|
213 void mouseDoubleClickEvent( QMouseEvent * ); |
|
214 void mouseMoveEvent( QMouseEvent * ); |
|
215 void wheelEvent( QWheelEvent * ); |
|
216 void contextMenuEvent( QContextMenuEvent * ); |
|
217 bool eventFilter( QObject *, QEvent *e ); |
|
218 |
|
219 void setCachedSizeHint( const QSize &sh ) const; |
|
220 QSize cachedSizeHint() const; |
|
221 void fontChange( const QFont & ); |
|
222 |
|
223 private: |
|
224 void drawContents( QPainter* ); |
|
225 void moveContents(int x, int y); |
|
226 |
|
227 Q3ScrollViewData* d; |
|
228 |
|
229 private Q_SLOTS: |
|
230 void hslide(int); |
|
231 void vslide(int); |
|
232 void hbarIsPressed(); |
|
233 void hbarIsReleased(); |
|
234 void vbarIsPressed(); |
|
235 void vbarIsReleased(); |
|
236 void doDragAutoScroll(); |
|
237 void startDragAutoScroll(); |
|
238 void stopDragAutoScroll(); |
|
239 |
|
240 private: // Disabled copy constructor and operator= |
|
241 Q_DISABLE_COPY(Q3ScrollView) |
|
242 void changeFrameRect(const QRect&); |
|
243 |
|
244 public: |
|
245 void disableSizeHintCaching(); |
|
246 |
|
247 }; |
|
248 |
|
249 QT_END_NAMESPACE |
|
250 |
|
251 QT_END_HEADER |
|
252 |
|
253 #endif // Q3SCROLLVIEW_H |