]> git.lyx.org Git - lyx.git/blob - src/mathed/math_pos.C
add #pragme interface/implementation
[lyx.git] / src / mathed / math_pos.C
1
2 #ifdef __GNUG__
3 #pragma implementation 
4 #endif
5
6 #include "config.h"
7 #include "math_pos.h"
8 #include "math_inset.h"
9 #include "debug.h"
10 #include "support/LAssert.h"
11 #include "support/LOstream.h"
12
13
14 MathCursorPos::MathCursorPos()
15         : par_(0), idx_(0), pos_(0)
16 {}
17
18
19 MathCursorPos::MathCursorPos(MathInset * p)
20         : par_(p), idx_(0), pos_(0)
21 {
22         lyx::Assert(par_);
23 }
24
25
26
27 MathArray & MathCursorPos::cell(MathArray::idx_type idx) const
28 {
29         lyx::Assert(par_);
30         return par_->cell(idx);
31 }
32
33
34 MathArray & MathCursorPos::cell() const
35 {
36         lyx::Assert(par_);
37         return par_->cell(idx_);
38 }
39
40
41 void MathCursorPos::getPos(int & x, int & y) const
42 {
43         par_->getPos(idx_, pos_, x, y);
44 }
45
46
47 std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
48 {
49         os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")";
50         return os;
51 }
52
53
54 bool operator==(MathCursorPos const & p, MathCursorPos const & q)
55 {
56         return p.par_ == q.par_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
57 }
58
59
60 bool operator!=(MathCursorPos const & p, MathCursorPos const & q)
61 {
62         return p.par_ != q.par_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
63 }
64
65
66 bool operator<(MathCursorPos const & p, MathCursorPos const & q)
67 {
68         if (p.par_ != q.par_) {
69                 lyxerr << "can't compare cursor and anchor in different insets\n";
70                 return true;
71         }
72         if (p.idx_ != q.idx_)
73                 return p.idx_ < q.idx_;
74         return p.pos_ < q.pos_;
75 }