#endif
#include "math_nestinset.h"
+#include "math_cursor.h"
#include "math_mathmlstream.h"
#include "debug.h"
void MathNestInset::metrics(MathMetricsInfo const & mi) const
{
- for (idx_type i = 0; i < nargs(); ++i)
- xcell(i).metrics(mi);
+ MathMetricsInfo m = mi;
+ m.inset = this;
+ for (idx_type i = 0; i < nargs(); ++i) {
+ m.idx = i;
+ xcell(i).metrics(m);
+ }
}
}
-void MathNestInset::push_back(MathAtom const & t)
-{
- if (nargs())
- cells_.back().data_.push_back(t);
- else
- lyxerr << "can't push without a cell\n";
-}
-
-
void MathNestInset::validate(LaTeXFeatures & features) const
{
for (idx_type i = 0; i < nargs(); ++i)
}
-bool MathNestInset::covers(int x, int y) const
-{
- if (!nargs())
- return false;
- int x0 = xcell(0).xo();
- int y0 = xcell(0).yo() - xcell(0).ascent();
- int x1 = xcell(0).xo() + xcell(0).width();
- int y1 = xcell(0).yo() + xcell(0).descent();
- for (idx_type i = 1; i < nargs(); ++i) {
- x0 = std::min(x0, xcell(i).xo());
- y0 = std::min(y0, xcell(i).yo() - xcell(i).ascent());
- x1 = std::max(x1, xcell(i).xo() + xcell(i).width());
- y1 = std::max(y1, xcell(i).yo() + xcell(i).descent());
- }
- //lyxerr << "xO: " << x0 << " x1: " << x1 << " "
- // << "yO: " << y0 << " y1: " << y1 << " "
- // << "x: " << x << " y: " << y << '\n';
- return x >= x0 && x <= x1 && y >= y0 && y <= y1;
-}
-
-
bool MathNestInset::match(MathInset * p) const
{
if (nargs() != p->nargs())
for (idx_type i = 0; i < nargs(); ++i)
cell(i).replace(rep);
}
+
+
+bool MathNestInset::contains(MathArray const & ar)
+{
+ for (idx_type i = 0; i < nargs(); ++i)
+ if (cell(i).contains(ar))
+ return true;
+ return false;
+}
+
+
+bool MathNestInset::editing() const
+{
+ return mathcursor && mathcursor->isInside(this);
+}
+