]> git.lyx.org Git - lyx.git/blob - src/mathed/math_scriptinset.h
use stream-like syntax for LaTeX output
[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(MathWriteInfo & os) const;
25         ///
26         void metrics(MathMetricsInfo const & st) const;
27         ///
28         void draw(Painter &, int x, int y) const;
29
30         ///
31         void write(MathInset const *, MathWriteInfo & os) const;
32         ///
33         void metrics(MathInset const * nucleus, MathMetricsInfo const & 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         bool idxLeft(MathInset::idx_type &, MathInset::pos_type &) const;
45         ///
46         bool idxRight(MathInset::idx_type &, MathInset::pos_type &) const;
47
48         ///
49         MathScriptInset const * asScriptInset() const;
50         ///
51         MathScriptInset * asScriptInset();
52
53         /// set limits
54         void limits(int lim) { limits_ = lim; }
55         /// 
56         int limits() const { return limits_; }
57         ///
58         bool hasLimits(MathInset const * nucleus) const;
59         /// true if we have an "inner" position
60         MathXArray const & up() const;
61         /// returns subscript
62         MathXArray const & down() const;
63         /// returns superscript
64         MathXArray & up();
65         /// returns subscript
66         MathXArray & down();
67         /// do we have a superscript?
68         bool hasUp() const;
69         /// do we have a subscript?
70         bool hasDown() const;
71         /// do we have a script?
72         bool has(bool up) const;
73         /// remove script
74         void removeScript(bool up);
75         /// remove script
76         void removeEmptyScripts();
77         ///
78         void ensure(bool up);
79
80 public:
81         /// returns x offset for main part
82         int dxx(MathInset const * nuc) const;
83         /// returns width of nucleus if any
84         int nwid(MathInset const * nuc) const;
85 private:
86         /// returns y offset for superscript
87         int dy0(MathInset const * nuc) const;
88         /// returns y offset for subscript
89         int dy1(MathInset const * nuc) const;
90         /// returns x offset for superscript
91         int dx0(MathInset const * nuc) const;
92         /// returns x offset for subscript
93         int dx1(MathInset const * nuc) const;
94         /// returns ascent of nucleus if any
95         int nasc(MathInset const * nuc) const;
96         /// returns descent of nucleus if any
97         int ndes(MathInset const * nuc) const;
98
99         /// possible subscript (index 0) and superscript (index 1)
100         bool script_[2]; 
101         ///
102         int limits_;
103 };
104
105 #endif
106