Hello,
following the suggestion from Martin in an earlier mail i have a patch that adds support for \bm
from bm.sty package to lyx. The Files InsetMathBM.{cpp,h} are copied and adapted from
InsetMathBoldSymbol.{cpp,h}. I don't understand the comment
// FIXME: BROKEN!
in
void InsetMathBM::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/)
const
and therefore left it as it is in the boldsymbol counterpart.
I tried to adapt all build systems as well (but could test cmake and VC2005
only)
Comments are welcome.
Bernhard
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py (revision 23401)
+++ development/scons/scons_manifest.py (working copy)
@@ -455,6 +455,7 @@
InsetMathAMSArray.h
InsetMathArray.h
InsetMathBig.h
+ InsetMathBM.h
InsetMathBoldSymbol.h
InsetMathBox.h
InsetMathBrace.h
@@ -523,6 +524,7 @@
InsetMathAMSArray.cpp
InsetMathArray.cpp
InsetMathBig.cpp
+ InsetMathBM.cpp
InsetMathBoldSymbol.cpp
InsetMathBox.cpp
InsetMathBrace.cpp
Index: src/LaTeXFeatures.cpp
===================================================================
--- src/LaTeXFeatures.cpp (revision 23401)
+++ src/LaTeXFeatures.cpp (working copy)
@@ -547,7 +547,8 @@
"endnotes",
"ifthen",
"amsthm",
- "listings"
+ "listings",
+ "bm"
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
Index: src/Makefile.am
===================================================================
--- src/Makefile.am (revision 23401)
+++ src/Makefile.am (working copy)
@@ -332,6 +332,7 @@
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 @@
mathed/InsetMathAMSArray.h \
mathed/InsetMathArray.h \
mathed/InsetMathBig.h \
+ mathed/InsetMathBM.h \
mathed/InsetMathBoldSymbol.h \
mathed/InsetMathBox.h \
mathed/InsetMathBrace.h \
Index: src/mathed/InsetMathBM.cpp
===================================================================
--- src/mathed/InsetMathBM.cpp (revision 0)
+++ src/mathed/InsetMathBM.cpp (revision 0)
@@ -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 <config.h>
+
+#include "InsetMathBM.h"
+
+#include "MathStream.h"
+#include "MathData.h"
+#include "LaTeXFeatures.h"
+
+#include <ostream>
+
+
+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
Index: src/mathed/InsetMathBM.h
===================================================================
--- src/mathed/InsetMathBM.h (revision 0)
+++ src/mathed/InsetMathBM.h (revision 0)
@@ -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
Index: src/mathed/InsetMathNest.cpp
===================================================================
--- src/mathed/InsetMathNest.cpp (revision 23401)
+++ src/mathed/InsetMathNest.cpp (working copy)
@@ -1776,6 +1776,7 @@
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"));
Index: src/mathed/MathFactory.cpp
===================================================================
--- src/mathed/MathFactory.cpp (revision 23401)
+++ src/mathed/MathFactory.cpp (working copy)
@@ -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 @@
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")