scramble email addresses
[lyx.git] / src / ParagraphMetrics.h
blob43dbd747487afb505d5b42c6ded8626e4a9a9c24
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.
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
14 * Full author contact details are available in file CREDITS.
17 #ifndef PARAGRAPH_METRICS_H
18 #define PARAGRAPH_METRICS_H
20 #include "Dimension.h"
21 #include "Row.h"
23 #include <map>
24 #include <vector>
26 namespace lyx {
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.
33 typedef std::vector<Row> RowList;
35 class Buffer;
36 class BufferParams;
37 class Font;
38 class Inset;
39 class Paragraph;
40 class MetricsInfo;
41 class PainterInfo;
43 /// Helper class for paragraph metrics.
44 class ParagraphMetrics {
45 public:
46 /// Default constructor (only here for STL containers).
47 ParagraphMetrics() : par_(0) {}
48 /// The only useful constructor.
49 explicit ParagraphMetrics(Paragraph const & par);
51 /// Copy operator.
52 ParagraphMetrics & operator=(ParagraphMetrics const &);
54 void reset(Paragraph const & par);
56 ///
57 Row & getRow(pos_type pos, bool boundary);
58 ///
59 Row const & getRow(pos_type pos, bool boundary) const;
60 ///
61 size_t pos2row(pos_type pos) const;
63 /// BufferView::redoParagraph updates this
64 Dimension const & dim() const { return dim_; }
65 Dimension & dim() { return dim_; }
66 /// total height of paragraph
67 int height() const { return dim_.height(); }
68 /// total width of paragraph, may differ from workwidth
69 int width() const { return dim_.width(); }
70 /// ascend of paragraph above baseline
71 int ascent() const { return dim_.ascent(); }
72 /// descend of paragraph below baseline
73 int descent() const { return dim_.descent(); }
74 /// Text updates the rows using this access point
75 RowList & rows() { return rows_; }
76 /// The painter and others use this
77 RowList const & rows() const { return rows_; }
78 ///
79 int rightMargin(Buffer const & buffer) const;
80 ///
81 int singleWidth(pos_type pos, Font const & Font) const;
83 /// dump some information to lyxerr
84 void dump() const;
86 ///
87 bool hfillExpansion(Row const & row, pos_type pos) const;
89 ///
90 void computeRowSignature(Row &, BufferParams const & bparams);
92 ///
93 int position() const { return position_; }
94 void setPosition(int position);
96 ///
97 Dimension const & insetDimension(Inset const * inset) const;
98 ///
99 void setInsetDimension(Inset const *, Dimension const & dim);
101 private:
103 int position_;
105 mutable RowList rows_;
106 /// cached dimensions of paragraph
107 Dimension dim_;
109 Paragraph const * par_;
111 typedef std::map<Inset const *, Dimension> InsetDims;
113 InsetDims inset_dims_;
116 } // namespace lyx
118 #endif // PARAGRAPH_METRICS_H