Parse optional arguments of aligned, gathered and alignedat

* src/mathed/InsetMathSplit.[Ch]
	(InsetMathSplit): Add valignment argument to constructor

	* src/mathed/InsetMathSplit.C
	(InsetMathSplit::write): write vertical alignment if needed

	* src/mathed/MathParser.C
	(Parser::parse1): parse optional arguments of aligned, gathered and
	alignedat


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15202 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-10-02 20:01:30 +00:00
parent 5070d2f660
commit 8a9d0934e9
3 changed files with 15 additions and 7 deletions

View File

@ -30,10 +30,9 @@ using std::string;
using std::auto_ptr;
InsetMathSplit::InsetMathSplit(string const & name)
: InsetMathGrid(1, 1), name_(name)
InsetMathSplit::InsetMathSplit(string const & name, char valign)
: InsetMathGrid(1, 1, valign, string()), name_(name)
{
setDefaults();
}
@ -90,6 +89,8 @@ void InsetMathSplit::write(WriteStream & ws) const
if (ws.fragile())
ws << "\\protect";
ws << "\\begin{" << name_ << '}';
if (name_ != "split" && valign() != 'c')
ws << '[' << valign() << ']';
if (name_ == "alignedat")
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
InsetMathGrid::write(ws);

View File

@ -18,7 +18,7 @@
class InsetMathSplit : public InsetMathGrid {
public:
///
explicit InsetMathSplit(std::string const & name);
explicit InsetMathSplit(std::string const & name, char valign = 'c');
///
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -54,6 +54,7 @@ following hack as starting point to write some macros:
#include "InsetMathRef.h"
#include "InsetMathRoot.h"
#include "InsetMathScript.h"
#include "InsetMathSplit.h"
#include "InsetMathSqrt.h"
#include "InsetMathTabular.h"
#include "MathMacroTemplate.h"
@ -1099,16 +1100,22 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
}
else if (name == "split" || name == "cases" ||
name == "gathered" || name == "aligned") {
else if (name == "split" || name == "cases") {
cell->push_back(createInsetMath(name));
parse2(cell->back(), FLAG_END, mode, false);
}
else if (name == "gathered" || name == "aligned") {
string const valign = parse_verbatim_option() + 'c';
cell->push_back(MathAtom(new InsetMathSplit(name, valign[0])));
parse2(cell->back(), FLAG_END, mode, false);
}
else if (name == "alignedat") {
string const valign = parse_verbatim_option() + 'c';
// ignore this for a while
getArg('{', '}');
cell->push_back(createInsetMath(name));
cell->push_back(MathAtom(new InsetMathSplit(name, valign[0])));
parse2(cell->back(), FLAG_END, mode, false);
}