lyx_mirror/src/mathed/math_pos.C
André Pönitz 00413a7841 merge MathArray and MathXArray classes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4843 a592a061-630c-0410-9148-cb99ea01b6c8
2002-08-02 14:29:42 +00:00

75 lines
1.3 KiB
C

#include "config.h"
#include <iostream>
#include "math_pos.h"
#include "math_inset.h"
#include "debug.h"
#include "support/LAssert.h"
using std::ostream;
MathCursorPos::MathCursorPos()
: par_(0), idx_(0), pos_(0)
{}
MathCursorPos::MathCursorPos(MathInset * p)
: par_(p), idx_(0), pos_(0)
{
lyx::Assert(par_);
}
MathArray & MathCursorPos::cell(MathArray::idx_type idx) const
{
lyx::Assert(par_);
return par_->cell(idx);
}
MathArray & MathCursorPos::cell() const
{
lyx::Assert(par_);
return par_->cell(idx_);
}
void MathCursorPos::getPos(int & x, int & y) const
{
par_->getPos(idx_, pos_, x, y);
}
ostream & operator<<(ostream & os, MathCursorPos const & p)
{
os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")";
return os;
}
bool operator==(MathCursorPos const & p, MathCursorPos const & q)
{
return p.par_ == q.par_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
}
bool operator!=(MathCursorPos const & p, MathCursorPos const & q)
{
return p.par_ != q.par_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
}
bool operator<(MathCursorPos const & p, MathCursorPos const & q)
{
if (p.par_ != q.par_) {
lyxerr << "can't compare cursor and anchor in different insets\n";
return true;
}
if (p.idx_ != q.idx_)
return p.idx_ < q.idx_;
return p.pos_ < q.pos_;
}