]> git.lyx.org Git - lyx.git/blobdiff - src/coordcache.h
add config.h
[lyx.git] / src / coordcache.h
index 1d49a1aa8fd05d8643b76ef035b2ef4d08cef365..dba9b89fd4d283a2a27c7c31e9ecf2dac1a4c379 100644 (file)
 #ifndef COORDCACHE_H
 #define COORDCACHE_H
 
-class InsetBase;
-class LyXText;
-class MathArray;
-class Paragraph;
+// It seems that MacOSX define the check macro.
+#undef check
 
 #include "support/types.h"
 
-#include <boost/assert.hpp>
-
 #include <map>
 
+namespace lyx {
+
+class InsetBase;
+class LyXText;
+class MathArray;
+class Paragraph;
+
 void lyxbreaker(void const * data, const char * hint, int size);
 
 class Point {
@@ -30,14 +33,7 @@ public:
                : x_(0), y_(0)
        {}
 
-       Point(int x, int y)
-               : x_(x), y_(y)
-       {
-               BOOST_ASSERT(x > -1000000);
-               BOOST_ASSERT(x <  1000000);
-               BOOST_ASSERT(y > -1000000);
-               BOOST_ASSERT(y <  1000000);
-       }
+       Point(int x, int y);
 
        int x_, y_;
 };
@@ -49,6 +45,11 @@ public:
                data_.clear();
        }
 
+       bool const empty() const
+       {
+               return data_.empty();
+       }
+
        void add(T const * thing, int x, int y)
        {
                data_[thing] = Point(x, y);
@@ -94,25 +95,28 @@ private:
 
        typedef std::map<T const *, Point> cache_type;
        cache_type data_;
+
+public:
+       cache_type const & getData() const { return data_; }
 };
 
 /**
  * A global cache that allows us to come from a paragraph in a document
  * to a position point on the screen.
  * All points cached in this cache are only valid between subsequent
- * updated. (x,y) == (0,0) is the upper left screen corner, x increases
+ * updates. (x,y) == (0,0) is the upper left screen corner, x increases
  * to the right, y increases downwords.
- * The cache is built in BufferView::Pimpl::metrics which is called
- * from BufferView::Pimpl::update. The individual points are added
+ * The cache is built in BufferView::updateMetrics which is called
+ * from BufferView::update. The individual points are added
  * while we paint them. See for instance paintPar in RowPainter.C.
  */
 class CoordCache {
 public:
        void clear();
-       Point get(LyXText const *, lyx::pit_type);
+       Point get(LyXText const *, pit_type) const;
 
        /// A map from paragraph index number to screen point
-       typedef std::map<lyx::pit_type, Point> InnerParPosCache;
+       typedef std::map<pit_type, Point> InnerParPosCache;
        /// A map from a LyXText to the map of paragraphs to screen points
        typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
        /// A map from a CursorSlice to screen points
@@ -137,6 +141,8 @@ public:
                return boundary ? slices1_ : slices0_;
        }
 
+       /// Dump the contents of the cache to lyxerr in debugging form
+       void dump() const;
 private:
        /// MathArrays
        CoordCacheBase<MathArray> arrays_;
@@ -150,4 +156,6 @@ private:
        SliceCache slices1_;
 };
 
+} // namespace lyx
+
 #endif