1 | /****************************************************************************
|
---|
2 | ** $Id: qscrollview.h 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QScrollView class
|
---|
5 | **
|
---|
6 | ** Created : 970523
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 | #ifndef QSCROLLVIEW_H
|
---|
38 | #define QSCROLLVIEW_H
|
---|
39 |
|
---|
40 | #ifndef QT_H
|
---|
41 | #include "qframe.h"
|
---|
42 | #include "qscrollbar.h"
|
---|
43 | #endif // QT_H
|
---|
44 |
|
---|
45 | #ifndef QT_NO_SCROLLVIEW
|
---|
46 |
|
---|
47 | class QScrollViewData;
|
---|
48 |
|
---|
49 | class Q_EXPORT QScrollView : public QFrame
|
---|
50 | {
|
---|
51 | Q_OBJECT
|
---|
52 | Q_ENUMS( ResizePolicy ScrollBarMode )
|
---|
53 | Q_PROPERTY( ResizePolicy resizePolicy READ resizePolicy WRITE setResizePolicy )
|
---|
54 | Q_PROPERTY( ScrollBarMode vScrollBarMode READ vScrollBarMode WRITE setVScrollBarMode )
|
---|
55 | Q_PROPERTY( ScrollBarMode hScrollBarMode READ hScrollBarMode WRITE setHScrollBarMode )
|
---|
56 | Q_PROPERTY( int visibleWidth READ visibleWidth )
|
---|
57 | Q_PROPERTY( int visibleHeight READ visibleHeight )
|
---|
58 | Q_PROPERTY( int contentsWidth READ contentsWidth )
|
---|
59 | Q_PROPERTY( int contentsHeight READ contentsHeight )
|
---|
60 | Q_PROPERTY( int contentsX READ contentsX )
|
---|
61 | Q_PROPERTY( int contentsY READ contentsY )
|
---|
62 | #ifndef QT_NO_DRAGANDDROP
|
---|
63 | //@@TODO (dmik): no QDrag* and QDrop* classes yet (MOC ignores preprocessor macros)
|
---|
64 | // Q_PROPERTY( bool dragAutoScroll READ dragAutoScroll WRITE setDragAutoScroll )
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | public:
|
---|
68 | QScrollView(QWidget* parent=0, const char* name=0, WFlags f=0);
|
---|
69 | ~QScrollView();
|
---|
70 |
|
---|
71 | enum ResizePolicy { Default, Manual, AutoOne, AutoOneFit };
|
---|
72 | virtual void setResizePolicy( ResizePolicy );
|
---|
73 | ResizePolicy resizePolicy() const;
|
---|
74 |
|
---|
75 | void styleChange( QStyle & );
|
---|
76 | void removeChild(QWidget* child);
|
---|
77 | virtual void addChild( QWidget* child, int x=0, int y=0 );
|
---|
78 | virtual void moveChild( QWidget* child, int x, int y );
|
---|
79 | int childX(QWidget* child);
|
---|
80 | int childY(QWidget* child);
|
---|
81 | bool childIsVisible(QWidget* child) { return child->isVisible(); } // obsolete functions
|
---|
82 | void showChild(QWidget* child, bool yes=TRUE) {
|
---|
83 | if ( yes )
|
---|
84 | child->show();
|
---|
85 | else
|
---|
86 | child->hide();
|
---|
87 | }
|
---|
88 |
|
---|
89 | enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn };
|
---|
90 |
|
---|
91 | ScrollBarMode vScrollBarMode() const;
|
---|
92 | virtual void setVScrollBarMode( ScrollBarMode );
|
---|
93 |
|
---|
94 | ScrollBarMode hScrollBarMode() const;
|
---|
95 | virtual void setHScrollBarMode( ScrollBarMode );
|
---|
96 |
|
---|
97 | QWidget* cornerWidget() const;
|
---|
98 | virtual void setCornerWidget(QWidget*);
|
---|
99 |
|
---|
100 | // ### 4.0: Consider providing a factory function for scrollbars
|
---|
101 | // (e.g. make the two following functions virtual)
|
---|
102 | QScrollBar* horizontalScrollBar() const;
|
---|
103 | QScrollBar* verticalScrollBar() const;
|
---|
104 | QWidget* viewport() const;
|
---|
105 | QWidget* clipper() const;
|
---|
106 |
|
---|
107 | int visibleWidth() const;
|
---|
108 | int visibleHeight() const;
|
---|
109 |
|
---|
110 | int contentsWidth() const;
|
---|
111 | int contentsHeight() const;
|
---|
112 | int contentsX() const;
|
---|
113 | int contentsY() const;
|
---|
114 |
|
---|
115 | void resize( int w, int h );
|
---|
116 | void resize( const QSize& );
|
---|
117 | void show();
|
---|
118 |
|
---|
119 | void updateContents( int x, int y, int w, int h );
|
---|
120 | void updateContents( const QRect& r );
|
---|
121 | void updateContents();
|
---|
122 | void repaintContents( int x, int y, int w, int h, bool erase=TRUE );
|
---|
123 | void repaintContents( const QRect& r, bool erase=TRUE );
|
---|
124 | void repaintContents( bool erase=TRUE );
|
---|
125 | void contentsToViewport( int x, int y, int& vx, int& vy ) const;
|
---|
126 | void viewportToContents( int vx, int vy, int& x, int& y ) const;
|
---|
127 | QPoint contentsToViewport( const QPoint& ) const;
|
---|
128 | QPoint viewportToContents( const QPoint& ) const;
|
---|
129 | void enableClipper( bool y );
|
---|
130 |
|
---|
131 | void setStaticBackground( bool y );
|
---|
132 | bool hasStaticBackground() const;
|
---|
133 |
|
---|
134 | QSize viewportSize( int, int ) const;
|
---|
135 | QSize sizeHint() const;
|
---|
136 | QSize minimumSizeHint() const;
|
---|
137 |
|
---|
138 | void removeChild(QObject* child);
|
---|
139 |
|
---|
140 | bool isHorizontalSliderPressed();
|
---|
141 | bool isVerticalSliderPressed();
|
---|
142 |
|
---|
143 | #ifndef QT_NO_DRAGANDDROP
|
---|
144 | virtual void setDragAutoScroll( bool b );
|
---|
145 | bool dragAutoScroll() const;
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | signals:
|
---|
149 | void contentsMoving(int x, int y);
|
---|
150 | void horizontalSliderPressed();
|
---|
151 | void horizontalSliderReleased();
|
---|
152 | void verticalSliderPressed();
|
---|
153 | void verticalSliderReleased();
|
---|
154 |
|
---|
155 | public slots:
|
---|
156 | virtual void resizeContents( int w, int h );
|
---|
157 | void scrollBy( int dx, int dy );
|
---|
158 | virtual void setContentsPos( int x, int y );
|
---|
159 | void ensureVisible(int x, int y);
|
---|
160 | void ensureVisible(int x, int y, int xmargin, int ymargin);
|
---|
161 | void center(int x, int y);
|
---|
162 | void center(int x, int y, float xmargin, float ymargin);
|
---|
163 |
|
---|
164 | void updateScrollBars(); // ### virtual in 4.0
|
---|
165 | void setEnabled( bool enable );
|
---|
166 |
|
---|
167 | protected:
|
---|
168 | virtual void drawContents(QPainter*, int cx, int cy, int cw, int ch);
|
---|
169 | virtual void drawContentsOffset(QPainter*, int ox, int oy,
|
---|
170 | int cx, int cy, int cw, int ch);
|
---|
171 |
|
---|
172 |
|
---|
173 | virtual void contentsMousePressEvent( QMouseEvent* );
|
---|
174 | virtual void contentsMouseReleaseEvent( QMouseEvent* );
|
---|
175 | virtual void contentsMouseDoubleClickEvent( QMouseEvent* );
|
---|
176 | virtual void contentsMouseMoveEvent( QMouseEvent* );
|
---|
177 | #ifndef QT_NO_DRAGANDDROP
|
---|
178 | //@@TODO (dmik): no QDrag* and QDrop* classes yet (MOC ignores preprocessor macros)
|
---|
179 | // virtual void contentsDragEnterEvent( QDragEnterEvent * );
|
---|
180 | // virtual void contentsDragMoveEvent( QDragMoveEvent * );
|
---|
181 | // virtual void contentsDragLeaveEvent( QDragLeaveEvent * );
|
---|
182 | // virtual void contentsDropEvent( QDropEvent * );
|
---|
183 | #endif
|
---|
184 | #ifndef QT_NO_WHEELEVENT
|
---|
185 | virtual void contentsWheelEvent( QWheelEvent * );
|
---|
186 | #endif
|
---|
187 | virtual void contentsContextMenuEvent( QContextMenuEvent * );
|
---|
188 |
|
---|
189 |
|
---|
190 | virtual void viewportPaintEvent( QPaintEvent* );
|
---|
191 | virtual void viewportResizeEvent( QResizeEvent* );
|
---|
192 | virtual void viewportMousePressEvent( QMouseEvent* );
|
---|
193 | virtual void viewportMouseReleaseEvent( QMouseEvent* );
|
---|
194 | virtual void viewportMouseDoubleClickEvent( QMouseEvent* );
|
---|
195 | virtual void viewportMouseMoveEvent( QMouseEvent* );
|
---|
196 | #ifndef QT_NO_DRAGANDDROP
|
---|
197 | //@@TODO (dmik): no QDrag* and QDrop* classes yet (MOC ignores preprocessor macros)
|
---|
198 | // virtual void viewportDragEnterEvent( QDragEnterEvent * );
|
---|
199 | // virtual void viewportDragMoveEvent( QDragMoveEvent * );
|
---|
200 | // virtual void viewportDragLeaveEvent( QDragLeaveEvent * );
|
---|
201 | // virtual void viewportDropEvent( QDropEvent * );
|
---|
202 | #endif
|
---|
203 | #ifndef QT_NO_WHEELEVENT
|
---|
204 | virtual void viewportWheelEvent( QWheelEvent * );
|
---|
205 | #endif
|
---|
206 | virtual void viewportContextMenuEvent( QContextMenuEvent * );
|
---|
207 |
|
---|
208 | void frameChanged();
|
---|
209 |
|
---|
210 | virtual void setMargins(int left, int top, int right, int bottom);
|
---|
211 | int leftMargin() const;
|
---|
212 | int topMargin() const;
|
---|
213 | int rightMargin() const;
|
---|
214 | int bottomMargin() const;
|
---|
215 |
|
---|
216 | bool focusNextPrevChild( bool next );
|
---|
217 |
|
---|
218 | virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h);
|
---|
219 | virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h);
|
---|
220 |
|
---|
221 | void resizeEvent(QResizeEvent*);
|
---|
222 | void mousePressEvent( QMouseEvent * );
|
---|
223 | void mouseReleaseEvent( QMouseEvent * );
|
---|
224 | void mouseDoubleClickEvent( QMouseEvent * );
|
---|
225 | void mouseMoveEvent( QMouseEvent * );
|
---|
226 | #ifndef QT_NO_WHEELEVENT
|
---|
227 | void wheelEvent( QWheelEvent * );
|
---|
228 | #endif
|
---|
229 | void contextMenuEvent( QContextMenuEvent * );
|
---|
230 | bool eventFilter( QObject *, QEvent *e );
|
---|
231 |
|
---|
232 | void setCachedSizeHint( const QSize &sh ) const;
|
---|
233 | QSize cachedSizeHint() const;
|
---|
234 | void fontChange( const QFont & );
|
---|
235 |
|
---|
236 | private:
|
---|
237 | void drawContents( QPainter* );
|
---|
238 | void moveContents(int x, int y);
|
---|
239 |
|
---|
240 | QScrollViewData* d;
|
---|
241 |
|
---|
242 | private slots:
|
---|
243 | void hslide(int);
|
---|
244 | void vslide(int);
|
---|
245 | void hbarIsPressed();
|
---|
246 | void hbarIsReleased();
|
---|
247 | void vbarIsPressed();
|
---|
248 | void vbarIsReleased();
|
---|
249 | #ifndef QT_NO_DRAGANDDROP
|
---|
250 | //@@TODO (dmik): no QDrag* and QDrop* classes yet (MOC ignores preprocessor macros)
|
---|
251 | // void doDragAutoScroll();
|
---|
252 | // void startDragAutoScroll();
|
---|
253 | // void stopDragAutoScroll();
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | private: // Disabled copy constructor and operator=
|
---|
257 | #if defined(Q_DISABLE_COPY)
|
---|
258 | QScrollView( const QScrollView & );
|
---|
259 | QScrollView &operator=( const QScrollView & );
|
---|
260 | #endif
|
---|
261 | void changeFrameRect(const QRect&);
|
---|
262 |
|
---|
263 | public:
|
---|
264 | void disableSizeHintCaching();
|
---|
265 |
|
---|
266 | };
|
---|
267 |
|
---|
268 | #endif // QT_NO_SCROLLVIEW
|
---|
269 |
|
---|
270 | #endif // QSCROLLVIEW_H
|
---|