]> git.lyx.org Git - lyx.git/blob - src/mathed/math_splitinset.C
macro rework
[lyx.git] / src / mathed / math_splitinset.C
1 /**
2  * \file math_splitinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_splitinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17
18
19 using std::string;
20 using std::auto_ptr;
21
22
23 MathSplitInset::MathSplitInset(string const & name)
24         : MathGridInset(1, 1), name_(name)
25 {
26         setDefaults();
27 }
28
29
30 auto_ptr<InsetBase> MathSplitInset::clone() const
31 {
32         return auto_ptr<InsetBase>(new MathSplitInset(*this));
33 }
34
35
36 char MathSplitInset::defaultColAlign(col_type col)
37 {
38         if (name_ == "split")
39                 return 'l';
40         if (name_ == "gathered")
41                 return 'c';
42         if (name_ == "aligned")
43                 return (col & 1) ? 'l' : 'r';
44         return 'l';
45 }
46
47
48 void MathSplitInset::write(WriteStream & ws) const
49 {
50         if (ws.fragile())
51                 ws << "\\protect";
52         ws << "\\begin{" << name_ << '}';
53         MathGridInset::write(ws);
54         if (ws.fragile())
55                 ws << "\\protect";
56         ws << "\\end{" << name_ << "}\n";
57 }