From: André Pönitz Date: Tue, 30 Jul 2002 16:04:41 +0000 (+0000) Subject: support for AMS's \boxed{} command X-Git-Tag: 1.6.10~18731 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6c57f7353f0f6bba93181d56d06ddd9469170b5a;p=features.git support for AMS's \boxed{} command git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4807 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index f328ed3a57..f07ebda69e 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -69,7 +69,8 @@ bool math_font_available(string & name) return true; } - lyxerr[Debug::MATHED] << "font " << name << " not available and I can't fake it\n"; + lyxerr[Debug::MATHED] + << "font " << name << " not available and I can't fake it\n"; return false; } @@ -233,7 +234,7 @@ MathAtom createMathInset(string const & s) if (inset == "parbox") return MathAtom(new MathParboxInset); if (inset == "fbox") - return MathAtom(new MathFboxInset); + return MathAtom(new MathFboxInset(l)); if (inset == "style") return MathAtom(new MathSizeInset(l)); if (inset == "font") diff --git a/src/mathed/math_fboxinset.C b/src/mathed/math_fboxinset.C index 138e2fe407..b187cff13b 100644 --- a/src/mathed/math_fboxinset.C +++ b/src/mathed/math_fboxinset.C @@ -7,12 +7,14 @@ #include "math_fboxinset.h" #include "math_support.h" #include "math_mathmlstream.h" +#include "math_streamstr.h" +#include "math_parser.h" #include "frontends/Painter.h" -MathFboxInset::MathFboxInset() - : MathNestInset(1) +MathFboxInset::MathFboxInset(latexkeys const * key) + : MathNestInset(1), key_(key) {} @@ -22,30 +24,47 @@ MathInset * MathFboxInset::clone() const } +MathInset::mode_type MathFboxInset::currentMode() const +{ + if (key_->name == "fbox") + return TEXT_MODE; + return MATH_MODE; +} + + void MathFboxInset::metrics(MathMetricsInfo & mi) const { - MathFontSetChanger dummy(mi.base, "textnormal"); - dim_ = xcell(0).metrics(mi); - metricsMarkers2(5); // 5 pixels margin + if (key_->name == "fbox") { + MathFontSetChanger dummy(mi.base, "textnormal"); + dim_ = xcell(0).metrics(mi); + metricsMarkers2(5); // 5 pixels margin + } else { + dim_ = xcell(0).metrics(mi); + metricsMarkers2(5); // 5 pixels margin + } } void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const { - MathFontSetChanger dummy(pi.base, "textnormal"); pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, LColor::black); - xcell(0).draw(pi, x + 5, y); + if (key_->name == "fbox") { + MathFontSetChanger dummy(pi.base, "textnormal"); + xcell(0).draw(pi, x + 5, y); + } else { + xcell(0).draw(pi, x + 5, y); + } } void MathFboxInset::write(WriteStream & os) const { - os << "\\fbox{" << cell(0) << '}'; + os << '\\' << key_->name << '{' << cell(0) << '}'; } void MathFboxInset::normalize(NormalStream & os) const { - os << "[fbox " << cell(0) << ']'; + os << '[' << key_->name << ' ' << cell(0) << ']'; } diff --git a/src/mathed/math_fboxinset.h b/src/mathed/math_fboxinset.h index 9f1ea4a770..ac84e9a869 100644 --- a/src/mathed/math_fboxinset.h +++ b/src/mathed/math_fboxinset.h @@ -13,14 +13,16 @@ \author André Pönitz */ +class latexkeys; + class MathFboxInset : public MathNestInset { public: /// - MathFboxInset(); + MathFboxInset(latexkeys const * key); /// MathInset * clone() const; /// - mode_type currentMode() const { return TEXT_MODE; } + mode_type currentMode() const; /// void metrics(MathMetricsInfo & mi) const; /// @@ -29,6 +31,9 @@ public: void write(WriteStream & os) const; /// write normalized content void normalize(NormalStream & ns) const; +private: + /// + latexkeys const * key_; }; #endif