]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMath.h
Remove unused method in ArgumentProxy
[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 "MathClass.h"
17
18 #include "insets/Inset.h"
19
20
21 namespace lyx {
22
23 enum HullType {
24         hullNone,
25         hullSimple,
26         hullEquation,
27         hullEqnArray,
28         hullAlign,
29         hullAlignAt,
30         hullXAlignAt,
31         hullXXAlignAt,
32         hullFlAlign,
33         hullMultline,
34         hullGather,
35         hullRegexp,
36         hullUnknown
37 };
38
39 HullType hullType(docstring const & name);
40 docstring hullName(HullType type);
41
42 /**
43
44 Abstract base class for all math objects.  A math insets is for use of the
45 math editor only, it isn't a general LyX inset. It's used to represent all
46 the math objects.
47
48 Math insets do not know their parents, a cursor position or things
49 like that. They are dumb objects that are contained in other math insets
50 (InsetMathNests, in fact) thus forming a tree. The root of this tree is
51 always a InsetMathHull, which provides an interface to the Outer World by
52 inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
53
54 */
55
56 class Cursor;
57 class OutputParams;
58 class MetricsInfo;
59
60 class InsetMathArray;
61 class InsetMathAMSArray;
62 class InsetMathBrace;
63 class InsetMathChar;
64 class InsetMathDelim;
65 class InsetMathFracBase;
66 class InsetMathFrac;
67 class InsetMathFont;
68 class InsetMathGrid;
69 class InsetMathHull;
70 class InsetMathMatrix;
71 class InsetMathNest;
72 class InsetMathScript;
73 class InsetMathString;
74 class InsetMathSpace;
75 class InsetMathSpecialChar;
76 class InsetMathSymbol;
77 class InsetMathUnknown;
78 class InsetMathRef;
79
80 class HtmlStream;
81 class NormalStream;
82 class OctaveStream;
83 class MapleStream;
84 class MaximaStream;
85 class MathematicaStream;
86 class MathStream;
87 class WriteStream;
88
89 class MathData;
90 class MathMacroTemplate;
91 class MathMacro;
92 class MathRow;
93 class TextPainter;
94 class TextMetricsInfo;
95 class ReplaceData;
96
97 /// Type of unique identifiers for math insets (used in TexRow)
98 typedef void const * uid_type;
99
100
101 class InsetMath : public Inset {
102 public:
103         ///
104         InsetMath(Buffer * buf = 0) : Inset(buf) {}
105         /// identification as math inset
106         InsetMath * asInsetMath() { return this; }
107         /// identification as math inset
108         InsetMath const * asInsetMath() const { return this; }
109         /// this is overridden in math text insets (i.e. mbox)
110         bool inMathed() const { return true; }
111         ///
112         virtual docstring name() const;
113
114         /// this is overridden by specific insets
115         virtual mode_type currentMode() const { return MATH_MODE; }
116
117         /// the ascent of the inset above the baseline
118         /// compute the size of the object for text based drawing
119         virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
120         /// draw the object as text
121         virtual void drawT(TextPainter &, int x, int y) const;
122
123         /// return cell given its number
124         virtual MathData & cell(idx_type);
125         /// return cell given its number
126         virtual MathData const & cell(idx_type) const;
127
128         /// identifies certain types of insets
129         virtual InsetMathAMSArray       * asAMSArrayInset()       { return 0; }
130         virtual InsetMathAMSArray const * asAMSArrayInset() const { return 0; }
131         virtual InsetMathArray          * asArrayInset()          { return 0; }
132         virtual InsetMathArray const    * asArrayInset() const    { return 0; }
133         virtual InsetMathBrace          * asBraceInset()          { return 0; }
134         virtual InsetMathBrace const    * asBraceInset() const    { return 0; }
135         virtual InsetMathChar const     * asCharInset() const     { return 0; }
136         virtual InsetMathDelim          * asDelimInset()          { return 0; }
137         virtual InsetMathDelim const    * asDelimInset() const    { return 0; }
138         virtual InsetMathFracBase       * asFracBaseInset()       { return 0; }
139         virtual InsetMathFracBase const * asFracBaseInset() const { return 0; }
140         virtual InsetMathFrac           * asFracInset()           { return 0; }
141         virtual InsetMathFrac const     * asFracInset() const     { return 0; }
142         virtual InsetMathFont           * asFontInset()           { return 0; }
143         virtual InsetMathFont const     * asFontInset() const     { return 0; }
144         virtual InsetMathGrid           * asGridInset()           { return 0; }
145         virtual InsetMathGrid const     * asGridInset() const     { return 0; }
146         virtual InsetMathHull           * asHullInset()           { return 0; }
147         virtual InsetMathHull const     * asHullInset() const     { return 0; }
148         virtual MathMacro               * asMacro()               { return 0; }
149         virtual MathMacro const         * asMacro() const         { return 0; }
150         virtual MathMacroTemplate       * asMacroTemplate()       { return 0; }
151         virtual MathMacroTemplate const * asMacroTemplate() const { return 0; }
152         virtual InsetMathMatrix const   * asMatrixInset() const   { return 0; }
153         virtual InsetMathNest           * asNestInset()           { return 0; }
154         virtual InsetMathNest const     * asNestInset() const     { return 0; }
155         virtual InsetMathScript         * asScriptInset()         { return 0; }
156         virtual InsetMathScript const   * asScriptInset() const   { return 0; }
157         virtual InsetMathSpace          * asSpaceInset()          { return 0; }
158         virtual InsetMathSpace const    * asSpaceInset() const    { return 0; }
159         virtual InsetMathString         * asStringInset()         { return 0; }
160         virtual InsetMathString const   * asStringInset() const   { return 0; }
161         virtual InsetMathSymbol const   * asSymbolInset() const   { return 0; }
162         virtual InsetMathUnknown        * asUnknownInset()        { return 0; }
163         virtual InsetMathUnknown const  * asUnknownInset() const  { return 0; }
164         virtual InsetMathRef            * asRefInset()            { return 0; }
165         virtual InsetMathSpecialChar const * asSpecialCharInset() const { return 0; }
166
167         /// The class of the math object (used primarily for spacing)
168         virtual MathClass mathClass() const;
169         /// Add this inset to a math row. Return true if contents got added
170         virtual bool addToMathRow(MathRow &, MetricsInfo & mi) const;
171
172         /// draw four angular markers
173         void drawMarkers(PainterInfo & pi, int x, int y) const;
174         /// draw two angular markers
175         void drawMarkers2(PainterInfo & pi, int x, int y) const;
176         /// add space for markers
177         void metricsMarkers(MetricsInfo & mi, Dimension & dim, int framesize = 1) const;
178         /// add space for markers
179         void metricsMarkers2(MetricsInfo & mi, Dimension & dim, int framesize = 1) const;
180
181         /// identifies things that can get scripts
182         virtual bool isScriptable() const { return false; }
183         /// will this get written as a single block in {..}
184         virtual bool extraBraces() const { return false; }
185
186         /// return the content as char if the inset is able to do so
187         virtual char_type getChar() const { return 0; }
188         /// identifies things that can get \limits or \nolimits
189         virtual bool takesLimits() const { return false; }
190
191         /// replace things by other things
192         virtual void replace(ReplaceData &) {}
193         /// do we contain a given subsequence?
194         virtual bool contains(MathData const &) const { return false; }
195         /// access to the lock (only nest array have one)
196         virtual bool lock() const { return false; }
197         /// access to the lock (only nest array have one)
198         virtual void lock(bool) {}
199
200         // Indicate that we do not want to hide the normal version of
201         // write(). This is to shut off a clang warning.
202         using Inset::write;
203         /// write LaTeX and LyX code
204         virtual void write(WriteStream & os) const;
205         /// write normalized content
206         virtual void normalize(NormalStream &) const;
207         /// write content as something readable by Maple
208         virtual void maple(MapleStream &) const;
209         /// write content as something readable by Maxima
210         virtual void maxima(MaximaStream &) const;
211         /// write content as something readable by Mathematica
212         virtual void mathematica(MathematicaStream &) const;
213         /// write content as MathML
214         virtual void mathmlize(MathStream &) const;
215         /// write content as HTML, best we can.
216         /// the idea for this, and some of the details, come from
217         /// eLyXer, written by Alex Fernandez. no code is borrowed. rather,
218         /// we try to mimic how eLyXer outputs some math.
219         virtual void htmlize(HtmlStream &) const;
220         /// write content as something readable by Octave
221         virtual void octave(OctaveStream &) const;
222
223         /// plain text output in ucs4 encoding
224         int plaintext(odocstringstream &, OutputParams const &, size_t) const;
225
226         /// dump content to stderr for debugging
227         virtual void dump() const;
228
229         /// LyXInset stuff
230         virtual bool numberedType() const { return false; }
231         /// hull type
232         virtual HullType getType() const;
233         /// change type
234         virtual void mutate(HullType /*newtype*/) {}
235
236         /// math stuff usually isn't allowed in text mode
237         virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
238
239         /// superscript kerning
240         virtual int kerning(BufferView const *) const { return 0; }
241         ///
242         bool isInToc() const { return true; }
243         ///
244         InsetCode lyxCode() const { return MATH_CODE; }
245         ///
246         uid_type id() const { return this; }
247 };
248
249 ///
250 std::ostream & operator<<(std::ostream &, MathAtom const &);
251 ///
252 odocstream & operator<<(odocstream &, MathAtom const &);
253
254 // initialize math
255 void initMath();
256
257
258 } // namespace lyx
259
260 #endif