/*
* File: math_macro.C
- * Purpose: Implementation of macro class for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Implementation of macro class for mathed
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: November 1996
* Description: WYSIWYG math macros
*
}
+void MathMacro::expand() const
+{
+ expanded_ = tmplate_->xcell(tmplate_->cell(1).empty() ? 0 : 1);
+}
+
+
void MathMacro::metrics(MathMetricsInfo const & mi) const
{
whichFont(font_, LM_TC_TEX, mi);
}
if (editing()) {
- expanded_ = tmplate_->xcell(0);
+ expand();
expanded_.metrics(mi_);
width_ = expanded_.width() + 4;
ascent_ = expanded_.ascent() + 2;
descent_ += max(c.descent(), ldes) + 5;
}
return;
- }
+ }
- expanded_ = tmplate_->xcell(0);
+ expand();
expanded_.data_.substitute(*this);
expanded_.metrics(mi_);
width_ = expanded_.width();
}
-bool MathMacro::idxUp(idx_type & idx) const
+bool MathMacro::idxUpDown(idx_type & idx, bool up) const
{
pos_type pos;
- return MathNestInset::idxLeft(idx, pos);
-}
-
-
-bool MathMacro::idxDown(idx_type & idx) const
-{
- pos_type pos;
- return MathNestInset::idxRight(idx, pos);
+ return
+ up ? MathNestInset::idxLeft(idx, pos) : MathNestInset::idxRight(idx, pos);
}
void MathMacro::normalize(NormalStream & os) const
{
os << "[macro " << name() << " ";
- for (idx_type i = 0; i < nargs(); ++i)
+ for (idx_type i = 0; i < nargs(); ++i)
os << cell(i) << ' ';
os << ']';
}
os << '\\' << name();
for (idx_type i = 0; i < nargs(); ++i)
os << '{' << cell(i) << '}';
- if (nargs() == 0)
+ if (nargs() == 0)
os << ' ';
}
void MathMacro::updateExpansion() const
{
- expanded_ = tmplate_->xcell(0);
+ expand();
expanded_.data_.substitute(*this);
}