X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_rootinset.C;h=bf3c211f94f9dbf12d1effc501aa81dad24ce1f3;hb=6aa8d56bddcb29d2c266dc520a4e725958c31db1;hp=4760854461e16b54c97c023e0b39a413623f466d;hpb=9295f8236e01a5e425d808eb0d2bdd0460d1f423;p=lyx.git diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index 4760854461..bf3c211f94 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -1,7 +1,7 @@ /* * File: math_root.C - * Purpose: Implementation of the root object - * Author: Alejandro Aguilar Sierra + * Purpose: Implementation of the root object + * Author: Alejandro Aguilar Sierra * Created: January 1999 * Description: Root math object * @@ -16,8 +16,12 @@ #endif #include "math_rootinset.h" -#include "support/LOstream.h" -#include "Painter.h" +#include "math_mathmlstream.h" +#include "frontends/Painter.h" + + +using std::max; + MathRootInset::MathRootInset() : MathNestInset(2) @@ -30,23 +34,22 @@ MathInset * MathRootInset::clone() const } -void MathRootInset::metrics(MathStyles st) const +void MathRootInset::metrics(MathMetricsInfo & mi) const { - MathNestInset::metrics(st); - size_ = st; - ascent_ = std::max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2; - descent_ = std::max(xcell(1).descent() + 5, xcell(0).descent()) + 2; + MathNestInset::metrics(mi); + ascent_ = max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2; + descent_ = 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) const +void MathRootInset::draw(MathPainterInfo & 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" + // the "exponent" + xcell(0).draw(pain, x, y - 5 - xcell(0).descent()); + // the "base" + xcell(1).draw(pain, x + w + 8, y); int const a = ascent(); int const d = descent(); int xp[5]; @@ -56,45 +59,39 @@ void MathRootInset::draw(Painter & pain, int x, int y) const 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.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(0) << ' ' << cell(1) << ']'; } -bool MathRootInset::idxUp(int & idx, int & pos) const +bool MathRootInset::idxUpDown(idx_type & idx, bool up) const { - if (idx == 0) + bool target = !up; // up ? 0 : 1; + if (idx == target) return false; - idx = 0; - pos = cell(0).size(); + idx = target; return true; } -bool MathRootInset::idxDown(int & idx, int & pos) const +void MathRootInset::octavize(OctaveStream & os) const { - if (idx == 1) - return false; - idx = 1; - pos = 0; - return true; + os << "root(" << cell(1) << ',' << cell(0) <<')'; +} + + +void MathRootInset::mathmlize(MathMLStream & os) const +{ + os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot"); }