3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 // It seems that MacOSX define the check macro.
17 #include "Dimension.h"
19 #include "support/types.h"
30 void lyxbreaker(void const * data, const char * hint, int size);
50 template <class T> class CoordCacheBase {
62 void add(T const * thing, int x, int y)
64 data_[thing].pos = Point(x, y);
67 void add(T const * thing, Dimension const & dim)
69 data_[thing].dim = dim;
72 Dimension const & dim(T const * thing) const
74 //check(thing, "dim");
75 return data_.find(thing)->second.dim;
78 int x(T const * thing) const
81 return data_.find(thing)->second.pos.x_;
84 int y(T const * thing) const
87 return data_.find(thing)->second.pos.y_;
90 Point xy(T const * thing) const
93 return data_.find(thing)->second.pos;
96 bool has(T const * thing) const
98 return data_.find(thing) != data_.end();
101 // T * find(int x, int y) const
108 friend class CoordCache;
110 void check(T const * thing, char const * hint) const
113 lyxbreaker(thing, hint, data_.size());
116 typedef std::map<T const *, Geometry> cache_type;
120 cache_type const & getData() const { return data_; }
124 * A global cache that allows us to come from a paragraph in a document
125 * to a position point on the screen.
126 * All points cached in this cache are only valid between subsequent
127 * updates. (x,y) == (0,0) is the upper left screen corner, x increases
128 * to the right, y increases downwords.
129 * The cache is built in BufferView::updateMetrics which is called
130 * from BufferView::update. The individual points are added
131 * while we paint them. See for instance paintPar in RowPainter.C.
137 /// A map from MathData to position on the screen
138 CoordCacheBase<MathData> & arrays() { return arrays_; }
139 CoordCacheBase<MathData> const & getArrays() const { return arrays_; }
140 /// A map from insets to positions on the screen
141 CoordCacheBase<Inset> & insets() { return insets_; }
142 CoordCacheBase<Inset> const & getInsets() const { return insets_; }
144 /// Dump the contents of the cache to lyxerr in debugging form
148 CoordCacheBase<MathData> arrays_;
150 CoordCacheBase<Inset> insets_;