#include "gettext.h"
#include "debug.h"
#include "lyx_gui_misc.h"
+#include "lyxtext.h"
#include "support/LOstream.h"
#include "support/LAssert.h"
#include "support/lyxlib.h"
}
+//std::ostream & operator<<(std::ostream & os, LyXCursor const & c)
+//{
+// os << '[' << c.x() << ' ' << c.y() << ' ' << c.pos() << ']';
+// return os;
+//}
+
+
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
{
int w = par_->width();
int h = par_->height();
int a = par_->ascent();
- pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
- if (mathcursor && mathcursor->formula() == this) {
- mathcursor->drawSelection(pain);
- pain.rectangle(x, y - a, w, h, LColor::mathframe);
+ bool done = false;
+/*
+ if (LyXText * t = bv->getLyXText()) {
+ LyXText::Selection & sel = t->selection;
+ lyxerr << "sel.start: " << sel.start << "\n";
+ lyxerr << "sel.end: " << sel.end << "\n";
+ lyxerr << "t->cursor: " << t->cursor << "\n";
+ if (sel.set() && sel.start < t->cursor && t->cursor < sel.end) {
+ pain.fillRectangle(x, y - a, w, h, LColor::selection);
+ done = true;
+ }
+ }
+*/
+
+ if (!done) {
+ pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
+ if (mathcursor && mathcursor->formula() == this) {
+ mathcursor->drawSelection(pain);
+ pain.rectangle(x, y - a, w, h, LColor::mathframe);
+ }
}
par_->draw(pain, x, y);
#include "math_spaceinset.h"
#include "math_macrotable.h"
#include "math_factory.h"
+#include "math_parser.h"
#include "undo_funcs.h"
using std::endl;
}
-void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
+void InsetFormulaBase::edit(BufferView * bv, int x, int y, unsigned int button)
{
if (!bv->lockInset(this))
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
- mathcursor = new MathCursor(this, x == 0);
+ //lyxerr << "edit: " << x << " " << y << " button: " << button << "\n";
+ if (!mathcursor)
+ mathcursor = new MathCursor(this, x == 0);
metrics(bv);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
void InsetFormulaBase::insetButtonRelease(BufferView * bv,
- int x, int y, int /*button*/)
+ int /*x*/, int /*y*/, int /*button*/)
{
if (!mathcursor)
return;
void InsetFormulaBase::insetButtonPress(BufferView * bv,
- int x, int y, int /*button*/)
+ int x, int y, int button)
{
- //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_ << "\n";
- first_x = x;
- first_y = y;
- if (mathcursor) {
- mathcursor->selClear();
- mathcursor->setPos(x + xo_, y + yo_);
+ //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_
+ // << " but: " << button << "\n";
+ switch (button) {
+ default:
+ case 1:
+ // just click
+ first_x = x;
+ first_y = y;
+ if (mathcursor) {
+ mathcursor->selClear();
+ mathcursor->setPos(x + xo_, y + yo_);
+ }
+ break;
+ case 2:
+ lyxerr << "insetButtonPress: 2\n";
+ // insert stuff
+ if (mathcursor) {
+ bv->lockedInsetStoreUndo(Undo::EDIT);
+ MathArray ar;
+ mathcursor->selGet(ar);
+ mathcursor->setPos(x + xo_, y + yo_);
+ string sel =
+ bv->getLyXText()->selectionAsString(bv->buffer(), false);
+ //mathed_parse_cell(ar, sel);
+ mathcursor->insert(ar);
+ }
+ break;
}
bv->updateInset(this, false);
}
void InsetFormulaBase::insetMotionNotify(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int /*button*/)
{
if (!mathcursor)
return;