]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
support for wasy symbols
[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         ///
67         void irow(Row * r);
68         ///
69         Row * irow() const;
70 private:
71         /// The paragraph the cursor is in.
72         Paragraph * par_;
73         /// The position inside the paragraph
74         lyx::pos_type pos_;
75         ///
76         bool boundary_;
77         ///
78         int x_;
79         /// the x position of the position before the inset when we put
80         /// the cursor on the end of the row before, otherwise equal to x.
81         int ix_;
82         ///
83         int x_fix_;
84         ///
85         int y_;
86         /// the y position of the position before the inset when we put
87         /// the cursor on the end of the row before, otherwise equal to y.
88         int iy_;
89         ///
90         Row * row_;
91         /// the row of the position before the inset when we put
92         /// the cursor on the end of the row before, otherwise equal to row.
93         Row * irow_;
94 };
95
96 ///
97 inline
98 bool operator==(LyXCursor const & a, LyXCursor const & b)
99 {
100         return (a.par() == b.par())
101                 && (a.pos() == b.pos())
102                 && a.boundary() == b.boundary();
103 }
104
105 ///
106 inline
107 bool operator!=(LyXCursor const & a, LyXCursor const & b)
108 {
109         return !(a == b);
110 }
111
112 ///
113 inline
114 bool operator<(LyXCursor const & a, LyXCursor const & b)
115 {
116         // Can this be done in a nother way?
117         return (a.y() < b.y() && a.pos() < b.pos());
118 }
119
120 ///
121 inline
122 bool operator>(LyXCursor const & a, LyXCursor const & b)
123 {
124         return b < a;
125 }
126
127 ///
128 inline
129 bool operator>=(LyXCursor const & a, LyXCursor const & b)
130 {
131         return !(a < b);
132 }
133
134
135 ///
136 inline
137 bool operator<=(LyXCursor const & a, LyXCursor const & b)
138 {
139         return !(a > b);
140 }
141
142 #endif