]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.h
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / TextMetrics.h
index 22197707014f4f1560e7d9d1f886a99f39dc2a5a..0e9df1111171f6e7e0ad5d0ce9c6d05b7061f18f 100644 (file)
 namespace lyx {
 
 class BufferView;
-class LyXText;
+class Text;
 class MetricsInfo;
 
-/// A map from a LyXText to the map of paragraphs metrics
+/// A map from a Text to the map of paragraphs metrics
 class TextMetrics
 {
 public:
        /// Default constructor (only here for STL containers).
        TextMetrics(): text_(0) {}
        /// The only useful constructor.
-       TextMetrics(BufferView *, LyXText *);
+       TextMetrics(BufferView *, Text *);
        ///
        ParagraphMetrics const & parMetrics(pit_type) const;
        ///
@@ -48,6 +48,8 @@ public:
        /// \retval true if a full screen redraw is needed.
        /// \retval false if a single paragraph redraw is enough.
        bool redoParagraph(pit_type const pit);
+       /// Clear cache of paragraph metrics
+       void clear() { par_metrics_.clear(); }
 
        ///
        int ascent() const { return dim_.asc; }
@@ -60,6 +62,8 @@ public:
 
        ///
        int maxWidth() const { return max_width_; }
+       ///
+       int singleWidth(pit_type const pit,     pos_type pos) const;
 
        ///
        int rightMargin(ParagraphMetrics const & pm) const;
@@ -71,11 +75,11 @@ public:
 
 
 private:
-       /// 
+       ///
        ParagraphMetrics & parMetrics(pit_type, bool redo_paragraph);
 
        /// the minimum space a manual label needs on the screen in pixels
-       int labelFill(Paragraph const & par, Row const & row) const;
+       int labelFill(pit_type const pit, Row const & row) const;
 
        /// FIXME??
        int labelEnd(pit_type const pit) const;
@@ -90,18 +94,28 @@ private:
        /// Calculate and set the height of the row
        void setHeightOfRow(pit_type, Row & row);
 
+// Temporary public:
+public:
        /// returns the column near the specified x-coordinate of the row.
        /// x is an absolute screen coord, it is set to the real beginning
        /// of this column.
        pos_type getColumnNearX(pit_type pit, Row const & row, int & x,
                bool & boundary) const;
 
+       /// returns pos in given par at given x coord.
+       pos_type x2pos(pit_type pit, int row, int x) const;
+
+       // FIXME: is there a need for this?
+       //int pos2x(pit_type pit, pos_type pos) const;
+
+private:
+
        /// The BufferView owner.
        BufferView * bv_;
 
        /// The text contents (the model).
        /// \todo FIXME: this should be const.
-       LyXText * text_;
+       Text * text_;
 
        bool main_text_;
        /// A map from paragraph index number to paragraph metrics
@@ -115,8 +129,8 @@ private:
        /*
        /// A map from paragraph index number to screen point
        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 Text to the map of paragraphs to screen points
+       typedef std::map<Text const *, InnerParPosCache> ParPosCache;
        /// Paragraph grouped by owning text
        ParPosCache pars_;
        */