]> git.lyx.org Git - lyx.git/blob - src/mathed/math_scriptinset.h
enable direct input of #1...#9; some whitespace changes
[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 const & st) const;
29         ///
30         void draw(Painter &, int x, int y) const;
31
32         ///
33         void metrics(MathInset const * nuc, MathMetricsInfo const & st) const;
34         ///
35         void draw(MathInset const * nuc, Painter &, int x, int y) const;
36         ///
37         int ascent2(MathInset const * nuc) const;
38         ///
39         int descent2(MathInset const * nuc) const;
40         ///
41         int width2(MathInset const * nuc) const;
42
43         ///
44         bool idxLeft(idx_type &, pos_type &) const;
45         ///
46         bool idxRight(idx_type &, pos_type &) const;
47
48         /// identifies scriptinsets
49         MathScriptInset const * asScriptInset() const;
50         ///
51         MathScriptInset * asScriptInset();
52
53         /// set limits
54         void limits(int lim) { limits_ = lim; }
55         /// get limits
56         int limits() const { return limits_; }
57         /// true if we have an "inner" position
58         MathXArray const & up() const;
59         /// returns subscript
60         MathXArray const & down() const;
61         /// returns superscript
62         MathXArray & up();
63         /// returns subscript
64         MathXArray & down();
65         /// do we have a superscript?
66         bool hasUp() const;
67         /// do we have a subscript?
68         bool hasDown() const;
69         /// do we have a script?
70         bool has(bool up) const;
71         /// remove script
72         void removeScript(bool up);
73         /// remove script
74         void removeEmptyScripts();
75         /// make sure a script is accessible
76         void ensure(bool up);
77
78         // call these methods ...2 to make compaq cxx in anal mode happy...
79         /// suppresses empty braces if necessary
80         virtual void write2(MathInset const * nuc, WriteStream & os) const;
81         virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
82         virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
83         virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
84         virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
85
86 public:
87         /// returns x offset for main part
88         int dxx(MathInset const * nuc) const;
89         /// returns width of nucleus if any
90         int nwid(MathInset const * nuc) const;
91 private:
92         /// returns y offset for superscript
93         int dy0(MathInset const * nuc) const;
94         /// returns y offset for subscript
95         int dy1(MathInset const * nuc) const;
96         /// returns x offset for superscript
97         int dx0(MathInset const * nuc) const;
98         /// returns x offset for subscript
99         int dx1(MathInset const * nuc) const;
100         /// returns ascent of nucleus if any
101         int nasc(MathInset const * nuc) const;
102         /// returns descent of nucleus if any
103         int ndes(MathInset const * nuc) const;
104         /// where do we have to draw the scripts?
105         bool hasLimits(MathInset const * nuc) const;
106
107         /// possible subscript (index 0) and superscript (index 1)
108         bool script_[2]; 
109         /// 1 - "limits", -1 - "nolimits", 0 - "default"
110         int limits_;
111         /// cached MathMetricsInfo
112         mutable MathMetricsInfo mi_;
113 };
114
115 #endif
116