X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetert.C;h=37fc79acc64456f9aa8825f7a73db9708581581b;hb=ce1f7f257823c9995035c6cbb75f1ea63d9995b6;hp=8513b19e8c7e19c1c2e40925c1ab78e3dff6d9bb;hpb=064714a10232d49de3d1dd46f6903b6ab5d27c48;p=lyx.git diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 8513b19e8c..37fc79acc6 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -243,12 +243,14 @@ bool InsetERT::insertInset(BufferView *, Inset *) void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall) { +#ifdef WITH_WARNINGS +#warning FIXME. More UI stupidity... +#endif // if selectall is activated then the fontchange was an outside general // fontchange and this messages is not needed if (!selectall) - Alert::alert(_("Impossible operation!"), - _("Not permitted to change font-types inside ERT-insets!"), - _("Sorry.")); + Alert::error(_("Cannot change font"), + _("You cannot change font settings inside TeX code.")); } @@ -445,7 +447,19 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) InsetERTMailer::string2params(cmd.argument, status_); status(bv, status_); - bv->updateInset(this, true); + + /* FIXME: I refuse to believe we have to live + * with ugliness like this ! Note that this + * rebreak *is* needed. Consider a change from + * Open (needfullrow) to Inlined (only the space + * taken by the text). + */ + LyXText * t = inset.getLyXText(cmd.view()); + t->need_break_row = t->rows().begin(); + t->fullRebreak(); + t->setCursorIntern(t->cursor.par(), t->cursor.pos()); + inset.update(cmd.view(), true); + bv->updateInset(this); result = DISPATCHED; } break; @@ -569,39 +583,7 @@ int InsetERT::width(BufferView * bv, LyXFont const & font) const void InsetERT::draw(BufferView * bv, LyXFont const & f, int baseline, float & x) const { - lyx::Assert(bv); - cache(bv); - - Painter & pain = bv->painter(); - - button_length = width_collapsed(); - button_top_y = -ascent(bv, f); - button_bottom_y = -ascent(bv, f) + ascent_collapsed() + - descent_collapsed(); - - if (!isOpen()) { - draw_collapsed(pain, baseline, x); - return; - } - - float old_x = x; - - if (!owner()) - x += static_cast(scroll()); - - top_x = int(x); - topx_set = true; - top_baseline = baseline; - - int const bl = baseline - ascent(bv, f) + ascent_collapsed(); - - if (inlined()) { - inset.draw(bv, f, baseline, x); - } else { - draw_collapsed(pain, bl, old_x); - inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x); - } - need_update = NONE; + InsetCollapsable::draw(bv, f, baseline, x, inlined()); } @@ -623,7 +605,6 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const { if (st != status_) { status_ = st; - need_update = FULL; switch (st) { case Inlined: if (bv) @@ -640,8 +621,10 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const bv->unlockInset(const_cast(this)); break; } - if (bv) - bv->updateInset(const_cast(this), false); + if (bv) { + bv->updateInset(const_cast(this)); + bv->buffer()->markDirty(); + } } } @@ -694,25 +677,24 @@ int InsetERT::getMaxWidth(BufferView * bv, UpdatableInset const * in) const if (status_ != Inlined || w < 0) return w; LyXText * text = inset.getLyXText(bv); - int rw = text->firstRow()->width(); + int rw = text->rows().begin()->width(); if (!rw) rw = w; rw += 40; - if (!text->firstRow()->next() && rw < w) + if (text->rows().size() == 1 && rw < w) return -1; return w; } -void InsetERT::update(BufferView * bv, LyXFont const & font, - bool reinit) +void InsetERT::update(BufferView * bv, bool reinit) { if (inset.need_update & InsetText::INIT || - inset.need_update & InsetText::FULL) - { + inset.need_update & InsetText::FULL) { setButtonLabel(); } - InsetCollapsable::update(bv, font, reinit); + + InsetCollapsable::update(bv, reinit); }