]> git.lyx.org Git - lyx.git/blob - src/mathed/math_factory.C
Tweaking of the math panel dialogs from Martin...
[lyx.git] / src / mathed / math_factory.C
1 #include <config.h>
2
3 #include "math_parser.h"
4 #include "math_arrayinset.h"
5 #include "math_amsarrayinset.h"
6 #include "math_binominset.h"
7 #include "math_boxinset.h"
8 #include "math_casesinset.h"
9 #include "math_decorationinset.h"
10 #include "math_dotsinset.h"
11 #include "math_funcinset.h"
12 #include "math_funcliminset.h"
13 #include "math_fracinset.h"
14 #include "math_kerninset.h"
15 #include "math_lefteqninset.h"
16 #include "math_macro.h"
17 #include "math_macrotable.h"
18 #include "math_macroarg.h"
19 #include "math_notinset.h"
20 #include "math_rootinset.h"
21 #include "math_sizeinset.h"
22 #include "math_spaceinset.h"
23 #include "math_splitinset.h"
24 #include "math_specialcharinset.h"
25 #include "math_sqrtinset.h"
26 #include "math_stackrelinset.h"
27 #include "math_substackinset.h"
28 #include "math_symbolinset.h"
29 #include "math_undersetinset.h"
30 #include "math_unknowninset.h"
31 #include "math_xarrowinset.h"
32 #include "math_xymatrixinset.h"
33 #include "math_xyarrowinset.h"
34
35
36 MathAtom createMathInset(latexkeys const * l)
37 {
38         switch (l->token) {
39         case LM_TK_FUNCLIM:
40                 return MathAtom(new MathFuncLimInset(l->name));
41         case LM_TK_SPECIAL:
42                 return MathAtom(new MathSpecialCharInset(static_cast<char>(l->id)));
43         case LM_TK_SYM:
44         case LM_TK_CMR:
45         case LM_TK_CMSY:
46         case LM_TK_CMM:
47         case LM_TK_CMEX:
48         case LM_TK_MSA:
49         case LM_TK_MSB:
50                 return MathAtom(new MathSymbolInset(l));
51         case LM_TK_STACK:
52                 return MathAtom(new MathStackrelInset);
53         case LM_TK_UNDERSET:
54                 return MathAtom(new MathUndersetInset);
55         case LM_TK_KERN: 
56                 return MathAtom(new MathKernInset);
57         case LM_TK_BINOM:
58         case LM_TK_CHOOSE:
59                 return MathAtom(new MathBinomInset);
60         case LM_TK_OVER:
61         case LM_TK_FRAC:
62                 return MathAtom(new MathFracInset);
63         case LM_TK_ATOP:
64                 return MathAtom(new MathFracInset(true));
65         case LM_TK_NOT:
66                 return MathAtom(new MathNotInset);
67         case LM_TK_LEFTEQN:
68                 return MathAtom(new MathLefteqnInset);
69         case LM_TK_SQRT:
70                 return MathAtom(new MathSqrtInset);
71         case LM_TK_ROOT:
72                 return MathAtom(new MathRootInset);
73         case LM_TK_DECORATION:
74                 return MathAtom(new MathDecorationInset(l->name));
75         case LM_TK_SPACE:
76                 return MathAtom(new MathSpaceInset(l->id));
77         case LM_TK_DOTS:
78                 return MathAtom(new MathDotsInset(l->name));
79         case LM_TK_BOX:
80                 return MathAtom(new MathBoxInset(l->name));
81         case LM_TK_FUNC:
82                 return MathAtom(new MathFuncInset(l->name));
83         case LM_TK_STY:
84                 return MathAtom(new MathSizeInset(l));
85         default:
86                 return MathAtom(new MathUnknownInset(l->name));
87         }
88 }
89
90
91 MathAtom createMathInset(string const & s)
92 {
93         //cerr << "creating inset with name: '" << s << "'\n";
94         if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
95                 return MathAtom(new MathMacroArgument(s[1] - '0'));
96
97         if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
98                         && s[2] >= '1' && s[2] <= '9')
99                 return MathAtom(new MathMacroArgument(s[2] - '0'));
100
101         if (s == "xymatrix")
102                 return MathAtom(new MathXYMatrixInset);
103
104         if (s == "xrightarrow" || s == "xleftarrow")
105                 return MathAtom(new MathXArrowInset(s));
106
107         if (s == "split" || s == "gathered" || s == "aligned")
108                 return MathAtom(new MathSplitInset(s));
109
110         if (s == "cases")
111                 return MathAtom(new MathCasesInset);
112
113         if (s == "substack")
114                 return MathAtom(new MathSubstackInset);
115
116         if (s == "subarray" || s == "array")
117                 return MathAtom(new MathArrayInset(s, 1, 1));
118
119         if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix" ||
120                   s == "matrix") 
121                 return MathAtom(new MathAMSArrayInset(s));
122
123         latexkeys const * l = in_word_set(s);
124         if (l)
125                 return createMathInset(l);
126
127         if (MathMacroTable::has(s)) 
128                 return MathAtom(new MathMacro(s));
129
130         //cerr << "creating inset 2 with name: '" << s << "'\n";
131         return MathAtom(new MathUnknownInset(s));
132 }