]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
Fix the cursor position to be on the end of the row before an inset which
[lyx.git] / src / lyxcursor.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYXCURSOR_H
13 #define LYXCURSOR_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "support/types.h"
20
21 class Paragraph;
22 class Row;
23
24 /** All these variables should be explained. Matthias?
25  */
26 class LyXCursor {
27 public:
28         ///
29         LyXCursor();
30         ///
31         void par(Paragraph * p);
32         ///
33         Paragraph * par() const;
34         ///
35         void pos(lyx::pos_type p);
36         ///
37         lyx::pos_type pos() const;
38         ///
39         void boundary(bool b);
40         ///
41         bool boundary() const;
42         ///
43         void x(int i);
44         ///
45         int x() const;
46         ///
47         void x_fix(int i);
48         ///
49         int x_fix() const;
50         ///
51         void y(int i);
52         ///
53         int y() const;
54         ///
55         void iy(int i);
56         ///
57         int iy() const;
58         ///
59         void row(Row * r);
60         ///
61         Row * row() const;
62 private:
63         /// The paragraph the cursor is in.
64         Paragraph * par_;
65         /// The position inside the paragraph
66         lyx::pos_type pos_;
67         ///
68         bool boundary_;
69         ///
70         int x_;
71         ///
72         int x_fix_;
73         ///
74         int y_;
75         /// the y position of the position before the inset when we put
76         /// the cursor on the end of the row before, otherwise equal to y.
77         int iy_;
78         ///
79         Row * row_;
80 };
81
82 ///
83 inline
84 bool operator==(LyXCursor const & a, LyXCursor const & b)
85 {
86         return (a.par() == b.par())
87                 && (a.pos() == b.pos())
88                 && a.boundary() == b.boundary();
89 }
90
91 ///
92 inline
93 bool operator!=(LyXCursor const & a, LyXCursor const & b)
94 {
95         return !(a == b);
96 }
97
98 ///
99 inline
100 bool operator<(LyXCursor const & a, LyXCursor const & b)
101 {
102         // Can this be done in a nother way?
103         return (a.y() < b.y() && a.pos() < b.pos());
104 }
105
106 ///
107 inline
108 bool operator>(LyXCursor const & a, LyXCursor const & b)
109 {
110         return b < a;
111 }
112
113 ///
114 inline
115 bool operator>=(LyXCursor const & a, LyXCursor const & b)
116 {
117         return !(a < b);
118 }
119
120
121 ///
122 inline
123 bool operator<=(LyXCursor const & a, LyXCursor const & b)
124 {
125         return !(a > b);
126 }
127
128 #endif