2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathBox.cpp
|
2003-08-19 13:00:56 +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
|
2007-11-06 20:57:29 +00:00
|
|
|
* \author Ling Li (InsetMathMakebox)
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathBox.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2007-11-06 20:57:29 +00:00
|
|
|
#include "MathSupport.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
2014-11-14 17:18:30 +00:00
|
|
|
#include "support/gettext.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
2015-12-10 00:15:16 +00:00
|
|
|
#include <algorithm>
|
2008-05-06 10:36:32 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
2014-11-14 17:18:30 +00:00
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetMathBox
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathBox::InsetMathBox(Buffer * buf, docstring const & name)
|
|
|
|
: InsetMathNest(buf, 1), name_(name)
|
2001-10-19 16:07:10 +00:00
|
|
|
{}
|
2001-10-19 11:25:48 +00:00
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBox::write(WriteStream & os) const
|
2001-10-19 11:25:48 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
ModeSpecifier specifier(os, TEXT_MODE);
|
2002-11-27 10:30:28 +00:00
|
|
|
os << '\\' << name_ << '{' << cell(0) << '}';
|
2001-10-19 11:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBox::normalize(NormalStream & os) const
|
2001-10-19 11:25:48 +00:00
|
|
|
{
|
2001-12-18 12:21:33 +00:00
|
|
|
os << '[' << name_ << ' ';
|
2001-10-19 11:25:48 +00:00
|
|
|
//text_->write(buffer(), os);
|
|
|
|
os << "] ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 15:46:39 +00:00
|
|
|
void InsetMathBox::mathmlize(MathStream & ms) const
|
2011-04-01 22:34:40 +00:00
|
|
|
{
|
2011-06-30 02:17:49 +00:00
|
|
|
// FIXME XHTML
|
|
|
|
// Need to do something special for tags here.
|
2011-06-30 02:16:34 +00:00
|
|
|
// Probably will have to involve deferring them, which
|
|
|
|
// means returning something from this routine.
|
2011-04-01 22:34:40 +00:00
|
|
|
SetMode textmode(ms, true);
|
|
|
|
ms << MTag("mstyle", "class='mathbox'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("mstyle");
|
2009-11-14 21:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-30 02:37:05 +00:00
|
|
|
void InsetMathBox::htmlize(HtmlStream & ms) const
|
|
|
|
{
|
|
|
|
SetHTMLMode textmode(ms, true);
|
2011-04-01 22:34:40 +00:00
|
|
|
ms << MTag("span", "class='mathbox'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("span");
|
2010-03-30 02:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-10-19 11:25:48 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = mi.base.changeFontSet("textnormal");
|
2004-01-30 11:41:12 +00:00
|
|
|
cell(0).metrics(mi, dim);
|
2002-06-04 09:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathBox::draw(PainterInfo & pi, int x, int y) const
|
2002-06-04 09:06:04 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = pi.base.changeFontSet("textnormal");
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
2001-10-24 19:09:31 +00:00
|
|
|
}
|
2002-07-10 07:15:36 +00:00
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathBox::infoize(odocstream & os) const
|
2017-01-06 08:52:10 +00:00
|
|
|
{
|
2014-11-14 17:18:30 +00:00
|
|
|
os << bformat(_("Box: %1$s"), name_);
|
2002-07-10 07:15:36 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2008-03-05 18:57:08 +00:00
|
|
|
void InsetMathBox::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
2011-04-01 22:34:40 +00:00
|
|
|
// FIXME XHTML
|
|
|
|
// It'd be better to be able to get this from an InsetLayout, but at present
|
|
|
|
// InsetLayouts do not seem really to work for things that aren't InsetTexts.
|
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("mstyle.mathbox { font-style: normal; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.mathbox { font-style: normal; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
|
2008-03-05 18:57:08 +00:00
|
|
|
if (name_ == "tag" || name_ == "tag*")
|
|
|
|
features.require("amsmath");
|
2010-03-30 02:37:05 +00:00
|
|
|
|
2011-04-01 22:34:40 +00:00
|
|
|
InsetMathNest::validate(features);
|
2008-03-05 18:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetMathFBox
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathFBox::InsetMathFBox(Buffer * buf)
|
|
|
|
: InsetMathNest(buf, 1)
|
2007-11-06 20:57:29 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = mi.base.changeFontSet("textnormal");
|
2007-11-06 20:57:29 +00:00
|
|
|
cell(0).metrics(mi, dim);
|
2017-01-06 08:52:10 +00:00
|
|
|
// 1 pixel space, 1 frame, 1 space
|
|
|
|
dim.wid += 2 * 3;
|
|
|
|
dim.asc += 3;
|
|
|
|
dim.des += 3;
|
2007-11-06 20:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
|
|
|
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
|
|
|
dim.width() - 2, dim.height() - 2, Color_foreground);
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = pi.base.changeFontSet("textnormal");
|
2007-11-06 20:57:29 +00:00
|
|
|
cell(0).draw(pi, x + 3, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathFBox::write(WriteStream & os) const
|
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
ModeSpecifier specifier(os, TEXT_MODE);
|
2007-11-06 20:57:29 +00:00
|
|
|
os << "\\fbox{" << cell(0) << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathFBox::normalize(NormalStream & os) const
|
|
|
|
{
|
|
|
|
os << "[fbox " << cell(0) << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
void InsetMathFBox::mathmlize(MathStream & ms) const
|
|
|
|
{
|
2011-04-01 22:34:40 +00:00
|
|
|
SetMode textmode(ms, true);
|
|
|
|
ms << MTag("mstyle", "class='fbox'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("mstyle");
|
2009-12-31 20:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-30 02:37:05 +00:00
|
|
|
void InsetMathFBox::htmlize(HtmlStream & ms) const
|
|
|
|
{
|
2011-04-01 22:34:40 +00:00
|
|
|
SetHTMLMode textmode(ms, true);
|
|
|
|
ms << MTag("span", "class='fbox'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("span");
|
2010-03-30 02:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
void InsetMathFBox::infoize(odocstream & os) const
|
|
|
|
{
|
|
|
|
os << "FBox: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
void InsetMathFBox::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
// FIXME XHTML
|
|
|
|
// It'd be better to be able to get this from an InsetLayout, but at present
|
|
|
|
// InsetLayouts do not seem really to work for things that aren't InsetTexts.
|
2010-03-31 18:24:52 +00:00
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet(
|
|
|
|
"mstyle.fbox { border: 1px solid black; font-style: normal; padding: 0.5ex; }");
|
2010-03-31 18:24:52 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet(
|
|
|
|
"span.fbox { border: 1px solid black; font-style: normal; padding: 0.5ex; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
|
|
|
|
cell(0).validate(features);
|
2010-03-31 18:24:52 +00:00
|
|
|
InsetMathNest::validate(features);
|
2009-12-31 20:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2008-02-28 12:46:32 +00:00
|
|
|
// InsetMathMakebox
|
2007-11-06 20:57:29 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathMakebox::InsetMathMakebox(Buffer * buf, bool framebox)
|
|
|
|
: InsetMathNest(buf, 3), framebox_(framebox)
|
2007-11-06 20:57:29 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const
|
2007-11-06 20:57:29 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = mi.base.changeFontSet("textnormal");
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2008-02-28 12:45:36 +00:00
|
|
|
Dimension wdim;
|
|
|
|
static docstring bracket = from_ascii("[");
|
2012-05-03 14:28:28 +00:00
|
|
|
metricsStrRedBlack(mi, wdim, bracket);
|
2008-02-28 12:45:36 +00:00
|
|
|
int w = wdim.wid;
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2008-02-28 12:45:36 +00:00
|
|
|
Dimension dim0;
|
|
|
|
Dimension dim1;
|
|
|
|
Dimension dim2;
|
|
|
|
cell(0).metrics(mi, dim0);
|
|
|
|
cell(1).metrics(mi, dim1);
|
|
|
|
cell(2).metrics(mi, dim2);
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
dim.wid = w + dim0.wid + w + w + dim1.wid + w + 2 + dim2.wid;
|
2017-01-06 08:52:10 +00:00
|
|
|
dim.asc = std::max(std::max(wdim.asc, dim0.asc), std::max(dim1.asc, dim2.asc));
|
2008-02-28 12:45:36 +00:00
|
|
|
dim.des = std::max(std::max(wdim.des, dim0.des), std::max(dim1.des, dim2.des));
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
if (framebox_) {
|
|
|
|
dim.wid += 4;
|
|
|
|
dim.asc += 3;
|
|
|
|
dim.des += 2;
|
|
|
|
} else {
|
|
|
|
dim.asc += 1;
|
|
|
|
dim.des += 1;
|
|
|
|
}
|
2007-11-06 20:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const
|
2007-11-06 20:57:29 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = pi.base.changeFontSet("textnormal");
|
2008-02-28 12:46:32 +00:00
|
|
|
BufferView const & bv = *pi.base.bv;
|
2008-02-28 12:45:36 +00:00
|
|
|
int w = mathed_char_width(pi.base.font, '[');
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
if (framebox_) {
|
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
|
|
|
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
|
|
|
dim.width() - 2, dim.height() - 2, Color_foreground);
|
|
|
|
x += 2;
|
|
|
|
}
|
2017-01-06 08:52:10 +00:00
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
drawStrBlack(pi, x, y, from_ascii("["));
|
2008-02-28 12:45:36 +00:00
|
|
|
x += w;
|
2007-11-06 20:57:29 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
|
|
|
x += cell(0).dimension(bv).wid;
|
|
|
|
drawStrBlack(pi, x, y, from_ascii("]"));
|
2008-02-28 12:46:32 +00:00
|
|
|
x += w;
|
2007-11-06 20:57:29 +00:00
|
|
|
|
|
|
|
drawStrBlack(pi, x, y, from_ascii("["));
|
2008-02-28 12:45:36 +00:00
|
|
|
x += w;
|
2007-11-06 20:57:29 +00:00
|
|
|
cell(1).draw(pi, x, y);
|
|
|
|
x += cell(1).dimension(bv).wid;
|
|
|
|
drawStrBlack(pi, x, y, from_ascii("]"));
|
2008-02-28 12:46:32 +00:00
|
|
|
x += w + 2;
|
2007-11-06 20:57:29 +00:00
|
|
|
|
|
|
|
cell(2).draw(pi, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
void InsetMathMakebox::write(WriteStream & os) const
|
2007-11-06 20:57:29 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
ModeSpecifier specifier(os, TEXT_MODE);
|
2008-02-28 12:46:32 +00:00
|
|
|
os << (framebox_ ? "\\framebox" : "\\makebox");
|
2012-10-21 19:14:16 +00:00
|
|
|
if (!cell(0).empty() || !os.latex()) {
|
2008-02-28 12:46:32 +00:00
|
|
|
os << '[' << cell(0) << ']';
|
2012-10-21 19:14:16 +00:00
|
|
|
if (!cell(1).empty() || !os.latex())
|
2008-02-28 12:46:32 +00:00
|
|
|
os << '[' << cell(1) << ']';
|
|
|
|
}
|
2007-11-06 20:57:29 +00:00
|
|
|
os << '{' << cell(2) << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
void InsetMathMakebox::normalize(NormalStream & os) const
|
2007-11-06 20:57:29 +00:00
|
|
|
{
|
2008-02-28 12:46:32 +00:00
|
|
|
os << (framebox_ ? "[framebox " : "[makebox ")
|
|
|
|
<< cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
|
2007-11-06 20:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-28 12:46:32 +00:00
|
|
|
void InsetMathMakebox::infoize(odocstream & os) const
|
|
|
|
{
|
|
|
|
os << (framebox_ ? "Framebox" : "Makebox")
|
|
|
|
<< " (width: " << cell(0)
|
|
|
|
<< " pos: " << cell(1) << ")";
|
|
|
|
}
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
void InsetMathMakebox::mathmlize(MathStream & ms) const
|
|
|
|
{
|
|
|
|
// FIXME We could do something with the other arguments.
|
|
|
|
std::string const cssclass = framebox_ ? "framebox" : "makebox";
|
2011-04-01 22:34:40 +00:00
|
|
|
SetMode textmode(ms, true);
|
|
|
|
ms << MTag("mstyle", "class='" + cssclass + "'")
|
|
|
|
<< cell(2)
|
|
|
|
<< ETag("mstyle");
|
2009-12-31 20:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-30 02:37:05 +00:00
|
|
|
void InsetMathMakebox::htmlize(HtmlStream & ms) const
|
|
|
|
{
|
|
|
|
// FIXME We could do something with the other arguments.
|
2011-04-01 22:34:40 +00:00
|
|
|
SetHTMLMode textmode(ms, true);
|
2010-03-30 02:37:05 +00:00
|
|
|
std::string const cssclass = framebox_ ? "framebox" : "makebox";
|
2011-04-01 22:34:40 +00:00
|
|
|
ms << MTag("span", "class='" + cssclass + "'")
|
|
|
|
<< cell(2)
|
|
|
|
<< ETag("span");
|
2010-03-30 02:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
void InsetMathMakebox::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
// FIXME XHTML
|
|
|
|
// It'd be better to be able to get this from an InsetLayout, but at present
|
|
|
|
// InsetLayouts do not seem really to work for things that aren't InsetTexts.
|
2010-03-31 18:24:52 +00:00
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("mstyle.framebox { border: 1px solid black; }");
|
2010-03-31 18:24:52 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.framebox { border: 1px solid black; }");
|
2010-03-31 18:24:52 +00:00
|
|
|
InsetMathNest::validate(features);
|
2009-12-31 20:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetMathBoxed
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathBoxed::InsetMathBoxed(Buffer * buf)
|
|
|
|
: InsetMathNest(buf, 1)
|
2007-11-06 20:57:29 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
{
|
|
|
|
cell(0).metrics(mi, dim);
|
2017-01-06 08:52:10 +00:00
|
|
|
// 1 pixel space, 1 frame, 1 space
|
|
|
|
dim.wid += 2 * 3;
|
|
|
|
dim.asc += 3;
|
|
|
|
dim.des += 3;
|
2007-11-06 20:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
|
|
|
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
|
|
|
dim.width() - 2, dim.height() - 2, Color_foreground);
|
|
|
|
cell(0).draw(pi, x + 3, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathBoxed::write(WriteStream & os) const
|
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
ModeSpecifier specifier(os, MATH_MODE);
|
2007-11-06 20:57:29 +00:00
|
|
|
os << "\\boxed{" << cell(0) << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathBoxed::normalize(NormalStream & os) const
|
|
|
|
{
|
|
|
|
os << "[boxed " << cell(0) << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathBoxed::infoize(odocstream & os) const
|
|
|
|
{
|
|
|
|
os << "Boxed: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
void InsetMathBoxed::mathmlize(MathStream & ms) const
|
|
|
|
{
|
2011-04-01 22:34:40 +00:00
|
|
|
ms << MTag("mstyle", "class='boxed'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("mstyle");
|
2009-12-31 20:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-30 02:37:05 +00:00
|
|
|
void InsetMathBoxed::htmlize(HtmlStream & ms) const
|
|
|
|
{
|
2011-04-01 22:34:40 +00:00
|
|
|
ms << MTag("span", "class='boxed'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("span");
|
2010-03-30 02:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-06 20:57:29 +00:00
|
|
|
void InsetMathBoxed::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
features.require("amsmath");
|
2010-03-31 18:24:52 +00:00
|
|
|
|
2009-12-31 20:36:34 +00:00
|
|
|
// FIXME XHTML
|
|
|
|
// It'd be better to be able to get this from an InsetLayout, but at present
|
|
|
|
// InsetLayouts do not seem really to work for things that aren't InsetTexts.
|
2010-03-31 18:24:52 +00:00
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("mstyle.boxed { border: 1px solid black; }");
|
2010-03-31 18:24:52 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.boxed { border: 1px solid black; }");
|
2010-03-31 18:24:52 +00:00
|
|
|
|
2009-11-01 22:16:49 +00:00
|
|
|
InsetMathNest::validate(features);
|
2007-11-06 20:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|