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);
28 Point(int x, int y) : x_(x), y_(y)
30 BOOST_ASSERT(x > -3000);
31 BOOST_ASSERT(x < 4000);
32 BOOST_ASSERT(y > -3000);
33 BOOST_ASSERT(y < 4000);
40 template <class T> class CoordCacheBase {
47 void add(T const * thing, int x, int y)
49 data_[thing] = Point(x, y);
52 int x(T const * thing) const
55 return data_.find(thing)->second.x_;
58 int y(T const * thing) const
61 return data_.find(thing)->second.y_;
64 Point xy(T const * thing) const
67 return data_.find(thing)->second;
70 bool has(T const * thing) const
72 return data_.find(thing) != data_.end();
75 // T * find(int x, int y) const
82 friend class CoordCache;
84 void check(T const * thing, char const * hint) const
87 lyxbreaker(thing, hint, data_.size());
90 typedef std::map<T const *, Point> cache_type;
98 Point get(LyXText const *, lyx::pit_type);
100 CoordCacheBase<MathArray> arrays_;
103 CoordCacheBase<InsetBase> insets_;
105 // paragraph grouped by owning text
106 typedef std::map<lyx::pit_type, Point> InnerParPosCache;
107 typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
111 extern CoordCache theCoords;