summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenwidget.cpp2
-rw-r--r--inputmethods/handwriting/qimpenwidget.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/handwriting/qimpenwidget.cpp b/inputmethods/handwriting/qimpenwidget.cpp
index 8f8f582..7223e1a 100644
--- a/inputmethods/handwriting/qimpenwidget.cpp
+++ b/inputmethods/handwriting/qimpenwidget.cpp
@@ -237,97 +237,97 @@ void QIMPenWidget::timeout()
237 QPoint off = lastPoint - outputChar->startingPoint(); 237 QPoint off = lastPoint - outputChar->startingPoint();
238 lastPoint = outputStroke->startingPoint() + off; 238 lastPoint = outputStroke->startingPoint() + off;
239 } else { 239 } else {
240 timer->stop(); 240 timer->stop();
241 mode = Waiting; 241 mode = Waiting;
242 } 242 }
243 } 243 }
244 } else if ( mode == Waiting ) { 244 } else if ( mode == Waiting ) {
245 QRect r( dirtyRect ); 245 QRect r( dirtyRect );
246 if ( !r.isNull() ) { 246 if ( !r.isNull() ) {
247 r.moveBy( -2, -2 ); 247 r.moveBy( -2, -2 );
248 r.setSize( r.size() + QSize( 4, 4 ) ); 248 r.setSize( r.size() + QSize( 4, 4 ) );
249 repaint( r ); 249 repaint( r );
250 } 250 }
251 } 251 }
252} 252}
253 253
254/*! 254/*!
255 If the point \a p is over one of the character set titles, switch 255 If the point \a p is over one of the character set titles, switch
256 to the set and return TRUE. 256 to the set and return TRUE.
257*/ 257*/
258bool QIMPenWidget::selectSet( QPoint p ) 258bool QIMPenWidget::selectSet( QPoint p )
259{ 259{
260 if ( charSets.count() ) { 260 if ( charSets.count() ) {
261 CharSetEntryIterator it( charSets ); 261 CharSetEntryIterator it( charSets );
262 int spos = 0; 262 int spos = 0;
263 int idx = 0; 263 int idx = 0;
264 for ( ; it.current(); ++it, idx++ ) { 264 for ( ; it.current(); ++it, idx++ ) {
265 int setWidth = width() * it.current()->stretch / totalStretch; 265 int setWidth = width() * it.current()->stretch / totalStretch;
266 spos += setWidth; 266 spos += setWidth;
267 if ( p.x() < spos ) { 267 if ( p.x() < spos ) {
268 if ( idx != currCharSet ) { 268 if ( idx != currCharSet ) {
269 currCharSet = idx; 269 currCharSet = idx;
270 update( 0, 0, width(), 12 ); 270 update( 0, 0, width(), 12 );
271 emit changeCharSet( currCharSet ); 271 emit changeCharSet( currCharSet );
272 emit changeCharSet( charSets.at(currCharSet)->cs ); 272 emit changeCharSet( charSets.at(currCharSet)->cs );
273 } 273 }
274 break; 274 break;
275 } 275 }
276 } 276 }
277 } 277 }
278 278
279 return FALSE; 279 return FALSE;
280} 280}
281 281
282/*! 282/*!
283 Hopefully returns a sensible size. 283 Hopefully returns a sensible size.
284*/ 284*/
285QSize QIMPenWidget::sizeHint() 285QSize QIMPenWidget::sizeHint() const
286{ 286{
287 return QSize( TITLE_WIDTH * charSets.count(), 75 ); 287 return QSize( TITLE_WIDTH * charSets.count(), 75 );
288} 288}
289 289
290void QIMPenWidget::mousePressEvent( QMouseEvent *e ) 290void QIMPenWidget::mousePressEvent( QMouseEvent *e )
291{ 291{
292 if ( !readOnly && e->button() == LeftButton && mode == Waiting ) { 292 if ( !readOnly && e->button() == LeftButton && mode == Waiting ) {
293 // if selectSet returns false the click was not over the 293 // if selectSet returns false the click was not over the
294 // char set selectors. 294 // char set selectors.
295 if ( !selectSet( e->pos() ) ) { 295 if ( !selectSet( e->pos() ) ) {
296 // start of character input 296 // start of character input
297 timer->stop(); 297 timer->stop();
298 if ( outputChar ) { 298 if ( outputChar ) {
299 outputChar = 0; 299 outputChar = 0;
300 outputStroke = 0; 300 outputStroke = 0;
301 repaint(); 301 repaint();
302 } 302 }
303 mode = Input; 303 mode = Input;
304 lastPoint = e->pos(); 304 lastPoint = e->pos();
305 emit beginStroke(); 305 emit beginStroke();
306 inputStroke = new QIMPenStroke; 306 inputStroke = new QIMPenStroke;
307 strokes.append( inputStroke ); 307 strokes.append( inputStroke );
308 inputStroke->beginInput( e->pos() ); 308 inputStroke->beginInput( e->pos() );
309 QPainter paint( this ); 309 QPainter paint( this );
310 paint.setBrush( Qt::black ); 310 paint.setBrush( Qt::black );
311 paint.drawRect( lastPoint.x()-1, lastPoint.y()-1, 2, 2 ); 311 paint.drawRect( lastPoint.x()-1, lastPoint.y()-1, 2, 2 );
312 } 312 }
313 } 313 }
314} 314}
315 315
316void QIMPenWidget::mouseReleaseEvent( QMouseEvent *e ) 316void QIMPenWidget::mouseReleaseEvent( QMouseEvent *e )
317{ 317{
318 if ( !readOnly && e->button() == LeftButton && mode == Input ) { 318 if ( !readOnly && e->button() == LeftButton && mode == Input ) {
319 mode = Waiting; 319 mode = Waiting;
320 inputStroke->endInput(); 320 inputStroke->endInput();
321 if ( charSets.count() ) 321 if ( charSets.count() )
322 emit stroke( inputStroke ); 322 emit stroke( inputStroke );
323 inputStroke = 0; 323 inputStroke = 0;
324 } 324 }
325} 325}
326 326
327void QIMPenWidget::mouseMoveEvent( QMouseEvent *e ) 327void QIMPenWidget::mouseMoveEvent( QMouseEvent *e )
328{ 328{
329 if ( !readOnly && mode == Input ) { 329 if ( !readOnly && mode == Input ) {
330 int dx = QABS( e->pos().x() - lastPoint.x() ); 330 int dx = QABS( e->pos().x() - lastPoint.x() );
331 int dy = QABS( e->pos().y() - lastPoint.y() ); 331 int dy = QABS( e->pos().y() - lastPoint.y() );
332 if ( dx + dy > 1 ) { 332 if ( dx + dy > 1 ) {
333 if ( inputStroke->addPoint( e->pos() ) ) { 333 if ( inputStroke->addPoint( e->pos() ) ) {
diff --git a/inputmethods/handwriting/qimpenwidget.h b/inputmethods/handwriting/qimpenwidget.h
index 98d7f5c..d156554 100644
--- a/inputmethods/handwriting/qimpenwidget.h
+++ b/inputmethods/handwriting/qimpenwidget.h
@@ -1,88 +1,88 @@
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 <qwidget.h> 21#include <qwidget.h>
22#include <qlist.h> 22#include <qlist.h>
23#include "qimpenchar.h" 23#include "qimpenchar.h"
24 24
25class QIMPenWidget : public QWidget 25class QIMPenWidget : public QWidget
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
29 QIMPenWidget( QWidget *parent ); 29 QIMPenWidget( QWidget *parent );
30 30
31 void clear(); 31 void clear();
32 void greyStroke(); 32 void greyStroke();
33 void setReadOnly( bool r ) { readOnly = r; } 33 void setReadOnly( bool r ) { readOnly = r; }
34 34
35 void insertCharSet( QIMPenCharSet *cs, int stretch=1, int pos=-1 ); 35 void insertCharSet( QIMPenCharSet *cs, int stretch=1, int pos=-1 );
36 void removeCharSet( int ); 36 void removeCharSet( int );
37 void changeCharSet( QIMPenCharSet *cs, int pos ); 37 void changeCharSet( QIMPenCharSet *cs, int pos );
38 void clearCharSets(); 38 void clearCharSets();
39 void showCharacter( QIMPenChar *, int speed = 10 ); 39 void showCharacter( QIMPenChar *, int speed = 10 );
40 virtual QSize sizeHint(); 40 virtual QSize sizeHint() const;
41 41
42public slots: 42public slots:
43 void removeStroke(); 43 void removeStroke();
44 44
45signals: 45signals:
46 void changeCharSet( QIMPenCharSet *cs ); 46 void changeCharSet( QIMPenCharSet *cs );
47 void changeCharSet( int ); 47 void changeCharSet( int );
48 void beginStroke(); 48 void beginStroke();
49 void stroke( QIMPenStroke *ch ); 49 void stroke( QIMPenStroke *ch );
50 50
51protected slots: 51protected slots:
52 void timeout(); 52 void timeout();
53 53
54protected: 54protected:
55 enum Mode { Waiting, Input, Output }; 55 enum Mode { Waiting, Input, Output };
56 bool selectSet( QPoint ); 56 bool selectSet( QPoint );
57 virtual void mousePressEvent( QMouseEvent *e ); 57 virtual void mousePressEvent( QMouseEvent *e );
58 virtual void mouseReleaseEvent( QMouseEvent *e ); 58 virtual void mouseReleaseEvent( QMouseEvent *e );
59 virtual void mouseMoveEvent( QMouseEvent *e ); 59 virtual void mouseMoveEvent( QMouseEvent *e );
60 virtual void paintEvent( QPaintEvent *e ); 60 virtual void paintEvent( QPaintEvent *e );
61 virtual void resizeEvent( QResizeEvent *e ); 61 virtual void resizeEvent( QResizeEvent *e );
62 62
63 struct CharSetEntry { 63 struct CharSetEntry {
64 QIMPenCharSet *cs; 64 QIMPenCharSet *cs;
65 int stretch; 65 int stretch;
66 }; 66 };
67 typedef QList<CharSetEntry> CharSetEntryList; 67 typedef QList<CharSetEntry> CharSetEntryList;
68 typedef QListIterator<CharSetEntry> CharSetEntryIterator; 68 typedef QListIterator<CharSetEntry> CharSetEntryIterator;
69 69
70protected: 70protected:
71 Mode mode; 71 Mode mode;
72 bool autoHide; 72 bool autoHide;
73 bool readOnly; 73 bool readOnly;
74 QPoint lastPoint; 74 QPoint lastPoint;
75 unsigned pointIndex; 75 unsigned pointIndex;
76 int strokeIndex; 76 int strokeIndex;
77 int currCharSet; 77 int currCharSet;
78 QTimer *timer; 78 QTimer *timer;
79 QColor strokeColor; 79 QColor strokeColor;
80 QRect dirtyRect; 80 QRect dirtyRect;
81 QIMPenChar *outputChar; 81 QIMPenChar *outputChar;
82 QIMPenStroke *outputStroke; 82 QIMPenStroke *outputStroke;
83 QIMPenStroke *inputStroke; 83 QIMPenStroke *inputStroke;
84 QIMPenStrokeList strokes; 84 QIMPenStrokeList strokes;
85 CharSetEntryList charSets; 85 CharSetEntryList charSets;
86 int totalStretch; 86 int totalStretch;
87}; 87};
88 88