2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_tabularinset.C
|
|
|
|
|
* 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
|
|
|
|
|
|
|
|
|
#include "math_tabularinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2003-03-03 16:15:38 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
|
|
|
|
#include "math_streamstr.h"
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-03-03 16:15:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathTabularInset::MathTabularInset(string const & name, int m, int n)
|
|
|
|
|
: MathGridInset(m, n), name_(name)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathTabularInset::MathTabularInset(string const & name, int m, int n,
|
|
|
|
|
char valign, string const & halign)
|
|
|
|
|
: MathGridInset(m, n, valign, halign), name_(name)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathTabularInset::MathTabularInset(string const & name, char valign,
|
|
|
|
|
string const & halign)
|
|
|
|
|
: MathGridInset(valign, halign), name_(name)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathTabularInset::doClone() const
|
2003-03-03 16:15:38 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathTabularInset(*this));
|
2003-03-03 16:15:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-04 22:11:53 +00:00
|
|
|
|
void MathTabularInset::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");
|
2005-04-04 22:11:53 +00:00
|
|
|
|
MathGridInset::metrics(mi, dim);
|
|
|
|
|
dim.wid += 6;
|
|
|
|
|
dim_ = dim;
|
2003-03-03 16:15:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathTabularInset::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");
|
2005-04-04 22:11:53 +00:00
|
|
|
|
MathGridInset::drawWithMargin(pi, x, y, 4, 2);
|
2003-03-03 16:15:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathTabularInset::write(WriteStream & os) const
|
|
|
|
|
{
|
|
|
|
|
if (os.fragile())
|
|
|
|
|
os << "\\protect";
|
|
|
|
|
os << "\\begin{" << name_ << '}';
|
|
|
|
|
|
|
|
|
|
if (v_align_ == 't' || v_align_ == 'b')
|
|
|
|
|
os << '[' << char(v_align_) << ']';
|
|
|
|
|
os << '{' << halign() << "}\n";
|
|
|
|
|
|
|
|
|
|
MathGridInset::write(os);
|
|
|
|
|
|
|
|
|
|
if (os.fragile())
|
|
|
|
|
os << "\\protect";
|
|
|
|
|
os << "\\end{" << name_ << '}';
|
|
|
|
|
// adding a \n here is bad if the tabular is the last item
|
|
|
|
|
// in an \eqnarray...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
void MathTabularInset::infoize(std::ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
string name = name_;
|
|
|
|
|
name[0] = lyx::support::uppercase(name[0]);
|
|
|
|
|
os << name << ' ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-03 16:15:38 +00:00
|
|
|
|
void MathTabularInset::normalize(NormalStream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << '[' << name_ << ' ';
|
|
|
|
|
MathGridInset::normalize(os);
|
|
|
|
|
os << ']';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathTabularInset::maple(MapleStream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << "array(";
|
|
|
|
|
MathGridInset::maple(os);
|
|
|
|
|
os << ')';
|
|
|
|
|
}
|