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 "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,12 +344,28 @@ 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);
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);
xx += par_->width();

View File

@ -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,11 +126,13 @@ 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;
//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
@ -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";
//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;

View File

@ -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();
}

View File

@ -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());
}