]> git.lyx.org Git - lyx.git/blob - src/ParagraphMetrics.h
* src/support/unicode.C
[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         Row & getRow(pos_type pos, bool boundary);
36         ///
37         Row const & getRow(pos_type pos, bool boundary) const;
38         ///
39         size_t pos2row(pos_type pos) const;
40
41         /// BufferView::redoParagraph updates this
42         Dimension const & dim() const { return dim_; }
43         Dimension & dim() { return dim_; }
44         /// total height of paragraph
45         unsigned int height() const { return dim_.height(); }
46         /// total width of paragraph, may differ from workwidth
47         unsigned int width() const { return dim_.width(); }
48         /// ascend of paragraph above baseline
49         unsigned int ascent() const { return dim_.ascent(); }
50         /// descend of paragraph below baseline
51         unsigned int descent() const { return dim_.descent(); }
52         /// LyXText updates the rows using this access point
53         RowList & rows() { return rows_; }
54         /// The painter and others use this
55         RowList const & rows() const { return rows_; }
56         ///
57         RowSignature & rowSignature() const { return rowSignature_; }
58         ///
59         int rightMargin(Buffer const & buffer) const;
60
61         /// dump some information to lyxerr
62         void dump() const;
63
64 private:
65         ///
66         mutable RowList rows_;
67         ///
68         mutable RowSignature rowSignature_;
69         /// cached dimensions of paragraph
70         Dimension dim_;
71         ///
72         Paragraph const * par_;
73 };
74
75 } // namespace lyx
76
77 #endif // PARAGRAPH_METRICS_H