]> git.lyx.org Git - lyx.git/blobdiff - src/lyxcursor.h
selection using the mouse should work now. Note: an x is not a y, nor is
[lyx.git] / src / lyxcursor.h
index 256a130e7daa03fa4a43e29a8b460dccdbdbe18d..1032055f0e5006f217dfe3fe6ee165907d9a3214 100644 (file)
  *           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 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(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