]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathDecoration.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathDecoration.cpp
index 9879d558ba35a8bb8a9527a0c419c26b3405aa4b..484a33bb2ecc868e8cf5cff296f0c9513b5897d2 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 #include <config.h>
 
 #include "InsetMathDecoration.h"
+
 #include "MathData.h"
 #include "MathParser.h"
 #include "MathSupport.h"
 #include "MathStream.h"
+#include "MetricsInfo.h"
 
 #include "LaTeXFeatures.h"
-#include "debug.h"
 
-#include "support/std_ostream.h"
+#include "support/debug.h"
+
+#include <ostream>
 
 
 namespace lyx {
@@ -29,7 +32,7 @@ namespace lyx {
 InsetMathDecoration::InsetMathDecoration(latexkeys const * key)
        : InsetMathNest(1), key_(key)
 {
-//     lyxerr << " creating deco " << key->name << std::endl;
+//     lyxerr << " creating deco " << key->name << endl;
 }
 
 
@@ -101,7 +104,7 @@ bool InsetMathDecoration::ams() const
 }
 
 
-bool InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
 
@@ -117,20 +120,17 @@ bool InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
        }
 
        metricsMarkers(dim);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
 }
 
 
 void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const
 {
        cell(0).draw(pi, x + 1, y);
+       Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
        if (wide())
-               mathed_draw_deco(pi, x + 1, y + dy_, cell(0).width(), dh_, key_->name);
+               mathed_draw_deco(pi, x + 1, y + dy_, dim0.wid, dh_, key_->name);
        else
-               mathed_draw_deco(pi, x + 1 + (cell(0).width() - dw_) / 2,
+               mathed_draw_deco(pi, x + 1 + (dim0.wid - dw_) / 2,
                        y + dy_, dw_, dh_, key_->name);
        drawMarkers(pi, x, y);
        setPosCache(pi, x, y);
@@ -139,6 +139,7 @@ void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathDecoration::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        if (os.fragile() && protect())
                os << "\\protect";
        os << '\\' << key_->name << '{' << cell(0) << '}';