aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/basetexteditor.cpp
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-09-23 18:38:36 +0200
committerhjk <hjk121@nokiamail.com>2014-09-24 21:21:25 +0200
commit209f0086629b4f39518e8f0787702d53a26d2655 (patch)
tree802f1a3b55f5a119d474cb6530bcc4dd7ca036d7 /src/plugins/texteditor/basetexteditor.cpp
parent2b8e81893aaa9b034cc37522b656dce1af0756a2 (diff)
TextEditor: Draw background first.
Task-number: QTCREATORBUG-13028 Change-Id: I14ae1794c920b3877f9eca468e1180042b51fb3f Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src/plugins/texteditor/basetexteditor.cpp')
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 1179561bce..0180d5e938 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -3435,6 +3435,27 @@ static QTextLayout::FormatRange createBlockCursorCharFormatRange(int pos, const
void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
{
+ // draw backgrond to the right of the wrap column before everything else
+ qreal lineX = 0;
+ QPointF offset(contentOffset());
+ QRect viewportRect = viewport()->rect();
+ QRect er = e->rect();
+
+ const FontSettings &fs = textDocument()->fontSettings();
+ const QTextCharFormat &searchScopeFormat = fs.toTextCharFormat(C_SEARCH_SCOPE);
+ const QTextCharFormat &ifdefedOutFormat = fs.toTextCharFormat(C_DISABLED_CODE);
+
+ if (d->m_visibleWrapColumn > 0) {
+ QPainter painter(viewport());
+ // Don't use QFontMetricsF::averageCharWidth here, due to it returning
+ // a fractional size even when this is not supported by the platform.
+ lineX = QFontMetricsF(font()).width(QLatin1Char('x')) * d->m_visibleWrapColumn + offset.x() + 4;
+ if (lineX < viewportRect.width())
+ painter.fillRect(QRectF(lineX, er.top(), viewportRect.width() - lineX, er.height()),
+ ifdefedOutFormat.background());
+ }
+
+ innerPaintEvent(e);
/*
Here comes an almost verbatim copy of
QPlainTextEdit::paintEvent() so we can adjust the extra
@@ -3446,22 +3467,13 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
QTextDocument *doc = document();
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
QTC_ASSERT(documentLayout, return);
- const FontSettings &fs = textDocument()->fontSettings();
- const QTextCharFormat &searchScopeFormat = fs.toTextCharFormat(C_SEARCH_SCOPE);
- const QTextCharFormat &ifdefedOutFormat = fs.toTextCharFormat(C_DISABLED_CODE);
- QPointF offset(contentOffset());
QTextBlock textCursorBlock = textCursor().block();
bool hasMainSelection = textCursor().hasSelection();
bool suppressSyntaxInIfdefedOutBlock = (ifdefedOutFormat.foreground()
!= palette().foreground());
- QRect er = e->rect();
- QRect viewportRect = viewport()->rect();
-
- qreal lineX = 0;
-
// Set a brush origin so that the WaveUnderline knows where the wave started
painter.setBrushOrigin(offset);
@@ -3607,15 +3619,8 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
// draw wrap column after ifdefed out blocks
if (d->m_visibleWrapColumn > 0) {
- // Don't use QFontMetricsF::averageCharWidth here, due to it returning
- // a fractional size even when this is not supported by the platform.
- lineX = QFontMetricsF(font()).width(QLatin1Char('x')) * d->m_visibleWrapColumn + offset.x() + 4;
-
if (lineX < viewportRect.width()) {
const QBrush background = ifdefedOutFormat.background();
- painter.fillRect(QRectF(lineX, er.top(), viewportRect.width() - lineX, er.height()),
- background);
-
const QColor col = (palette().base().color().value() > 128) ? Qt::black : Qt::white;
const QPen pen = painter.pen();
painter.setPen(blendColors(background.isOpaque() ? background.color() : palette().base().color(),