summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenwidget.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/handwriting/qimpenwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenwidget.cpp2
1 files changed, 1 insertions, 1 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
@@ -221,129 +221,129 @@ void QIMPenWidget::timeout()
lastPoint.rx() += chain[pointIndex].dx;
lastPoint.ry() += chain[pointIndex].dy;
pointIndex++;
paint.drawRect( lastPoint.x()-1, lastPoint.y()-1, 2, 2 );
}
}
if ( pointIndex >= chain.count() ) {
QIMPenStrokeList strokes = outputChar->penStrokes();
if ( strokeIndex < (int)strokes.count() - 1 ) {
pointIndex = 0;
strokeIndex++;
outputStroke = strokes.at( strokeIndex );
lastPoint = outputChar->startingPoint();
QRect br( outputChar->boundingRect() );
lastPoint.setX( (width() - br.width()) / 2
+ (lastPoint.x () - br.left()) );
QPoint off = lastPoint - outputChar->startingPoint();
lastPoint = outputStroke->startingPoint() + off;
} else {
timer->stop();
mode = Waiting;
}
}
} else if ( mode == Waiting ) {
QRect r( dirtyRect );
if ( !r.isNull() ) {
r.moveBy( -2, -2 );
r.setSize( r.size() + QSize( 4, 4 ) );
repaint( r );
}
}
}
/*!
If the point \a p is over one of the character set titles, switch
to the set and return TRUE.
*/
bool QIMPenWidget::selectSet( QPoint p )
{
if ( charSets.count() ) {
CharSetEntryIterator it( charSets );
int spos = 0;
int idx = 0;
for ( ; it.current(); ++it, idx++ ) {
int setWidth = width() * it.current()->stretch / totalStretch;
spos += setWidth;
if ( p.x() < spos ) {
if ( idx != currCharSet ) {
currCharSet = idx;
update( 0, 0, width(), 12 );
emit changeCharSet( currCharSet );
emit changeCharSet( charSets.at(currCharSet)->cs );
}
break;
}
}
}
return FALSE;
}
/*!
Hopefully returns a sensible size.
*/
-QSize QIMPenWidget::sizeHint()
+QSize QIMPenWidget::sizeHint() const
{
return QSize( TITLE_WIDTH * charSets.count(), 75 );
}
void QIMPenWidget::mousePressEvent( QMouseEvent *e )
{
if ( !readOnly && e->button() == LeftButton && mode == Waiting ) {
// if selectSet returns false the click was not over the
// char set selectors.
if ( !selectSet( e->pos() ) ) {
// start of character input
timer->stop();
if ( outputChar ) {
outputChar = 0;
outputStroke = 0;
repaint();
}
mode = Input;
lastPoint = e->pos();
emit beginStroke();
inputStroke = new QIMPenStroke;
strokes.append( inputStroke );
inputStroke->beginInput( e->pos() );
QPainter paint( this );
paint.setBrush( Qt::black );
paint.drawRect( lastPoint.x()-1, lastPoint.y()-1, 2, 2 );
}
}
}
void QIMPenWidget::mouseReleaseEvent( QMouseEvent *e )
{
if ( !readOnly && e->button() == LeftButton && mode == Input ) {
mode = Waiting;
inputStroke->endInput();
if ( charSets.count() )
emit stroke( inputStroke );
inputStroke = 0;
}
}
void QIMPenWidget::mouseMoveEvent( QMouseEvent *e )
{
if ( !readOnly && mode == Input ) {
int dx = QABS( e->pos().x() - lastPoint.x() );
int dy = QABS( e->pos().y() - lastPoint.y() );
if ( dx + dy > 1 ) {
if ( inputStroke->addPoint( e->pos() ) ) {
QPainter paint( this );
paint.setPen( Qt::black );
paint.setBrush( Qt::black );
const QArray<QIMPenGlyphLink> &chain = inputStroke->chain();
QPoint p( e->pos() );
for ( int i = (int)chain.count()-1; i >= 0; i-- ) {
paint.drawRect( p.x()-1, p.y()-1, 2, 2 );
p.rx() -= chain[i].dx;
p.ry() -= chain[i].dy;
if ( p == lastPoint )
break;
}
/* ### use this when thick lines work properly on all devices
paint.setPen( QPen( Qt::black, 2 ) );
paint.drawLine( lastPoint, e->pos() );