1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-08-04 23:11:50 +00:00
|
|
|
/**
|
|
|
|
* \file lyxcursor.h
|
|
|
|
* Copyright 1995-2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2002-08-04 23:11:50 +00:00
|
|
|
* \author Matthias Ettrich
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef LYXCURSOR_H
|
|
|
|
#define LYXCURSOR_H
|
|
|
|
|
2003-04-09 09:15:20 +00:00
|
|
|
#include "ParagraphList.h"
|
2001-11-26 16:42:04 +00:00
|
|
|
#include "support/types.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
/**
|
2002-08-04 23:11:50 +00:00
|
|
|
* The cursor class describes the position of a cursor within a document.
|
|
|
|
* Several cursors exist within LyX; for example, when locking an inset,
|
|
|
|
* the position of the cursor in the containing inset is stored.
|
|
|
|
*
|
|
|
|
* FIXME: true ?
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
2000-06-08 23:16:16 +00:00
|
|
|
class LyXCursor {
|
|
|
|
public:
|
2001-01-08 14:19:29 +00:00
|
|
|
LyXCursor();
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the paragraph that contains this cursor
|
2003-04-09 09:15:20 +00:00
|
|
|
void par(ParagraphList::iterator pit);
|
2002-08-04 23:11:50 +00:00
|
|
|
/// return the paragraph this cursor is in
|
2003-04-09 09:15:20 +00:00
|
|
|
ParagraphList::iterator par() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the position within the paragraph
|
2001-11-27 10:34:16 +00:00
|
|
|
void pos(lyx::pos_type p);
|
2002-08-04 23:11:50 +00:00
|
|
|
/// return the position within the paragraph
|
2001-11-27 10:34:16 +00:00
|
|
|
lyx::pos_type pos() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// FIXME
|
2000-06-08 23:16:16 +00:00
|
|
|
void boundary(bool b);
|
2002-08-04 23:11:50 +00:00
|
|
|
/// FIXME
|
2000-06-08 23:16:16 +00:00
|
|
|
bool boundary() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the x position in pixels
|
2000-06-08 23:16:16 +00:00
|
|
|
void x(int i);
|
2002-08-04 23:11:50 +00:00
|
|
|
/// return the x position in pixels
|
2000-06-08 23:16:16 +00:00
|
|
|
int x() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the stored next-line position when at the end of a row
|
2002-04-12 15:59:03 +00:00
|
|
|
void ix(int i);
|
2002-08-04 23:11:50 +00:00
|
|
|
/**
|
|
|
|
* Return the x position of the start of the next row, when this
|
|
|
|
* cursor is at the end of the previous row, for insets that take
|
|
|
|
* a full row.
|
|
|
|
*
|
|
|
|
* FIXME: explain why we need this ?
|
|
|
|
*/
|
2002-04-12 15:59:03 +00:00
|
|
|
int ix() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the cached x position
|
2000-06-08 23:16:16 +00:00
|
|
|
void x_fix(int i);
|
2002-08-04 23:11:50 +00:00
|
|
|
/**
|
|
|
|
* Return the cached x position of the cursor. This is used for when
|
|
|
|
* we have text like :
|
|
|
|
*
|
|
|
|
* blah blah blah blah| blah blah blah
|
|
|
|
* blah blah blah
|
|
|
|
* blah blah blah blah blah blah
|
|
|
|
*
|
|
|
|
* When we move onto row 3, we would like to be vertically aligned
|
2002-11-27 10:30:28 +00:00
|
|
|
* with where we were in row 1, despite the fact that row 2 is
|
2002-08-04 23:11:50 +00:00
|
|
|
* shorter than x()
|
|
|
|
*/
|
2000-06-08 23:16:16 +00:00
|
|
|
int x_fix() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the y position in pixels
|
2000-09-29 18:44:07 +00:00
|
|
|
void y(int i);
|
2002-08-04 23:11:50 +00:00
|
|
|
/// return the y position in pixels
|
2000-09-29 18:44:07 +00:00
|
|
|
int y() const;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// set the stored next-line y position when at the end of a row
|
2002-04-11 09:53:23 +00:00
|
|
|
void iy(int i);
|
2002-08-04 23:11:50 +00:00
|
|
|
/**
|
|
|
|
* Return the y position of the start of the next row, when this
|
|
|
|
* cursor is at the end of the previous row, for insets that take
|
|
|
|
* a full row.
|
|
|
|
*
|
|
|
|
* FIXME: explain why we need this ? especially for y...
|
|
|
|
*/
|
2002-04-11 09:53:23 +00:00
|
|
|
int iy() const;
|
2000-06-08 23:16:16 +00:00
|
|
|
private:
|
|
|
|
/// The paragraph the cursor is in.
|
2003-04-09 09:15:20 +00:00
|
|
|
ParagraphList::iterator par_;
|
2000-06-08 23:16:16 +00:00
|
|
|
/// The position inside the paragraph
|
2001-11-27 10:34:16 +00:00
|
|
|
lyx::pos_type pos_;
|
2002-09-02 12:10:26 +00:00
|
|
|
/**
|
|
|
|
* When the cursor position is i, is the cursor is after the i-th char
|
|
|
|
* or before the i+1-th char ? Normally, these two interpretations are
|
|
|
|
* equivalent, except when the fonts of the i-th and i+1-th char
|
|
|
|
* differ.
|
|
|
|
* We use boundary_ to distinguish between the two options:
|
|
|
|
* If boundary_=true, then the cursor is after the i-th char
|
|
|
|
* and if boundary_=false, then the cursor is before the i+1-th char.
|
|
|
|
*
|
|
|
|
* We currently use the boundary only when the language direction of
|
|
|
|
* the i-th char is different than the one of the i+1-th char.
|
|
|
|
* In this case it is important to distinguish between the two
|
|
|
|
* cursor interpretations, in order to give a reasonable behavior to
|
|
|
|
* the user.
|
|
|
|
*/
|
2000-06-08 23:16:16 +00:00
|
|
|
bool boundary_;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// the pixel x position
|
2000-06-08 23:16:16 +00:00
|
|
|
int x_;
|
2002-11-27 10:30:28 +00:00
|
|
|
/// the stored next-row x position
|
2002-04-12 15:59:03 +00:00
|
|
|
int ix_;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// the cached x position
|
2000-06-08 23:16:16 +00:00
|
|
|
int x_fix_;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// the pixel y position
|
2000-09-29 18:44:07 +00:00
|
|
|
int y_;
|
2002-08-04 23:11:50 +00:00
|
|
|
/// the stored next-row y position
|
2002-04-11 09:53:23 +00:00
|
|
|
int iy_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2003-06-26 09:42:28 +00:00
|
|
|
///
|
|
|
|
bool operator==(LyXCursor const & a, LyXCursor const & b);
|
|
|
|
///
|
|
|
|
bool operator!=(LyXCursor const & a, LyXCursor const & b);
|
2001-06-27 18:29:18 +00:00
|
|
|
|
2002-08-04 23:11:50 +00:00
|
|
|
#endif // LYXCURSOR_H
|