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