]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
Point fix, earlier forgotten
[lyx.git] / src / lyxcursor.h
1 // -*- C++ -*-
2 /**
3  * \file lyxcursor.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Matthias Ettrich
9  * \author John Levon
10  * \author André Pönitz
11  * \author Dekel Tsur
12  * \author Jürgen Vigna
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #ifndef LYXCURSOR_H
18 #define LYXCURSOR_H
19
20 #include "ParagraphList.h"
21 #include "support/types.h"
22
23 /**
24  * The cursor class describes the position of a cursor within a document.
25  * Several cursors exist within LyX; for example, when locking an inset,
26  * the position of the cursor in the containing inset is stored.
27  *
28  * FIXME: true ?
29  */
30 class LyXCursor {
31 public:
32         LyXCursor();
33         /// set the paragraph that contains this cursor
34         void par(ParagraphList::iterator pit);
35         /// return the paragraph this cursor is in
36         ParagraphList::iterator par() const;
37         /// set the position within the paragraph
38         void pos(lyx::pos_type p);
39         /// return the position within the paragraph
40         lyx::pos_type pos() const;
41         /// FIXME
42         void boundary(bool b);
43         /// FIXME
44         bool boundary() const;
45         /// set the x position in pixels
46         void x(int i);
47         /// return the x position in pixels
48         int x() const;
49         /// set the cached x position
50         void x_fix(int i);
51         /**
52          * Return the cached x position of the cursor. This is used for when
53          * we have text like :
54          *
55          * blah blah blah blah| blah blah blah
56          * blah blah blah
57          * blah blah blah blah blah blah
58          *
59          * When we move onto row 3, we would like to be vertically aligned
60          * with where we were in row 1, despite the fact that row 2 is
61          * shorter than x()
62          */
63         int x_fix() const;
64         /// set the y position in pixels
65         void y(int i);
66         /// return the y position in pixels
67         int y() const;
68
69 private:
70         /// The paragraph the cursor is in.
71         ParagraphList::iterator par_;
72         /// The position inside the paragraph
73         lyx::pos_type pos_;
74         /**
75          * When the cursor position is i, is the cursor is after the i-th char
76          * or before the i+1-th char ? Normally, these two interpretations are
77          * equivalent, except when the fonts of the i-th and i+1-th char
78          * differ.
79          * We use boundary_ to distinguish between the two options:
80          * If boundary_=true, then the cursor is after the i-th char
81          * and if boundary_=false, then the cursor is before the i+1-th char.
82          *
83          * We currently use the boundary only when the language direction of
84          * the i-th char is different than the one of the i+1-th char.
85          * In this case it is important to distinguish between the two
86          * cursor interpretations, in order to give a reasonable behavior to
87          * the user.
88          */
89         bool boundary_;
90         /// the pixel x position
91         int x_;
92         /// the cached x position
93         int x_fix_;
94         /// the pixel y position
95         int y_;
96 };
97
98 ///
99 bool operator==(LyXCursor const & a, LyXCursor const & b);
100 ///
101 bool operator!=(LyXCursor const & a, LyXCursor const & b);
102
103 #endif // LYXCURSOR_H