summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2002-10-17 17:03:21 (UTC)
committer zecke <zecke>2002-10-17 17:03:21 (UTC)
commitd7cdf9468af510848688584caf34cb1cc03b8562 (patch) (unidiff)
treedfd7a19eec935385262ad003883dd7d384872bbd /core
parent0655456f68849bfad9019a7760dec961792d7519 (diff)
downloadopie-d7cdf9468af510848688584caf34cb1cc03b8562.zip
opie-d7cdf9468af510848688584caf34cb1cc03b8562.tar.gz
opie-d7cdf9468af510848688584caf34cb1cc03b8562.tar.bz2
stupid #ifdefs around Calibrate...
tell moc to ignore them or put them inside the methods :(
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/calibrate/calibrate.cpp27
-rw-r--r--core/apps/calibrate/calibrate.h6
2 files changed, 29 insertions, 4 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
@@ -23,23 +23,24 @@
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
37Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : 37Calibrate::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;
@@ -55,30 +56,35 @@ Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) :
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
63Calibrate::~Calibrate() 65Calibrate::~Calibrate()
64{ 66{
65 store(); 67 store();
66} 68}
67 69
68void Calibrate::show() 70void 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
76void Calibrate::store() 80void Calibrate::store()
77{ 81{
82#ifdef QWS
78 QWSServer::mouseHandler() ->calibrate( &goodcd ); 83 QWSServer::mouseHandler() ->calibrate( &goodcd );
84#endif
79} 85}
80 86
81void Calibrate::hide() 87void Calibrate::hide()
82{ 88{
83 if ( isVisible ( )) { 89 if ( isVisible ( )) {
84 store(); 90 store();
@@ -91,24 +97,32 @@ void Calibrate::hide()
91 } 97 }
92 QDialog::hide(); 98 QDialog::hide();
93} 99}
94 100
95void Calibrate::reset() 101void 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
102QPoint Calibrate::fromDevice( const QPoint &p ) 110QPoint 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
107bool Calibrate::sanityCheck() 120bool 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
@@ -143,12 +157,15 @@ bool Calibrate::sanityCheck()
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;
163#else
164return true;
165#endif
149 } 166 }
150 167
151void Calibrate::moveCrosshair( QPoint pt ) 168void 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 );
@@ -187,23 +204,26 @@ void Calibrate::paintEvent( QPaintEvent * )
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
191void Calibrate::mousePressEvent( QMouseEvent *e ) 208void 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
202void Calibrate::mouseReleaseEvent( QMouseEvent * ) 221void 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;
@@ -226,16 +246,18 @@ void Calibrate::mouseReleaseEvent( QMouseEvent * )
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
234void Calibrate::timeout() 255void 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
@@ -252,9 +274,10 @@ void Calibrate::timeout()
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
@@ -17,13 +17,13 @@
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
28class QTimer; 28class QTimer;
29 29
@@ -49,19 +49,21 @@ private slots:
49 void timeout(); 49 void timeout();
50 50
51private: 51private:
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