]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
more IU
[lyx.git] / src / mathed / math_nestinset.C
index d3954a3b49c4017a0cd356acf438afecba94081f..36c90752345b9f5985e801c132b0b36cdbcdd3d5 100644 (file)
@@ -1,16 +1,29 @@
+/**
+ * \file math_nestinset.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_nestinset.h"
 #include "math_cursor.h"
 #include "math_mathmlstream.h"
 #include "math_parser.h"
-#include "funcrequest.h"
-#include "debug.h"
 #include "BufferView.h"
+#include "dispatchresult.h"
+#include "debug.h"
+#include "funcrequest.h"
+#include "LColor.h"
 #include "frontends/Painter.h"
 
 
 MathNestInset::MathNestInset(idx_type nargs)
-       : MathDimInset(), cells_(nargs), lock_(false)
+       : cells_(nargs), lock_(false)
 {}
 
 
@@ -58,21 +71,6 @@ void MathNestInset::metrics(MetricsInfo const & mi) const
 }
 
 
-void MathNestInset::metricsMarkers(int frame) const
-{
-       dim_.des += frame;
-       dim_.wid += 2 * frame;
-}
-
-
-void MathNestInset::metricsMarkers2(int frame) const
-{
-       dim_.asc += frame;
-       dim_.des += frame;
-       dim_.wid += 2 * frame;
-}
-
-
 bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
 {
        if (idx + 1 >= nargs())
@@ -105,22 +103,22 @@ bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
 }
 
 
-bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
+bool MathNestInset::idxFirst(idx_type & idx, pos_type & pos) const
 {
        if (nargs() == 0)
                return false;
-       i = 0;
+       idx = 0;
        pos = 0;
        return true;
 }
 
 
-bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
+bool MathNestInset::idxLast(idx_type & idx, pos_type & pos) const
 {
        if (nargs() == 0)
                return false;
-       i = nargs() - 1;
-       pos = cell(i).size();
+       idx = nargs() - 1;
+       pos = cell(idx).size();
        return true;
 }
 
@@ -192,33 +190,6 @@ void MathNestInset::drawSelection(PainterInfo & pi,
 }
 
 
-void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
-{
-       if (!editing())
-               return;
-       int t = x + width() - 1;
-       int d = y + descent();
-       pi.pain.line(x, d - 3, x, d, LColor::mathframe);
-       pi.pain.line(t, d - 3, t, d, LColor::mathframe);
-       pi.pain.line(x, d, x + 3, d, LColor::mathframe);
-       pi.pain.line(t - 3, d, t, d, LColor::mathframe);
-}
-
-
-void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const
-{
-       if (!editing())
-               return;
-       drawMarkers(pi, x, y);
-       int t = x + width() - 1;
-       int a = y - ascent();
-       pi.pain.line(x, a + 3, x, a, LColor::mathframe);
-       pi.pain.line(t, a + 3, t, a, LColor::mathframe);
-       pi.pain.line(x, a, x + 3, a, LColor::mathframe);
-       pi.pain.line(t - 3, a, t, a, LColor::mathframe);
-}
-
-
 void MathNestInset::validate(LaTeXFeatures & features) const
 {
        for (idx_type i = 0; i < nargs(); ++i)
@@ -226,17 +197,6 @@ void MathNestInset::validate(LaTeXFeatures & features) const
 }
 
 
-bool MathNestInset::match(MathAtom const & at) const
-{
-       if (nargs() != at->nargs())
-               return false;
-       for (idx_type i = 0; i < nargs(); ++i)
-               if (!cell(i).match(at->cell(i)))
-                       return false;
-       return true;
-}
-
-
 void MathNestInset::replace(ReplaceData & rep)
 {
        for (idx_type i = 0; i < nargs(); ++i)
@@ -315,8 +275,9 @@ void MathNestInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-dispatch_result MathNestInset::dispatch
-       (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult
+MathNestInset::priv_dispatch(FuncRequest const & cmd,
+                            idx_type & idx, pos_type & pos)
 {
        BufferView * bv = cmd.view();
 
@@ -327,7 +288,7 @@ dispatch_result MathNestInset::dispatch
                        mathed_parse_cell(ar, cmd.argument);
                        cell(idx).insert(pos, ar);
                        pos += ar.size();
-                       return DISPATCHED;
+                       return DispatchResult(true, true);
                }
 
                case LFUN_PASTESELECTION:
@@ -337,11 +298,51 @@ dispatch_result MathNestInset::dispatch
 
                case LFUN_MOUSE_PRESS:
                        if (cmd.button() == mouse_button::button2)
-                               return dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
-                       return UNDISPATCHED;
+                               return priv_dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
+                       return DispatchResult(false);
 
                default:
-                       return MathInset::dispatch(cmd, idx, pos);
+                       return MathInset::priv_dispatch(cmd, idx, pos);
        }
-       return UNDISPATCHED;
+}
+
+
+void MathNestInset::metricsMarkers(int) const
+{
+       dim_.wid += 2;
+       dim_.asc += 1;
+}
+
+
+void MathNestInset::metricsMarkers2(int) const
+{
+       dim_.wid += 2;
+       dim_.asc += 1;
+       dim_.des += 1;
+}
+
+void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
+{
+       if (!editing())
+               return;
+       int t = x + dim_.width() - 1;
+       int d = y + dim_.descent();
+       pi.pain.line(x, d - 3, x, d, LColor::mathframe);
+       pi.pain.line(t, d - 3, t, d, LColor::mathframe);
+       pi.pain.line(x, d, x + 3, d, LColor::mathframe);
+       pi.pain.line(t - 3, d, t, d, LColor::mathframe);
+}
+
+
+void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const
+{
+       if (!editing())
+               return;
+       drawMarkers(pi, x, y);
+       int t = x + dim_.width() - 1;
+       int a = y - dim_.ascent();
+       pi.pain.line(x, a + 3, x, a, LColor::mathframe);
+       pi.pain.line(t, a + 3, t, a, LColor::mathframe);
+       pi.pain.line(x, a, x + 3, a, LColor::mathframe);
+       pi.pain.line(t - 3, a, t, a, LColor::mathframe);
 }