| 396 | } |
| 397 | |
| 398 | void |
| 399 | InputScriptTextEdit::lineNumberAreaPaintEvent(QPaintEvent *event) |
| 400 | { |
| 401 | QPainter painter(_lineNumber); |
| 402 | QColor fillColor; |
| 403 | QColor txtColor; |
| 404 | QColor selColor; |
| 405 | { |
| 406 | double r, g, b; |
| 407 | appPTR->getCurrentSettings()->getRaisedColor(&r, &g, &b); |
| 408 | fillColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) ); |
| 409 | appPTR->getCurrentSettings()->getTextColor(&r, &g, &b); |
| 410 | txtColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) ); |
| 411 | appPTR->getCurrentSettings()->getSelectionColor(&r, &g, &b); |
| 412 | selColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) ); |
| 413 | } |
| 414 | |
| 415 | painter.fillRect(event->rect(), fillColor); |
| 416 | |
| 417 | QTextBlock block = firstVisibleBlock(); |
| 418 | int blockNumber = block.blockNumber(); |
| 419 | int top = (int) blockBoundingGeometry(block).translated( contentOffset() ).top(); |
| 420 | int bottom = top + (int) blockBoundingRect(block).height(); |
| 421 | |
| 422 | while ( block.isValid() && top <= event->rect().bottom() ) { |
| 423 | if ( block.isVisible() && ( bottom >= event->rect().top() ) ) { |
| 424 | QString number = QString::number(blockNumber + 1); |
| 425 | if ( blockNumber == textCursor().block().blockNumber() ) { |
| 426 | painter.setPen(selColor); |
| 427 | } else { |
| 428 | painter.setPen(txtColor); |
| 429 | } |
| 430 | |
| 431 | painter.drawText(0, top, _lineNumber->width(), fontMetrics().height(), |
| 432 | Qt::AlignRight, number); |
| 433 | } |
| 434 | |
| 435 | block = block.next(); |
| 436 | top = bottom; |
| 437 | bottom = top + (int) blockBoundingRect(block).height(); |
| 438 | ++blockNumber; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | void |
| 443 | InputScriptTextEdit::dragEnterEvent(QDragEnterEvent* e) |
no test coverage detected