From d39896da58e159b82f7711315791bc2543378c80 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sun, 19 Aug 2007 10:08:09 +0000 Subject: [PATCH] Small cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19642 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCharStyle.cpp | 66 ++++++++++++++++----------------- src/insets/InsetCharStyle.h | 12 +----- src/insets/InsetCollapsable.cpp | 12 +++--- src/insets/InsetCollapsable.h | 2 - 4 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/insets/InsetCharStyle.cpp b/src/insets/InsetCharStyle.cpp index effe8269ac..5822b50f82 100644 --- a/src/insets/InsetCharStyle.cpp +++ b/src/insets/InsetCharStyle.cpp @@ -56,7 +56,7 @@ void InsetCharStyle::init() InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s) : InsetCollapsable(bp, Collapsed) { - params_.type = s; + params_.name = s; setUndefined(); init(); } @@ -66,7 +66,7 @@ InsetCharStyle::InsetCharStyle(BufferParams const & bp, CharStyles::iterator cs) : InsetCollapsable(bp, Collapsed) { - params_.type = cs->name; + params_.name = cs->name; setDefined(cs); init(); } @@ -87,28 +87,24 @@ auto_ptr InsetCharStyle::doClone() const bool InsetCharStyle::undefined() const { - return params_.latexname.empty(); + return layout_.latexname.empty(); } void InsetCharStyle::setUndefined() { - params_.latextype.clear(); - params_.latexname.clear(); - params_.latexparam.clear(); - params_.font = Font(Font::ALL_INHERIT); - params_.labelfont = Font(Font::ALL_INHERIT); - params_.labelfont.setColor(Color::error); + layout_.latextype.clear(); + layout_.latexname.clear(); + layout_.latexparam.clear(); + layout_.font = Font(Font::ALL_INHERIT); + layout_.labelfont = Font(Font::ALL_INHERIT); + layout_.labelfont.setColor(Color::error); } void InsetCharStyle::setDefined(CharStyles::iterator cs) { - params_.latextype = cs->latextype; - params_.latexname = cs->latexname; - params_.latexparam = cs->latexparam; - params_.font = cs->font; - params_.labelfont = cs->labelfont; + layout_ = *cs; } @@ -143,7 +139,7 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const mi.base.font = tmpfont; if (status() == Open) { // consider width of the inset label - Font font(params_.labelfont); + Font font(layout_.labelfont); font.realize(Font(Font::ALL_SANE)); font.decSize(); font.decSize(); @@ -151,7 +147,7 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const int a = 0; int d = 0; // FIXME UNICODE - docstring s(from_utf8(params_.type)); + docstring s(from_utf8(params_.name)); if (undefined()) s = _("Undef: ") + s; // Chop off prefix: @@ -193,15 +189,15 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const else desc -= 3; - pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color()); + pi.pain.line(x, y + desc - 4, x, y + desc, layout_.labelfont.color()); pi.pain.line(x, y + desc, x + dim_.wid - 3, y + desc, - params_.labelfont.color()); + layout_.labelfont.color()); pi.pain.line(x + dim_.wid - 3, y + desc, x + dim_.wid - 3, y + desc - 4, - params_.labelfont.color()); + layout_.labelfont.color()); // the name of the charstyle. Can be toggled. if (status() == Open) { - Font font(params_.labelfont); + Font font(layout_.labelfont); font.realize(Font(Font::ALL_SANE)); font.decSize(); font.decSize(); @@ -209,7 +205,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const int a = 0; int d = 0; // FIXME UNICODE - docstring s(from_utf8(params_.type)); + docstring s(from_utf8(params_.name)); if (undefined()) s = _("Undef: ") + s; // Chop off prefix: @@ -225,19 +221,19 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const if (cur.isInside(this)) { y -= ascent(); y += 3; - pi.pain.line(x, y + 4, x, y, params_.labelfont.color()); - pi.pain.line(x + 4, y, x, y, params_.labelfont.color()); + pi.pain.line(x, y + 4, x, y, layout_.labelfont.color()); + pi.pain.line(x + 4, y, x, y, layout_.labelfont.color()); pi.pain.line(x + dim_.wid - 3, y + 4, x + dim_.wid - 3, y, - params_.labelfont.color()); + layout_.labelfont.color()); pi.pain.line(x + dim_.wid - 7, y, x + dim_.wid - 3, y, - params_.labelfont.color()); + layout_.labelfont.color()); } } void InsetCharStyle::getDrawFont(Font & font) const { - font = params_.font; + font = layout_.font; } @@ -299,9 +295,9 @@ int InsetCharStyle::latex(Buffer const & buf, odocstream & os, { if (!undefined()) { // FIXME UNICODE - os << '\\' << from_utf8(params_.latexname); - if (!params_.latexparam.empty()) - os << from_utf8(params_.latexparam); + os << '\\' << from_utf8(layout_.latexname); + if (!layout_.latexparam.empty()) + os << from_utf8(layout_.latexparam); os << '{'; } int i = InsetText::latex(buf, os, runparams); @@ -327,8 +323,8 @@ int InsetCharStyle::docbook(Buffer const & buf, odocstream & os, if (!undefined()) // FIXME UNICODE - sgml::openTag(os, params_.latexname, - par->getID(buf, runparams) + params_.latexparam); + sgml::openTag(os, layout_.latexname, + par->getID(buf, runparams) + layout_.latexparam); for (; par != end; ++par) { par->simpleDocBookOnePar(buf, os, runparams, @@ -337,7 +333,7 @@ int InsetCharStyle::docbook(Buffer const & buf, odocstream & os, } if (!undefined()) - sgml::closeTag(os, params_.latexname); + sgml::closeTag(os, layout_.latexname); return 0; } @@ -352,14 +348,14 @@ void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const void InsetCharStyle::validate(LaTeXFeatures & features) const { // Force inclusion of preamble snippet in layout file - features.require(params_.type); + features.require(params_.name); InsetText::validate(features); } void InsetCharStyleParams::write(ostream & os) const { - os << "CharStyle " << type << "\n"; + os << "CharStyle " << name << "\n"; } @@ -371,7 +367,7 @@ void InsetCharStyleParams::read(Lexer & lex) if (token == "CharStyle") { lex.next(); - type = lex.getString(); + name = lex.getString(); } // This is handled in Collapsable diff --git a/src/insets/InsetCharStyle.h b/src/insets/InsetCharStyle.h index 91040e4d86..cf1b450f9a 100644 --- a/src/insets/InsetCharStyle.h +++ b/src/insets/InsetCharStyle.h @@ -27,17 +27,7 @@ public: /// void read(Lexer & lex); /// - std::string type; - /// - std::string latextype; - /// - std::string latexname; - /// - std::string latexparam; - /// - Font font; - /// - Font labelfont; + std::string name; }; diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 23b7414b19..d248bed312 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -76,7 +76,7 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const InsetCollapsable::InsetCollapsable (BufferParams const & bp, CollapseStatus status) - : InsetText(bp), label(from_ascii("Label")), status_(status), + : InsetText(bp), status_(status), openinlined_(false), autoOpen_(false), mouse_hover_(false) { setAutoBreakRows(true); @@ -91,7 +91,6 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs) button_dim(rhs.button_dim), topx(rhs.topx), topbaseline(rhs.topbaseline), - label(rhs.label), layout_(rhs.layout_), status_(rhs.status_), openinlined_(rhs.openinlined_), @@ -105,8 +104,7 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs) void InsetCollapsable::setLayout(BufferParams const & bp) { - setLabelFont(getLayout(bp).labelfont); - setLabel(getLayout(bp).labelstring); + layout_ = getLayout(bp); } @@ -168,7 +166,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const { Dimension dim; theFontMetrics(layout_.labelfont).buttonText( - label, dim.wid, dim.asc, dim.des); + layout_.labelstring, dim.wid, dim.asc, dim.des); return dim; } @@ -237,7 +235,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const button_dim.y1 = top; button_dim.y2 = top + dimc.height(); - pi.pain.buttonText(xx, top + dimc.asc, label, layout_.labelfont, mouse_hover_); + pi.pain.buttonText(xx, top + dimc.asc, layout_.labelstring, layout_.labelfont, mouse_hover_); } int textx, texty; @@ -507,7 +505,7 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetCollapsable::setLabel(docstring const & l) { - label = l; + layout_.labelstring = l; } diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 742a4acb2e..cf45b8bd0e 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -153,8 +153,6 @@ protected: /// mutable int topbaseline; /// - mutable docstring label; - /// mutable InsetLayout layout_; private: /// -- 2.39.2