]> git.lyx.org Git - lyx.git/blob - src/mathed/math_rowst.C
Applied Angus patch to compile on DEC C++ and to avoid name clashes
[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 string const & MathedRowStruct::getLabel() const
16 {
17         return label_;
18 }
19
20 bool MathedRowStruct::isNumbered() const
21 {
22         return numbered_;
23 }
24
25 int MathedRowStruct::getBaseline() const
26 {
27         return y_;
28 }
29
30 void MathedRowStruct::setBaseline(int b)
31 {
32         y_ = b;
33 }
34
35 int MathedRowStruct::ascent() const
36 {
37         return asc_;
38 }
39
40 int MathedRowStruct::descent() const
41 {
42         return desc_;
43 }
44
45 void MathedRowStruct::ascent(int a)
46 {
47         asc_ = a;
48 }
49
50 void MathedRowStruct::descent(int d)
51 {
52         desc_ = d;
53 }
54
55 int MathedRowStruct::getTab(unsigned int i) const
56 {
57         return i < widths_.size() ? widths_[i] : 0;
58 }
59
60 void MathedRowStruct::setLabel(string const & l)
61 {
62         label_ = l;
63 }
64
65 void MathedRowStruct::setNumbered(bool nf)
66 {
67         numbered_ = nf;
68 }
69
70 void MathedRowStruct::setTab(unsigned int i, int t)
71 {
72         if (i >= widths_.size())
73                 widths_.resize(i + 2);  
74         widths_[i] = t;
75 }
76
77
78
79 //
80 // MathedRowContainer
81 //
82
83
84 MathedRowContainer::iterator MathedRowContainer::begin()
85 {
86         return iterator(this);
87 }
88
89 MathedRowContainer::iterator MathedRowContainer::end()
90 {
91         iterator it(this);
92         it.pos_ = data_.size();
93         return it;
94 }
95
96 bool MathedRowContainer::empty() const
97 {
98         return data_.size() == 0;
99 }
100
101 void MathedRowContainer::insert(iterator const & it)
102 {
103         Assert(it.st_ == this);
104         data_.insert(data_.begin() + it.pos_, MathedRowStruct());
105 }
106                 
107 void MathedRowContainer::erase(iterator & it)
108 {
109         Assert(it.st_ == this);
110         data_.erase(data_.begin() + it.pos_);
111 }
112
113 MathedRowStruct & MathedRowContainer::back()
114 {
115         Assert(data_.size());
116         return data_.back();
117 }
118
119 void MathedRowContainer::push_back()
120 {
121         data_.push_back(MathedRowStruct());
122 }
123
124
125 MathedRowContainer::size_type MathedRowContainer::size() const
126 {
127         return data_.size();
128 }
129
130
131
132 //
133 // MathedRowContainer::iterator
134 //
135
136 MathedRowContainer::iterator::iterator()
137         : st_(0), pos_(0)
138 {}
139
140 MathedRowContainer::iterator::iterator(MathedRowContainer * m)
141         : st_(m), pos_(0)
142 {}
143
144 MathedRowContainer::iterator::operator void *() const
145 {
146         return (void *)(st_ && pos_ < st_->size());
147 }
148
149 MathedRowStruct * MathedRowContainer::iterator::operator->()
150 {
151         Assert(st_);
152         return &st_->data_[pos_];
153 }
154
155 MathedRowStruct const * MathedRowContainer::iterator::operator->() const
156 {
157         Assert(st_);
158         return &st_->data_[pos_];
159 }
160
161 void MathedRowContainer::iterator::operator++()
162 {
163         Assert(st_);
164         ++pos_;
165 }
166
167 bool MathedRowContainer::iterator::is_last() const
168 {
169         Assert(st_);
170         return pos_ == st_->size() - 1;
171 }
172
173 bool MathedRowContainer::iterator::operator==(const iterator & it) const
174 {
175         return st_ == it.st_ && pos_ == it.pos_;
176 }
177
178