]> git.lyx.org Git - lyx.git/blob - src/Row.cpp
Fix bug 4212
[lyx.git] / src / Row.cpp
1 /**
2  * \file Row.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author unknown
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  * \author André Pönitz
10  * \author Jürgen Vigna
11  *
12  * Full author contact details are available in file CREDITS.
13  *
14  * Metrics for an on-screen text row.
15  */
16
17 #include <config.h>
18
19 #include "Row.h"
20 #include "debug.h"
21
22
23 namespace lyx {
24
25
26 Row::Row()
27         : changed_(false), crc_(0), pos_(0), end_(0), separator(0), hfill(0),
28         label_hfill(0), x(0), sel_beg(-1), sel_end(-1)
29 {}
30
31
32 Row::Row(pos_type pos)
33         : changed_(false), crc_(0), pos_(pos), end_(0), separator(0), hfill(0),
34         label_hfill(0), x(0), sel_beg(-1), sel_end(-1)
35 {}
36
37
38 void Row::setCrc(size_type crc)
39 {
40         changed_ |= crc != crc_;
41         crc_ = crc;
42 }
43
44
45 void Row::setDimension(Dimension const & dim)
46 {
47         changed_ |= dim != dim_;
48         dim_ = dim;
49 }
50
51
52 void Row::pos(pos_type p)
53 {
54         pos_ = p;
55 }
56
57
58 void Row::endpos(pos_type p)
59 {
60         end_ = p;
61 }
62
63
64 void Row::setSelection(pos_type beg, pos_type end)
65 {
66         pos_type sel_beg_b = sel_beg;
67         if (pos_ >= beg && pos_ <= end)
68                 sel_beg = pos_;
69         else if (beg > pos_ && beg <= end_)
70                 sel_beg = beg;
71         else
72                 sel_beg = -1;
73
74         pos_type sel_end_b = sel_end;
75         if (end_ >= beg && end_ <= end)
76                 sel_end = end_;
77         else if (end < end_ && end >= pos_)
78                 sel_end = end;
79         else
80                 sel_end = -1;
81 /*
82                         && ((rit->pos() >= beg.pos() && rit->pos() <= end.pos())
83                                 || (rit->endpos() >= beg.pos() && rit->endpos() <= end.pos())
84                                 || (beg.pos() >= rit->pos() && beg.pos() <= rit->endpos())
85                                 || (end.pos() >= rit->pos() && end.pos() <= rit->endpos()));
86 */
87         changed_ |= sel_beg_b != sel_beg;
88         changed_ |= sel_end_b != sel_end;
89 }
90
91
92 void Row::dump(const char * s) const
93 {
94         lyxerr << s << " pos: " << pos_ << " end: " << end_
95                 << " width: " << dim_.wid
96                 << " ascent: " << dim_.asc
97                 << " descent: " << dim_.des
98                 << std::endl;
99 }
100
101
102 } // namespace lyx