-rw-r--r-- | core/apps/calibrate/calibrate.cpp | 37 | ||||
-rw-r--r-- | core/apps/calibrate/calibrate.h | 6 |
2 files changed, 34 insertions, 9 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp index a5f8792..e079195 100644 --- a/core/apps/calibrate/calibrate.cpp +++ b/core/apps/calibrate/calibrate.cpp | |||
@@ -5,256 +5,279 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <math.h> | 21 | #include <math.h> |
22 | 22 | ||
23 | #include "calibrate.h" | 23 | #include "calibrate.h" |
24 | 24 | ||
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qapplication.h> | 27 | #include <qapplication.h> |
28 | 28 | ||
29 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 29 | //#if defined(Q_WS_QWS) || defined(_WS_QWS_) |
30 | 30 | ||
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwindowsystem_qws.h> | 33 | #include <qwindowsystem_qws.h> |
34 | #include <qgfx_qws.h> | 34 | #include <qgfx_qws.h> |
35 | 35 | ||
36 | 36 | ||
37 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : | 37 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : |
38 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) | 38 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) |
39 | { | 39 | { |
40 | #ifdef QWS | ||
40 | showCross = TRUE; | 41 | showCross = TRUE; |
41 | const int offset = 30; | 42 | const int offset = 30; |
42 | QRect desk = qApp->desktop() ->geometry(); | 43 | QRect desk = qApp->desktop() ->geometry(); |
43 | setGeometry( 0, 0, desk.width(), desk.height() ); | 44 | setGeometry( 0, 0, desk.width(), desk.height() ); |
44 | if ( desk.height() < 250 ) { | 45 | if ( desk.height() < 250 ) { |
45 | int w = desk.height() / 3; | 46 | int w = desk.height() / 3; |
46 | logo.convertFromImage( Resource::loadImage( "logo/opielogo" ).smoothScale( w, w ) ); | 47 | logo.convertFromImage( Resource::loadImage( "logo/opielogo" ).smoothScale( w, w ) ); |
47 | } | 48 | } |
48 | else { | 49 | else { |
49 | logo = Resource::loadPixmap( "logo/opielogo" ); | 50 | logo = Resource::loadPixmap( "logo/opielogo" ); |
50 | } | 51 | } |
51 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); | 52 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); |
52 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); | 53 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); |
53 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); | 54 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); |
54 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); | 55 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); |
55 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); | 56 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); |
56 | goodcd = cd; | 57 | goodcd = cd; |
57 | reset(); | 58 | reset(); |
58 | 59 | ||
59 | timer = new QTimer( this ); | 60 | timer = new QTimer( this ); |
60 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); | 61 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); |
62 | #endif | ||
61 | } | 63 | } |
62 | 64 | ||
63 | Calibrate::~Calibrate() | 65 | Calibrate::~Calibrate() |
64 | { | 66 | { |
65 | store(); | 67 | store(); |
66 | } | 68 | } |
67 | 69 | ||
68 | void Calibrate::show() | 70 | void Calibrate::show() |
69 | { | 71 | { |
72 | #ifdef QWS | ||
70 | grabMouse(); | 73 | grabMouse(); |
71 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); | 74 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); |
72 | QWSServer::mouseHandler() ->clearCalibration(); | 75 | QWSServer::mouseHandler() ->clearCalibration(); |
73 | QDialog::show(); | 76 | QDialog::show(); |
77 | #endif | ||
74 | } | 78 | } |
75 | 79 | ||
76 | void Calibrate::store() | 80 | void Calibrate::store() |
77 | { | 81 | { |
82 | #ifdef QWS | ||
78 | QWSServer::mouseHandler() ->calibrate( &goodcd ); | 83 | QWSServer::mouseHandler() ->calibrate( &goodcd ); |
84 | #endif | ||
79 | } | 85 | } |
80 | 86 | ||
81 | void Calibrate::hide() | 87 | void Calibrate::hide() |
82 | { | 88 | { |
83 | if ( isVisible ( )) { | 89 | if ( isVisible ( )) { |
84 | store(); | 90 | store(); |
85 | 91 | ||
86 | // hack - calibrate is a launcher dialog, but treated like a standalone app | 92 | // hack - calibrate is a launcher dialog, but treated like a standalone app |
87 | { | 93 | { |
88 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 94 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
89 | e << QString ( "calibrate" ); | 95 | e << QString ( "calibrate" ); |
90 | } | 96 | } |
91 | } | 97 | } |
92 | QDialog::hide(); | 98 | QDialog::hide(); |
93 | } | 99 | } |
94 | 100 | ||
95 | void Calibrate::reset() | 101 | void Calibrate::reset() |
96 | { | 102 | { |
103 | #ifdef QWS | ||
97 | penPos = QPoint(); | 104 | penPos = QPoint(); |
98 | location = QWSPointerCalibrationData::TopLeft; | 105 | location = QWSPointerCalibrationData::TopLeft; |
99 | crossPos = fromDevice( cd.screenPoints[ location ] ); | 106 | crossPos = fromDevice( cd.screenPoints[ location ] ); |
107 | #endif | ||
100 | } | 108 | } |
101 | 109 | ||
102 | QPoint Calibrate::fromDevice( const QPoint &p ) | 110 | QPoint Calibrate::fromDevice( const QPoint &p ) |
103 | { | 111 | { |
112 | #ifdef QWS | ||
104 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); | 113 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); |
114 | #else | ||
115 | return QPoint(); | ||
116 | #endif | ||
117 | |||
105 | } | 118 | } |
106 | 119 | ||
107 | bool Calibrate::sanityCheck() | 120 | bool Calibrate::sanityCheck() |
108 | { | 121 | { |
122 | #ifdef QWS | ||
109 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; | 123 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; |
110 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; | 124 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; |
111 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; | 125 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; |
112 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; | 126 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; |
113 | 127 | ||
114 | // not needed anywhere .. just calculate it, so it's there | 128 | // not needed anywhere .. just calculate it, so it's there |
115 | cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); | 129 | cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); |
116 | 130 | ||
117 | int dlx = QABS( bl. x ( ) - tl. x ( )); | 131 | int dlx = QABS( bl. x ( ) - tl. x ( )); |
118 | int dly = QABS( bl. y ( ) - tl. y ( )); | 132 | int dly = QABS( bl. y ( ) - tl. y ( )); |
119 | int drx = QABS( br. x ( ) - tr. x ( )); | 133 | int drx = QABS( br. x ( ) - tr. x ( )); |
120 | int dry = QABS( br. y ( ) - tr. y ( )); | 134 | int dry = QABS( br. y ( ) - tr. y ( )); |
121 | int dtx = QABS( tr. x ( ) - tl. x ( )); | 135 | int dtx = QABS( tr. x ( ) - tl. x ( )); |
122 | int dty = QABS( tr. y ( ) - tl. y ( )); | 136 | int dty = QABS( tr. y ( ) - tl. y ( )); |
123 | int dbx = QABS( br. x ( ) - bl. x ( )); | 137 | int dbx = QABS( br. x ( ) - bl. x ( )); |
124 | int dby = QABS( br. y ( ) - bl. y ( )); | 138 | int dby = QABS( br. y ( ) - bl. y ( )); |
125 | 139 | ||
126 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides | 140 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides |
127 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); | 141 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); |
128 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); | 142 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); |
129 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); | 143 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); |
130 | 144 | ||
131 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) | 145 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) |
132 | int diff1 = QABS( dl - dr ); | 146 | int diff1 = QABS( dl - dr ); |
133 | int avg1 = ( dl + dr ) / 2; | 147 | int avg1 = ( dl + dr ) / 2; |
134 | int diff2 = QABS( dt - db ); | 148 | int diff2 = QABS( dt - db ); |
135 | int avg2 = ( dt + db ) / 2; | 149 | int avg2 = ( dt + db ) / 2; |
136 | 150 | ||
137 | // Calculate leeway for "real" vector length against "manhattan" vector length | 151 | // Calculate leeway for "real" vector length against "manhattan" vector length |
138 | // This is a check, if the rect is rotated (other then 0/90/180/270) | 152 | // This is a check, if the rect is rotated (other then 0/90/180/270) |
139 | // It needs to be performed only for the triange (bl, tl, tr) | 153 | // It needs to be performed only for the triange (bl, tl, tr) |
140 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); | 154 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); |
141 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; | 155 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; |
142 | 156 | ||
143 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway | 157 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway |
144 | ( diff2 > ( avg2 / 20 )) || | 158 | ( diff2 > ( avg2 / 20 )) || |
145 | ( diff3 > ( avg3 / 20 ))) | 159 | ( diff3 > ( avg3 / 20 ))) |
146 | return false; | 160 | return false; |
147 | else | 161 | else |
148 | return true; | 162 | return true; |
149 | } | 163 | #else |
164 | return true; | ||
165 | #endif | ||
166 | } | ||
150 | 167 | ||
151 | void Calibrate::moveCrosshair( QPoint pt ) | 168 | void Calibrate::moveCrosshair( QPoint pt ) |
152 | { | 169 | { |
153 | showCross = FALSE; | 170 | showCross = FALSE; |
154 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 171 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); |
155 | showCross = TRUE; | 172 | showCross = TRUE; |
156 | crossPos = pt; | 173 | crossPos = pt; |
157 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 174 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); |
158 | } | 175 | } |
159 | 176 | ||
160 | void Calibrate::paintEvent( QPaintEvent * ) | 177 | void Calibrate::paintEvent( QPaintEvent * ) |
161 | { | 178 | { |
162 | QPainter p( this ); | 179 | QPainter p( this ); |
163 | 180 | ||
164 | int y; | 181 | int y; |
165 | 182 | ||
166 | if ( !logo.isNull() ) { | 183 | if ( !logo.isNull() ) { |
167 | y = height() / 2 - logo.height() - 15; | 184 | y = height() / 2 - logo.height() - 15; |
168 | p.drawPixmap( ( width() - logo.width() ) / 2, y, logo ); | 185 | p.drawPixmap( ( width() - logo.width() ) / 2, y, logo ); |
169 | } | 186 | } |
170 | 187 | ||
171 | y = height() / 2 + 15; | 188 | y = height() / 2 + 15; |
172 | 189 | ||
173 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, | 190 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, |
174 | tr( "Touch the crosshairs firmly and\n" | 191 | tr( "Touch the crosshairs firmly and\n" |
175 | "accurately to calibrate your screen." ) ); | 192 | "accurately to calibrate your screen." ) ); |
176 | 193 | ||
177 | QFont f = p.font(); | 194 | QFont f = p.font(); |
178 | f.setBold( TRUE ); | 195 | f.setBold( TRUE ); |
179 | p.setFont( f ); | 196 | p.setFont( f ); |
180 | p.drawText( 0, y, width(), height() - y, AlignHCenter | WordBreak, | 197 | p.drawText( 0, y, width(), height() - y, AlignHCenter | WordBreak, |
181 | tr( "Welcome to Opie" ) ); | 198 | tr( "Welcome to Opie" ) ); |
182 | 199 | ||
183 | if ( showCross ) { | 200 | if ( showCross ) { |
184 | p.drawRect( crossPos.x() - 1, crossPos.y() - 8, 2, 7 ); | 201 | p.drawRect( crossPos.x() - 1, crossPos.y() - 8, 2, 7 ); |
185 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 7 ); | 202 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 7 ); |
186 | p.drawRect( crossPos.x() - 8, crossPos.y() - 1, 7, 2 ); | 203 | p.drawRect( crossPos.x() - 8, crossPos.y() - 1, 7, 2 ); |
187 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 7, 2 ); | 204 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 7, 2 ); |
188 | } | 205 | } |
189 | } | 206 | } |
190 | 207 | ||
191 | void Calibrate::mousePressEvent( QMouseEvent *e ) | 208 | void Calibrate::mousePressEvent( QMouseEvent *e ) |
192 | { | 209 | { |
210 | #ifdef QWS | ||
193 | // map to device coordinates | 211 | // map to device coordinates |
194 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); | 212 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); |
195 | if ( penPos.isNull() ) | 213 | if ( penPos.isNull() ) |
196 | penPos = devPos; | 214 | penPos = devPos; |
197 | else | 215 | else |
198 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, | 216 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, |
199 | ( penPos.y() + devPos.y() ) / 2 ); | 217 | ( penPos.y() + devPos.y() ) / 2 ); |
218 | #endif | ||
200 | } | 219 | } |
201 | 220 | ||
202 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) | 221 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) |
203 | { | 222 | { |
223 | #ifdef QWS | ||
204 | if ( timer->isActive() ) | 224 | if ( timer->isActive() ) |
205 | return ; | 225 | return ; |
206 | 226 | ||
207 | bool doMove = TRUE; | 227 | bool doMove = TRUE; |
208 | 228 | ||
209 | cd.devPoints[ location ] = penPos; | 229 | cd.devPoints[ location ] = penPos; |
210 | if ( location < QWSPointerCalibrationData::TopRight ) { | 230 | if ( location < QWSPointerCalibrationData::TopRight ) { |
211 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); | 231 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); |
212 | } | 232 | } |
213 | else { | 233 | else { |
214 | if ( sanityCheck() ) { | 234 | if ( sanityCheck() ) { |
215 | reset(); | 235 | reset(); |
216 | goodcd = cd; | 236 | goodcd = cd; |
217 | hide(); | 237 | hide(); |
218 | emit accept(); | 238 | emit accept(); |
219 | doMove = FALSE; | 239 | doMove = FALSE; |
220 | } | 240 | } |
221 | else { | 241 | else { |
222 | location = QWSPointerCalibrationData::TopLeft; | 242 | location = QWSPointerCalibrationData::TopLeft; |
223 | } | 243 | } |
224 | } | 244 | } |
225 | 245 | ||
226 | if ( doMove ) { | 246 | if ( doMove ) { |
227 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 247 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
228 | dx = ( target.x() - crossPos.x() ) / 10; | 248 | dx = ( target.x() - crossPos.x() ) / 10; |
229 | dy = ( target.y() - crossPos.y() ) / 10; | 249 | dy = ( target.y() - crossPos.y() ) / 10; |
230 | timer->start( 30 ); | 250 | timer->start( 30 ); |
231 | } | 251 | } |
252 | #endif | ||
232 | } | 253 | } |
233 | 254 | ||
234 | void Calibrate::timeout() | 255 | void Calibrate::timeout() |
235 | { | 256 | { |
257 | #ifdef QWS | ||
236 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 258 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
237 | 259 | ||
238 | bool doneX = FALSE; | 260 | bool doneX = FALSE; |
239 | bool doneY = FALSE; | 261 | bool doneY = FALSE; |
240 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); | 262 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); |
241 | 263 | ||
242 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { | 264 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { |
243 | newPos.setX( target.x() ); | 265 | newPos.setX( target.x() ); |
244 | doneX = TRUE; | 266 | doneX = TRUE; |
245 | } | 267 | } |
246 | 268 | ||
247 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { | 269 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { |
248 | newPos.setY( target.y() ); | 270 | newPos.setY( target.y() ); |
249 | doneY = TRUE; | 271 | doneY = TRUE; |
250 | } | 272 | } |
251 | 273 | ||
252 | if ( doneX && doneY ) { | 274 | if ( doneX && doneY ) { |
253 | penPos = QPoint(); | 275 | penPos = QPoint(); |
254 | timer->stop(); | 276 | timer->stop(); |
255 | } | 277 | } |
256 | 278 | ||
257 | moveCrosshair( newPos ); | 279 | moveCrosshair( newPos ); |
280 | #endif | ||
258 | } | 281 | } |
259 | 282 | ||
260 | #endif // _WS_QWS_ | 283 | //#endif // _WS_QWS_ |
diff --git a/core/apps/calibrate/calibrate.h b/core/apps/calibrate/calibrate.h index 97108c9..06aa0c9 100644 --- a/core/apps/calibrate/calibrate.h +++ b/core/apps/calibrate/calibrate.h | |||
@@ -1,67 +1,69 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qwsmouse_qws.h> | 21 | #include <qwsmouse_qws.h> |
22 | 22 | ||
23 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 23 | //#if defined(Q_WS_QWS) || defined(_WS_QWS_) |
24 | 24 | ||
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | 27 | ||
28 | class QTimer; | 28 | class QTimer; |
29 | 29 | ||
30 | class Calibrate : public QDialog | 30 | class Calibrate : public QDialog |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | Calibrate(QWidget* parent=0, const char * name=0, WFlags=0); | 34 | Calibrate(QWidget* parent=0, const char * name=0, WFlags=0); |
35 | ~Calibrate(); | 35 | ~Calibrate(); |
36 | 36 | ||
37 | void show(); | 37 | void show(); |
38 | void hide(); | 38 | void hide(); |
39 | 39 | ||
40 | private: | 40 | private: |
41 | QPoint fromDevice( const QPoint &p ); | 41 | QPoint fromDevice( const QPoint &p ); |
42 | bool sanityCheck(); | 42 | bool sanityCheck(); |
43 | void moveCrosshair( QPoint pt ); | 43 | void moveCrosshair( QPoint pt ); |
44 | void paintEvent( QPaintEvent * ); | 44 | void paintEvent( QPaintEvent * ); |
45 | void mousePressEvent( QMouseEvent * ); | 45 | void mousePressEvent( QMouseEvent * ); |
46 | void mouseReleaseEvent( QMouseEvent * ); | 46 | void mouseReleaseEvent( QMouseEvent * ); |
47 | 47 | ||
48 | private slots: | 48 | private slots: |
49 | void timeout(); | 49 | void timeout(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | void store(); | 52 | void store(); |
53 | void reset(); | 53 | void reset(); |
54 | QPixmap logo; | 54 | QPixmap logo; |
55 | #ifdef QWS | ||
55 | QWSPointerCalibrationData goodcd,cd; | 56 | QWSPointerCalibrationData goodcd,cd; |
56 | QWSPointerCalibrationData::Location location; | 57 | QWSPointerCalibrationData::Location location; |
58 | #endif | ||
57 | QPoint crossPos; | 59 | QPoint crossPos; |
58 | QPoint penPos; | 60 | QPoint penPos; |
59 | QPixmap saveUnder; | 61 | QPixmap saveUnder; |
60 | QTimer *timer; | 62 | QTimer *timer; |
61 | int dx; | 63 | int dx; |
62 | int dy; | 64 | int dy; |
63 | bool showCross; | 65 | bool showCross; |
64 | }; | 66 | }; |
65 | 67 | ||
66 | #endif // _WS_QWS_ | 68 | //#endif // _WS_QWS_ |
67 | 69 | ||