]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
start reducing header file dependencies
[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         /// position in a paragraph
29         typedef lyx::pos_type pos_type;
30         ///
31         LyXCursor();
32         ///
33         void par(Paragraph * p);
34         ///
35         Paragraph * par() const;
36         ///
37         void pos(pos_type p);
38         ///
39         pos_type pos() const;
40         ///
41         void boundary(bool b);
42         ///
43         bool boundary() const;
44         ///
45         void x(int i);
46         ///
47         int x() const;
48         ///
49         void x_fix(int i);
50         ///
51         int x_fix() const;
52         ///
53         void y(int i);
54         ///
55         int y() const;
56         ///
57         void row(Row * r);
58         ///
59         Row * row() const;
60 private:
61         /// The paragraph the cursor is in.
62         Paragraph * par_;
63         /// The position inside the paragraph
64         pos_type pos_;
65         ///
66         bool boundary_;
67         ///
68         int x_;
69         ///
70         int x_fix_;
71         ///
72         int y_;
73         ///
74         Row * row_;
75 };
76
77 ///
78 inline
79 bool operator==(LyXCursor const & a, LyXCursor const & b)
80 {
81         return (a.par() == b.par())
82                 && (a.pos() == b.pos())
83                 && a.boundary() == b.boundary();
84 }
85
86 ///
87 inline
88 bool operator!=(LyXCursor const & a, LyXCursor const & b)
89 {
90         return !(a == b);
91 }
92
93 ///
94 inline
95 bool operator<(LyXCursor const & a, LyXCursor const & b) 
96 {
97         // Can this be done in a nother way?
98         return (a.y() < b.y() && a.pos() < b.pos());
99 }
100
101 ///
102 inline
103 bool operator>(LyXCursor const & a, LyXCursor const & b) 
104 {
105         return b < a;
106 }
107
108 ///
109 inline
110 bool operator>=(LyXCursor const & a, LyXCursor const & b)
111 {
112         return !(a < b);
113 }
114
115
116 ///
117 inline
118 bool operator<=(LyXCursor const & a, LyXCursor const & b)
119 {
120         return !(a > b);
121 }
122
123 #endif