]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.C
more cleanup:
[lyx.git] / src / insets / insetcollapsable.C
index 3d4434aa79e138ec868fac88b959d75115e279f8..d1e6949a5c875b9c9e7c00c7042c9938cbd1f71c 100644 (file)
@@ -53,7 +53,7 @@ InsetCollapsable::CollapseStatus InsetCollapsable::status() const
 InsetCollapsable::InsetCollapsable
                (BufferParams const & bp, CollapseStatus status)
        : InsetText(bp), label(from_ascii("Label")), status_(status),
-         openinlined_(false), autoOpen_(false)
+         openinlined_(false), autoOpen_(false), mouse_hover_(false)
 {
        setAutoBreakRows(true);
        setDrawFrame(true);
@@ -63,6 +63,23 @@ InsetCollapsable::InsetCollapsable
 }
 
 
+InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs):
+       InsetText(rhs),         
+       labelfont_(rhs.labelfont_),
+       button_dim(rhs.button_dim),
+       topx(rhs.topx),
+       topbaseline(rhs.topbaseline),
+       label(rhs.label),
+       status_(rhs.status_),
+       openinlined_(rhs.openinlined_),
+       autoOpen_(rhs.autoOpen_),
+       textdim_(rhs.textdim_),
+       // the sole purpose of this copy constructor
+       mouse_hover_(false)
+{
+}
+
+
 void InsetCollapsable::write(Buffer const & buf, ostream & os) const
 {
        os << "status ";
@@ -132,7 +149,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const
 }
 
 
-void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        autoOpen_ = mi.base.bv->cursor().isInside(this);
        mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
@@ -162,7 +179,16 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.des += TEXT_TO_INSET_OFFSET;
        dim.wid += 2 * TEXT_TO_INSET_OFFSET;
        mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
+       bool const changed = dim_ != dim;
        dim_ = dim;
+       return changed;
+}
+
+
+bool InsetCollapsable::setMouseHover(bool mouse_hover)
+{
+       mouse_hover_ = mouse_hover;
+       return true;
 }
 
 
@@ -179,7 +205,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                button_dim.y1 = top;
                button_dim.y2 = top + dimc.height();
 
-               pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_);
+               pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_, mouse_hover_);
 
                if (status() == Open) {
                        int textx, texty;
@@ -279,7 +305,7 @@ void InsetCollapsable::edit(LCursor & cur, bool left)
 InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
 {
        //lyxerr << "InsetCollapsable: edit xy" << endl;
-       if (status() == Collapsed)
+       if (status() == Collapsed || button_dim.contains(x, y))
                return this;
        cur.push(*this);
        return InsetText::editXY(cur, x, y);