]> git.lyx.org Git - lyx.git/blob - src/Row.h
more latin1..utf8 schanges. all of src/* should be utf8 now
[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         bool changed() const { return changed_; }
38         ///
39         void setChanged(bool c) { changed_ = c; }
40         ///
41         void setCrc(size_type crc) const;
42         /// Set the selection begin and end.
43         /**
44           * This is const because we update the selection status only at draw()
45           * time.
46           */
47         void setSelection(pos_type sel_beg, pos_type sel_end) const;
48         ///
49         bool selection() const;
50         /// Set the selection begin and end and whether the left and/or right
51         /// margins are selected.
52         void setSelectionAndMargins(DocIterator const & beg, 
53                 DocIterator const & end) const;
54         
55         ///
56         void pos(pos_type p);
57         ///
58         pos_type pos() const { return pos_; }
59         ///
60         void endpos(pos_type p);
61         ///
62         pos_type endpos() const { return end_; }
63         ///
64         void setDimension(Dimension const & dim);
65         ///
66         Dimension const & dimension() const { return dim_; }
67         ///
68         int height() const { return dim_.height(); }
69         ///
70         int width() const { return dim_.wid; }
71         ///
72         int ascent() const { return dim_.asc; }
73         ///
74         int descent() const { return dim_.des; }
75
76         /// current debugging only
77         void dump(char const * = "") const;
78
79         /// width of a separator (i.e. space)
80         double separator;
81         /// width of hfills in the label
82         double label_hfill;
83         /// the x position of the row
84         double x;
85         ///
86         mutable pos_type sel_beg;
87         ///
88         mutable pos_type sel_end;
89         ///
90         mutable bool begin_margin_sel;
91         ///
92         mutable bool end_margin_sel;
93
94 private:
95         /// Decides whether the margin is selected.
96         /**
97           * \param margin_begin
98           * \param beg
99           * \param end
100           */
101         bool isMarginSelected(bool left_margin, DocIterator const & beg,
102                 DocIterator const & end) const;
103
104         /// has the Row appearance changed since last drawing?
105         mutable bool changed_;
106         /// CRC of row contents.
107         mutable size_type crc_;
108         /// first pos covered by this row
109         pos_type pos_;
110         /// one behind last pos covered by this row
111         pos_type end_;
112         /// Row dimension.
113         Dimension dim_;
114 };
115
116
117 } // namespace lyx
118
119 #endif