disable leaving the inset during selection

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2877 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-10-12 16:12:32 +00:00
parent db033af700
commit df1613ed4a
3 changed files with 47 additions and 29 deletions

View File

@ -279,9 +279,7 @@ bool MathCursor::posLeft()
{ {
if (pos() == 0) if (pos() == 0)
return false; return false;
--pos(); --pos();
return true; return true;
} }
@ -290,9 +288,7 @@ bool MathCursor::posRight()
{ {
if (pos() == size()) if (pos() == size())
return false; return false;
++pos(); ++pos();
return true; return true;
} }
@ -313,7 +309,7 @@ bool MathCursor::left(bool sel)
return true; return true;
} }
return posLeft() || idxLeft() || popLeft(); return posLeft() || idxLeft() || popLeft() || selection_;
} }
@ -333,7 +329,7 @@ bool MathCursor::right(bool sel)
return true; return true;
} }
return posRight() || idxRight() || popRight(); return posRight() || idxRight() || popRight() || selection_;
} }
@ -591,7 +587,7 @@ bool MathCursor::up(bool sel)
} }
} }
return goUp(); return goUp() || selection_;
} }
@ -624,7 +620,7 @@ bool MathCursor::down(bool sel)
} }
} }
return goDown(); return goDown() || selection_;
} }

View File

@ -23,8 +23,8 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "debug.h" #include "debug.h"
#include "mathed/support.h" #include "support.h"
#include "mathed/math_cursor.h" #include "math_cursor.h"
#include "math_macrotable.h" #include "math_macrotable.h"
#include "math_macrotemplate.h" #include "math_macrotemplate.h"
#include "Painter.h" #include "Painter.h"
@ -57,9 +57,28 @@ const char * MathMacro::name() const
} }
bool MathMacro::defining() const
{
return 0;
//return mathcursor && mathcursor->formula()->getInsetName() == name();
}
bool MathMacro::editing() const
{
return mathcursor && mathcursor->isInside(this);
}
void MathMacro::metrics(MathStyles st) const void MathMacro::metrics(MathStyles st) const
{ {
if (mathcursor && mathcursor->isInside(this)) { if (defining()) {
size_ = st;
mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
return;
}
if (editing()) {
expanded_ = tmplate_->xcell(0); expanded_ = tmplate_->xcell(0);
expanded_.metrics(st); expanded_.metrics(st);
size_ = st; size_ = st;
@ -81,15 +100,16 @@ void MathMacro::metrics(MathStyles st) const
descent_ += std::max(c.ascent(), lasc) + 5; descent_ += std::max(c.ascent(), lasc) + 5;
descent_ += std::max(c.descent(), ldes) + 5; descent_ += std::max(c.descent(), ldes) + 5;
} }
} else { return;
expanded_ = tmplate_->xcell(0); }
expanded_.data_.substitute(*this);
expanded_.metrics(st); expanded_ = tmplate_->xcell(0);
size_ = st; expanded_.data_.substitute(*this);
width_ = expanded_.width() + 6; expanded_.metrics(st);
ascent_ = expanded_.ascent() + 3; size_ = st;
descent_ = expanded_.descent() + 3; width_ = expanded_.width() + 6;
} ascent_ = expanded_.ascent() + 3;
descent_ = expanded_.descent() + 3;
} }
@ -100,10 +120,12 @@ void MathMacro::draw(Painter & pain, int x, int y) const
metrics(size()); metrics(size());
//LColor::color col; if (defining()) {
drawStr(pain, LM_TC_TEX, size_, x, y, name());
if (mathcursor && mathcursor->isInside(this)) { return;
}
if (editing()) {
int h = y - ascent() + 2 + expanded_.ascent(); int h = y - ascent() + 2 + expanded_.ascent();
drawStr(pain, LM_TC_TEXTRM, size(), x + 3, h, name()); drawStr(pain, LM_TC_TEXTRM, size(), x + 3, h, name());
@ -125,14 +147,10 @@ void MathMacro::draw(Painter & pain, int x, int y) const
drawStr(pain, LM_TC_TEX, size(), x + 3, h, str); drawStr(pain, LM_TC_TEX, size(), x + 3, h, str);
h += std::max(c.descent(), ldes) + 5; h += std::max(c.descent(), ldes) + 5;
} }
//col = LColor::red; return;
} else {
expanded_.draw(pain, x + 3, y);
//col = LColor::black;
} }
//if (nargs() > 0) expanded_.draw(pain, x + 3, y);
// pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, col);
} }

View File

@ -73,6 +73,10 @@ private:
void operator=(MathMacro const &); void operator=(MathMacro const &);
/// ///
char const * name() const; char const * name() const;
///
bool editing() const;
///
bool defining() const;
/// ///
MathAtom & tmplate_; MathAtom & tmplate_;