1 | /****************************************************************************
|
---|
2 | ** $Id: qscrollbar.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QScrollBar class
|
---|
5 | **
|
---|
6 | ** Created : 940427
|
---|
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 |
|
---|
38 | #ifndef QSCROLLBAR_H
|
---|
39 | #define QSCROLLBAR_H
|
---|
40 |
|
---|
41 | class QTimer;
|
---|
42 |
|
---|
43 | #ifndef QT_H
|
---|
44 | #include "qwidget.h"
|
---|
45 | #include "qrangecontrol.h"
|
---|
46 | #endif // QT_H
|
---|
47 |
|
---|
48 | #ifndef QT_NO_SCROLLBAR
|
---|
49 |
|
---|
50 | class Q_EXPORT QScrollBar : public QWidget, public QRangeControl
|
---|
51 | {
|
---|
52 | Q_OBJECT
|
---|
53 | Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
|
---|
54 | Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
|
---|
55 | Q_PROPERTY( int lineStep READ lineStep WRITE setLineStep )
|
---|
56 | Q_PROPERTY( int pageStep READ pageStep WRITE setPageStep )
|
---|
57 | Q_PROPERTY( int value READ value WRITE setValue )
|
---|
58 | Q_PROPERTY( bool tracking READ tracking WRITE setTracking )
|
---|
59 | Q_PROPERTY( bool draggingSlider READ draggingSlider )
|
---|
60 | Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
|
---|
61 |
|
---|
62 | public:
|
---|
63 | QScrollBar( QWidget *parent, const char* name = 0 );
|
---|
64 | QScrollBar( Orientation, QWidget *parent, const char* name = 0 );
|
---|
65 | QScrollBar( int minValue, int maxValue, int lineStep, int pageStep,
|
---|
66 | int value, Orientation, QWidget *parent, const char* name = 0 );
|
---|
67 | ~QScrollBar();
|
---|
68 |
|
---|
69 | virtual void setOrientation( Orientation );
|
---|
70 | Orientation orientation() const;
|
---|
71 | virtual void setTracking( bool enable );
|
---|
72 | bool tracking() const;
|
---|
73 | bool draggingSlider() const;
|
---|
74 |
|
---|
75 | virtual void setPalette( const QPalette & );
|
---|
76 | virtual QSize sizeHint() const;
|
---|
77 | virtual void setSizePolicy( QSizePolicy sp );
|
---|
78 | void setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw = FALSE );
|
---|
79 |
|
---|
80 | int minValue() const;
|
---|
81 | int maxValue() const;
|
---|
82 | void setMinValue( int );
|
---|
83 | void setMaxValue( int );
|
---|
84 | int lineStep() const;
|
---|
85 | int pageStep() const;
|
---|
86 | void setLineStep( int );
|
---|
87 | void setPageStep( int );
|
---|
88 | int value() const;
|
---|
89 |
|
---|
90 | int sliderStart() const;
|
---|
91 | QRect sliderRect() const;
|
---|
92 |
|
---|
93 | public slots:
|
---|
94 | void setValue( int );
|
---|
95 |
|
---|
96 | signals:
|
---|
97 | void valueChanged( int value );
|
---|
98 | void sliderPressed();
|
---|
99 | void sliderMoved( int value );
|
---|
100 | void sliderReleased();
|
---|
101 | void nextLine();
|
---|
102 | void prevLine();
|
---|
103 | void nextPage();
|
---|
104 | void prevPage();
|
---|
105 |
|
---|
106 | protected:
|
---|
107 | #ifndef QT_NO_WHEELEVENT
|
---|
108 | void wheelEvent( QWheelEvent * );
|
---|
109 | #endif
|
---|
110 | void keyPressEvent( QKeyEvent * );
|
---|
111 | void resizeEvent( QResizeEvent * );
|
---|
112 | void paintEvent( QPaintEvent * );
|
---|
113 |
|
---|
114 | void mousePressEvent( QMouseEvent * );
|
---|
115 | void mouseReleaseEvent( QMouseEvent * );
|
---|
116 | void mouseMoveEvent( QMouseEvent * );
|
---|
117 | void contextMenuEvent( QContextMenuEvent * );
|
---|
118 | void hideEvent( QHideEvent* );
|
---|
119 |
|
---|
120 | void valueChange();
|
---|
121 | void stepChange();
|
---|
122 | void rangeChange();
|
---|
123 |
|
---|
124 | void styleChange( QStyle& );
|
---|
125 |
|
---|
126 | private slots:
|
---|
127 | void doAutoRepeat();
|
---|
128 |
|
---|
129 | private:
|
---|
130 | void init();
|
---|
131 | void positionSliderFromValue();
|
---|
132 | int calculateValueFromSlider() const;
|
---|
133 |
|
---|
134 | void startAutoRepeat();
|
---|
135 | void stopAutoRepeat();
|
---|
136 |
|
---|
137 | int rangeValueToSliderPos( int val ) const;
|
---|
138 | int sliderPosToRangeValue( int val ) const;
|
---|
139 |
|
---|
140 | void action( int control );
|
---|
141 |
|
---|
142 | void drawControls( uint controls, uint activeControl ) const;
|
---|
143 | void drawControls( uint controls, uint activeControl,
|
---|
144 | QPainter *p ) const;
|
---|
145 |
|
---|
146 | uint pressedControl;
|
---|
147 | bool track;
|
---|
148 | bool clickedAt;
|
---|
149 | Orientation orient;
|
---|
150 |
|
---|
151 | int slidePrevVal;
|
---|
152 | QCOORD sliderPos;
|
---|
153 | QCOORD clickOffset;
|
---|
154 |
|
---|
155 | QTimer * repeater;
|
---|
156 | void * d;
|
---|
157 |
|
---|
158 | private: // Disabled copy constructor and operator=
|
---|
159 | #if defined(Q_DISABLE_COPY)
|
---|
160 | QScrollBar( const QScrollBar & );
|
---|
161 | QScrollBar &operator=( const QScrollBar & );
|
---|
162 | #endif
|
---|
163 | };
|
---|
164 |
|
---|
165 |
|
---|
166 | inline void QScrollBar::setTracking( bool t )
|
---|
167 | {
|
---|
168 | track = t;
|
---|
169 | }
|
---|
170 |
|
---|
171 | inline bool QScrollBar::tracking() const
|
---|
172 | {
|
---|
173 | return track;
|
---|
174 | }
|
---|
175 |
|
---|
176 | inline QScrollBar::Orientation QScrollBar::orientation() const
|
---|
177 | {
|
---|
178 | return orient;
|
---|
179 | }
|
---|
180 |
|
---|
181 | inline int QScrollBar::sliderStart() const
|
---|
182 | {
|
---|
183 | return sliderPos;
|
---|
184 | }
|
---|
185 |
|
---|
186 | inline void QScrollBar::setSizePolicy( QSizePolicy::SizeType hor, QSizePolicy::SizeType ver, bool hfw )
|
---|
187 | {
|
---|
188 | QWidget::setSizePolicy( hor, ver, hfw );
|
---|
189 | }
|
---|
190 |
|
---|
191 |
|
---|
192 | #endif // QT_NO_SCROLLBAR
|
---|
193 |
|
---|
194 | #endif // QSCROLLBAR_H
|
---|