]> git.lyx.org Git - lyx.git/blob - src/Row.h
055608bc2e0c87c04a9e94a240e38999111abc67
[lyx.git] / src / Row.h
1 // -*- C++ -*-
2 /**
3  * \file Row.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * Metrics for an on-screen text row.
13  */
14
15 #ifndef ROW_H
16 #define ROW_H
17
18 #include "support/types.h"
19
20 #include "Dimension.h"
21
22
23 namespace lyx {
24
25 class DocIterator;
26
27 /**
28  * An on-screen row of text. A paragraph is broken into a
29  * RowList for display. Each Row contains position pointers
30  * into the first and last character positions of that row.
31  */
32 class Row {
33 public:
34         ///
35         Row();
36         ///
37         Row(pos_type pos);
38         ///
39         bool changed() const { return changed_; }
40         ///
41         void setChanged(bool c) { changed_ = c; }
42         ///
43         void setCrc(size_type crc) const;
44         /// Set the selection begin and end.
45         /**
46           * This is const because we update the selection status only at draw()
47           * time.
48           */
49         void setSelection(pos_type sel_beg, pos_type sel_end) const;
50         ///
51         bool selection() const;
52         /// Set the selection begin and end and whether the margin begin and end
53         /// are selected.
54         void setSelectionAndMargins(DocIterator const & beg, 
55                 DocIterator const & end) const;
56         
57         ///
58         void pos(pos_type p);
59         ///
60         pos_type pos() const { return pos_; }
61         ///
62         void endpos(pos_type p);
63         ///
64         pos_type endpos() const { return end_; }
65         ///
66         void setDimension(Dimension const & dim);
67         ///
68         Dimension const & dimension() const { return dim_; }
69         ///
70         int height() const { return dim_.height(); }
71         ///
72         int width() const { return dim_.wid; }
73         ///
74         int ascent() const { return dim_.asc; }
75         ///
76         int descent() const { return dim_.des; }
77
78         /// current debugging only
79         void dump(char const * = "") const;
80
81         /// width of a separator (i.e. space)
82         double separator;
83         /// width of hfills in the label
84         double label_hfill;
85         /// the x position of the row
86         double x;
87         ///
88         mutable pos_type sel_beg;
89         ///
90         mutable pos_type sel_end;
91         ///
92         mutable bool left_margin_sel;
93         ///
94         mutable bool right_margin_sel;
95
96 private:
97         /// Decides whether the margin is selected.
98         /**
99           * \param margin_begin
100           * \param beg
101           * \param end
102           */
103         bool isMarginSelected(bool margin_begin, DocIterator const & beg, 
104                 DocIterator const & end) const;
105
106         /// has the Row appearance changed since last drawing?
107         mutable bool changed_;
108         /// CRC of row contents.
109         mutable size_type crc_;
110         /// first pos covered by this row
111         pos_type pos_;
112         /// one behind last pos covered by this row
113         pos_type end_;
114         /// Row dimension.
115         Dimension dim_;
116 };
117
118
119 } // namespace lyx
120
121 #endif