]> git.lyx.org Git - lyx.git/blobdiff - src/lyxcursor.h
fix typo that put too many include paths for most people
[lyx.git] / src / lyxcursor.h
index 9699f7561474d73198eb6b7127ff66e2c8619be3..c36812befd3ac70d82f49f08ab19a6df233d88ab 100644 (file)
 // -*- C++ -*-
 /* This file is part of
- * ====================================================== 
- * 
+ * ======================================================
+ *
  *           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 "support/types.h"
 
-struct Row;
+class Paragraph;
+class Row;
 
-/** All these variavles should be explained. Matthias?
+/** All these variables should be explained. Matthias?
  */
-struct LyXCursor {
+class LyXCursor {
+public:
+       ///
+       LyXCursor();
+       ///
+       void par(Paragraph * p);
+       ///
+       Paragraph * par() const;
+       ///
+       void pos(lyx::pos_type p);
+       ///
+       lyx::pos_type pos() const;
+       ///
+       void boundary(bool b);
+       ///
+       bool boundary() const;
+       ///
+       void x(int i);
+       ///
+       int x() const;
        ///
-       LyXParagraph * par;
+       void x_fix(int i);
        ///
-       LyXParagraph::size_type pos;
+       int x_fix() const;
        ///
-       int x;
+       void y(int i);
        ///
-       int x_fix;
+       int y() const;
        ///
-       unsigned long y;
+       void row(Row * r);
        ///
-       Row * row;
+       Row * row() const;
+private:
+       /// The paragraph the cursor is in.
+       Paragraph * par_;
+       /// The position inside the paragraph
+       lyx::pos_type pos_;
+       ///
+       bool boundary_;
+       ///
+       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