2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathSubstack.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
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2002-02-14 14:52:23 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathSubstack.h"
|
2007-11-06 21:45:24 +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"
|
2002-02-14 14:52:23 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2005-04-03 12:07:49 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/gettext.h"
|
2005-04-03 12:07:49 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2008-05-06 10:36:32 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
using support::bformat;
|
|
|
|
|
2002-02-14 14:52:23 +00:00
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathSubstack::InsetMathSubstack()
|
|
|
|
: InsetMathGrid(1, 1)
|
2002-02-14 14:52:23 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathSubstack::clone() const
|
2002-02-14 14:52:23 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathSubstack(*this);
|
2002-02-14 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-02-14 14:52:23 +00:00
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
if (mi.base.style == LM_ST_DISPLAY) {
|
2003-03-21 14:20:48 +00:00
|
|
|
StyleChanger dummy(mi.base, LM_ST_TEXT);
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2002-05-30 07:09:54 +00:00
|
|
|
} else {
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2002-05-30 07:09:54 +00:00
|
|
|
}
|
2003-05-14 16:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
|
2003-05-14 16:29:25 +00:00
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::draw(pi, x + 1, y);
|
2003-05-14 16:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2005-04-03 12:07:49 +00:00
|
|
|
FuncStatus & flag) const
|
|
|
|
{
|
|
|
|
switch (cmd.action) {
|
|
|
|
case LFUN_TABULAR_FEATURE: {
|
2007-08-30 18:03:17 +00:00
|
|
|
string const name = "substack";
|
2006-09-01 15:41:38 +00:00
|
|
|
docstring const & s = cmd.argument();
|
2005-04-03 12:07:49 +00:00
|
|
|
if (s == "add-vline-left" || s == "add-vline-right") {
|
|
|
|
flag.message(bformat(
|
2007-08-30 18:03:17 +00:00
|
|
|
from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
|
|
|
|
from_utf8(name)));
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(false);
|
2005-04-03 12:07:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-09-16 18:11:38 +00:00
|
|
|
return InsetMathGrid::getStatus(cur, cmd, flag);
|
2005-04-03 12:07:49 +00:00
|
|
|
}
|
|
|
|
default:
|
2006-09-16 18:11:38 +00:00
|
|
|
return InsetMathGrid::getStatus(cur, cmd, flag);
|
2005-04-03 12:07:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathSubstack::infoize(odocstream & os) const
|
2003-05-14 16:29:25 +00:00
|
|
|
{
|
|
|
|
os << "Substack ";
|
2002-02-14 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathSubstack::write(WriteStream & os) const
|
2002-02-14 14:52:23 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
MathEnsurer ensurer(os);
|
2002-02-14 14:52:23 +00:00
|
|
|
os << "\\substack{";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::write(os);
|
2002-02-14 14:52:23 +00:00
|
|
|
os << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathSubstack::normalize(NormalStream & os) const
|
2002-02-14 14:52:23 +00:00
|
|
|
{
|
|
|
|
os << "[substack ";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::normalize(os);
|
2002-11-27 10:30:28 +00:00
|
|
|
os << ']';
|
2002-02-14 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathSubstack::maple(MapleStream & os) const
|
2002-02-14 14:52:23 +00:00
|
|
|
{
|
|
|
|
os << "substack(";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::maple(os);
|
2002-11-27 10:30:28 +00:00
|
|
|
os << ')';
|
2002-02-14 14:52:23 +00:00
|
|
|
}
|
2005-03-30 09:05:30 +00:00
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathSubstack::validate(LaTeXFeatures & features) const
|
2005-03-30 09:05:30 +00:00
|
|
|
{
|
|
|
|
features.require("amsmath");
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::validate(features);
|
2005-03-30 09:05:30 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|