#include "debug.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
+#include "frontends/Painter.h"
using std::string;
using std::max;
{}
-auto_ptr<InsetBase> MathMacro::clone() const
+auto_ptr<InsetBase> MathMacro::doClone() const
{
return auto_ptr<InsetBase>(new MathMacro(*this));
}
}
+void MathMacro::cursorPos(CursorSlice const & sl, bool boundary, int & x,
+ int & y) const
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0)
+ MathNestInset::cursorPos(sl, boundary, x, y);
+}
+
+
void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!MacroTable::globalMacros().has(name())) {
LyXFont font = pi.base.font;
augmentFont(font, "lyxtex");
int h = y - dim_.ascent() + 2 + tmpl_.ascent();
- drawStr(pi, font, x + 3, h, name());
+ pi.pain.text(x + 3, h, name(), font);
int const w = mathed_string_width(font, name());
tmpl_.draw(pi, x + w + 12, h);
h += tmpl_.descent();
c.draw(pi, x + ldim.wid, h);
char str[] = "#1:";
str[1] += static_cast<char>(i);
- drawStr(pi, font, x + 3, h, str);
+ pi.pain.text(x + 3, h, str, font);
h += max(c.descent(), ldim.des) + 5;
}
} else {
}
+void MathMacro::drawSelection(PainterInfo & pi, int x, int y) const
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0)
+ MathNestInset::drawSelection(pi, x, y);
+}
+
+
void MathMacro::validate(LaTeXFeatures & features) const
{
if (name() == "binom" || name() == "mathcircumflex")
}
+InsetBase * MathMacro::editXY(LCursor & cur, int x, int y)
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0) {
+ // Prevent crash due to cold coordcache
+ // FIXME: This is only a workaround, the call of
+ // MathNestInset::editXY is correct. The correct fix would
+ // ensure that the coordcache of the arguments is valid.
+ if (!editing(&cur.bv())) {
+ edit(cur, true);
+ return this;
+ }
+ return MathNestInset::editXY(cur, x, y);
+ }
+ return this;
+}
+
+
void MathMacro::maple(MapleStream & os) const
{
updateExpansion();