2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_splitinset.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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2001-09-05 12:57:13 +00:00
|
|
|
|
#include "math_splitinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2002-02-15 14:50:40 +00:00
|
|
|
|
#include "math_streamstr.h"
|
2001-09-05 12:57:13 +00:00
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
#include "funcrequest.h"
|
|
|
|
|
#include "FuncStatus.h"
|
|
|
|
|
#include "gettext.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
#include "support/std_ostream.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using lyx::support::bformat;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2001-09-05 12:57:13 +00:00
|
|
|
|
|
2002-02-15 14:50:40 +00:00
|
|
|
|
MathSplitInset::MathSplitInset(string const & name)
|
|
|
|
|
: MathGridInset(1, 1), name_(name)
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
|
|
|
|
setDefaults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathSplitInset::doClone() const
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathSplitInset(*this));
|
2001-09-05 12:57:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-02-15 14:50:40 +00:00
|
|
|
|
char MathSplitInset::defaultColAlign(col_type col)
|
|
|
|
|
{
|
|
|
|
|
if (name_ == "split")
|
|
|
|
|
return 'l';
|
|
|
|
|
if (name_ == "gathered")
|
|
|
|
|
return 'c';
|
|
|
|
|
if (name_ == "aligned")
|
|
|
|
|
return (col & 1) ? 'l' : 'r';
|
2004-08-14 14:03:42 +00:00
|
|
|
|
if (name_ == "alignedat")
|
|
|
|
|
return (col & 1) ? 'l' : 'r';
|
2002-02-15 14:50:40 +00:00
|
|
|
|
return 'l';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-04 13:40:27 +00:00
|
|
|
|
void MathSplitInset::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
MathGridInset::draw(pi, x, y);
|
|
|
|
|
setPosCache(pi, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
bool MathSplitInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|
|
|
|
FuncStatus & flag) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
case LFUN_TABULAR_FEATURE: {
|
|
|
|
|
string const s = cmd.argument;
|
|
|
|
|
if (s == "add-vline-left" || s == "add-vline-right") {
|
|
|
|
|
flag.message(bformat(
|
|
|
|
|
N_("Can't add vertical grid lines in '%1$s'"),
|
|
|
|
|
name_));
|
|
|
|
|
flag.enabled(false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return MathGridInset::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return MathGridInset::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
void MathSplitInset::write(WriteStream & ws) const
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
|
if (ws.fragile())
|
|
|
|
|
ws << "\\protect";
|
2002-11-27 10:30:28 +00:00
|
|
|
|
ws << "\\begin{" << name_ << '}';
|
2005-10-14 10:50:23 +00:00
|
|
|
|
if (name_ == "alignedat")
|
|
|
|
|
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
2001-12-03 16:24:50 +00:00
|
|
|
|
MathGridInset::write(ws);
|
|
|
|
|
if (ws.fragile())
|
|
|
|
|
ws << "\\protect";
|
2002-02-15 14:50:40 +00:00
|
|
|
|
ws << "\\end{" << name_ << "}\n";
|
2001-09-05 12:57:13 +00:00
|
|
|
|
}
|
2005-04-03 12:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathSplitInset::infoize(std::ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
string name = name_;
|
|
|
|
|
name[0] = lyx::support::uppercase(name[0]);
|
|
|
|
|
os << name << ' ';
|
|
|
|
|
}
|