]> git.lyx.org Git - features.git/commitdiff
Parse optional arguments of aligned, gathered and alignedat
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 2 Oct 2006 20:01:30 +0000 (20:01 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 2 Oct 2006 20:01:30 +0000 (20:01 +0000)
* 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

src/mathed/InsetMathSplit.C
src/mathed/InsetMathSplit.h
src/mathed/MathParser.C

index b78c5708f332a15f2b343a83a79b537c49f0e5be..606191e1fd405affd6c91a261688b53728b873a2 100644 (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);
index b77b0db3f1d142688d4ada4902b968f36dfe9138..327b3010d6135bd613fb9b0760945b3a8b3a96aa 100644 (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;
index f71fccab460081e952a3ef93c4bf310e3dbf1824..f2196d2175f95c08ed3f4f686c58514dadb255a8 100644 (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);
                        }