]> git.lyx.org Git - lyx.git/blob - src/mathed/math_rowst.C
update libtool
[lyx.git] / src / mathed / math_rowst.C
1 #include <config.h>
2
3 #include "math_rowst.h"
4 #include "support/LAssert.h"
5
6
7 //
8 // MathedRowContainer
9 //
10
11 MathedRowStruct::MathedRowStruct()
12         : asc_(0), desc_(0), y_(0), numbered_(true)
13 {}
14
15
16 string const & MathedRowStruct::getLabel() const
17 {
18         return label_;
19 }
20
21
22 bool MathedRowStruct::isNumbered() const
23 {
24         return numbered_;
25 }
26
27
28 int MathedRowStruct::getBaseline() const
29 {
30         return y_;
31 }
32
33
34 void MathedRowStruct::setBaseline(int b)
35 {
36         y_ = b;
37 }
38
39
40 int MathedRowStruct::ascent() const
41 {
42         return asc_;
43 }
44
45
46 int MathedRowStruct::descent() const
47 {
48         return desc_;
49 }
50
51
52 void MathedRowStruct::ascent(int a)
53 {
54         asc_ = a;
55 }
56
57
58 void MathedRowStruct::descent(int d)
59 {
60         desc_ = d;
61 }
62
63
64 int MathedRowStruct::getTab(unsigned int i) const
65 {
66         return i < widths_.size() ? widths_[i] : 0;
67 }
68
69
70 void MathedRowStruct::setLabel(string const & l)
71 {
72         label_ = l;
73 }
74
75
76 void MathedRowStruct::setNumbered(bool nf)
77 {
78         numbered_ = nf;
79 }
80
81
82 void MathedRowStruct::setTab(unsigned int i, int t)
83 {
84         if (i >= widths_.size())
85                 widths_.resize(i + 2);  
86         widths_[i] = t;
87 }
88
89
90
91 //
92 // MathedRowContainer
93 //
94
95
96 MathedRowContainer::iterator MathedRowContainer::begin()
97 {
98         return iterator(this);
99 }
100
101
102 MathedRowContainer::iterator MathedRowContainer::end()
103 {
104         iterator it(this);
105         it.pos_ = data_.size();
106         return it;
107 }
108
109
110 bool MathedRowContainer::empty() const
111 {
112         return data_.size() == 0;
113 }
114
115
116 void MathedRowContainer::insert(iterator const & it)
117 {
118         lyx::Assert(it.st_ == this);
119         data_.insert(data_.begin() + it.pos_, MathedRowStruct());
120 }
121
122
123 void MathedRowContainer::erase(iterator & it)
124 {
125         lyx::Assert(it.st_ == this);
126         data_.erase(data_.begin() + it.pos_);
127 }
128
129
130 MathedRowStruct & MathedRowContainer::back()
131 {
132         lyx::Assert(data_.size());
133         return data_.back();
134 }
135
136
137 MathedRowStruct const & MathedRowContainer::back() const
138 {
139         lyx::Assert(data_.size());
140         return data_.back();
141 }
142
143
144 void MathedRowContainer::push_back()
145 {
146         data_.push_back(MathedRowStruct());
147 }
148
149
150 MathedRowContainer::size_type MathedRowContainer::size() const
151 {
152         return data_.size();
153 }
154
155
156
157 //
158 // MathedRowContainer::iterator
159 //
160
161 MathedRowContainer::iterator::iterator()
162         : st_(0), pos_(0)
163 {}
164
165
166 MathedRowContainer::iterator::iterator(MathedRowContainer * m)
167         : st_(m), pos_(0)
168 {}
169
170
171 MathedRowContainer::iterator::operator void *() const
172 {
173         return (void *)(st_ && pos_ < st_->size());
174 }
175
176
177 MathedRowStruct * MathedRowContainer::iterator::operator->()
178 {
179         lyx::Assert(st_);
180         return &st_->data_[pos_];
181 }
182
183
184 MathedRowStruct const * MathedRowContainer::iterator::operator->() const
185 {
186         lyx::Assert(st_);
187         return &st_->data_[pos_];
188 }
189
190
191 void MathedRowContainer::iterator::operator++()
192 {
193         lyx::Assert(st_);
194         ++pos_;
195 }
196
197
198 bool MathedRowContainer::iterator::is_last() const
199 {
200         lyx::Assert(st_);
201         return pos_ == st_->size() - 1;
202 }
203
204
205 bool MathedRowContainer::iterator::operator==(const iterator & it) const
206 {
207         return st_ == it.st_ && pos_ == it.pos_;
208 }
209
210