* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#ifndef LYXCURSOR_H
#define LYXCURSOR_H
-#include "lyxparagraph.h"
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "paragraph.h"
struct Row;
/** All these variables should be explained. Matthias?
*/
-struct LyXCursor {
+class LyXCursor {
+public:
+ LyXCursor();
+ ///
+ void par(Paragraph * p);
+ ///
+ Paragraph * par() const;
+ ///
+ void pos(Paragraph::size_type p);
+ ///
+ Paragraph::size_type pos() const;
+ ///
+ void boundary(bool b);
+ ///
+ bool boundary() const;
+ ///
+ void x(int i);
+ ///
+ int x() const;
+ ///
+ void x_fix(int i);
///
- LyXParagraph * par;
+ int x_fix() const;
///
- LyXParagraph::size_type pos;
+ void y(int i);
///
- int x;
+ int y() const;
///
- int x_fix;
+ void row(Row * r);
///
- unsigned long y;
+ Row * row() const;
+private:
+ /// The paragraph the cursor is in.
+ Paragraph * par_;
+ /// The position inside the paragraph
+ Paragraph::size_type pos_;
///
- Row * row;
+ bool boundary_;
///
- inline bool operator==(const LyXCursor &a) const
- { return (a.par == par) && (a.pos == pos); }
- inline bool operator!=(const LyXCursor &a) const
- { return (a.par != par) || (a.pos != pos); }
+ int x_;
+ ///
+ int x_fix_;
+ ///
+ int y_;
+ ///
+ Row * row_;
};
+///
+inline
+bool operator==(LyXCursor const & a, LyXCursor const & b)
+{
+ return (a.par() == b.par())
+ && (a.pos() == b.pos())
+ && a.boundary() == b.boundary();
+}
+
+///
+inline
+bool operator!=(LyXCursor const & a, LyXCursor const & b)
+{
+ return !(a == b);
+}
+
+///
+inline
+bool operator<(LyXCursor const & a, LyXCursor const & b)
+{
+ // Can this be done in a nother way?
+ return (a.y() < b.y() && a.pos() < b.pos());
+}
+
+///
+inline
+bool operator>(LyXCursor const & a, LyXCursor const & b)
+{
+ 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);
+}
+
#endif