/*
* File: math_root.C
- * Purpose: Implementation of the root object
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Implementation of the root object
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1999
* Description: Root math object
*
#include "Painter.h"
+using std::max;
+
+
MathRootInset::MathRootInset()
: MathNestInset(2)
{}
void MathRootInset::metrics(MathMetricsInfo const & mi) const
{
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;
+ 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
{
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];
void MathRootInset::normalize(NormalStream & os) const
{
- os << "[root " << cell(1) << ' ' << cell(1) << ']';
-}
-
-
-bool MathRootInset::idxUp(idx_type & idx) const
-{
- if (idx == 0)
- return false;
- idx = 0;
- return true;
+ os << "[root " << cell(0) << ' ' << cell(1) << ']';
}
-bool MathRootInset::idxDown(idx_type & idx) const
+bool MathRootInset::idxUpDown(idx_type & idx, bool up) const
{
- if (idx == 1)
+ bool target = !up; // up ? 0 : 1;
+ if (idx == target)
return false;
- idx = 1;
+ idx = target;
return true;
}