]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
Fix for wrong cursor.x pos when before a fullRow inset (added ix), small
[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 ix(int i);
48         ///
49         int ix() const;
50         ///
51         void x_fix(int i);
52         ///
53         int x_fix() const;
54         ///
55         void y(int i);
56         ///
57         int y() const;
58         ///
59         void iy(int i);
60         ///
61         int iy() const;
62         ///
63         void row(Row * r);
64         ///
65         Row * row() const;
66 private:
67         /// The paragraph the cursor is in.
68         Paragraph * par_;
69         /// The position inside the paragraph
70         lyx::pos_type pos_;
71         ///
72         bool boundary_;
73         ///
74         int x_;
75         /// the x position of the position before the inset when we put
76         /// the cursor on the end of the row before, otherwise equal to x.
77         int ix_;
78         ///
79         int x_fix_;
80         ///
81         int y_;
82         /// the y position of the position before the inset when we put
83         /// the cursor on the end of the row before, otherwise equal to y.
84         int iy_;
85         ///
86         Row * row_;
87 };
88
89 ///
90 inline
91 bool operator==(LyXCursor const & a, LyXCursor const & b)
92 {
93         return (a.par() == b.par())
94                 && (a.pos() == b.pos())
95                 && a.boundary() == b.boundary();
96 }
97
98 ///
99 inline
100 bool operator!=(LyXCursor const & a, LyXCursor const & b)
101 {
102         return !(a == b);
103 }
104
105 ///
106 inline
107 bool operator<(LyXCursor const & a, LyXCursor const & b)
108 {
109         // Can this be done in a nother way?
110         return (a.y() < b.y() && a.pos() < b.pos());
111 }
112
113 ///
114 inline
115 bool operator>(LyXCursor const & a, LyXCursor const & b)
116 {
117         return b < a;
118 }
119
120 ///
121 inline
122 bool operator>=(LyXCursor const & a, LyXCursor const & b)
123 {
124         return !(a < b);
125 }
126
127
128 ///
129 inline
130 bool operator<=(LyXCursor const & a, LyXCursor const & b)
131 {
132         return !(a > b);
133 }
134
135 #endif