#endif
#include "math_rootinset.h"
-#include "support/LOstream.h"
+#include "math_mathmlstream.h"
#include "Painter.h"
+
MathRootInset::MathRootInset()
- : MathInset(2)
+ : MathNestInset(2)
{}
}
-void MathRootInset::Metrics(MathStyles st, int, int)
+void MathRootInset::metrics(MathMetricsInfo const & mi) const
{
- MathInset::Metrics(st);
- size_ = st;
+ MathNestInset::metrics(mi);
ascent_ = std::max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2;
descent_ = std::max(xcell(1).descent() + 5, xcell(0).descent()) + 2;
width_ = xcell(0).width() + xcell(1).width() + 10;
}
-void MathRootInset::draw(Painter & pain, int x, int y)
+void MathRootInset::draw(Painter & pain, int x, int y) const
{
- xo(x);
- yo(y);
int const w = xcell(0).width();
xcell(0).draw(pain, x, y - 5 - xcell(0).descent()); // the "exponent"
xcell(1).draw(pain, x + w + 8, y); // the "base"
xp[2] = x + w; yp[2] = y + d;
xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2;
xp[4] = x; yp[4] = y + (d - a)/2 + 2;
- pain.lines(xp, yp, 5, LColor::mathline);
+ pain.lines(xp, yp, 5, LColor::math);
}
-void MathRootInset::Write(std::ostream & os, bool fragile) const
+void MathRootInset::write(WriteStream & os) const
{
- os << "\\sqrt[";
- cell(0).Write(os, fragile);
- os << "]{";
- cell(1).Write(os, fragile);
- os << '}';
+ os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
}
-void MathRootInset::WriteNormal(std::ostream & os) const
+void MathRootInset::normalize(NormalStream & os) const
{
- os << "[root ";
- cell(1).WriteNormal(os);
- os << " ";
- cell(0).WriteNormal(os);
- os << "] ";
+ os << "[root " << cell(1) << ' ' << cell(1) << ']';
}
-bool MathRootInset::idxUp(int & idx, int & pos) const
+
+bool MathRootInset::idxUp(idx_type & idx) const
{
if (idx == 0)
return false;
idx = 0;
- pos = 0;
return true;
}
-bool MathRootInset::idxDown(int & idx, int & pos) const
+
+bool MathRootInset::idxDown(idx_type & idx) const
{
if (idx == 1)
return false;
idx = 1;
- pos = 0;
return true;
}
+
+
+void MathRootInset::octavize(OctaveStream & os) const
+{
+ os << "root(" << cell(1) << ',' << cell(0) <<')';
+}
+
+
+void MathRootInset::mathmlize(MathMLStream & os) const
+{
+ os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot");
+}