2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathTabular.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.
|
|
|
|
*/
|
2003-03-03 16:15:38 +00:00
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
#include <config.h>
|
2003-03-03 16:15:38 +00:00
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathTabular.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2003-03-03 16:15:38 +00:00
|
|
|
|
2016-06-04 08:41:13 +00:00
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
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
|
|
|
InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
|
|
|
|
int n)
|
|
|
|
: InsetMathGrid(buf, m, n), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
|
|
|
|
int n, char valign, docstring const & halign)
|
|
|
|
: InsetMathGrid(buf, m, n, valign, halign), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathTabular::clone() const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathTabular(*this);
|
2003-03-03 16:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = mi.base.changeFontSet("textnormal");
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2003-03-03 16:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
2016-05-23 21:30:23 +00:00
|
|
|
Changer dummy = pi.base.changeFontSet("textnormal");
|
2016-09-29 18:20:33 +00:00
|
|
|
InsetMathGrid::draw(pi, x, y);
|
2003-03-03 16:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:04:36 +00:00
|
|
|
void InsetMathTabular::write(TeXMathStream & os) const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
ModeSpecifier specifier(os, TEXT_MODE);
|
2008-06-16 01:21:17 +00:00
|
|
|
|
2003-03-03 16:15:38 +00:00
|
|
|
if (os.fragile())
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\begin{" << name_ << '}';
|
2015-10-07 03:13:21 +00:00
|
|
|
bool open = os.startOuterRow();
|
2003-03-03 16:15:38 +00:00
|
|
|
|
2008-03-15 08:43:16 +00:00
|
|
|
char const v = verticalAlignment();
|
|
|
|
if (v == 't' || v == 'b')
|
|
|
|
os << '[' << v << ']';
|
|
|
|
os << '{' << horizontalAlignments() << "}\n";
|
2003-03-03 16:15:38 +00:00
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::write(os);
|
2003-03-03 16:15:38 +00:00
|
|
|
|
|
|
|
if (os.fragile())
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\end{" << name_ << '}';
|
2015-10-07 03:13:21 +00:00
|
|
|
if (open)
|
|
|
|
os.startOuterRow();
|
2003-03-03 16:15:38 +00:00
|
|
|
// adding a \n here is bad if the tabular is the last item
|
|
|
|
// in an \eqnarray...
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathTabular::infoize(odocstream & os) const
|
2005-04-03 12:07:49 +00:00
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring name = name_;
|
2006-10-21 00:16:43 +00:00
|
|
|
name[0] = support::uppercase(name[0]);
|
2005-04-03 12:07:49 +00:00
|
|
|
os << name << ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathTabular::normalize(NormalStream & os) const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
|
|
|
os << '[' << name_ << ' ';
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::normalize(os);
|
2003-03-03 16:15:38 +00:00
|
|
|
os << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathTabular::maple(MapleStream & os) const
|
2003-03-03 16:15:38 +00:00
|
|
|
{
|
|
|
|
os << "array(";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::maple(os);
|
2003-03-03 16:15:38 +00:00
|
|
|
os << ')';
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|