]> git.lyx.org Git - features.git/blob - src/mathed/math_scriptinset.C
a8bf9d6b7b64d1c0489437d7c13406c3bc6ba661
[features.git] / src / mathed / math_scriptinset.C
1 #include <config.h>
2 #include "debug.h"
3 #include "support.h"
4 #include "support/LOstream.h"
5
6 #ifdef __GNUG__
7 #pragma implementation
8 #endif
9
10 #include "math_scriptinset.h"
11
12
13 MathScriptInset::MathScriptInset(bool up)
14         : MathNestInset(1), up_(up)
15 {}
16
17
18 MathInset * MathScriptInset::clone() const
19 {
20         return new MathScriptInset(*this);
21 }
22
23 #if 0
24
25 bool MathScriptInset::idxUp(int & idx, int & pos) const
26 {
27         if (idx == 0 || !up()) 
28                 return false;
29         idx = 0;
30         pos = 0;
31         return true;
32 }
33
34 bool MathScriptInset::idxDown(int & idx, int & pos) const
35 {
36         if (idx == 1 || !down()) 
37                 return false;
38         idx = 1;
39         pos = 0;
40         return true;
41 }
42
43 bool MathScriptInset::idxFirst(int & idx, int & pos) const
44 {
45         idx = up() ? 0 : 1;
46         pos = 0;
47         return true;
48 }
49
50 bool MathScriptInset::idxLast(int & idx, int & pos) const
51 {
52         idx = down() ? 1 : 0;
53         pos = cell(idx).size();
54         return true;
55 }
56
57
58 bool MathScriptInset::idxFirstUp(int & idx, int & pos) const
59 {
60         if (!up()) 
61                 return false;
62         idx = 0;
63         pos = 0;
64         return true;
65 }
66
67
68 bool MathScriptInset::idxFirstDown(int & idx, int & pos) const
69 {
70         if (!down()) 
71                 return false;
72         idx = 1;
73         pos = 0;
74         return true;
75 }
76
77
78 bool MathScriptInset::idxLastUp(int & idx, int & pos) const
79 {
80         if (!up()) 
81                 return false;
82         idx = 0;
83         pos = cell(idx).size();
84         return true;
85 }
86
87
88 bool MathScriptInset::idxLastDown(int & idx, int & pos) const
89 {
90         if (!down()) 
91                 return false;
92         idx = 1;
93         pos = cell(idx).size();
94         return true;
95 }
96
97 void MathScriptInset::idxDelete(int & idx, bool & popit, bool & deleteit)
98 {
99         if (idx == 0) 
100                 up(false);
101         else
102                 down(false);
103         popit = true;
104         deleteit = !(up() || down());
105 }
106
107 #endif
108
109
110 void MathScriptInset::write(std::ostream & os, bool fragile) const
111 {
112         cell(0).write(os, fragile);
113 }
114
115
116 void MathScriptInset::metrics(MathStyles st) const
117 {
118         size_    = st;
119         xcell(0).metrics(st);   
120         width_   = xcell(0).width();
121         ascent_  = xcell(0).ascent();
122         descent_ = xcell(0).descent();
123 }
124
125
126 void MathScriptInset::draw(Painter & pain, int x, int y) const
127 {
128         xo(x);
129         yo(y);
130         xcell(0).draw(pain, x, y);
131 }