]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathScript.h
Rename files in src/mathed and src/graphics from .C to .cpp, step 2
[lyx.git] / src / mathed / InsetMathScript.h
1 // -*- C++ -*-
2 /**
3  * \file InsetMathScript.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_SCRIPTINSET_H
13 #define MATH_SCRIPTINSET_H
14
15 #include "InsetMathNest.h"
16
17
18 namespace lyx {
19
20
21 // An inset for super- and subscripts or both.  The 'nucleus' is always
22 // cell 0.  If there is just one script, it's cell 1 and cell_1_is_up_
23 // is set accordingly.  If both are used, cell 1 is up and cell 2 is down.
24
25 class InsetMathScript : public InsetMathNest {
26 public:
27         /// create inset without scripts
28         InsetMathScript();
29         /// create inset with single script
30         explicit InsetMathScript(bool up);
31         /// create inset with single script and given nucleus
32         InsetMathScript(MathAtom const & at, bool up);
33         ///
34         mode_type currentMode() const { return MATH_MODE; }
35         ///
36         bool metrics(MetricsInfo & mi, Dimension & dim) const;
37         ///
38         void draw(PainterInfo & pi, int x, int y) const;
39         ///
40         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
41         ///
42         void drawT(TextPainter & pi, int x, int y) const;
43
44         /// move cursor left
45         bool idxLeft(LCursor & cur) const;
46         /// move cursor right
47         bool idxRight(LCursor & cur) const;
48         /// move cursor up or down
49         bool idxUpDown(LCursor & cur, bool up) const;
50         /// Target pos when we enter the inset from the left by pressing "Right"
51         bool idxFirst(LCursor & cur) const;
52         /// Target pos when we enter the inset from the right by pressing "Left"
53         bool idxLast(LCursor & cur) const;
54
55         /// write LaTeX and Lyx code
56         void write(WriteStream & os) const;
57         /// write normalized content
58         void normalize(NormalStream &) const;
59         /// write content as something readable by Maple
60         void maple(MapleStream &) const;
61         /// write content as something readable by Mathematica
62         void mathematica(MathematicaStream &) const;
63         /// write content as something resembling MathML
64         void mathmlize(MathStream &) const;
65         /// write content as something readable by Octave
66         void octave(OctaveStream &) const;
67
68         /// identifies scriptinsets
69         InsetMathScript const * asScriptInset() const;
70         ///
71         InsetMathScript * asScriptInset();
72
73         /// set limits
74         void limits(int lim) { limits_ = lim; }
75         /// get limits
76         int limits() const { return limits_; }
77         /// returns subscript. Always run 'hasDown' or 'has(false)' before!
78         MathArray const & down() const;
79         /// returns subscript. Always run 'hasDown' or 'has(false)' before!
80         MathArray & down();
81         /// returns superscript. Always run 'hasUp' or 'has(true)' before!
82         MathArray const & up() const;
83         /// returns superscript. Always run 'hasUp' or 'has(true)' before!
84         MathArray & up();
85         /// returns nucleus
86         MathArray const & nuc() const;
87         /// returns nucleus
88         MathArray & nuc();
89         /// do we have a superscript?
90         bool hasUp() const;
91         /// do we have a subscript?
92         bool hasDown() const;
93         /// do we have a script?
94         bool has(bool up) const;
95         /// what idx has super/subscript?
96         idx_type idxOfScript(bool up) const;
97         /// remove script
98         void removeScript(bool up);
99         /// make sure a script is accessible
100         void ensure(bool up);
101         /// say that we have scripts
102         void infoize(odocstream & os) const;
103         /// say whether we have displayed limits
104         void infoize2(odocstream & os) const;
105 protected:
106         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
107 private:
108         virtual std::auto_ptr<InsetBase> doClone() const;
109         /// returns x offset for main part
110         int dxx() const;
111         /// returns width of nucleus if any
112         int nwid() const;
113         /// returns y offset for either superscript or subscript
114         int dy01(int asc, int des, int what) const;
115         /// returns y offset for superscript
116         int dy0() const;
117         /// returns y offset for subscript
118         int dy1() const;
119         /// returns x offset for superscript
120         int dx0() const;
121         /// returns x offset for subscript
122         int dx1() const;
123         /// returns ascent of nucleus if any
124         int nasc() const;
125         /// returns descent of nucleus if any
126         int ndes() const;
127         /// returns superscript kerning of nucleus if any
128         int nker() const;
129         /// where do we have to draw the scripts?
130         bool hasLimits() const;
131         /// clean up empty cells and return true if a cell has been deleted.
132         bool notifyCursorLeaves(LCursor & cur);
133
134         /// possible subscript (index 0) and superscript (index 1)
135         bool cell_1_is_up_;
136         /// 1 - "limits", -1 - "nolimits", 0 - "default"
137         int limits_;
138 };
139
140
141
142 } // namespace lyx
143 #endif