1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-02-14 00:41:44 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Row.h
|
2003-02-14 00:41:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-04-01 16:55:48 +00:00
|
|
|
* \author Matthias Ettrich
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
2003-02-14 00:41:44 +00:00
|
|
|
* Metrics for an on-screen text row.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#ifndef ROW_H
|
|
|
|
#define ROW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
#include "Changes.h"
|
2007-08-28 09:21:48 +00:00
|
|
|
#include "Dimension.h"
|
2013-06-25 12:57:09 +00:00
|
|
|
#include "Font.h"
|
|
|
|
|
|
|
|
#include "support/docstring.h"
|
|
|
|
#include "support/types.h"
|
2007-08-28 09:21:48 +00:00
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
#include <vector>
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
class DocIterator;
|
2013-06-25 12:57:09 +00:00
|
|
|
class Inset;
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
|
2005-01-31 16:29:48 +00:00
|
|
|
/**
|
2013-07-21 18:22:32 +00:00
|
|
|
* An on-screen row of text. A paragraph is broken into a RowList for
|
|
|
|
* display. Each Row contains a tokenized description of the contents
|
|
|
|
* of the line.
|
2005-01-31 16:29:48 +00:00
|
|
|
*/
|
2000-06-08 23:16:16 +00:00
|
|
|
class Row {
|
|
|
|
public:
|
2013-07-21 18:22:32 +00:00
|
|
|
// Possible types of row elements
|
|
|
|
enum Type {
|
|
|
|
// a string of character
|
|
|
|
STRING,
|
|
|
|
/**
|
|
|
|
* Something (completion, end-of-par marker)
|
|
|
|
* that occupies space one screen but does not
|
|
|
|
* correspond to any paragraph contents
|
|
|
|
*/
|
|
|
|
VIRTUAL,
|
|
|
|
// A stretchable space, basically
|
|
|
|
SEPARATOR,
|
|
|
|
// An inset
|
|
|
|
INSET,
|
|
|
|
// Some spacing described by its width, not a string
|
|
|
|
SPACE
|
|
|
|
};
|
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
/**
|
|
|
|
* One element of a Row. It has a set of attributes that can be used
|
|
|
|
* by other methods that need to parse the Row contents.
|
|
|
|
*/
|
|
|
|
struct Element {
|
2013-07-17 22:25:08 +00:00
|
|
|
Element(Type const t, pos_type p, Font const & f, Change const & ch)
|
|
|
|
: type(t), pos(p), endpos(p + 1), inset(0),
|
|
|
|
extra(0), font(f), change(ch), final(false) {}
|
2013-06-25 12:57:09 +00:00
|
|
|
|
2013-07-17 22:25:08 +00:00
|
|
|
// returns total width of element, including separator overhead
|
|
|
|
double width() const { return dim.wid + extra; };
|
|
|
|
// returns position in pixels (from the left) of position
|
2014-03-21 10:56:42 +00:00
|
|
|
// \param i in the row element.
|
2013-07-17 22:25:08 +00:00
|
|
|
double pos2x(pos_type const i) const;
|
2013-06-25 12:57:09 +00:00
|
|
|
|
2013-07-21 18:22:32 +00:00
|
|
|
/** Return character position that is the closest to
|
|
|
|
* pixel position \param x. The value \param x is
|
2014-05-14 15:46:43 +00:00
|
|
|
* adjusted to the actual pixel position.
|
2013-07-21 18:22:32 +00:00
|
|
|
*/
|
2014-05-14 15:46:43 +00:00
|
|
|
pos_type x2pos(double &x) const;
|
2013-07-21 18:22:32 +00:00
|
|
|
|
2014-03-21 10:56:42 +00:00
|
|
|
// Returns the position on left side of the element.
|
|
|
|
pos_type left_pos() const;
|
|
|
|
// Returns the position on right side of the element.
|
|
|
|
pos_type right_pos() const;
|
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
// The kind of row element
|
|
|
|
Type type;
|
|
|
|
// position of the element in the paragraph
|
|
|
|
pos_type pos;
|
2013-07-16 22:59:34 +00:00
|
|
|
// first position after the element in the paragraph
|
|
|
|
pos_type endpos;
|
2013-07-17 22:25:08 +00:00
|
|
|
// The dimension of the chunk (does not contains the
|
|
|
|
// separator correction)
|
2013-06-25 12:57:09 +00:00
|
|
|
Dimension dim;
|
|
|
|
|
2013-07-17 22:25:08 +00:00
|
|
|
// Non-zero only if element is an inset
|
2013-06-25 12:57:09 +00:00
|
|
|
Inset const * inset;
|
|
|
|
|
2013-07-17 22:25:08 +00:00
|
|
|
// Only non-null for separator elements
|
|
|
|
double extra;
|
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
// Non-empty if element is a string or separator
|
|
|
|
docstring str;
|
|
|
|
//
|
|
|
|
Font font;
|
|
|
|
//
|
|
|
|
Change change;
|
2013-07-17 22:25:08 +00:00
|
|
|
// is it possible to add contents to this element?
|
|
|
|
bool final;
|
|
|
|
|
|
|
|
friend std::ostream & operator<<(std::ostream & os, Element const & row);
|
2013-06-25 12:57:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
Row();
|
2003-03-29 23:11:20 +00:00
|
|
|
///
|
2007-08-29 21:03:41 +00:00
|
|
|
bool changed() const { return changed_; }
|
|
|
|
///
|
2007-08-29 23:06:14 +00:00
|
|
|
void setChanged(bool c) { changed_ = c; }
|
|
|
|
///
|
2007-11-17 11:27:03 +00:00
|
|
|
void setCrc(size_type crc) const;
|
2008-03-03 11:03:47 +00:00
|
|
|
/// Set the selection begin and end.
|
|
|
|
/**
|
|
|
|
* This is const because we update the selection status only at draw()
|
|
|
|
* time.
|
|
|
|
*/
|
|
|
|
void setSelection(pos_type sel_beg, pos_type sel_end) const;
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
///
|
|
|
|
bool selection() const;
|
2008-09-14 22:09:10 +00:00
|
|
|
/// Set the selection begin and end and whether the left and/or right
|
|
|
|
/// margins are selected.
|
2013-06-25 12:57:09 +00:00
|
|
|
void setSelectionAndMargins(DocIterator const & beg,
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
DocIterator const & end) const;
|
2013-06-25 12:57:09 +00:00
|
|
|
|
2007-08-29 21:03:41 +00:00
|
|
|
///
|
2013-07-23 14:24:01 +00:00
|
|
|
void pos(pos_type p) { pos_ = p; }
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
2007-08-29 21:03:41 +00:00
|
|
|
pos_type pos() const { return pos_; }
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
2013-07-23 14:24:01 +00:00
|
|
|
void endpos(pos_type p) { end_ = p; }
|
2003-08-22 07:49:57 +00:00
|
|
|
///
|
2007-08-29 21:03:41 +00:00
|
|
|
pos_type endpos() const { return end_; }
|
2013-07-23 14:24:01 +00:00
|
|
|
///
|
|
|
|
void right_boundary(bool b) { right_boundary_ = b; }
|
|
|
|
///
|
|
|
|
bool right_boundary() const { return right_boundary_; }
|
|
|
|
|
2007-08-29 21:03:41 +00:00
|
|
|
///
|
2007-08-28 09:21:48 +00:00
|
|
|
Dimension const & dimension() const { return dim_; }
|
|
|
|
///
|
2013-06-14 17:24:29 +00:00
|
|
|
Dimension & dimension() { return dim_; }
|
|
|
|
///
|
2007-08-28 09:21:48 +00:00
|
|
|
int height() const { return dim_.height(); }
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
2007-08-28 09:21:48 +00:00
|
|
|
int width() const { return dim_.wid; }
|
2000-06-26 15:10:49 +00:00
|
|
|
///
|
2007-08-28 09:21:48 +00:00
|
|
|
int ascent() const { return dim_.asc; }
|
2000-06-08 23:16:16 +00:00
|
|
|
///
|
2007-08-28 09:21:48 +00:00
|
|
|
int descent() const { return dim_.des; }
|
2007-08-29 21:03:41 +00:00
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
///
|
2013-07-16 22:59:34 +00:00
|
|
|
void add(pos_type pos, Inset const * ins, Dimension const & dim,
|
2013-06-25 12:57:09 +00:00
|
|
|
Font const & f, Change const & ch);
|
|
|
|
///
|
|
|
|
void add(pos_type pos, char_type const c,
|
|
|
|
Font const & f, Change const & ch);
|
|
|
|
///
|
2013-07-21 18:22:32 +00:00
|
|
|
void addVirtual(pos_type pos, docstring const & s,
|
|
|
|
Font const & f, Change const & ch);
|
2013-07-16 22:59:34 +00:00
|
|
|
///
|
2013-06-25 12:57:09 +00:00
|
|
|
void addSeparator(pos_type pos, char_type const c,
|
|
|
|
Font const & f, Change const & ch);
|
|
|
|
///
|
2013-07-16 22:59:34 +00:00
|
|
|
void addSpace(pos_type pos, int width, Font const & f, Change const & ch);
|
2013-07-17 22:25:08 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
typedef std::vector<Element> Elements;
|
|
|
|
///
|
|
|
|
typedef Elements::iterator iterator;
|
|
|
|
///
|
|
|
|
typedef Elements::const_iterator const_iterator;
|
|
|
|
///
|
|
|
|
iterator begin() { return elements_.begin(); }
|
|
|
|
///
|
|
|
|
iterator end() { return elements_.end(); }
|
|
|
|
///
|
|
|
|
const_iterator begin() const { return elements_.begin(); }
|
|
|
|
///
|
|
|
|
const_iterator end() const { return elements_.end(); }
|
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
///
|
|
|
|
bool empty() const { return elements_.empty(); }
|
|
|
|
///
|
2014-03-19 13:44:53 +00:00
|
|
|
Element & front() { return elements_.front(); }
|
|
|
|
///
|
|
|
|
Element const & front() const { return elements_.front(); }
|
|
|
|
///
|
2013-06-25 12:57:09 +00:00
|
|
|
Element & back() { return elements_.back(); }
|
|
|
|
///
|
|
|
|
Element const & back() const { return elements_.back(); }
|
|
|
|
/// remove last element
|
|
|
|
void pop_back();
|
|
|
|
/// remove all row elements
|
|
|
|
void clear() { elements_.clear(); }
|
|
|
|
/**
|
2013-07-21 18:22:32 +00:00
|
|
|
* if row width is too large, remove all elements after last
|
|
|
|
* separator and update endpos if necessary. If all that
|
2014-03-21 10:56:42 +00:00
|
|
|
* remains is a large word, cut it to \param width.
|
2013-07-21 18:22:32 +00:00
|
|
|
* \param body_pos minimum amount of text to keep.
|
|
|
|
* \param width maximum width of the row
|
2013-06-25 12:57:09 +00:00
|
|
|
*/
|
2013-07-21 18:22:32 +00:00
|
|
|
void shorten_if_needed(pos_type const body_pos, int const width);
|
2013-06-25 12:57:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If last element of the row is a string, compute its width
|
|
|
|
* and mark it final.
|
|
|
|
*/
|
|
|
|
void finalizeLast();
|
|
|
|
|
2013-07-16 22:59:34 +00:00
|
|
|
/**
|
2013-07-21 18:22:32 +00:00
|
|
|
* Find sequences of right-to-left elements and reverse them.
|
2013-07-16 22:59:34 +00:00
|
|
|
* This should be called once the row is completely built.
|
|
|
|
*/
|
2014-03-19 13:44:31 +00:00
|
|
|
void reverseRTL(bool rtl_par);
|
2013-06-25 12:57:09 +00:00
|
|
|
|
2013-07-16 22:59:34 +00:00
|
|
|
friend std::ostream & operator<<(std::ostream & os, Row const & row);
|
2004-03-01 12:23:17 +00:00
|
|
|
|
|
|
|
/// width of a separator (i.e. space)
|
|
|
|
double separator;
|
|
|
|
/// width of hfills in the label
|
|
|
|
double label_hfill;
|
2013-07-21 18:22:32 +00:00
|
|
|
/// the x position of the row (left margin)
|
2004-03-01 12:23:17 +00:00
|
|
|
double x;
|
2013-07-21 18:22:32 +00:00
|
|
|
/// the right margin of the row
|
|
|
|
int right_margin;
|
2007-09-05 13:04:05 +00:00
|
|
|
///
|
2008-03-03 11:03:47 +00:00
|
|
|
mutable pos_type sel_beg;
|
2007-09-05 13:04:05 +00:00
|
|
|
///
|
2008-03-03 11:03:47 +00:00
|
|
|
mutable pos_type sel_end;
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
///
|
2008-10-13 23:19:06 +00:00
|
|
|
mutable bool begin_margin_sel;
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
///
|
2008-10-13 23:19:06 +00:00
|
|
|
mutable bool end_margin_sel;
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
|
2007-08-28 15:47:53 +00:00
|
|
|
private:
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
/// Decides whether the margin is selected.
|
|
|
|
/**
|
|
|
|
* \param margin_begin
|
|
|
|
* \param beg
|
|
|
|
* \param end
|
|
|
|
*/
|
2008-09-14 22:09:10 +00:00
|
|
|
bool isMarginSelected(bool left_margin, DocIterator const & beg,
|
Patch by Vincent that solves a number of problems related to the painting of a selection:
1. When a listing is inserted in a bit of text, the line above the listing is not drawn over the full width like it is done for lines above other insets. This is because InsetListing has a AlignLeft alignment. Now, if you start selecting downwards with the mouse in this empty area, strange selection drawings appear (see attachment).
This is caused by the fact that starting your selection at such a place, causes beg.boundary() to be true in TextMetrics::drawRowSelection(..). This is correct, but this value is true for _all_ selected lines. Now, the selection acts as if it is RTL text. Therefore, just like for end.boundary, this value needs to be reset for every line.
2. Starting your selection in an end margin often causes the selection in this end margin to be painted later. This is because when starting your selection in an end margin, you may have set a (possible empty) selection before really selecting the end margin. The problem is that the checksum (computed later) is the same for this empty selection and for the end margin selection. Therfore, we need a call to cur.setSelection() before evaluating cur.selection().
3. In the following two lines, it is assumed that there is only an end margin to be painted if the selection extends to the next paragraph. This is not true for the above described case of an AlignLeft Inset. Then, the margin has also be drawn within a paragraph
4. The end and begin margins are only painted when the selection extends into the following or previous paragraph. This difference is not resembled in the checksum if you first select a row completely and then procede to the next or previous paragraph as the selection remains at the end of a row. This also holds for the AlignLeft case. Therefore I added a term to the checksum to monitor whether the end and begin margins need to be drawn.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26399 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-14 14:32:40 +00:00
|
|
|
DocIterator const & end) const;
|
|
|
|
|
2013-06-25 12:57:09 +00:00
|
|
|
/**
|
|
|
|
* Returns true if a char or string with font \c f and change
|
|
|
|
* type \c ch can be added to the current last element of the
|
|
|
|
* row.
|
|
|
|
*/
|
|
|
|
bool sameString(Font const & f, Change const & ch) const;
|
|
|
|
|
|
|
|
///
|
|
|
|
Elements elements_;
|
|
|
|
|
2007-08-29 21:03:41 +00:00
|
|
|
/// has the Row appearance changed since last drawing?
|
2007-11-17 11:27:03 +00:00
|
|
|
mutable bool changed_;
|
2007-08-29 21:03:41 +00:00
|
|
|
/// CRC of row contents.
|
2007-11-17 11:27:03 +00:00
|
|
|
mutable size_type crc_;
|
2007-08-28 15:47:53 +00:00
|
|
|
/// first pos covered by this row
|
|
|
|
pos_type pos_;
|
|
|
|
/// one behind last pos covered by this row
|
|
|
|
pos_type end_;
|
2013-07-23 14:24:01 +00:00
|
|
|
// Is there is a boundary at the end of the row (display inset...)
|
|
|
|
bool right_boundary_;
|
2007-08-28 15:47:53 +00:00
|
|
|
/// Row dimension.
|
|
|
|
Dimension dim_;
|
|
|
|
};
|
2004-03-01 12:23:17 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|