1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
1999-09-27 18:44:28 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef LYXCURSOR_H
|
|
|
|
#define LYXCURSOR_H
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
#include "support/types.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
|
2001-11-26 16:42:04 +00:00
|
|
|
class Paragraph;
|
|
|
|
class Row;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-05-22 13:20:51 +00:00
|
|
|
/** All these variables should be explained. Matthias?
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
2000-06-08 23:16:16 +00:00
|
|
|
class LyXCursor {
|
|
|
|
public:
|
2001-11-26 16:42:04 +00:00
|
|
|
///
|
2001-01-08 14:19:29 +00:00
|
|
|
LyXCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void par(Paragraph * p);
|
1999-11-04 01:40:20 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * par() const;
|
2000-05-30 19:31:11 +00:00
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
void pos(lyx::pos_type p);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
lyx::pos_type pos() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
void boundary(bool b);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
bool boundary() const;
|
2000-05-04 08:14:34 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
void x(int i);
|
|
|
|
///
|
|
|
|
int x() const;
|
|
|
|
///
|
|
|
|
void x_fix(int i);
|
|
|
|
///
|
|
|
|
int x_fix() const;
|
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
void y(int i);
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
int y() const;
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
|
|
|
void row(Row * r);
|
|
|
|
///
|
|
|
|
Row * row() const;
|
|
|
|
private:
|
|
|
|
/// The paragraph the cursor is in.
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * par_;
|
2000-06-08 23:16:16 +00:00
|
|
|
/// The position inside the paragraph
|
2001-11-27 10:34:16 +00:00
|
|
|
lyx::pos_type pos_;
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
|
|
|
bool boundary_;
|
|
|
|
///
|
|
|
|
int x_;
|
|
|
|
///
|
|
|
|
int x_fix_;
|
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
int y_;
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
|
|
|
Row * row_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
inline
|
|
|
|
bool operator==(LyXCursor const & a, LyXCursor const & b)
|
|
|
|
{
|
|
|
|
return (a.par() == b.par())
|
|
|
|
&& (a.pos() == b.pos())
|
|
|
|
&& a.boundary() == b.boundary();
|
|
|
|
}
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
inline
|
|
|
|
bool operator!=(LyXCursor const & a, LyXCursor const & b)
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2001-06-27 18:29:18 +00:00
|
|
|
///
|
|
|
|
inline
|
2002-03-21 17:27:08 +00:00
|
|
|
bool operator<(LyXCursor const & a, LyXCursor const & b)
|
2001-06-27 18:29:18 +00:00
|
|
|
{
|
|
|
|
// Can this be done in a nother way?
|
|
|
|
return (a.y() < b.y() && a.pos() < b.pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
2002-03-21 17:27:08 +00:00
|
|
|
bool operator>(LyXCursor const & a, LyXCursor const & b)
|
2001-06-27 18:29:18 +00:00
|
|
|
{
|
|
|
|
return b < a;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
|
|
|
bool operator>=(LyXCursor const & a, LyXCursor const & b)
|
|
|
|
{
|
|
|
|
return !(a < b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
|
|
|
bool operator<=(LyXCursor const & a, LyXCursor const & b)
|
|
|
|
{
|
|
|
|
return !(a > b);
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|