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) (ignore whitespace changes)
-rw-r--r--core/apps/calibrate/calibrate.cpp37
-rw-r--r--core/apps/calibrate/calibrate.h6
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
@@ -26,7 +26,7 @@
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>
@@ -37,6 +37,7 @@
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();
@@ -58,6 +59,7 @@ Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) :
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()
@@ -67,15 +69,19 @@ Calibrate::~Calibrate()
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()
@@ -87,25 +93,33 @@ void Calibrate::hide()
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
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];
@@ -127,8 +141,8 @@ bool Calibrate::sanityCheck()
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 );
@@ -137,7 +151,7 @@ bool Calibrate::sanityCheck()
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
@@ -146,7 +160,10 @@ bool Calibrate::sanityCheck()
146 return false; 160 return false;
147 else 161 else
148 return true; 162 return true;
149 } 163#else
164return true;
165#endif
166}
150 167
151void Calibrate::moveCrosshair( QPoint pt ) 168void Calibrate::moveCrosshair( QPoint pt )
152{ 169{
@@ -190,6 +207,7 @@ void Calibrate::paintEvent( QPaintEvent * )
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() )
@@ -197,10 +215,12 @@ void Calibrate::mousePressEvent( QMouseEvent *e )
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
@@ -229,10 +249,12 @@ void Calibrate::mouseReleaseEvent( QMouseEvent * )
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;
@@ -255,6 +277,7 @@ void Calibrate::timeout()
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
@@ -20,7 +20,7 @@
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>
@@ -52,8 +52,10 @@ 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;
@@ -63,5 +65,5 @@ private:
63 bool showCross; 65 bool showCross;
64}; 66};
65 67
66#endif // _WS_QWS_ 68//#endif // _WS_QWS_
67 69