]> git.lyx.org Git - lyx.git/blob - src/mathed/math_scriptinset.h
Trivial compile fixes.
[lyx.git] / src / mathed / math_scriptinset.h
1 // -*- C++ -*-
2 #ifndef MATH_SCRIPTINSET_H
3 #define MATH_SCRIPTINSET_H
4
5 #include "math_nestinset.h"
6
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10
11 /** Inset for super- and subscripts
12     \author André Pönitz
13  */
14
15 class MathScriptInset : public MathNestInset {
16 public:
17         /// create inset without scripts
18         MathScriptInset();
19         /// create inset with single script
20         explicit MathScriptInset(bool up);
21         ///
22         MathInset * clone() const;
23         ///
24         void write(WriteStream & os) const;
25         ///
26         void normalize(NormalStream & os) const;
27         ///
28         void metrics(MathMetricsInfo & st) const;
29         ///
30         void draw(MathPainterInfo &, int x, int y) const;
31         ///
32         void metricsT(TextMetricsInfo const & st) const;
33         ///
34         void drawT(TextPainter &, int x, int y) const;
35
36         ///
37         void metrics(MathInset const * nuc, MathMetricsInfo & st) const;
38         ///
39         void draw(MathInset const * nuc, MathPainterInfo &, int x, int y) const;
40         ///
41         void metricsT(MathInset const * nuc, TextMetricsInfo const & st) const;
42         ///
43         void drawT(MathInset const * nuc, TextPainter &, int x, int y) const;
44         /// helper
45         void dimensions2(MathInset const * nuc, int & w, int & a, int & d) const;
46         /// only the width
47         int width2(MathInset const * nuc) const;
48
49         ///
50         bool idxLeft(idx_type &, pos_type &) const;
51         ///
52         bool idxRight(idx_type &, pos_type &) const;
53         /// can we enter this cell?
54         bool validCell(idx_type i) const { return script_[i]; }
55
56         /// identifies scriptinsets
57         MathScriptInset const * asScriptInset() const;
58         ///
59         MathScriptInset * asScriptInset();
60
61         /// set limits
62         void limits(int lim) { limits_ = lim; }
63         /// get limits
64         int limits() const { return limits_; }
65         /// true if we have an "inner" position
66         MathXArray const & up() const;
67         /// returns subscript
68         MathXArray const & down() const;
69         /// returns superscript
70         MathXArray & up();
71         /// returns subscript
72         MathXArray & down();
73         /// do we have a superscript?
74         bool hasUp() const;
75         /// do we have a subscript?
76         bool hasDown() const;
77         /// do we have a script?
78         bool has(bool up) const;
79         /// do we have a anything?
80         bool empty() const;
81         /// remove script
82         void removeScript(bool up);
83         /// remove script
84         void removeEmptyScripts();
85         /// make sure a script is accessible
86         void ensure(bool up);
87         ///
88         void infoize(std::ostream & os) const;
89
90         // call these methods ...2 to make compaq cxx in anal mode happy...
91         /// suppresses empty braces if necessary
92         virtual void write2(MathInset const * nuc, WriteStream & os) const;
93         virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
94         virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
95         virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
96         virtual void mathematicize2(MathInset const * nuc, MathematicaStream & os) const;
97         virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
98 public:
99         /// returns x offset for main part
100         int dxx(MathInset const * nuc) const;
101         /// returns width of nucleus if any
102         int nwid(MathInset const * nuc) const;
103 private:
104         /// returns y offset for superscript
105         int dy0(MathInset const * nuc) const;
106         /// returns y offset for subscript
107         int dy1(MathInset const * nuc) const;
108         /// returns x offset for superscript
109         int dx0(MathInset const * nuc) const;
110         /// returns x offset for subscript
111         int dx1(MathInset const * nuc) const;
112         /// returns ascent of nucleus if any
113         int nasc(MathInset const * nuc) const;
114         /// returns descent of nucleus if any
115         int ndes(MathInset const * nuc) const;
116         /// where do we have to draw the scripts?
117         bool hasLimits(MathInset const * nuc) const;
118
119         /// possible subscript (index 0) and superscript (index 1)
120         bool script_[2];
121         /// 1 - "limits", -1 - "nolimits", 0 - "default"
122         int limits_;
123         /// cached font
124         mutable LyXFont font_;
125 };
126
127 #endif