4 #include "mathed/math_data.h"
5 #include "insets/insetbase.h"
8 #include <boost/assert.hpp>
13 // All positions cached in this cache are only valid between subsequent
14 // updated. (x,y) == (0,0) is the upper left screen corner, x increases
15 // to the right, y increases downwords.
17 void lyxbreaker(void const * data, const char * hint, int size);
24 Point(int x, int y) : x_(x), y_(y)
26 BOOST_ASSERT(x > -3000);
27 BOOST_ASSERT(x < 4000);
28 BOOST_ASSERT(y > -3000);
29 BOOST_ASSERT(y < 4000);
36 template <class T> class CoordCacheBase {
43 void add(T const * thing, int x, int y)
45 data_[thing] = Point(x, y);
48 int x(T const * thing) const
51 return data_.find(thing)->second.x_;
54 int y(T const * thing) const
57 return data_.find(thing)->second.y_;
60 Point xy(T const * thing) const
63 return data_.find(thing)->second;
66 bool has(T const * thing) const
68 return data_.find(thing) != data_.end();
71 // T * find(int x, int y) const
78 friend class CoordCache;
80 void check(T const * thing, char const * hint) const
83 lyxbreaker(thing, hint, data_.size());
88 typedef std::map<T const *, Point> cache_type;
97 CoordCacheBase<MathArray> arrays_;
98 CoordCacheBase<InsetBase> insets_;
101 extern CoordCache theCoords;