Add support for \bm from bm.sty

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23520 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bernhard Roider 2008-03-06 20:49:59 +00:00
parent f401ce5d29
commit a99c5828f8
7 changed files with 143 additions and 1 deletions

View File

@ -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

View File

@ -547,7 +547,8 @@ char const * simplefeatures[] = {
"endnotes",
"ifthen",
"amsthm",
"listings"
"listings",
"bm"
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);

View File

@ -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 \

View File

@ -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

47
src/mathed/InsetMathBM.h Normal file
View File

@ -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

View File

@ -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"));

View File

@ -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")