]> git.lyx.org Git - lyx.git/blob - src/Row.cpp
f4e62014358740360967da486a3db4f32109848f
[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 "support/debug.h"
21
22
23 namespace lyx {
24
25
26 Row::Row()
27         : separator(0), hfill(0), label_hfill(0), x(0),
28         sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(0), end_(0)
29 {}
30
31
32 Row::Row(pos_type pos)
33         : separator(0), hfill(0), label_hfill(0), x(0),
34         sel_beg(-1), sel_end(-1), changed_(false), crc_(0), pos_(pos), end_(0)
35 {}
36
37
38 void Row::setCrc(size_type crc) const
39 {
40         changed_ = crc != crc_;
41         crc_ = crc;
42 }
43
44
45 void Row::setDimension(Dimension const & dim)
46 {
47         dim_ = dim;
48 }
49
50
51 void Row::pos(pos_type p)
52 {
53         pos_ = p;
54 }
55
56
57 void Row::endpos(pos_type p)
58 {
59         end_ = p;
60 }
61
62
63 void Row::setSelection(pos_type beg, pos_type end)
64 {
65         if (pos_ >= beg && pos_ <= end)
66                 sel_beg = pos_;
67         else if (beg > pos_ && beg <= end_)
68                 sel_beg = beg;
69         else
70                 sel_beg = -1;
71
72         if (end_ >= beg && end_ <= end)
73                 sel_end = end_;
74         else if (end < end_ && end >= pos_)
75                 sel_end = end;
76         else
77                 sel_end = -1;
78 }
79
80
81 void Row::dump(char const * s) const
82 {
83         LYXERR0(s << " pos: " << pos_ << " end: " << end_
84                 << " width: " << dim_.wid
85                 << " ascent: " << dim_.asc
86                 << " descent: " << dim_.des);
87 }
88
89
90 } // namespace lyx