diff options
Diffstat (limited to 'experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp')
-rw-r--r-- | experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp b/experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp index 8b614d610..00484d60c 100644 --- a/experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp +++ b/experimental/tqtinterface/qt4/src/kernel/tqrichtext.cpp @@ -9028,7 +9028,7 @@ void TQTextCursor::restoreState() pop(); } -bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link ) +bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link, bool loosePlacing, bool matchBetweenCharacters ) { TQPoint pos( p ); TQRect r; @@ -9046,7 +9046,7 @@ bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link ) str = s; if ( pos.y() >= r.y() && pos.y() <= r.y() + r.height() ) break; - if ( !s->next() ) { + if ( loosePlacing == TRUE && !s->next() ) { #ifdef TQ_WS_MACX pos.setX( s->rect().x() + s->rect().width() ); #endif @@ -9087,7 +9087,7 @@ bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link ) if ( pos.x() < x ) pos.setX( x + 1 ); int cw; - int curpos = s->length()-1; + int curpos = -1; int dist = 10000000; bool inCustom = FALSE; while ( i < nextLine ) { @@ -9109,14 +9109,21 @@ bool TQTextCursor::place( const TQPoint &p, TQTextParagraph *s, bool link ) cpos += cw; int d = cpos - pos.x(); bool dm = d < 0 ? !chr->rightToLeft : chr->rightToLeft; - if ( (TQABS( d ) < dist || (dist == d && dm == TRUE )) && para->string()->validCursorPosition( i ) ) { + if ( ( matchBetweenCharacters == TRUE && (TQABS( d ) < dist || (dist == d && dm == TRUE )) && para->string()->validCursorPosition( i ) ) || + ( matchBetweenCharacters == FALSE && ( d == 0 || dm == TRUE ) ) ) { dist = TQABS( d ); - if ( !link || pos.x() >= x + chr->x ) + if ( !link || ( pos.x() >= x + chr->x && ( loosePlacing == TRUE || pos.x() < cpos ) ) ) curpos = i; } } i++; } + if ( curpos == -1 ) { + if ( loosePlacing == TRUE ) + curpos = s->length()-1; + else + return FALSE; + } setIndex( curpos ); #ifndef TQT_NO_TEXTCUSTOMITEM @@ -13244,6 +13251,9 @@ void TQTextParagraph::drawString( TQPainter &painter, const TQString &str, int s tmpw = fullSelectionWidth - xleft; painter.fillRect( xleft, y, tmpw, h, color ); painter.drawText( xstart, y + baseLine, str, start, len, dir ); + // draw preedit's underline + if (selection == TQTextDocument::IMCompositionText) + painter.drawLine(xstart, y + baseLine + 1, xstart + w, y + baseLine + 1); if (selStart != start || selEnd != start + len || selWrap) painter.restore(); } |