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