From bc6304d760f5bd8ef67065fdc73279e1aa792c85 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 2 Sep 2007 14:34:15 +0000 Subject: [PATCH] Don't save background color in Text. Hand it down at drawing time. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20002 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 3 ++- src/MetricsInfo.cpp | 3 ++- src/MetricsInfo.h | 2 ++ src/Text.cpp | 6 ------ src/Text.h | 6 ------ src/Text2.cpp | 3 +-- src/TextMetrics.cpp | 4 ++-- src/insets/InsetCollapsable.cpp | 2 +- 8 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 7fbd7187be..a418509625 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1545,7 +1545,8 @@ void BufferView::draw(frontend::Painter & pain) if (pi.full_repaint) // Clear background (if not delegated to rows) pain.fillRectangle(0, metrics_info_.y1, width_, - metrics_info_.y2 - metrics_info_.y1, text.backgroundColor()); + metrics_info_.y2 - metrics_info_.y1, + buffer_.inset().backgroundColor()); TextMetrics const & tm = text_metrics_[&text]; diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp index b9c903f143..0ddf21ca17 100644 --- a/src/MetricsInfo.cpp +++ b/src/MetricsInfo.cpp @@ -50,7 +50,8 @@ MetricsInfo::MetricsInfo(BufferView * bv, Font const & font, int textwidth) PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter) - : pain(painter), ltr_pos(false), erased_(false), full_repaint(true) + : pain(painter), ltr_pos(false), erased_(false), full_repaint(true), + background_color(Color::background) { base.bv = bv; } diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h index fc62d226da..055b172732 100644 --- a/src/MetricsInfo.h +++ b/src/MetricsInfo.h @@ -98,6 +98,8 @@ public: bool erased_; /// bool full_repaint; + /// + int background_color; }; class TextMetricsInfo {}; diff --git a/src/Text.cpp b/src/Text.cpp index 35912086a8..8250030e36 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -356,12 +356,6 @@ double Text::spacing(Buffer const & buffer, } -Color_color Text::backgroundColor() const -{ - return Color_color(Color::color(background_color_)); -} - - void Text::breakParagraph(Cursor & cur, bool keep_layout) { BOOST_ASSERT(this == cur.text()); diff --git a/src/Text.h b/src/Text.h index 766229dce9..a586998225 100644 --- a/src/Text.h +++ b/src/Text.h @@ -244,9 +244,6 @@ public: /// FIXME: replace Cursor with DocIterator. void insertStringAsParagraphs(Cursor & cur, docstring const & str); - /// return the color of the canvas - Color_color backgroundColor() const; - /// access to our paragraphs ParagraphList const & paragraphs() const { return pars_; } ParagraphList & paragraphs() { return pars_; } @@ -289,9 +286,6 @@ public: void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges); public: - /// - int background_color_; - /// ParagraphList pars_; diff --git a/src/Text2.cpp b/src/Text2.cpp index 14afb1a49b..0d4358d8f3 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -71,8 +71,7 @@ using std::istringstream; namespace lyx { Text::Text() - : background_color_(Color::background), - autoBreakRows_(false) + : autoBreakRows_(false) {} diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index cb59462668..06982eab97 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1716,8 +1716,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co // (if paragraph background was not cleared) if (!pi.full_repaint && row_has_changed) { pi.pain.fillRectangle(x, y - rit->ascent(), - width(), rit->height(), - text_->backgroundColor()); + width(), rit->height(), + Color_color(Color::color(pi.background_color))); } // Instrumentation for testing row cache (see also diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 2534109cec..fc842f7d6e 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -244,7 +244,7 @@ bool InsetCollapsable::setMouseHover(bool mouse_hover) void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const { autoOpen_ = pi.base.bv->cursor().isInside(this); - text_.background_color_ = backgroundColor(); + pi.background_color = backgroundColor(); const int xx = x + TEXT_TO_INSET_OFFSET; // Draw button first -- top, left or only -- 2.39.2