]> git.lyx.org Git - features.git/blobdiff - src/insets/insetcollapsable.C
fix insertion of raw double quote, reading of Info inset, initial width of collapsed...
[features.git] / src / insets / insetcollapsable.C
index b99efbb55cb38cd6290c2e0db28e4aa019442bde..5d6739fbcf57fda2ed5940257b093a3b7d0135f5 100644 (file)
@@ -32,20 +32,18 @@ using std::endl;
 using std::max;
 
 
-InsetCollapsable::InsetCollapsable()
-       : UpdatableInset()
+InsetCollapsable::InsetCollapsable(bool collapsed)
+       : UpdatableInset(), collapsed_(collapsed), 
+       button_length(0), button_top_y(0), button_bottom_y(0),
+       label("Label"), autocollapse(true), 
+       widthCollapsed(0), oldWidth(0), need_update(FULL)
+
 {
        inset.setOwner(this);
-       collapsed_ = false;
-       label = "Label";
-       autocollapse = true;
        inset.setAutoBreakRows(true);
        inset.setDrawFrame(0, InsetText::ALWAYS);
        inset.setFrameColor(0, LColor::collapsableframe);
-       button_length = button_top_y = button_bottom_y = 0;
        setInsetName("Collapsable");
-       widthCollapsed = oldWidth = 0;
-       need_update = FULL;
 }
 
 
@@ -138,6 +136,9 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
 
 int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
 {
+       if (!widthCollapsed)
+               widthCollapsed = width_collapsed(bv->painter(), font);
+
        if (collapsed_) 
                return widthCollapsed;
 
@@ -164,6 +165,9 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
 
        Painter & pain = bv->painter();
 
+       if (!widthCollapsed)
+               widthCollapsed = width_collapsed(pain, f);
+
        button_length = widthCollapsed;
        button_top_y = -ascent(bv, f);
        button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +