]> git.lyx.org Git - lyx.git/blob - src/mathed/math_scriptinset.h
Use references instead of pointers where possible
[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         ///
18         MathScriptInset();
19         ///
20         explicit MathScriptInset(bool up);
21         ///
22         MathInset * clone() const;
23         ///
24         void write(std::ostream &, bool fragile) const;
25         ///
26         void metrics(MathStyles st) const;
27         ///
28         void draw(Painter &, int x, int y) const;
29
30         ///
31         void write(MathInset const * nucleus, std::ostream &, bool fragile) const;
32         ///
33         void metrics(MathInset const * nucleus, MathStyles st) const;
34         ///
35         void draw(MathInset const * nucleus, Painter &, int x, int y) const;
36         ///
37         int ascent(MathInset const * nucleus) const;
38         ///
39         int descent(MathInset const * nucleus) const;
40         ///
41         int width(MathInset const * nucleus) const;
42
43         ///
44         MathScriptInset const * asScriptInset() const;
45         ///
46         MathScriptInset * asScriptInset();
47
48         /// set limits
49         void limits(int lim) { limits_ = lim; }
50         /// 
51         int limits() const { return limits_; }
52         ///
53         bool hasLimits(MathInset const * nucleus) const;
54         /// true if we have an "inner" position
55         MathXArray const & up() const;
56         /// returns subscript
57         MathXArray const & down() const;
58         /// returns superscript
59         MathXArray & up();
60         /// returns subscript
61         MathXArray & down();
62         /// do we have a superscript?
63         bool hasUp() const;
64         /// do we have a subscript?
65         bool hasDown() const;
66         /// do we have a script?
67         bool has(bool up) const;
68         /// remove script
69         void removeScript(bool up);
70         /// remove script
71         void removeEmptyScripts();
72         ///
73         void ensure(bool up);
74
75 public:
76         /// returns x offset for main part
77         int dxx(MathInset const * nuc) const;
78         /// returns width of nucleus if any
79         int nwid(MathInset const * nuc) const;
80 private:
81         /// returns y offset for superscript
82         int dy0(MathInset const * nuc) const;
83         /// returns y offset for subscript
84         int dy1(MathInset const * nuc) const;
85         /// returns x offset for superscript
86         int dx0(MathInset const * nuc) const;
87         /// returns x offset for subscript
88         int dx1(MathInset const * nuc) const;
89         /// returns ascent of nucleus if any
90         int nasc(MathInset const * nuc) const;
91         /// returns descent of nucleus if any
92         int ndes(MathInset const * nuc) const;
93
94         /// possible subscript (index 0) and superscript (index 1)
95         bool script_[2]; 
96         ///
97         int limits_;
98 };
99
100 #endif
101