From: Jean-Marc Lasgouttes Date: Tue, 12 Jun 2007 13:45:49 +0000 (+0000) Subject: Remove background_color_ in Insets: it takes a lot of unnecessary memory, X-Git-Tag: 1.6.10~9411 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4ba4d701f798488c098ecbc740c3020ed514cd96;p=features.git Remove background_color_ in Insets: it takes a lot of unnecessary memory, especially in math where each equation has many insets. * src/Insets.cpp: remove background_color_ member (setBackgroundColor): remove (backgroundColor): make virtual * insets/InsetBranch.cpp: * insets/InsetNote.cpp: move color setting code from setButtonLabel to backgroundColor. * insets/InsetBox.cpp (setButtonLabel): remove call to setBackgroundColor. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18750 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 09be84e480..8664c5f8d9 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -117,7 +117,7 @@ static TranslatorMap const build_translator() /// pretty arbitrary dimensions Inset::Inset() - : dim_(10, 10, 10), background_color_(Color::background) + : dim_(10, 10, 10) {} @@ -351,15 +351,9 @@ void Inset::dump() const } -void Inset::setBackgroundColor(Color_color color) -{ - background_color_ = color; -} - - Color_color Inset::backgroundColor() const { - return Color::color(background_color_); + return Color::background; } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index ca824c8ee4..57c3a27cd4 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -470,9 +470,7 @@ public: /// int scroll() const { return 0; } /// - void setBackgroundColor(Color_color); - /// - Color_color backgroundColor() const; + virtual Color_color backgroundColor() const; /// enum CollapseStatus { Collapsed, @@ -504,10 +502,6 @@ protected: mutable Dimension dim_; private: virtual std::auto_ptr doClone() const = 0; - /** We store the Color::color value as an int to get Color.h out - * of the header file. - */ - int background_color_; }; diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 1ca10c186b..934ec0b4eb 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -164,7 +164,6 @@ void InsetBox::setButtonLabel() setLabel(label); font.setColor(Color::foreground); - setBackgroundColor(Color::background); setLabelFont(font); } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 407f7d848e..67ef02f193 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -98,22 +98,33 @@ void InsetBranch::setButtonLabel() font.decSize(); docstring s = _("Branch: ") + params_.branch; - font.setColor(Color::foreground); if (!params_.branch.empty()) { // FIXME UNICODE Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch)); if (c == Color::none) { - c = Color::error; s = _("Undef: ") + s; } - setBackgroundColor(c); - } else - setBackgroundColor(Color::background); + } + font.setColor(Color::foreground); setLabel(isOpen() ? s : getNewLabel(s) ); setLabelFont(font); } +Color_color InsetBranch::backgroundColor() const +{ + if (!params_.branch.empty()) { + // FIXME UNICODE + Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch)); + if (c == Color::none) { + c = Color::error; + } + return c; + } else + return Inset::backgroundColor(); +} + + bool InsetBranch::showInsetDialog(BufferView * bv) const { InsetBranchMailer(const_cast(*this)).showDialog(bv); diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 72d30a263f..5df7b15d32 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -53,6 +53,8 @@ public: /// void setButtonLabel(); /// + virtual Color_color backgroundColor() const; + /// bool showInsetDialog(BufferView *) const; /// int latex(Buffer const &, odocstream &, diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 1a0cadc5fe..511d95a111 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -186,32 +186,53 @@ void InsetNote::setButtonLabel() font.decSize(); font.decSize(); + Color_color c; switch (params_.type) { case InsetNoteParams::Note: - font.setColor(Color::note); - setBackgroundColor(Color::notebg); + c = Color::note; break; case InsetNoteParams::Comment: - font.setColor(Color::comment); - setBackgroundColor(Color::commentbg); + c = Color::comment; break; case InsetNoteParams::Greyedout: - font.setColor(Color::greyedout); - setBackgroundColor(Color::greyedoutbg); + c = Color::greyedout; break; case InsetNoteParams::Framed: - font.setColor(Color::greyedout); - setBackgroundColor(Color::greyedoutbg); + c = Color::greyedout; break; case InsetNoteParams::Shaded: - font.setColor(Color::greyedout); - setBackgroundColor(Color::shadedbg); + c = Color::greyedout; break; } + font.setColor(c); setLabelFont(font); } +Color_color InsetNote::backgroundColor() const +{ + Color_color c; + switch (params_.type) { + case InsetNoteParams::Note: + c = Color::notebg; + break; + case InsetNoteParams::Comment: + c = Color::commentbg; + break; + case InsetNoteParams::Greyedout: + c = Color::greyedoutbg; + break; + case InsetNoteParams::Framed: + c = Color::greyedoutbg; + break; + case InsetNoteParams::Shaded: + c = Color::shadedbg; + break; + } + return c; +} + + bool InsetNote::showInsetDialog(BufferView * bv) const { InsetNoteMailer(const_cast(*this)).showDialog(bv); diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 97cd5d4256..a17889aba4 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -61,6 +61,8 @@ public: void read(Buffer const & buf, Lexer & lex); /// void setButtonLabel(); + /// + virtual Color_color backgroundColor() const; /// show the note dialog bool showInsetDialog(BufferView * bv) const; ///