3 * \file math_scriptinset.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef MATH_SCRIPTINSET_H
13 #define MATH_SCRIPTINSET_H
15 #include "math_nestinset.h"
18 /// An inset for super- and subscripts.
19 class MathScriptInset : public MathNestInset {
21 /// create inset without scripts
23 /// create inset with single script
24 explicit MathScriptInset(bool up);
25 /// create inset with single script and given nucleus
26 MathScriptInset(MathAtom const & at, bool up);
28 virtual std::auto_ptr<InsetBase> clone() const;
30 void metrics(MetricsInfo & mi, Dimension & dim) const;
32 void draw(PainterInfo & pi, int x, int y) const;
34 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
36 void drawT(TextPainter & pi, int x, int y) const;
38 /// write LaTeX and Lyx code
39 void write(WriteStream & os) const;
40 /// write normalized content
41 void normalize(NormalStream &) const;
42 /// write content as something readable by Maple
43 void maple(MapleStream &) const;
44 /// write content as something readable by Mathematica
45 void mathematica(MathematicaStream &) const;
46 /// write content as something resembling MathML
47 void mathmlize(MathMLStream &) const;
48 /// write content as something readable by Octave
49 void octave(OctaveStream &) const;
51 bool idxLeft(idx_type &, pos_type &) const;
53 bool idxRight(idx_type &, pos_type &) const;
54 /// move cursor up or down
55 bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
56 /// Target pos when we enter the inset from the left by pressing "Right"
57 bool idxFirst(idx_type & idx, pos_type & pos) const;
58 /// Target pos when we enter the inset from the right by pressing "Left"
59 bool idxLast(idx_type & idx, pos_type & pos) const;
60 /// can we enter this cell?
61 bool validCell(idx_type i) const { return i == 2 || script_[i]; }
63 /// identifies scriptinsets
64 MathScriptInset const * asScriptInset() const;
66 MathScriptInset * asScriptInset();
69 void limits(int lim) { limits_ = lim; }
71 int limits() const { return limits_; }
73 MathArray const & down() const;
76 /// returns superscript
77 MathArray const & up() const;
78 /// returns superscript
81 MathArray const & nuc() const;
84 /// do we have a superscript?
86 /// do we have a subscript?
88 /// do we have a script?
89 bool has(bool up) const;
91 void removeScript(bool up);
92 /// make sure a script is accessible
94 /// say that we have scripts
95 void infoize(std::ostream & os) const;
96 /// say whether we have displayed limits
97 void infoize2(std::ostream & os) const;
102 priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
104 /// returns x offset for main part
106 /// returns width of nucleus if any
108 /// returns y offset for superscript
110 /// returns y offset for subscript
112 /// returns x offset for superscript
114 /// returns x offset for subscript
116 /// returns ascent of nucleus if any
118 /// returns descent of nucleus if any
120 /// where do we have to draw the scripts?
121 bool hasLimits() const;
122 /// clean up empty cells
123 void notifyCursorLeaves(idx_type idx);
125 /// possible subscript (index 0) and superscript (index 1)
127 /// 1 - "limits", -1 - "nolimits", 0 - "default"