* lyx_1_6.py:
[lyx.git] / src / ParagraphMetrics.h
bloba100651957d0c4714c146bc3d7d655f11b383bd0
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 BufferView;
37 class BufferParams;
38 class Font;
39 class Inset;
40 class Paragraph;
41 class MetricsInfo;
42 class PainterInfo;
44 /// Helper class for paragraph metrics.
45 class ParagraphMetrics {
46 public:
47 /// Default constructor (only here for STL containers).
48 ParagraphMetrics() : par_(0) {}
49 /// The only useful constructor.
50 explicit ParagraphMetrics(Paragraph const & par);
52 /// Copy operator.
53 ParagraphMetrics & operator=(ParagraphMetrics const &);
55 void reset(Paragraph const & par);
57 ///
58 Row & getRow(pos_type pos, bool boundary);
59 ///
60 Row const & getRow(pos_type pos, bool boundary) const;
61 ///
62 size_t pos2row(pos_type pos) const;
64 /// BufferView::redoParagraph updates this
65 Dimension const & dim() const { return dim_; }
66 Dimension & dim() { return dim_; }
67 /// total height of paragraph
68 int height() const { return dim_.height(); }
69 /// total width of paragraph, may differ from workwidth
70 int width() const { return dim_.width(); }
71 /// ascend of paragraph above baseline
72 int ascent() const { return dim_.ascent(); }
73 /// descend of paragraph below baseline
74 int descent() const { return dim_.descent(); }
75 /// Text updates the rows using this access point
76 RowList & rows() { return rows_; }
77 /// The painter and others use this
78 RowList const & rows() const { return rows_; }
79 ///
80 int rightMargin(BufferView const & bv) const;
81 ///
82 int singleWidth(pos_type pos, Font const & Font) const;
84 /// dump some information to lyxerr
85 void dump() const;
87 ///
88 bool hfillExpansion(Row const & row, pos_type pos) const;
90 ///
91 size_t computeRowSignature(Row const &, BufferParams const & bparams) const;
93 ///
94 int position() const { return position_; }
95 void setPosition(int position);
97 ///
98 Dimension const & insetDimension(Inset const * inset) const;
99 ///
100 void setInsetDimension(Inset const *, Dimension const & dim);
102 private:
104 int position_;
106 mutable RowList rows_;
107 /// cached dimensions of paragraph
108 Dimension dim_;
110 Paragraph const * par_;
112 typedef std::map<Inset const *, Dimension> InsetDims;
114 InsetDims inset_dims_;
117 } // namespace lyx
119 #endif // PARAGRAPH_METRICS_H