]> git.lyx.org Git - lyx.git/blob - src/ParagraphMetrics.h
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[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 "Dimension.h"
21 #include "Paragraph.h"
22 #include "Row.h"
23
24 namespace lyx {
25
26 /**
27  * Each paragraph is broken up into a number of rows on the screen.
28  * This is a list of such on-screen rows, ordered from the top row
29  * downwards.
30  */
31 typedef std::vector<Row> RowList;
32
33 class MetricsInfo;
34 class PainterInfo;
35
36 /// Helper class for Paragraph Metrics.
37 class ParagraphMetrics  {
38 public:
39         /// Default constructor (only here for STL containers).
40         ParagraphMetrics(): par_(0) {};
41         /// The only useful constructor.
42         ParagraphMetrics(Paragraph const & par);
43
44         /// Copy operator.
45         ParagraphMetrics & operator=(ParagraphMetrics const &);
46
47         void reset(Paragraph const & par);
48
49         ///
50         Row & getRow(pos_type pos, bool boundary);
51         ///
52         Row const & getRow(pos_type pos, bool boundary) const;
53         ///
54         size_t pos2row(pos_type pos) const;
55
56         /// BufferView::redoParagraph updates this
57         Dimension const & dim() const { return dim_; }
58         Dimension & dim() { return dim_; }
59         /// total height of paragraph
60         int height() const { return dim_.height(); }
61         /// total width of paragraph, may differ from workwidth
62         int width() const { return dim_.width(); }
63         /// ascend of paragraph above baseline
64         int ascent() const { return dim_.ascent(); }
65         /// descend of paragraph below baseline
66         int descent() const { return dim_.descent(); }
67         /// Text updates the rows using this access point
68         RowList & rows() { return rows_; }
69         /// The painter and others use this
70         RowList const & rows() const { return rows_; }
71         ///
72         int rightMargin(Buffer const & buffer) const;
73         ///
74         int singleWidth(pos_type pos, Font const & Font) const;
75
76         /// dump some information to lyxerr
77         void dump() const;
78
79         ///
80         bool hfillExpansion(Row const & row, pos_type pos) const;
81
82         /// 
83         void computeRowSignature(Row &, BufferParams const & bparams);
84
85         ///
86         int position() const { return position_; }
87         void setPosition(int position);
88
89
90 private:
91         ///
92         int position_;
93         ///
94         mutable RowList rows_;
95         /// cached dimensions of paragraph
96         Dimension dim_;
97         ///
98         Paragraph const * par_;
99 };
100
101 } // namespace lyx
102
103 #endif // PARAGRAPH_METRICS_H