2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathTabular.C
|
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.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* 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"
|
|
|
|
|
#include "MathData.h"
|
|
|
|
|
#include "MathMLStream.h"
|
|
|
|
|
#include "MathStream.h"
|
2003-03-03 16:15:38 +00:00
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
#include "support/std_ostream.h"
|
|
|
|
|
|
2003-03-03 16:15:38 +00:00
|
|
|
|
#include <iterator>
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-03-03 16:15:38 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathTabular::InsetMathTabular(string const & name, int m, int n)
|
|
|
|
|
: InsetMathGrid(m, n), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathTabular::InsetMathTabular(string const & name, int m, int n,
|
2003-03-03 16:15:38 +00:00
|
|
|
|
char valign, string const & halign)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathGrid(m, n, valign, halign), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathTabular::InsetMathTabular(string const & name, char valign,
|
2003-03-03 16:15:38 +00:00
|
|
|
|
string const & halign)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathGrid(valign, halign), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathTabular::doClone() const
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathTabular(*this));
|
2003-03-03 16:15:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(mi.base, "textnormal");
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2005-04-04 22:11:53 +00:00
|
|
|
|
dim.wid += 6;
|
|
|
|
|
dim_ = 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
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(pi.base, "textnormal");
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::drawWithMargin(pi, x, y, 4, 2);
|
2003-03-03 16:15:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathTabular::write(WriteStream & os) const
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (os.fragile())
|
|
|
|
|
os << "\\protect";
|
|
|
|
|
os << "\\begin{" << name_ << '}';
|
|
|
|
|
|
|
|
|
|
if (v_align_ == 't' || v_align_ == 'b')
|
|
|
|
|
os << '[' << char(v_align_) << ']';
|
|
|
|
|
os << '{' << halign() << "}\n";
|
|
|
|
|
|
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_ << '}';
|
|
|
|
|
// adding a \n here is bad if the tabular is the last item
|
|
|
|
|
// in an \eqnarray...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathTabular::infoize(std::ostream & os) const
|
2005-04-03 12:07:49 +00:00
|
|
|
|
{
|
|
|
|
|
string 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
|