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