4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alejandro Aguilar Sierra
10 * Full author contact details are available in file CREDITS.
18 #include "insets/Inset.h"
37 HullType hullType(docstring const & name);
38 docstring hullName(HullType type);
42 Abstract base class for all math objects. A math insets is for use of the
43 math editor only, it isn't a general LyX inset. It's used to represent all
46 Math insets do not know there parents, a cursor position or things
47 like that. The are dumb object that are contained in other math insets
48 (InsetMathNests, in fact) thus forming a tree. The root of this tree is
49 always a InsetMathHull, which provides an interface to the Outer World by
50 inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
56 class InsetMathAMSArray;
64 class InsetMathMatrix;
66 class InsetMathScript;
67 class InsetMathString;
69 class InsetMathSpecialChar;
70 class InsetMathSymbol;
71 class InsetMathUnknown;
79 class MathematicaStream;
84 class MathMacroTemplate;
89 class TextMetricsInfo;
93 class InsetMath : public Inset {
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; }
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;
106 /// return cell given its number
107 virtual MathData & cell(idx_type);
108 /// return cell given its number
109 virtual MathData const & cell(idx_type) const;
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 * asBraceInset() { return 0; }
117 virtual InsetMathBrace const * asBraceInset() const { return 0; }
118 virtual InsetMathChar const * asCharInset() const { return 0; }
119 virtual InsetMathDelim * asDelimInset() { return 0; }
120 virtual InsetMathDelim const * asDelimInset() const { return 0; }
121 virtual InsetMathFrac * asFracInset() { return 0; }
122 virtual InsetMathFrac const * asFracInset() const { return 0; }
123 virtual InsetMathFont * asFontInset() { return 0; }
124 virtual InsetMathFont const * asFontInset() const { return 0; }
125 virtual InsetMathGrid * asGridInset() { return 0; }
126 virtual InsetMathGrid const * asGridInset() const { return 0; }
127 virtual InsetMathHull * asHullInset() { return 0; }
128 virtual InsetMathHull const * asHullInset() const { return 0; }
129 virtual MathMacro * asMacro() { return 0; }
130 virtual MathMacro const * asMacro() const { return 0; }
131 virtual MathMacroTemplate * asMacroTemplate() { return 0; }
132 virtual MathMacroTemplate const * asMacroTemplate() const { return 0; }
133 virtual InsetMathMatrix const * asMatrixInset() const { return 0; }
134 virtual InsetMathNest * asNestInset() { return 0; }
135 virtual InsetMathNest const * asNestInset() const { 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 InsetMathRef * asRefInset() { return 0; }
146 virtual InsetMathSpecialChar const * asSpecialCharInset() const { return 0; }
148 /// identifies things that can get scripts
149 virtual bool isScriptable() const { return false; }
150 /// is the a relational operator (used for splitting equations)
151 virtual bool isRelOp() const { return false; }
152 /// will this get written as a single block in {..}
153 virtual bool extraBraces() const { return false; }
155 /// return the content as char if the inset is able to do so
156 virtual char_type getChar() const { return 0; }
157 /// identifies things that can get \limits or \nolimits
158 virtual bool takesLimits() const { return false; }
160 /// char char code if possible
161 virtual void handleFont(docstring const &) {}
162 /// replace things by other things
163 virtual void replace(ReplaceData &) {}
164 /// do we contain a given subsequence?
165 virtual bool contains(MathData const &) const { return false; }
166 /// access to the lock (only nest array have one)
167 virtual bool lock() const { return false; }
168 /// access to the lock (only nest array have one)
169 virtual void lock(bool) {}
171 /// write LaTeX and Lyx code
172 virtual void write(WriteStream & os) const;
173 /// write normalized content
174 virtual void normalize(NormalStream &) const;
175 /// write content as something readable by Maple
176 virtual void maple(MapleStream &) const;
177 /// write content as something readable by Maxima
178 virtual void maxima(MaximaStream &) const;
179 /// write content as something readable by Mathematica
180 virtual void mathematica(MathematicaStream &) const;
181 /// write content as something resembling MathML
182 virtual void mathmlize(MathStream &) const;
183 /// write content as something readable by Octave
184 virtual void octave(OctaveStream &) const;
186 /// plain text output in ucs4 encoding
187 int plaintext(odocstream &, OutputParams const &) const;
189 /// dump content to stderr for debugging
190 virtual void dump() const;
193 virtual bool numberedType() const { return false; }
195 virtual HullType getType() const;
197 virtual void mutate(HullType /*newtype*/) {}
199 /// math stuff usually isn't allowed in text mode
200 virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
202 /// superscript kerning
203 virtual int kerning(BufferView const *) const { return 0; }
207 std::ostream & operator<<(std::ostream &, MathAtom const &);
209 odocstream & operator<<(odocstream &, MathAtom const &);