]> git.lyx.org Git - lyx.git/blob - src/lyxcursor.h
ws changes only
[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 "support/types.h"
21
22 /**
23  * The cursor class describes the position of a cursor within a document.
24  * Several cursors exist within LyX; for example, when locking an inset,
25  * the position of the cursor in the containing inset is stored.
26  *
27  * FIXME: true ?
28  */
29 class LyXCursor {
30 public:
31         LyXCursor();
32         /// set the paragraph that contains this cursor
33         void par(lyx::paroffset_type pit);
34         /// return the paragraph this cursor is in
35         lyx::paroffset_type par() const;
36         /// set the position within the paragraph
37         void pos(lyx::pos_type p);
38         /// return the position within the paragraph
39         lyx::pos_type pos() const;
40         /// FIXME
41         void boundary(bool b);
42         /// FIXME
43         bool boundary() const;
44         /// set the x position in pixels
45         void x(int i);
46         /// return the x position in pixels
47         int x() const;
48         /// set the cached x position
49         void x_fix(int i);
50         /**
51          * Return the cached x position of the cursor. This is used for when
52          * we have text like :
53          *
54          * blah blah blah blah| blah blah blah
55          * blah blah blah
56          * blah blah blah blah blah blah
57          *
58          * When we move onto row 3, we would like to be vertically aligned
59          * with where we were in row 1, despite the fact that row 2 is
60          * shorter than x()
61          */
62         int x_fix() const;
63         /// set the y position in pixels
64         void y(int i);
65         /// return the y position in pixels
66         int y() const;
67
68 private:
69         /// The paragraph the cursor is in.
70         lyx::paroffset_type par_;
71         /// The position inside the paragraph
72         lyx::pos_type pos_;
73         /**
74          * When the cursor position is i, is the cursor is after the i-th char
75          * or before the i+1-th char ? Normally, these two interpretations are
76          * equivalent, except when the fonts of the i-th and i+1-th char
77          * differ.
78          * We use boundary_ to distinguish between the two options:
79          * If boundary_=true, then the cursor is after the i-th char
80          * and if boundary_=false, then the cursor is before the i+1-th char.
81          *
82          * We currently use the boundary only when the language direction of
83          * the i-th char is different than the one of the i+1-th char.
84          * In this case it is important to distinguish between the two
85          * cursor interpretations, in order to give a reasonable behavior to
86          * the user.
87          */
88         bool boundary_;
89         /// the pixel x position
90         int x_;
91         /// the cached x position
92         int x_fix_;
93         /// the pixel y position
94         int y_;
95 };
96
97 ///
98 bool operator==(LyXCursor const & a, LyXCursor const & b);
99 ///
100 bool operator!=(LyXCursor const & a, LyXCursor const & b);
101
102 #endif // LYXCURSOR_H