#include "lyxtext.h"
#include "WordLangTuple.h"
#include "funcrequest.h"
+#include "buffer.h"
#include "frontends/font_metrics.h"
#include "frontends/Painter.h"
+#include "frontends/LyXView.h"
+#include "support/LAssert.h"
#include "support/LOstream.h"
#include "support/lstrings.h"
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+ int baseline, float & x) const
{
+ lyx::Assert(bv);
+ cache(bv);
+
if (need_update != NONE) {
const_cast<InsetText *>(&inset)->update(bv, f, true);
- bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
+ bv->text->postChangedInDraw();
need_update = NONE;
return;
}
if (!owner())
x += static_cast<float>(scroll());
- if (!cleared && (inset.need_update == InsetText::FULL ||
- inset.need_update == InsetText::INIT ||
- top_x != int(x) ||
- top_baseline != baseline))
- {
- // we don't need anymore to clear here we just have to tell
- // the underlying LyXText that it should do the RowClear!
- inset.setUpdateStatus(bv, InsetText::FULL);
- bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
- return;
- }
-
top_x = int(x);
topx_set = true;
top_baseline = baseline;
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
draw_collapsed(pain, bl, old_x);
- inset.draw(bv, f,
- bl + descent_collapsed() + inset.ascent(bv, f),
- x, cleared);
+ inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET))
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
}
first_after_edit = true;
if (!bv->lockInset(this))
return;
- bv->updateInset(this, false);
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
inset.edit(bv);
} else {
if (!bv->lockInset(this))
if (!bv->lockInset(this))
return;
inset.setUpdateStatus(bv, InsetText::FULL);
- bv->updateInset(this, false);
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
inset.edit(bv, front);
first_after_edit = true;
} else {
inset.insetUnlock(bv);
if (scroll())
scroll(bv, 0.0F);
- bv->updateInset(this, false);
+ bv->updateInset(this);
}
// should not be called on inset open!
// inset.insetButtonRelease(bv, 0, 0, button);
inset.setUpdateStatus(bv, InsetText::FULL);
- bv->updateInset(this, false);
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
} else {
collapsed_ = true;
bv->unlockInset(this);
- bv->updateInset(this, false);
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
}
} else if (!collapsed_ && (cmd.y > button_bottom_y)) {
LyXFont font(LyXFont::ALL_SANE);
}
-bool InsetCollapsable::doClearArea() const
-{
- return inset.doClearArea();
-}
-
-
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
bool const recursive) const
{
}
-Paragraph * InsetCollapsable::getParFromID(int id) const
-{
- lyxerr[Debug::INFO] << "Looking for paragraph " << id << endl;
- return inset.getParFromID(id);
-}
-
-
Paragraph * InsetCollapsable::firstParagraph() const
{
return inset.firstParagraph();
if (!collapsed_) return;
collapsed_ = false;
- bv->updateInset(this, false);
+ bv->updateInset(this);
}
return;
collapsed_ = true;
- bv->updateInset(const_cast<InsetCollapsable *>(this), false);
+ bv->updateInset(const_cast<InsetCollapsable *>(this));
}
inset.markErased();
}
-
+
bool InsetCollapsable::nextChange(BufferView * bv, lyx::pos_type & length)
{
bool found = inset.nextChange(bv, length);
-
+
if (first_after_edit && !found)
close(bv);
else if (!found)
return found;
}
-
+
bool InsetCollapsable::searchForward(BufferView * bv, string const & str,
bool cs, bool mw)
{
{
inset.addPreview(loader);
}
+
+
+void InsetCollapsable::cache(BufferView * bv) const
+{
+ view_ = bv->owner()->view();
+}
+
+
+BufferView * InsetCollapsable::view() const
+{
+ return view_.lock().get();
+}