X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxcursor.h;h=c36812befd3ac70d82f49f08ab19a6df233d88ab;hb=98c966c64594611e469313314abd1e59524adb4a;hp=0a2af4cba0ce01d766bea41e55b7c9fcc976d9f9;hpb=f807fe1d6cd7359992b41ab8d75a42adfecf124e;p=lyx.git diff --git a/src/lyxcursor.h b/src/lyxcursor.h index 0a2af4cba0..c36812befd 100644 --- a/src/lyxcursor.h +++ b/src/lyxcursor.h @@ -1,41 +1,121 @@ // -*- 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 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); /// - LyXParagraph * par; + int x() const; /// - LyXParagraph::size_type pos; + void x_fix(int i); /// - int x; + int x_fix() const; /// - int x_fix; + void y(int i); /// - unsigned long y; + int y() const; /// - Row * row; + void row(Row * r); /// - 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); } + 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