]> git.lyx.org Git - lyx.git/blobdiff - src/coordcache.h
- Link against qt-mt333.lib which is what the current qt3 cvs produces
[lyx.git] / src / coordcache.h
index ac89bd251e7bd8d06f1df2924653dd8750394be9..3a70e6d78dbe7a653c1e2cf262912bf5ec42bd2e 100644 (file)
@@ -1,20 +1,30 @@
 #ifndef COORDCACHE_H
 #define COORDCACHE_H
 
-#include "mathed/math_data.h"
-#include "insets/insetbase.h"
-#include "lyxtext.h"
+class InsetBase;
+class LyXText;
+class MathArray;
+class Paragraph;
+
+#include "support/types.h"
 
 #include <boost/assert.hpp>
 
 #include <map>
 
+
+// All positions cached in this cache are only valid between subsequent
+// updated. (x,y) == (0,0) is the upper left screen corner, x increases
+// to the right, y increases downwords.
+
 void lyxbreaker(void const * data, const char * hint, int size);
+void lyxaborter(int x, int y);
 
-struct Point {
+class Point {
+public:
        Point()
                : x_(0), y_(0)
-       {}      
+       {}
 
        Point(int x, int y) : x_(x), y_(y)
        {
@@ -22,7 +32,7 @@ struct Point {
                BOOST_ASSERT(x <  4000);
                BOOST_ASSERT(y > -3000);
                BOOST_ASSERT(y <  4000);
-       }       
+       }
 
        int x_, y_;
 };
@@ -63,27 +73,40 @@ public:
                return data_.find(thing) != data_.end();
        }
 
+//     T * find(int x, int y) const
+//     {
+//             T *
+//             cache_type iter
+//     }
+
 private:
        friend class CoordCache;
 
        void check(T const * thing, char const * hint) const
        {
-               if (!has(thing)) {
+               if (!has(thing))
                        lyxbreaker(thing, hint, data_.size());
-                       BOOST_ASSERT(false);
-               }
        }
 
-       std::map<T const *, Point> data_;
+       typedef std::map<T const *, Point> cache_type;
+       cache_type data_;
 };
 
 
 class CoordCache {
 public:
        void clear();
+       Point get(LyXText const *, lyx::pit_type);
 
        CoordCacheBase<MathArray> arrays_;
+       
+       // all insets
        CoordCacheBase<InsetBase> insets_;
+
+       // paragraph grouped by owning text
+       typedef std::map<lyx::pit_type, Point> InnerParPosCache;
+       typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
+       ParPosCache pars_;
 };
 
 extern CoordCache theCoords;