+ bool ret = false;
+ if ((button != 3) && (x >= 0) && (x < button_length) &&
+ (y >= button_top_y) && (y <= button_bottom_y))
+ {
+ if (collapsed_) {
+ collapsed_ = false;
+// should not be called on inset open!
+// inset.insetButtonRelease(bv, 0, 0, button);
+ inset.setUpdateStatus(bv, InsetText::FULL);
+ bv->updateInset(this, false);
+ } else {
+ collapsed_ = true;
+ bv->unlockInset(this);
+ bv->updateInset(this, false);
+ }
+ } else if (!collapsed_ && (y > button_bottom_y)) {
+ LyXFont font(LyXFont::ALL_SANE);
+ int yy = ascent(bv, font) + y -
+ (ascent_collapsed() +
+ descent_collapsed() +
+ inset.ascent(bv, font));
+ ret = inset.insetButtonRelease(bv, x, yy, button);
+ }
+ if ((button == 3) && !ret) {
+ return showInsetDialog(bv);
+ }
+ return false;
+}
+
+
+void InsetCollapsable::insetMotionNotify(BufferView * bv,
+ int x, int y, int state)
+{
+ if (y > button_bottom_y) {
+ LyXFont font(LyXFont::ALL_SANE);
+ int yy = ascent(bv, font) + y -
+ (ascent_collapsed() +
+ descent_collapsed() +
+ inset.ascent(bv, font));
+ inset.insetMotionNotify(bv, x, yy, state);
+ }
+}
+
+
+void InsetCollapsable::insetKeyPress(XKeyEvent * xke)
+{
+ inset.insetKeyPress(xke);
+}
+
+
+int InsetCollapsable::latex(Buffer const * buf, ostream & os,
+ bool fragile, bool free_spc) const
+{
+ return inset.latex(buf, os, fragile, free_spc);
+}
+
+
+int InsetCollapsable::ascii(Buffer const * buf, ostream & os, int ll) const
+{
+ return inset.ascii(buf, os, ll);
+}
+
+
+int InsetCollapsable::linuxdoc(Buffer const * buf, ostream & os) const
+{
+ return inset.linuxdoc(buf, os);
+}
+
+
+int InsetCollapsable::docbook(Buffer const * buf, ostream & os) const
+{
+ return inset.docbook(buf, os);
+}
+
+#if 0
+int InsetCollapsable::getMaxWidth(BufferView * bv,
+ UpdatableInset const * in) const
+{
+#if 0
+ int const w = UpdatableInset::getMaxWidth(bv, in);
+
+ if (w < 0) {
+ // What does a negative max width signify? (Lgb)
+ // Use the max width of the draw-area (Jug)
+ return w;
+ }
+ // should be at least 30 pixels !!!
+ return max(30, w - width_collapsed());
+#else
+ return UpdatableInset::getMaxWidth(bv, in);
+#endif
+}
+#endif
+
+
+void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
+ bool reinit)
+{
+ if (in_update) {
+ if (reinit && owner()) {
+ owner()->update(bv, font, true);
+ }
+ return;
+ }
+ in_update = true;
+ inset.update(bv, font, reinit);
+ if (reinit && owner()) {
+ owner()->update(bv, font, true);