From: André Pönitz Date: Tue, 20 Nov 2001 14:48:25 +0000 (+0000) Subject: small stuff X-Git-Tag: 1.6.10~20316 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=932884ff5baa1990e8ba6fa05d9e1df0ab278493;p=features.git small stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3049 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 8ddb1a0754..337924f15f 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -31,6 +31,7 @@ #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" @@ -324,6 +325,13 @@ void InsetFormula::read(Buffer const *, LyXLex & lex) } +//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 { @@ -336,11 +344,27 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, 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); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 48b3041e00..aa5121a133 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -41,6 +41,7 @@ #include "math_spaceinset.h" #include "math_macrotable.h" #include "math_factory.h" +#include "math_parser.h" #include "undo_funcs.h" using std::endl; @@ -125,12 +126,14 @@ string const InsetFormulaBase::editMessage() const } -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 @@ -242,7 +245,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty) void InsetFormulaBase::insetButtonRelease(BufferView * bv, - int x, int y, int /*button*/) + int /*x*/, int /*y*/, int /*button*/) { if (!mathcursor) return; @@ -254,21 +257,42 @@ void InsetFormulaBase::insetButtonRelease(BufferView * bv, 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; diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 7740c47da6..93b0689b47 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -62,10 +62,6 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s) { string name = mathed_parse_macro(s); setInsetName(name); -#ifdef WITH_WARNINGS -#warning "metrics disabled" -#endif - //metrics(); } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index a6055f5e79..ea813276af 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -483,10 +483,6 @@ void MathCursor::niceInsert(MathAtom const & t) right(); // do not push for e.g. MathSymbolInset selPaste(); } -#ifdef WITH_WARNINGS -#warning "redraw disabled" -#endif - //p->metrics(p->size()); }