]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetminipage.C
use more specific smart_ptr headers
[lyx.git] / src / insets / insetminipage.C
index dcb8f6018b48784b97969fdf7a5a5a1546b8574e..9440b3def18b64e82fb2206cf3a5b100dad58802 100644 (file)
@@ -1,8 +1,8 @@
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
- *      
+ *
  *          Copyright 1998 The LyX Team.
  *
  *======================================================*/
@@ -59,8 +59,8 @@ using std::endl;
 // have to output "" for minipages.
 // (Lgb)
 
-InsetMinipage::InsetMinipage()
-       : InsetCollapsable(), pos_(center),
+InsetMinipage::InsetMinipage(BufferParams const & bp)
+       : InsetCollapsable(bp), pos_(center),
          inner_pos_(inner_center), width_(100, LyXLength::PW)
 {
        setLabel(_("minipage"));
@@ -72,11 +72,15 @@ InsetMinipage::InsetMinipage()
 #if 0
        setAutoCollapse(false);
 #endif
+
+#if 0
 #ifdef WITH_WARNINGS
 #warning Remove this color definitions before 1.2.0 final!
 #endif
        // just for experimentation :)
        setBackgroundColor(LColor::green);
+#endif
+
        inset.setFrameColor(0, LColor::blue);
        setInsetName("Minipage");
 }
@@ -101,7 +105,7 @@ InsetMinipage::~InsetMinipage()
 }
 
 
-void InsetMinipage::write(Buffer const * buf, ostream & os) const 
+void InsetMinipage::write(Buffer const * buf, ostream & os) const
 {
        os << getInsetName() << "\n"
           << "position " << pos_ << "\n"
@@ -241,7 +245,7 @@ int InsetMinipage::latex(Buffer const * buf,
        }
        os << "\\begin{minipage}[" << s_pos << "]{"
           << width_.asLatexString() << "}%\n";
-       
+
        int i = inset.latex(buf, os, fragile, fp);
 
        os << "\\end{minipage}%\n";
@@ -258,7 +262,7 @@ bool InsetMinipage::insetAllowed(Inset::Code code) const
 }
 
 
-InsetMinipage::Position InsetMinipage::pos() const 
+InsetMinipage::Position InsetMinipage::pos() const
 {
        return pos_;
 }
@@ -327,28 +331,24 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
        const
 {
        if (owner() &&
-               (static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0))
-       {
+           static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
                return -1;
        }
        if (!width_.zero()) {
-               switch(width_.unit()) {
-               case LyXLength::PW: // Always % of workarea
-               case LyXLength::PE:
-               case LyXLength::PP:
-               case LyXLength::PL:
-                       return (InsetCollapsable::getMaxWidth(bv, inset) * (int)width_.value()) / 100;
-               default: 
-               {
-                       int ww1 = width_.inPixels(bv);
-                       int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
-                       if (ww2 > 0 && ww2 < ww1) {
-                               return ww2;
-                       }
-                       return ww1;
-               }
+               int ww1 = latexTextWidth(bv);
+               int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
+               if (ww2 > 0 && ww2 < ww1) {
+                       return ww2;
                }
+               return ww1;
        }
        // this should not happen!
        return InsetCollapsable::getMaxWidth(bv, inset);
 }
+
+
+int InsetMinipage::latexTextWidth(BufferView * bv) const
+{
+       return width_.inPixels(InsetCollapsable::latexTextWidth(bv),
+                              bv->text->defaultHeight());
+}