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"
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "MathStream.h"
|
2003-03-03 16:15:38 +00:00
|
|
|
|
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 {
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n)
|
2006-09-16 18:11:38 +00:00
|
|
|
: InsetMathGrid(m, n), name_(name)
|
2003-03-03 16:15:38 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
|
|
|
|
char valign, docstring 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
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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;
|
2007-09-23 22:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dimension const InsetMathTabular::dimension(BufferView const & bv) const
|
|
|
|
{
|
|
|
|
Dimension dim = InsetMathGrid::dimension(bv);
|
|
|
|
dim.wid += 6;
|
|
|
|
return 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
|
|
|
{
|
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_ << '}';
|
|
|
|
|
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_ << '}';
|
|
|
|
// 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
|