small stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3049 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-20 14:48:25 +00:00
parent 0b506e0467
commit 932884ff5b
4 changed files with 63 additions and 23 deletions

View File

@ -31,6 +31,7 @@
#include "gettext.h" #include "gettext.h"
#include "debug.h" #include "debug.h"
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "lyxtext.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/lyxlib.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, void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const int y, float & xx, bool) const
{ {
@ -336,11 +344,27 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int w = par_->width(); int w = par_->width();
int h = par_->height(); int h = par_->height();
int a = par_->ascent(); int a = par_->ascent();
pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
if (mathcursor && mathcursor->formula() == this) { bool done = false;
mathcursor->drawSelection(pain); /*
pain.rectangle(x, y - a, w, h, LColor::mathframe); 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); par_->draw(pain, x, y);

View File

@ -41,6 +41,7 @@
#include "math_spaceinset.h" #include "math_spaceinset.h"
#include "math_macrotable.h" #include "math_macrotable.h"
#include "math_factory.h" #include "math_factory.h"
#include "math_parser.h"
#include "undo_funcs.h" #include "undo_funcs.h"
using std::endl; 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)) if (!bv->lockInset(this))
lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; 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); metrics(bv);
// if that is removed, we won't get the magenta box when entering an // if that is removed, we won't get the magenta box when entering an
// inset for the first time // inset for the first time
@ -242,7 +245,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
void InsetFormulaBase::insetButtonRelease(BufferView * bv, void InsetFormulaBase::insetButtonRelease(BufferView * bv,
int x, int y, int /*button*/) int /*x*/, int /*y*/, int /*button*/)
{ {
if (!mathcursor) if (!mathcursor)
return; return;
@ -254,21 +257,42 @@ void InsetFormulaBase::insetButtonRelease(BufferView * bv,
void InsetFormulaBase::insetButtonPress(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"; //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_
first_x = x; // << " but: " << button << "\n";
first_y = y; switch (button) {
if (mathcursor) { default:
mathcursor->selClear(); case 1:
mathcursor->setPos(x + xo_, y + yo_); // 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); bv->updateInset(this, false);
} }
void InsetFormulaBase::insetMotionNotify(BufferView * bv, void InsetFormulaBase::insetMotionNotify(BufferView * bv,
int x, int y, int button) int x, int y, int /*button*/)
{ {
if (!mathcursor) if (!mathcursor)
return; return;

View File

@ -62,10 +62,6 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
{ {
string name = mathed_parse_macro(s); string name = mathed_parse_macro(s);
setInsetName(name); setInsetName(name);
#ifdef WITH_WARNINGS
#warning "metrics disabled"
#endif
//metrics();
} }

View File

@ -483,10 +483,6 @@ void MathCursor::niceInsert(MathAtom const & t)
right(); // do not push for e.g. MathSymbolInset right(); // do not push for e.g. MathSymbolInset
selPaste(); selPaste();
} }
#ifdef WITH_WARNINGS
#warning "redraw disabled"
#endif
//p->metrics(p->size());
} }