]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_scriptinset.C
more IU
[lyx.git] / src / mathed / math_scriptinset.C
index c118f4be3c59bda1e7979cf7b28012a40811c16f..1118070fe76bf63b34a64b20214b594673d123a0 100644 (file)
@@ -1,14 +1,31 @@
+/**
+ * \file math_scriptinset.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.
+ */
+
+#include <config.h>
 
 #include "math_scriptinset.h"
+#include "math_data.h"
+#include "math_mathmlstream.h"
 #include "math_support.h"
 #include "math_symbolinset.h"
-#include "math_mathmlstream.h"
-#include "funcrequest.h"
-#include "support/LAssert.h"
+#include "dispatchresult.h"
 #include "debug.h"
+#include "funcrequest.h"
+
+#include <boost/assert.hpp>
 
 
+using std::string;
 using std::max;
+using std::auto_ptr;
+using std::endl;
 
 
 MathScriptInset::MathScriptInset()
@@ -37,9 +54,9 @@ MathScriptInset::MathScriptInset(MathAtom const & at, bool up)
 
 
 
-MathInset * MathScriptInset::clone() const
+auto_ptr<InsetBase> MathScriptInset::clone() const
 {
-       return new MathScriptInset(*this);
+       return auto_ptr<InsetBase>(new MathScriptInset(*this));
 }
 
 
@@ -144,21 +161,21 @@ int MathScriptInset::dy1() const
 
 int MathScriptInset::dx0() const
 {
-       lyx::Assert(hasDown());
-       return hasLimits() ? (dim_.w - down().width()) / 2 : nwid();
+       BOOST_ASSERT(hasDown());
+       return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid();
 }
 
 
 int MathScriptInset::dx1() const
 {
-       lyx::Assert(hasUp());
-       return hasLimits() ? (dim_.w - up().width()) / 2 : nwid();
+       BOOST_ASSERT(hasUp());
+       return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid();
 }
 
 
 int MathScriptInset::dxx() const
 {
-       return hasLimits() ? (dim_.w - nwid()) / 2  :  0;
+       return hasLimits() ? (dim_.wid - nwid()) / 2  :  0;
 }
 
 
@@ -180,29 +197,30 @@ int MathScriptInset::ndes() const
 }
 
 
-void MathScriptInset::metrics(MetricsInfo & mi) const
+void MathScriptInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(2).metrics(mi);
        ScriptChanger dummy(mi.base);
        cell(0).metrics(mi);
        cell(1).metrics(mi);
-       dim_.w = 0;
+       dim_.wid = 0;
        if (hasLimits()) {
-               dim_.w = nwid();
+               dim_.wid = nwid();
                if (hasUp())
-                       dim_.w = max(dim_.w, up().width());
+                       dim_.wid = max(dim_.wid, up().width());
                if (hasDown())
-                       dim_.w = max(dim_.w, down().width());
+                       dim_.wid = max(dim_.wid, down().width());
        } else {
                if (hasUp())
-                       dim_.w = max(dim_.w, up().width());
+                       dim_.wid = max(dim_.wid, up().width());
                if (hasDown())
-                       dim_.w = max(dim_.w, down().width());
-               dim_.w += nwid();
+                       dim_.wid = max(dim_.wid, down().width());
+               dim_.wid += nwid();
        }
-       dim_.a = dy1() + (hasUp() ? up().ascent() : 0);
-       dim_.d = dy0() + (hasDown() ? down().descent() : 0);
-       metricsMarkers2();
+       dim_.asc = dy1() + (hasUp() ? up().ascent() : 0);
+       dim_.des = dy0() + (hasDown() ? down().descent() : 0);
+       metricsMarkers();
+       dim = dim_;
 }
 
 
@@ -220,17 +238,17 @@ void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
                up().draw(pi, x + dx1(), y - dy1());
        if (hasDown())
                down().draw(pi, x + dx0(), y + dy0());
-       drawMarkers2(pi, x, y);
+       drawMarkers(pi, x, y);
 }
 
 
-void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
+void MathScriptInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
 {
        if (hasUp())
-               up().metricsT(mi);
+               up().metricsT(mi, dim);
        if (hasDown())
-               down().metricsT(mi);
-       nuc().metricsT(mi);
+               down().metricsT(mi, dim);
+       nuc().metricsT(mi, dim);
 }
 
 
@@ -357,7 +375,8 @@ void MathScriptInset::write(WriteStream & os) const
                //}
        } else {
                if (os.firstitem())
-                       lyxerr[Debug::MATHED] << "suppressing {} when writing\n";
+                       lyxerr[Debug::MATHED] << "suppressing {} when writing"
+                                             << endl;
                else
                        os << "{}";
        }
@@ -493,8 +512,9 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-dispatch_result MathScriptInset::dispatch
-       (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult
+MathScriptInset::priv_dispatch(FuncRequest const & cmd,
+                         idx_type & idx, pos_type & pos)
 {
        if (cmd.action == LFUN_MATH_LIMITS) {
                if (!cmd.argument.empty()) {
@@ -505,11 +525,11 @@ dispatch_result MathScriptInset::dispatch
                        else
                                limits_ = 0;
                } else if (limits_ == 0)
-                       limits_ =  (hasLimits()) ? -1 : 1;
+                       limits_ = hasLimits() ? -1 : 1;
                else
                        limits_ = 0;
-               return DISPATCHED;
+               return DispatchResult(true, true);
        }
 
-       return MathNestInset::dispatch(cmd, idx, pos);
+       return MathNestInset::priv_dispatch(cmd, idx, pos);
 }