]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.h
We only support gcc >= 4.9.
[lyx.git] / src / mathed / MathData.h
index 70c001975e9614a32f54c84ab6da621398cda9a7..865742df4cb9603040cf5ec8456d3f9bdf54a585 100644 (file)
 #ifndef MATH_DATA_H
 #define MATH_DATA_H
 
-#include "Dimension.h"
-
 #include "MathAtom.h"
-#include "MathRow.h"
+#include "MathClass.h"
 
+#include "Dimension.h"
 #include "OutputEnums.h"
 
 #include "support/strfwd.h"
 
 #include <cstddef>
 #include <vector>
-#include <map>
 
 
 namespace lyx {
@@ -34,14 +32,16 @@ namespace lyx {
 class Buffer;
 class BufferView;
 class Cursor;
+class Dimension;
 class DocIterator;
+class InsetMathMacro;
 class LaTeXFeatures;
-class ReplaceData;
 class MacroContext;
-class InsetMathMacro;
+class MathRow;
 class MetricsInfo;
 class PainterInfo;
 class ParIterator;
+class ReplaceData;
 class TextMetricsInfo;
 class TextPainter;
 
@@ -69,8 +69,9 @@ public:
 
 public:
        ///
-       MathData(Buffer * buf = 0) : minasc_(0), mindes_(0), slevel_(0),
-                                    sshift_(0), kerning_(0), buffer_(buf) {}
+       MathData() = default;
+       ///
+       explicit MathData(Buffer * buf) : buffer_(buf) {}
        ///
        MathData(Buffer * buf, const_iterator from, const_iterator to);
        ///
@@ -125,7 +126,11 @@ public:
        bool addToMathRow(MathRow &, MetricsInfo & mi) const;
 
        /// rebuild cached metrics information
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       /** When \c tight is true, the height of the cell will be at least
+        *  the x height of the font. Otherwise, it will be the max height
+        *  of the font.
+        */
+       void metrics(MetricsInfo & mi, Dimension & dim, bool tight = true) const;
        ///
        Dimension const & dimension(BufferView const &) const;
 
@@ -137,8 +142,14 @@ public:
        void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
        /// redraw cell using cache metrics information
        void drawT(TextPainter & pi, int x, int y) const;
-       /// approximate the math class of the data
+       /// approximate mathclass of the data
        MathClass mathClass() const;
+       /// math class of first interesting element
+       MathClass firstMathClass() const;
+       /// math class of last interesting element
+       MathClass lastMathClass() const;
+       /// is the cell in display style
+       bool displayStyle() const { return display_style_; }
 
        /// access to cached x coordinate of last drawing
        int xo(BufferView const & bv) const;
@@ -167,7 +178,7 @@ public:
        /// additional super/subscript shift
        int sshift() const { return sshift_; }
        /// Italic correction as described in InsetMathScript.h
-       int kerning(BufferView const *) const { return kerning_; }
+       int kerning(BufferView const *) const;
        ///
        void swap(MathData & ar) { base_type::swap(ar); }
 
@@ -175,21 +186,19 @@ public:
        /// stay visually at the same position (cur==0 is allowed)
        void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType, int nesting);
        ///
-       void updateBuffer(ParIterator const &, UpdateType);
+       void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false);
        ///
-       void setBuffer(Buffer & b) { buffer_ = &b; }
+       void setBuffer(Buffer & b);
 
 protected:
        /// cached values for super/subscript placement
-       mutable int minasc_;
-       mutable int mindes_;
-       mutable int slevel_;
-       mutable int sshift_;
-       mutable int kerning_;
-       Buffer * buffer_;
-
-       /// cached object that describes typeset data
-       mutable std::map<BufferView*, MathRow> mrow_cache_;
+       mutable int minasc_ = 0;
+       mutable int mindes_ = 0;
+       mutable int slevel_ = 0;
+       mutable int sshift_ = 0;
+       /// cached value for display style
+       mutable bool display_style_ = false;
+       Buffer * buffer_ = nullptr;
 
 private:
        /// is this an exact match at this position?