]> git.lyx.org Git - lyx.git/blob - src/Row.cpp
InsetHyperlink.cpp: fix a bug I introduced in r26218
[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
21 #include "support/debug.h"
22
23
24 namespace lyx {
25
26
27 Row::Row()
28         : separator(0), label_hfill(0), x(0),
29         sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(0), end_(0)
30 {}
31
32
33 Row::Row(pos_type pos)
34         : separator(0), label_hfill(0), x(0),
35         sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(pos), end_(0)
36 {}
37
38
39 void Row::setCrc(size_type crc) const
40 {
41         changed_ = crc != crc_;
42         crc_ = crc;
43 }
44
45
46 void Row::setDimension(Dimension const & dim)
47 {
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) const
65 {
66         if (pos_ >= beg && pos_ <= end)
67                 sel_beg = pos_;
68         else if (beg > pos_ && beg <= end_)
69                 sel_beg = beg;
70         else
71                 sel_beg = -1;
72
73         if (end_ >= beg && end_ <= end)
74                 sel_end = end_;
75         else if (end < end_ && end >= pos_)
76                 sel_end = end;
77         else
78                 sel_end = -1;
79 }
80
81
82 void Row::dump(char const * s) const
83 {
84         LYXERR0(s << " pos: " << pos_ << " end: " << end_
85                 << " width: " << dim_.wid
86                 << " ascent: " << dim_.asc
87                 << " descent: " << dim_.des);
88 }
89
90
91 } // namespace lyx