9 #include "support/types.h"
11 #include <boost/assert.hpp>
16 // All positions cached in this cache are only valid between subsequent
17 // updated. (x,y) == (0,0) is the upper left screen corner, x increases
18 // to the right, y increases downwords.
20 void lyxbreaker(void const * data, const char * hint, int size);
21 void lyxaborter(int x, int y);
29 Point(int x, int y) : x_(x), y_(y)
31 BOOST_ASSERT(x > -3000);
32 BOOST_ASSERT(x < 4000);
33 BOOST_ASSERT(y > -3000);
34 BOOST_ASSERT(y < 4000);
41 template <class T> class CoordCacheBase {
48 void add(T const * thing, int x, int y)
50 data_[thing] = Point(x, y);
53 int x(T const * thing) const
56 return data_.find(thing)->second.x_;
59 int y(T const * thing) const
62 return data_.find(thing)->second.y_;
65 Point xy(T const * thing) const
68 return data_.find(thing)->second;
71 bool has(T const * thing) const
73 return data_.find(thing) != data_.end();
76 // T * find(int x, int y) const
83 friend class CoordCache;
85 void check(T const * thing, char const * hint) const
88 lyxbreaker(thing, hint, data_.size());
91 typedef std::map<T const *, Point> cache_type;
99 Point get(LyXText const *, lyx::pit_type);
101 CoordCacheBase<MathArray> arrays_;
104 CoordCacheBase<InsetBase> insets_;
106 // paragraph grouped by owning text
107 typedef std::map<lyx::pit_type, Point> InnerParPosCache;
108 typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
112 extern CoordCache theCoords;