From a99c5828f89152a4b67deb2d72b8b5f2f1d435b1 Mon Sep 17 00:00:00 2001 From: Bernhard Roider Date: Thu, 6 Mar 2008 20:49:59 +0000 Subject: [PATCH] Add support for \bm from bm.sty git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23520 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 2 + src/LaTeXFeatures.cpp | 3 +- src/Makefile.am | 2 + src/mathed/InsetMathBM.cpp | 86 +++++++++++++++++++++++++++++ src/mathed/InsetMathBM.h | 47 ++++++++++++++++ src/mathed/InsetMathNest.cpp | 1 + src/mathed/MathFactory.cpp | 3 + 7 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/mathed/InsetMathBM.cpp create mode 100644 src/mathed/InsetMathBM.h diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 3916af57fd..48a79b24c4 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -455,6 +455,7 @@ src_mathed_header_files = Split(''' InsetMathAMSArray.h InsetMathArray.h InsetMathBig.h + InsetMathBM.h InsetMathBoldSymbol.h InsetMathBox.h InsetMathBrace.h @@ -523,6 +524,7 @@ src_mathed_files = Split(''' InsetMathAMSArray.cpp InsetMathArray.cpp InsetMathBig.cpp + InsetMathBM.cpp InsetMathBoldSymbol.cpp InsetMathBox.cpp InsetMathBrace.cpp diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index c4e3a642cd..8e0b42e63b 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -547,7 +547,8 @@ char const * simplefeatures[] = { "endnotes", "ifthen", "amsthm", - "listings" + "listings", + "bm" }; int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); diff --git a/src/Makefile.am b/src/Makefile.am index 7fa7a260b3..f8b6a2ee52 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -332,6 +332,7 @@ SOURCEFILESMATHED = \ mathed/InsetMathAMSArray.cpp \ mathed/InsetMathArray.cpp \ mathed/InsetMathBig.cpp \ + mathed/InsetMathBM.cpp \ mathed/InsetMathBoldSymbol.cpp \ mathed/InsetMathBox.cpp \ mathed/InsetMathBrace.cpp \ @@ -397,6 +398,7 @@ HEADERFILESMATHED = \ mathed/InsetMathAMSArray.h \ mathed/InsetMathArray.h \ mathed/InsetMathBig.h \ + mathed/InsetMathBM.h \ mathed/InsetMathBoldSymbol.h \ mathed/InsetMathBox.h \ mathed/InsetMathBrace.h \ diff --git a/src/mathed/InsetMathBM.cpp b/src/mathed/InsetMathBM.cpp new file mode 100644 index 0000000000..9001ea8473 --- /dev/null +++ b/src/mathed/InsetMathBM.cpp @@ -0,0 +1,86 @@ +/** + * \file InsetMathBM.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Bernhard Roider + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InsetMathBM.h" + +#include "MathStream.h" +#include "MathData.h" +#include "LaTeXFeatures.h" + +#include + + +namespace lyx { + +InsetMathBM::InsetMathBM() + : InsetMathNest(1) +{} + + +Inset * InsetMathBM::clone() const +{ + return new InsetMathBM(*this); +} + + +void InsetMathBM::metrics(MetricsInfo & mi, Dimension & dim) const +{ + //FontSetChanger dummy(mi.base, "mathbf"); + cell(0).metrics(mi, dim); + metricsMarkers(dim); + ++dim.wid; // for 'double stroke' +} + + +void InsetMathBM::draw(PainterInfo & pi, int x, int y) const +{ + //FontSetChanger dummy(pi.base, "mathbf"); + cell(0).draw(pi, x + 1, y); + cell(0).draw(pi, x + 2, y); + drawMarkers(pi, x, y); +} + + +void InsetMathBM::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const +{ + // FIXME: BROKEN! + Dimension dim; + cell(0).metricsT(mi, dim); +} + + +void InsetMathBM::drawT(TextPainter & pain, int x, int y) const +{ + cell(0).drawT(pain, x, y); +} + + +void InsetMathBM::validate(LaTeXFeatures & features) const +{ + InsetMathNest::validate(features); + features.require("bm"); +} + + +void InsetMathBM::write(WriteStream & os) const +{ + os << "\\bm{" << cell(0) << "}"; +} + + +void InsetMathBM::infoize(odocstream & os) const +{ + os << "bm "; +} + + +} // namespace lyx diff --git a/src/mathed/InsetMathBM.h b/src/mathed/InsetMathBM.h new file mode 100644 index 0000000000..5192930b28 --- /dev/null +++ b/src/mathed/InsetMathBM.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +/** + * \file InsetMathBM.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Bernhard Roider + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef MATH_BMINSET_H +#define MATH_BMINSET_H + +#include "InsetMathNest.h" + + +namespace lyx { + + +/// Inset for \bm +class InsetMathBM : public InsetMathNest { +public: + /// + InsetMathBM(); + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; + /// + void drawT(TextPainter & pi, int x, int y) const; + /// + void validate(LaTeXFeatures & features) const; + /// + void write(WriteStream & os) const; + /// + void infoize(odocstream & os) const; +private: + virtual Inset * clone() const; +}; + + +} // namespace lyx + +#endif diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 5e7d88f36d..b51e20c38a 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1767,6 +1767,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur) globals.push_back(from_ascii("\\atop")); globals.push_back(from_ascii("\\lefteqn")); globals.push_back(from_ascii("\\boldsymbol")); + globals.push_back(from_ascii("\\bm")); globals.push_back(from_ascii("\\color")); globals.push_back(from_ascii("\\normalcolor")); globals.push_back(from_ascii("\\textcolor")); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index dbeb6d61f0..b1e73b2a3a 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -14,6 +14,7 @@ #include "InsetMathAMSArray.h" #include "InsetMathArray.h" +#include "InsetMathBM.h" #include "InsetMathBoldSymbol.h" #include "InsetMathBox.h" #include "InsetMathCases.h" @@ -377,6 +378,8 @@ MathAtom createInsetMath(docstring const & s) return MathAtom(new InsetMathLefteqn); if (s == "boldsymbol") return MathAtom(new InsetMathBoldSymbol); + if (s == "bm") + return MathAtom(new InsetMathBM); if (s == "color" || s == "normalcolor") return MathAtom(new InsetMathColor(true)); if (s == "textcolor") -- 2.39.2