#include "math_support.h"
#include "math_mathmlstream.h"
#include "textpainter.h"
-#include "preview.h"
#include <fstream>
#include <boost/bind.hpp>
{}
-InsetFormula::InsetFormula(MathInsetTypes t)
- : par_(MathAtom(new MathHullInset(t))), loader_(0)
-{}
-
-
-InsetFormula::InsetFormula(string const & s)
+InsetFormula::InsetFormula(BufferView * bv)
+ : par_(MathAtom(new MathHullInset)), loader_(0)
{
- if (s.size()) {
- bool res = mathed_parse_normal(par_, s);
+ view_ = bv;
+}
- if (!res)
- res = mathed_parse_normal(par_, "$" + s + "$");
- if (!res) {
- lyxerr << "cannot interpret '" << s << "' as math\n";
- par_ = MathAtom(new MathHullInset(LM_OT_SIMPLE));
- }
- }
- metrics();
- updatePreview();
+InsetFormula::InsetFormula(string const & data)
+ : par_(MathAtom(new MathHullInset)), loader_(0)
+{
+ if (!data.size())
+ return;
+ if (!mathed_parse_normal(par_, data))
+ lyxerr << "cannot interpret '" << data << "' as math\n";
}
+
Inset * InsetFormula::clone(Buffer const &, bool) const
{
return new InsetFormula(*this);
}
+
int InsetFormula::ascii(Buffer const *, ostream & os, int) const
{
#if 0
if (canPreview()) {
pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, *(loader_->image()));
} else {
- pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT;
+ //pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT;
+ pi.base.style = LM_ST_TEXT;
pi.base.font = font;
pi.base.font.setColor(LColor::math);
if (lcolor.getX11Name(LColor::mathbg)
int x;
int y;
mathcursor->getPos(x, y);
- hull()->mutate(arg);
+ mutate(arg);
mathcursor->setPos(x, y);
mathcursor->normalize();
updateLocal(bv, true);
int x = 0;
int y = 0;
mathcursor->getPos(x, y);
- if (getType() == LM_OT_SIMPLE)
- hull()->mutate(LM_OT_EQUATION);
+ if (hullType() == "simple")
+ mutate("equation");
else
- hull()->mutate(LM_OT_SIMPLE);
+ mutate("simple");
mathcursor->setPos(x, y);
mathcursor->normalize();
updateLocal(bv, true);
bool InsetFormula::display() const
{
- return getType() != LM_OT_SIMPLE;
+ return hullType() != "simple" && hullType() != "none";
}
}
-MathInsetTypes InsetFormula::getType() const
+string InsetFormula::hullType() const
+{
+ return hull() ? hull()->getType() : "none";
+}
+
+
+void InsetFormula::mutate(string const & type )
{
- return hull()->getType();
+ if (hull())
+ hull()->mutate(type);
}
// is this old data?
if (it != theCache.end()) {
// we have already a loader, connect to it anyway
- lyxerr << "### updatePreview(), old loader: " << loader_ << "\n";
+ //lyxerr << "### updatePreview(), old loader: " << loader_ << "\n";
loader_ = it->second.get();
loader_->statusChanged.connect
(boost::bind(&InsetFormula::statusChanged, this));
string file = os.str();
// the real work starts
- lyxerr << "### updatePreview(), new file " << file << "\n";
+ //lyxerr << "### updatePreview(), new file " << file << "\n";
std::ofstream of(file.c_str());
of << "\\batchmode"
<< "\\documentclass{article}"
// now we are done, start actual loading we will get called back via
// InsetFormula::statusChanged() if this is finished
- lyxerr << "### updatePreview(), new loader: " << loader_ << "\n";
theCache[data].reset(new grfx::Loader(file));
+ //lyxerr << "### updatePreview(), new loader: " << loader_ << "\n";
loader_ = theCache.find(data)->second.get();
loader_->startLoading();
loader_->statusChanged.connect(boost::bind(&InsetFormula::statusChanged, this));