Merge InsetMathBoldSymbol and InsetMathBM by providing \boldsymbol

through the bm package.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23684 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2008-03-12 14:33:16 +00:00
parent bde87d4ce7
commit ba496b94ac
11 changed files with 32 additions and 155 deletions

View File

@ -453,7 +453,6 @@ src_mathed_header_files = Split('''
InsetMathAMSArray.h InsetMathAMSArray.h
InsetMathArray.h InsetMathArray.h
InsetMathBig.h InsetMathBig.h
InsetMathBM.h
InsetMathBoldSymbol.h InsetMathBoldSymbol.h
InsetMathBox.h InsetMathBox.h
InsetMathBrace.h InsetMathBrace.h
@ -522,7 +521,6 @@ src_mathed_files = Split('''
InsetMathAMSArray.cpp InsetMathAMSArray.cpp
InsetMathArray.cpp InsetMathArray.cpp
InsetMathBig.cpp InsetMathBig.cpp
InsetMathBM.cpp
InsetMathBoldSymbol.cpp InsetMathBoldSymbol.cpp
InsetMathBox.cpp InsetMathBox.cpp
InsetMathBrace.cpp InsetMathBrace.cpp

View File

@ -55,6 +55,7 @@
\bind "C-Prior" "buffer-previous" \bind "C-Prior" "buffer-previous"
\bind "C-S-Tab" "buffer-previous" \bind "C-S-Tab" "buffer-previous"
\bind "C-M-b" "math-insert \mathbf"
\bind "C-b" "font-bold" \bind "C-b" "font-bold"
\bind "C-e" "font-emph" \bind "C-e" "font-emph"
# used below for line-delete-forward # used below for line-delete-forward

View File

@ -42,6 +42,7 @@
\bind "M-Tab" "buffer-next" \bind "M-Tab" "buffer-next"
\bind "M-S-BackTab" "buffer-previous" \bind "M-S-BackTab" "buffer-previous"
\bind "C-M-b" "math-insert \mathbf"
\bind "C-b" "font-bold" \bind "C-b" "font-bold"
\bind "C-e" "font-emph" \bind "C-e" "font-emph"
\bind "C-k" "font-noun" # 'k' for capitals \bind "C-k" "font-noun" # 'k' for capitals

View File

@ -136,10 +136,6 @@ static string const floatingfootnote_def =
" \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n" " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n"
"\\def\\SF@gobble@twobracket[#1]#2{}\n"; "\\def\\SF@gobble@twobracket[#1]#2{}\n";
static string const boldsymbol_def =
"%% Bold symbol macro for standard LaTeX users\n"
"\\providecommand{\\boldsymbol}[1]{\\mbox{\\boldmath $#1$}}\n";
static string const binom_def = static string const binom_def =
"%% Binom macro for standard LaTeX users\n" "%% Binom macro for standard LaTeX users\n"
"\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n"; "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n";
@ -664,8 +660,6 @@ string const LaTeXFeatures::getMacros() const
macros << guillemotright_def << '\n'; macros << guillemotright_def << '\n';
// Math mode // Math mode
if (mustProvide("boldsymbol") && !isRequired("amsmath"))
macros << boldsymbol_def << '\n';
if (mustProvide("binom") && !isRequired("amsmath")) if (mustProvide("binom") && !isRequired("amsmath"))
macros << binom_def << '\n'; macros << binom_def << '\n';
if (mustProvide("mathcircumflex")) if (mustProvide("mathcircumflex"))

View File

@ -329,7 +329,6 @@ SOURCEFILESMATHED = \
mathed/InsetMathAMSArray.cpp \ mathed/InsetMathAMSArray.cpp \
mathed/InsetMathArray.cpp \ mathed/InsetMathArray.cpp \
mathed/InsetMathBig.cpp \ mathed/InsetMathBig.cpp \
mathed/InsetMathBM.cpp \
mathed/InsetMathBoldSymbol.cpp \ mathed/InsetMathBoldSymbol.cpp \
mathed/InsetMathBox.cpp \ mathed/InsetMathBox.cpp \
mathed/InsetMathBrace.cpp \ mathed/InsetMathBrace.cpp \
@ -395,7 +394,6 @@ HEADERFILESMATHED = \
mathed/InsetMathAMSArray.h \ mathed/InsetMathAMSArray.h \
mathed/InsetMathArray.h \ mathed/InsetMathArray.h \
mathed/InsetMathBig.h \ mathed/InsetMathBig.h \
mathed/InsetMathBM.h \
mathed/InsetMathBoldSymbol.h \ mathed/InsetMathBoldSymbol.h \
mathed/InsetMathBox.h \ mathed/InsetMathBox.h \
mathed/InsetMathBrace.h \ mathed/InsetMathBrace.h \

View File

@ -1,86 +0,0 @@
/**
* \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

View File

@ -1,47 +0,0 @@
// -*- 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

@ -21,8 +21,8 @@
namespace lyx { namespace lyx {
InsetMathBoldSymbol::InsetMathBoldSymbol() InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind)
: InsetMathNest(1) : InsetMathNest(1), kind_(kind)
{} {}
@ -67,19 +67,33 @@ void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
{ {
InsetMathNest::validate(features); InsetMathNest::validate(features);
features.require("amssymb"); features.require("bm");
} }
void InsetMathBoldSymbol::write(WriteStream & os) const void InsetMathBoldSymbol::write(WriteStream & os) const
{ {
os << "\\boldsymbol{" << cell(0) << "}"; switch (kind_) {
case BOLD:
os << "\\boldsymbol{" << cell(0) << "}";
break;
case HEAVY:
os << "\\heavysymbol{" << cell(0) << "}";
break;
}
} }
void InsetMathBoldSymbol::infoize(odocstream & os) const void InsetMathBoldSymbol::infoize(odocstream & os) const
{ {
os << "Boldsymbol "; switch (kind_) {
case BOLD:
os << "Boldsymbol ";
break;
case HEAVY:
os << "Heavysymbol ";
break;
}
} }

View File

@ -21,8 +21,12 @@ namespace lyx {
/// Inset for AMSTeX's \boldsymbol /// Inset for AMSTeX's \boldsymbol
class InsetMathBoldSymbol : public InsetMathNest { class InsetMathBoldSymbol : public InsetMathNest {
public: public:
enum Kind {
BOLD,
HEAVY
};
/// ///
InsetMathBoldSymbol(); InsetMathBoldSymbol(Kind kind = BOLD);
/// ///
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;
/// ///
@ -37,6 +41,8 @@ public:
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
void infoize(odocstream & os) const; void infoize(odocstream & os) const;
///
Kind kind_;
private: private:
virtual Inset * clone() const; virtual Inset * clone() const;
}; };

View File

@ -570,7 +570,6 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
//if (features.amsstyle) //if (features.amsstyle)
// return; // return;
features.require("boldsymbol");
//features.binom = true; //features.binom = true;
InsetMathGrid::validate(features); InsetMathGrid::validate(features);

View File

@ -14,7 +14,6 @@
#include "InsetMathAMSArray.h" #include "InsetMathAMSArray.h"
#include "InsetMathArray.h" #include "InsetMathArray.h"
#include "InsetMathBM.h"
#include "InsetMathBoldSymbol.h" #include "InsetMathBoldSymbol.h"
#include "InsetMathBox.h" #include "InsetMathBox.h"
#include "InsetMathCases.h" #include "InsetMathCases.h"
@ -376,10 +375,10 @@ MathAtom createInsetMath(docstring const & s)
return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP)); return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP));
if (s == "lefteqn") if (s == "lefteqn")
return MathAtom(new InsetMathLefteqn); return MathAtom(new InsetMathLefteqn);
if (s == "boldsymbol") if (s == "boldsymbol" || s == "bm")
return MathAtom(new InsetMathBoldSymbol); return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BOLD));
if (s == "bm") if (s == "heavysymbol" || s == "hm")
return MathAtom(new InsetMathBM); return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::HEAVY));
if (s == "color" || s == "normalcolor") if (s == "color" || s == "normalcolor")
return MathAtom(new InsetMathColor(true)); return MathAtom(new InsetMathColor(true));
if (s == "textcolor") if (s == "textcolor")