]> git.lyx.org Git - lyx.git/blob - src/ParagraphMetrics.h
add comment
[lyx.git] / src / ParagraphMetrics.h
1 // -*- C++ -*-
2 /**
3  * \file ParagraphMetrics.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  * \author André Pönitz
11  * \author Jürgen Vigna
12  * \author Abdelrazak Younes
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #ifndef PARAGRAPH_METRICS_H
18 #define PARAGRAPH_METRICS_H
19
20 #include "paragraph.h"
21
22 namespace lyx {
23
24 class MetricsInfo;
25 class PainterInfo;
26
27 /// Helper class for Paragraph Metrics.
28 class ParagraphMetrics  {
29 public:
30         /// Default constructor (only here for STL containers).
31         ParagraphMetrics(): par_(0) {};
32         /// The only useful constructor.
33         ParagraphMetrics(Paragraph const & par);
34
35         /// Copy operator.
36         /// Important note: We don't copy \c row_change_status_ and
37         /// \c row_signature_ because those are updated externally with
38         /// \c updateRowChangeStatus() in TextMetrics::redoParagraph().
39         ParagraphMetrics & operator=(ParagraphMetrics const &);
40
41         ///
42         Row & getRow(pos_type pos, bool boundary);
43         ///
44         Row const & getRow(pos_type pos, bool boundary) const;
45         ///
46         size_t pos2row(pos_type pos) const;
47
48         /// BufferView::redoParagraph updates this
49         Dimension const & dim() const { return dim_; }
50         Dimension & dim() { return dim_; }
51         /// total height of paragraph
52         unsigned int height() const { return dim_.height(); }
53         /// total width of paragraph, may differ from workwidth
54         unsigned int width() const { return dim_.width(); }
55         /// ascend of paragraph above baseline
56         unsigned int ascent() const { return dim_.ascent(); }
57         /// descend of paragraph below baseline
58         unsigned int descent() const { return dim_.descent(); }
59         /// LyXText updates the rows using this access point
60         RowList & rows() { return rows_; }
61         /// The painter and others use this
62         RowList const & rows() const { return rows_; }
63         /// The painter and others use this
64         std::vector<bool> const & rowChangeStatus() const 
65         { return row_change_status_; }
66         ///
67         void updateRowChangeStatus();
68         ///
69         int rightMargin(Buffer const & buffer) const;
70
71         /// dump some information to lyxerr
72         void dump() const;
73
74 private:
75         ///
76         size_type calculateRowSignature(Row const &);
77         ///
78         mutable RowList rows_;
79         ///
80         RowSignature row_signature_;
81         ///
82         std::vector<bool> row_change_status_;
83         /// cached dimensions of paragraph
84         Dimension dim_;
85         ///
86         Paragraph const * par_;
87 };
88
89 } // namespace lyx
90
91 #endif // PARAGRAPH_METRICS_H