]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_binominset.C
Fix math cursor positioning bug
[lyx.git] / src / mathed / math_binominset.C
index 5b6fdce321e3004d179fd6bfcc17bf0f10a02b0e..7e89c8f3f3a2c3f886eae54607c2cbe0d6bdd0ff 100644 (file)
@@ -1,16 +1,23 @@
-#include <config.h>
+/**
+ * \file math_binominset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "math_binominset.h"
+#include "math_data.h"
 #include "math_support.h"
-#include "support/LOstream.h"
 #include "math_mathmlstream.h"
 
 
 using std::max;
+using std::auto_ptr;
 
 
 MathBinomInset::MathBinomInset(bool choose)
@@ -18,15 +25,15 @@ MathBinomInset::MathBinomInset(bool choose)
 {}
 
 
-MathInset * MathBinomInset::clone() const
+auto_ptr<InsetBase> MathBinomInset::doClone() const
 {
-       return new MathBinomInset(*this);
+       return auto_ptr<InsetBase>(new MathBinomInset(*this));
 }
 
 
 int MathBinomInset::dw() const
 {
-       int w = height()/5;
+       int w = dim_.height() / 5;
        if (w > 15)
                w = 15;
        if (w < 6)
@@ -35,25 +42,29 @@ int MathBinomInset::dw() const
 }
 
 
-void MathBinomInset::metrics(MathMetricsInfo & mi) const
+void MathBinomInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       MathScriptChanger dummy(mi.base);
+       ScriptChanger dummy(mi.base);
        cell(0).metrics(mi);
        cell(1).metrics(mi);
-       dim_.a = cell(0).height() + 4 + 5;
-       dim_.d = cell(1).height() + 4 - 5;
-       dim_.w = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
+       dim.asc = cell(0).height() + 4 + 5;
+       dim.des = cell(1).height() + 4 - 5;
+       dim.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
+       metricsMarkers2(dim);
+       dim_ = dim;
 }
 
 
-void MathBinomInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
 {
-       int m = x + width() / 2;
-       MathScriptChanger dummy(pi.base);
+       int m = x + dim_.width() / 2;
+       ScriptChanger dummy(pi.base);
        cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
        cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 3 - 5);
-       mathed_draw_deco(pi, x, y - ascent(), dw(), height(), "(");
-       mathed_draw_deco(pi, x + width() - dw(), y - ascent(),  dw(), height(), ")");
+       mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), "(");
+       mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
+               dw(), dim_.height(), ")");
+       drawMarkers2(pi, x, y);
 }