]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetminipage.C
fix compilation pb ; update eu.po
[lyx.git] / src / insets / insetminipage.C
index 3424835567afcf4082e2007c02ea3f66666da368..d0d9ea13157a37d3a07c9a775f997dbb4960db1f 100644 (file)
@@ -24,6 +24,7 @@
 #include "support/LOstream.h"
 #include "support/lstrings.h"
 #include "debug.h"
+#include "gettext.h"
 
 using std::ostream;
 using std::endl;
@@ -69,7 +70,7 @@ InsetMinipage::InsetMinipage()
        setLabelFont(font);
        setAutoCollapse(false);
        setInsetName("Minipage");
-       widthp_ = 100; // set default to 100% of column_width
+       width_ = "100%"; // set default to 100% of column_width
 }
 
 
@@ -85,8 +86,7 @@ void InsetMinipage::Write(Buffer const * buf, ostream & os) const
           << "position " << pos_ << "\n"
           << "inner_position " << inner_pos_ << "\n"
           << "height \"" << height_ << "\"\n"
-          << "width \"" << width_ << "\"\n"
-          << "widthp " << widthp_ << "\n";
+          << "width \"" << width_ << "\"\n";
        InsetCollapsable::Write(buf, os);
 }
 
@@ -149,6 +149,12 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
                       << endl;
        }
     }
+#ifdef WITH_WARNINGS
+#warning Remove me before final 1.2.0 (Jug)
+#warning Can we please remove this as soon as possible? (Lgb)
+#endif
+    // this is only for compatibility to the intermediate format and should
+    // vanish till the final 1.2.0!
     if (lex.IsOK()) {
        if (token.empty()) {
            lex.next();
@@ -156,13 +162,17 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
        }
        if (token == "widthp") {
            lex.next();
-           widthp_ = lex.GetInteger();
+           // only do this if the width_-string was not already set!
+           if (width_.empty())
+               width_ = lex.GetString() + "%";
            token = string();
        } else {
                lyxerr << "InsetMinipage::Read: Missing 'widthp_'-tag!"
                       << endl;
        }
     }
+    if (!token.empty())
+       lex.pushToken(token);
     InsetCollapsable::Read(buf, lex);
 }
 
@@ -170,17 +180,19 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
 Inset * InsetMinipage::Clone(Buffer const &) const
 {
        InsetMinipage * result = new InsetMinipage;
-       result->inset->init(inset);
+       result->inset.init(&inset);
        
        result->collapsed = collapsed;
+       result->pos_ = pos_;
+       result->inner_pos_ = inner_pos_;
+       result->height_ = height_;
+       result->width_ = width_;
        return result;
 }
 
 
 int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
 {
-       lyxerr << "InsetMinipage::ascent" << endl;
-       
        if (collapsed)
                return ascent_collapsed(bv->painter(), font);
        else {
@@ -248,18 +260,12 @@ int InsetMinipage::Latex(Buffer const * buf,
                s_pos += "b";
                break;
        }
+       os << "\\begin{minipage}[" << s_pos << "]{"
+          << LyXLength(width_).asLatexString() << "}%\n";
        
-       if (width_.empty()) {
-           os << "\\begin{minipage}[" << s_pos << "]{."
-              << widthp_ << "\\columnwidth}%\n";
-       } else {
-           os << "\\begin{minipage}[" << s_pos << "]{"
-              << width_ << "}%\n";
-       }
-       
-       int i = inset->Latex(buf, os, fragile, fp);
+       int i = inset.Latex(buf, os, fragile, fp);
+
        os << "\\end{minipage}%\n";
-       
        return i + 2;
 }
 
@@ -321,21 +327,12 @@ void InsetMinipage::width(string const & ll)
        width_ = ll;
 }
 
-int InsetMinipage::widthp() const
-{
-       return widthp_;
-}
-
 
-void InsetMinipage::widthp(int ll)
+bool InsetMinipage::ShowInsetDialog(BufferView * bv) const
 {
-       widthp_ = ll;
-}
-
-
-void InsetMinipage::widthp(string const & ll)
-{
-       widthp_ = strToInt(ll);
+    if (!inset.ShowInsetDialog(bv))
+       bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
+    return true;
 }
 
 
@@ -343,27 +340,18 @@ void InsetMinipage::InsetButtonRelease(BufferView * bv, int x, int y,
                                       int button)
 {
     if (button == 3) {
-#if 0
-// we have to check first if we have a locking inset and if this locking inset
-// has a popup menu with the 3rd button
-       if (the_locking_inset) {
-           UpdatableInset * i;
-           if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
-               i->InsetButtonRelease(bv, x, y, button);
-               return;
-           }
-       }
-#endif
-       bv->owner()->getDialogs()->showMinipage(this);
+       ShowInsetDialog(bv);
        return;
     }
     InsetCollapsable::InsetButtonRelease(bv, x, y, button);
 }
 
-int InsetMinipage::getMaxWidth(Painter & pain, UpdatableInset const * inset)
+
+int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
     const
 {
     if (!width_.empty())
-       return VSpace(width_).inPixels(0, 0);
-    return InsetCollapsable::getMaxWidth(pain, inset) / 100 * widthp_;
+       return VSpace(width_).inPixels(bv);
+    // this should not happen!
+    return InsetCollapsable::getMaxWidth(bv, inset);
 }