* simplify editing logic of math macros by making it purely dynamic

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22260 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2007-12-22 14:39:47 +00:00
parent 9ac321f28f
commit 85e37b01b2
2 changed files with 4 additions and 17 deletions

View File

@ -163,6 +163,9 @@ bool MathMacro::editMode(Cursor const & cur) const {
void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
// set edit mode for which we will have calculated metrics
editing_[mi.base.bv] = editMode(mi.base.bv->cursor());
// calculate new metrics according to display mode
if (displayMode_ == DISPLAY_INIT || displayMode_ == DISPLAY_INTERACTIVE_INIT) {
mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim);
@ -246,20 +249,6 @@ void MathMacro::updateRepresentation(Cursor const * bvCur)
if (displayMode_ != DISPLAY_NORMAL)
return;
// set edit mode to draw box around if needed
bool prevEditing = false;
bool editing = false;
if (bvCur) {
prevEditing = editing_[&bvCur->bv()];
editing = editMode(*bvCur);
editing_[&bvCur->bv()] = editing;
}
// editMode changed and we have to switch default value and hole of optional?
if (optionals_ > 0 && nargs() > 0 &&
prevEditing != editing)
needsUpdate_ = true;
// macro changed?
if (needsUpdate_) {
needsUpdate_ = false;
@ -341,7 +330,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
pi.pain.rectangle(x, y - dim.asc, dim.wid, dim.height(), Color_mathmacroframe);
}
// another argument selected?
// another argument selected or edit mode changed?
idx_type curIdx = cursorIdx(pi.base.bv->cursor());
if (previousCurIdx_[pi.base.bv] != curIdx
|| editing_[pi.base.bv] != editMode(pi.base.bv->cursor()))

View File

@ -139,8 +139,6 @@ protected:
/// including the optional ones (even if it can be empty here)
void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
///
bool editing(BufferView * bv) { return editing_[bv]; }
///
MacroData const * macro() { return macro_; }
private: