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