2003-09-12 10:14:31 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathBoldSymbol.cpp
|
2003-09-12 10:14:31 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-09-12 10:14:31 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathBoldSymbol.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2016-11-22 10:26:15 +00:00
|
|
|
#include "MetricsInfo.h"
|
2003-09-12 10:14:31 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
2008-05-06 10:36:32 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathBoldSymbol::InsetMathBoldSymbol(Buffer * buf, Kind kind)
|
|
|
|
: InsetMathNest(buf, 1), kind_(kind)
|
2003-09-12 10:14:31 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathBoldSymbol::clone() const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathBoldSymbol(*this);
|
2003-09-12 10:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-15 16:49:11 +00:00
|
|
|
docstring InsetMathBoldSymbol::name() const
|
|
|
|
{
|
|
|
|
switch (kind_) {
|
|
|
|
case AMS_BOLD:
|
|
|
|
return from_ascii("boldsymbol");
|
|
|
|
case BM_BOLD:
|
|
|
|
return from_ascii("bm");
|
|
|
|
case BM_HEAVY:
|
|
|
|
return from_ascii("hm");
|
|
|
|
}
|
|
|
|
// avoid compiler warning
|
|
|
|
return docstring();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy = mi.base.changeEnsureMath();
|
2016-05-23 21:30:23 +00:00
|
|
|
//Changer dummy = mi.base.changeFontSet("mathbf");
|
2003-09-12 10:14:31 +00:00
|
|
|
cell(0).metrics(mi, dim);
|
|
|
|
++dim.wid; // for 'double stroke'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBoldSymbol::draw(PainterInfo & pi, int x, int y) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy = pi.base.changeEnsureMath();
|
2016-05-23 21:30:23 +00:00
|
|
|
//Changer dummy = pi.base.changeFontSet("mathbf");
|
2017-01-06 08:52:10 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
2003-09-12 10:14:31 +00:00
|
|
|
cell(0).draw(pi, x + 1, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2007-09-23 22:39:49 +00:00
|
|
|
// FIXME: BROKEN!
|
|
|
|
Dimension dim;
|
|
|
|
cell(0).metricsT(mi, dim);
|
2003-09-12 10:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
|
|
|
cell(0).drawT(pain, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathNest::validate(features);
|
2008-04-01 02:29:41 +00:00
|
|
|
if (kind_ == AMS_BOLD)
|
|
|
|
features.require("amsbsy");
|
|
|
|
else
|
|
|
|
features.require("bm");
|
2003-09-12 10:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBoldSymbol::write(WriteStream & os) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
MathEnsurer ensurer(os);
|
2008-03-12 14:33:16 +00:00
|
|
|
switch (kind_) {
|
2008-04-01 02:29:41 +00:00
|
|
|
case AMS_BOLD:
|
2008-03-12 14:33:16 +00:00
|
|
|
os << "\\boldsymbol{" << cell(0) << "}";
|
|
|
|
break;
|
2008-04-01 02:29:41 +00:00
|
|
|
case BM_BOLD:
|
|
|
|
os << "\\bm{" << cell(0) << "}";
|
|
|
|
break;
|
|
|
|
case BM_HEAVY:
|
|
|
|
os << "\\hm{" << cell(0) << "}";
|
2008-03-12 14:33:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-09-12 10:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 16:39:37 +00:00
|
|
|
void InsetMathBoldSymbol::mathmlize(MathStream & os) const
|
|
|
|
{
|
|
|
|
os << "<mstyle mathvariant='bold'>" << cell(0) << "</mstyle>";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-30 02:05:49 +00:00
|
|
|
void InsetMathBoldSymbol::htmlize(HtmlStream & os) const
|
|
|
|
{
|
|
|
|
os << MTag("b") << cell(0) << ETag("b");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathBoldSymbol::infoize(odocstream & os) const
|
2003-09-12 10:14:31 +00:00
|
|
|
{
|
2008-03-12 14:33:16 +00:00
|
|
|
switch (kind_) {
|
2008-04-01 02:29:41 +00:00
|
|
|
case AMS_BOLD:
|
2008-03-12 14:33:16 +00:00
|
|
|
os << "Boldsymbol ";
|
|
|
|
break;
|
2008-04-01 02:29:41 +00:00
|
|
|
case BM_BOLD:
|
|
|
|
os << "Boldsymbol (bm)";
|
|
|
|
break;
|
|
|
|
case BM_HEAVY:
|
|
|
|
os << "Heavysymbol (bm)";
|
2008-03-12 14:33:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-09-12 10:14:31 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|