]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.h
Fix command-line export
[lyx.git] / src / mathed / InsetMath.h
1 // -*- C++ -*-
2 /**
3  * \file InsetMath.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author André Pönitz
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_INSET_H
14 #define MATH_INSET_H
15
16 #include "MathData.h"
17
18 #include "insets/insetbase.h"
19
20 #include <string>
21
22 enum HullType {
23         hullNone,
24         hullSimple,
25         hullEquation,
26         hullEqnArray,
27         hullAlign,
28         hullAlignAt,
29         hullXAlignAt,
30         hullXXAlignAt,
31         hullFlAlign,
32         hullMultline,
33         hullGather
34 };
35
36 HullType hullType(std::string const & name);
37 std::string hullName(HullType type);
38
39 /**
40
41 Abstract base class for all math objects.  A math insets is for use of the
42 math editor only, it isn't a general LyX inset. It's used to represent all
43 the math objects.
44
45 Math insets do not know there parents, a cursor position or things
46 like that. The are dumb object that are contained in other math insets
47 (InsetMathNests, in fact) thus forming a tree. The root of this tree is
48 always a InsetMathHull, which provides an interface to the Outer World by
49 inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
50
51 */
52
53 class OutputParams;
54 class InsetMathArray;
55 class InsetMathAMSArray;
56 class InsetMathBrace;
57 class InsetMathChar;
58 class InsetMathDelim;
59 class InsetMathFrac;
60 class InsetMathFont;
61 class InsetMathGrid;
62 class InsetMathHull;
63 class InsetMathMatrix;
64 class InsetMathNest;
65 class InsetMathParbox;
66 class InsetMathScript;
67 class InsetMathString;
68 class InsetMathSpace;
69 class InsetMathSymbol;
70 class InsetMathUnknown;
71
72 class RefInset;
73
74 class NormalStream;
75 class OctaveStream;
76 class MapleStream;
77 class MaximaStream;
78 class MathematicaStream;
79 class MathMLStream;
80 class WriteStream;
81 class InfoStream;
82
83 class MathMacroTemplate;
84 class MathMacro;
85 class MathPosFinder;
86 class Dimension;
87 class LCursor;
88 class TextPainter;
89 class TextMetricsInfo;
90 class ReplaceData;
91
92
93 class InsetMath : public InsetBase {
94 public:
95         /// identification as math inset
96         InsetMath * asInsetMath() { return this; }
97         /// this is overridden in math text insets (i.e. mbox)
98         bool inMathed() const { return true; }
99
100         /// the ascent of the inset above the baseline
101         /// compute the size of the object for text based drawing
102         virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
103         /// draw the object as text
104         virtual void drawT(TextPainter &, int x, int y) const;
105
106         /// return cell given its number
107         virtual MathArray & cell(idx_type);
108         /// return cell given its number
109         virtual MathArray const & cell(idx_type) const;
110
111         /// identifies certain types of insets
112         virtual InsetMathAMSArray       * asAMSArrayInset()       { return 0; }
113         virtual InsetMathAMSArray const * asAMSArrayInset() const { return 0; }
114         virtual InsetMathArray          * asArrayInset()          { return 0; }
115         virtual InsetMathArray const    * asArrayInset() const    { return 0; }
116         virtual InsetMathBrace const    * asBraceInset() const    { return 0; }
117         virtual InsetMathChar const     * asCharInset() const     { return 0; }
118         virtual InsetMathDelim          * asDelimInset()          { return 0; }
119         virtual InsetMathDelim const    * asDelimInset() const    { return 0; }
120         virtual InsetMathFrac           * asFracInset()           { return 0; }
121         virtual InsetMathFrac const     * asFracInset() const     { return 0; }
122         virtual InsetMathFont           * asFontInset()           { return 0; }
123         virtual InsetMathFont const     * asFontInset() const     { return 0; }
124         virtual InsetMathGrid           * asGridInset()           { return 0; }
125         virtual InsetMathGrid const     * asGridInset() const     { return 0; }
126         virtual InsetMathHull           * asHullInset()           { return 0; }
127         virtual InsetMathHull const     * asHullInset() const     { return 0; }
128         virtual MathMacro               * asMacro()               { return 0; }
129         virtual MathMacro const         * asMacro() const         { return 0; }
130         virtual MathMacroTemplate       * asMacroTemplate()       { return 0; }
131         virtual MathMacroTemplate const * asMacroTemplate() const { return 0; }
132         virtual InsetMathMatrix const   * asMatrixInset() const   { return 0; }
133         virtual InsetMathNest           * asNestInset()           { return 0; }
134         virtual InsetMathNest const     * asNestInset() const     { return 0; }
135         virtual InsetMathParbox         * asParboxInset()         { return 0; }
136         virtual InsetMathScript         * asScriptInset()         { return 0; }
137         virtual InsetMathScript const   * asScriptInset() const   { return 0; }
138         virtual InsetMathSpace          * asSpaceInset()          { return 0; }
139         virtual InsetMathSpace const    * asSpaceInset() const    { return 0; }
140         virtual InsetMathString         * asStringInset()         { return 0; }
141         virtual InsetMathString const   * asStringInset() const   { return 0; }
142         virtual InsetMathSymbol const   * asSymbolInset() const   { return 0; }
143         virtual InsetMathUnknown        * asUnknownInset()        { return 0; }
144         virtual InsetMathUnknown const  * asUnknownInset() const  { return 0; }
145         virtual RefInset                * asRefInset()            { return 0; }
146
147         /// identifies things that can get scripts
148         virtual bool isScriptable() const { return false; }
149         /// is the a relational operator (used for splitting equations)
150         virtual bool isRelOp() const { return false; }
151         /// will this get written as a single block in {..}
152         virtual bool extraBraces() const { return false; }
153
154         /// return the content as char if the inset is able to do so
155         virtual char getChar() const { return 0; }
156         /// identifies things that can get \limits or \nolimits
157         virtual bool takesLimits() const { return false; }
158
159         /// char char code if possible
160         virtual void handleFont(std::string const &) {}
161         /// replace things by other things
162         virtual void replace(ReplaceData &) {}
163         /// do we contain a given subsequence?
164         virtual bool contains(MathArray const &) const { return false; }
165         /// access to the lock (only nest array have one)
166         virtual bool lock() const { return false; }
167         /// access to the lock (only nest array have one)
168         virtual void lock(bool) {}
169
170         /// write LaTeX and Lyx code
171         virtual void write(WriteStream & os) const;
172         /// write normalized content
173         virtual void normalize(NormalStream &) const;
174         /// write content as something readable by Maple
175         virtual void maple(MapleStream &) const;
176         /// write content as something readable by Maxima
177         virtual void maxima(MaximaStream &) const;
178         /// write content as something readable by Mathematica
179         virtual void mathematica(MathematicaStream &) const;
180         /// write content as something resembling MathML
181         virtual void mathmlize(MathMLStream &) const;
182         /// write content as something readable by Octave
183         virtual void octave(OctaveStream &) const;
184
185         /// dump content to stderr for debugging
186         virtual void dump() const;
187
188         /// LyXInset stuff
189         virtual bool numberedType() const { return false; }
190         /// hull type
191         virtual HullType getType() const;
192         /// change type
193         virtual void mutate(HullType /*newtype*/) {}
194         /// usually the latex name
195         virtual std::string name() const;
196
197         /// math stuff usually isn't allowed in text mode
198         virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
199 };
200
201 std::ostream & operator<<(std::ostream &, MathAtom const &);
202
203 // initialize math
204 void initMath();
205
206 #endif