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"
38 HullType hullType(docstring const & name);
39 docstring hullName(HullType type);
43 Abstract base class for all math objects. A math insets is for use of the
44 math editor only, it isn't a general LyX inset. It's used to represent all
47 Math insets do not know there parents, a cursor position or things
48 like that. The are dumb object that are contained in other math insets
49 (InsetMathNests, in fact) thus forming a tree. The root of this tree is
50 always a InsetMathHull, which provides an interface to the Outer World by
51 inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
57 class InsetMathAMSArray;
65 class InsetMathMatrix;
67 class InsetMathScript;
68 class InsetMathString;
70 class InsetMathSpecialChar;
71 class InsetMathSymbol;
72 class InsetMathUnknown;
80 class MathematicaStream;
85 class MathMacroTemplate;
90 class TextMetricsInfo;
94 class InsetMath : public Inset {
96 /// identification as math inset
97 InsetMath * asInsetMath() { return this; }
98 /// identification as math inset
99 InsetMath const * asInsetMath() const { return this; }
100 /// this is overridden in math text insets (i.e. mbox)
101 bool inMathed() const { return true; }
103 /// this is overridden by specific insets
104 virtual mode_type currentMode() const { return MATH_MODE; }
106 /// the ascent of the inset above the baseline
107 /// compute the size of the object for text based drawing
108 virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
109 /// draw the object as text
110 virtual void drawT(TextPainter &, int x, int y) const;
112 /// return cell given its number
113 virtual MathData & cell(idx_type);
114 /// return cell given its number
115 virtual MathData const & cell(idx_type) const;
117 /// identifies certain types of insets
118 virtual InsetMathAMSArray * asAMSArrayInset() { return 0; }
119 virtual InsetMathAMSArray const * asAMSArrayInset() const { return 0; }
120 virtual InsetMathArray * asArrayInset() { return 0; }
121 virtual InsetMathArray const * asArrayInset() const { return 0; }
122 virtual InsetMathBrace * asBraceInset() { return 0; }
123 virtual InsetMathBrace const * asBraceInset() const { return 0; }
124 virtual InsetMathChar const * asCharInset() const { return 0; }
125 virtual InsetMathDelim * asDelimInset() { return 0; }
126 virtual InsetMathDelim const * asDelimInset() const { return 0; }
127 virtual InsetMathFrac * asFracInset() { return 0; }
128 virtual InsetMathFrac const * asFracInset() const { return 0; }
129 virtual InsetMathFont * asFontInset() { return 0; }
130 virtual InsetMathFont const * asFontInset() const { return 0; }
131 virtual InsetMathGrid * asGridInset() { return 0; }
132 virtual InsetMathGrid const * asGridInset() const { return 0; }
133 virtual InsetMathHull * asHullInset() { return 0; }
134 virtual InsetMathHull const * asHullInset() const { return 0; }
135 virtual MathMacro * asMacro() { return 0; }
136 virtual MathMacro const * asMacro() const { return 0; }
137 virtual MathMacroTemplate * asMacroTemplate() { return 0; }
138 virtual MathMacroTemplate const * asMacroTemplate() const { return 0; }
139 virtual InsetMathMatrix const * asMatrixInset() const { return 0; }
140 virtual InsetMathNest * asNestInset() { return 0; }
141 virtual InsetMathNest const * asNestInset() const { return 0; }
142 virtual InsetMathScript * asScriptInset() { return 0; }
143 virtual InsetMathScript const * asScriptInset() const { return 0; }
144 virtual InsetMathSpace * asSpaceInset() { return 0; }
145 virtual InsetMathSpace const * asSpaceInset() const { return 0; }
146 virtual InsetMathString * asStringInset() { return 0; }
147 virtual InsetMathString const * asStringInset() const { return 0; }
148 virtual InsetMathSymbol const * asSymbolInset() const { return 0; }
149 virtual InsetMathUnknown * asUnknownInset() { return 0; }
150 virtual InsetMathUnknown const * asUnknownInset() const { return 0; }
151 virtual InsetMathRef * asRefInset() { return 0; }
152 virtual InsetMathSpecialChar const * asSpecialCharInset() const { return 0; }
154 /// identifies things that can get scripts
155 virtual bool isScriptable() const { return false; }
156 /// is the a relational operator (used for splitting equations)
157 virtual bool isRelOp() const { return false; }
158 /// will this get written as a single block in {..}
159 virtual bool extraBraces() const { return false; }
161 /// return the content as char if the inset is able to do so
162 virtual char_type getChar() const { return 0; }
163 /// identifies things that can get \limits or \nolimits
164 virtual bool takesLimits() const { return false; }
166 /// char char code if possible
167 virtual void handleFont(docstring const &) {}
168 /// replace things by other things
169 virtual void replace(ReplaceData &) {}
170 /// do we contain a given subsequence?
171 virtual bool contains(MathData const &) const { return false; }
172 /// access to the lock (only nest array have one)
173 virtual bool lock() const { return false; }
174 /// access to the lock (only nest array have one)
175 virtual void lock(bool) {}
177 /// write LaTeX and Lyx code
178 virtual void write(WriteStream & os) const;
179 /// write normalized content
180 virtual void normalize(NormalStream &) const;
181 /// write content as something readable by Maple
182 virtual void maple(MapleStream &) const;
183 /// write content as something readable by Maxima
184 virtual void maxima(MaximaStream &) const;
185 /// write content as something readable by Mathematica
186 virtual void mathematica(MathematicaStream &) const;
187 /// write content as something resembling MathML
188 virtual void mathmlize(MathStream &) const;
189 /// write content as something readable by Octave
190 virtual void octave(OctaveStream &) const;
192 /// plain text output in ucs4 encoding
193 int plaintext(odocstream &, OutputParams const &) const;
195 /// dump content to stderr for debugging
196 virtual void dump() const;
199 virtual bool numberedType() const { return false; }
201 virtual HullType getType() const;
203 virtual void mutate(HullType /*newtype*/) {}
205 /// math stuff usually isn't allowed in text mode
206 virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
208 /// superscript kerning
209 virtual int kerning(BufferView const *) const { return 0; }
211 InsetCode lyxCode() const { return MATH_CODE; }
215 std::ostream & operator<<(std::ostream &, MathAtom const &);
217 odocstream & operator<<(odocstream &, MathAtom const &);