]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbox.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetbox.C
index 3595606508ddf829a348f57c635b550a8d46cbf0..2af61d15e5f8c4343bb0e4a04d02b8b7be3cc14b 100644 (file)
@@ -30,8 +30,8 @@
 
 #include <sstream>
 
-using lyx::docstring;
-using lyx::odocstream;
+
+namespace lyx {
 
 using std::auto_ptr;
 using std::string;
@@ -44,6 +44,7 @@ using std::endl;
 namespace {
 
 typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
+typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
 
 BoxTranslator const init_boxtranslator()
 {
@@ -57,15 +58,14 @@ BoxTranslator const init_boxtranslator()
 }
 
 
-BoxTranslator const init_boxtranslator_loc()
+BoxTranslatorLoc const init_boxtranslator_loc()
 {
-       // FIXME UNICODE
-       BoxTranslator translator(lyx::to_utf8(_("Boxed")), InsetBox::Boxed);
-       translator.addPair(lyx::to_utf8(_("Frameless")), InsetBox::Frameless);
-       translator.addPair(lyx::to_utf8(_("ovalbox")), InsetBox::ovalbox);
-       translator.addPair(lyx::to_utf8(_("Ovalbox")), InsetBox::Ovalbox);
-       translator.addPair(lyx::to_utf8(_("Shadowbox")), InsetBox::Shadowbox);
-       translator.addPair(lyx::to_utf8(_("Doublebox")), InsetBox::Doublebox);
+       BoxTranslatorLoc translator(_("Boxed"), InsetBox::Boxed);
+       translator.addPair(_("Frameless"), InsetBox::Frameless);
+       translator.addPair(_("ovalbox"), InsetBox::ovalbox);
+       translator.addPair(_("Ovalbox"), InsetBox::Ovalbox);
+       translator.addPair(_("Shadowbox"), InsetBox::Shadowbox);
+       translator.addPair(_("Doublebox"), InsetBox::Doublebox);
        return translator;
 }
 
@@ -77,9 +77,9 @@ BoxTranslator const & boxtranslator()
 }
 
 
-BoxTranslator const & boxtranslator_loc()
+BoxTranslatorLoc const & boxtranslator_loc()
 {
-       static BoxTranslator translator = init_boxtranslator_loc();
+       static BoxTranslatorLoc translator = init_boxtranslator_loc();
        return translator;
 }
 
@@ -88,7 +88,7 @@ BoxTranslator const & boxtranslator_loc()
 
 void InsetBox::init()
 {
-       setInsetName("Box");
+       setInsetName(from_ascii("Box"));
        setButtonLabel();
 }
 
@@ -149,7 +149,6 @@ void InsetBox::setButtonLabel()
        BoxType btype = boxtranslator().find(params_.type);
 
        docstring label;
-       // FIXME UNICODE
        label += _("Box");
        label += " (";
        if (btype == Frameless) {
@@ -158,8 +157,7 @@ void InsetBox::setButtonLabel()
                else
                        label += _("Minipage");
        } else
-               // FXIME unicode
-               label += lyx::from_utf8(boxtranslator_loc().find(btype));
+               label += boxtranslator_loc().find(btype);
        label += ")";
 
        setLabel(label);
@@ -170,13 +168,21 @@ void InsetBox::setButtonLabel()
 }
 
 
-void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
+bool InsetBox::hasFixedWidth() const
+{
+      return params_.inner_box || params_.special != "width";
+}
+
+
+bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
 {
        MetricsInfo mi = m;
-       if (params_.inner_box || params_.special != "width")
+       if (hasFixedWidth())
                mi.base.textwidth = params_.width.inPixels(m.base.textwidth);
        InsetCollapsable::metrics(mi, dim);
+       bool const changed = dim_ != dim;
        dim_ = dim;
+       return changed;
 }
 
 
@@ -198,8 +204,8 @@ void InsetBox::doDispatch(LCursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
-               lyxerr << "InsetBox::dispatch MODIFY" << endl;
-               InsetBoxMailer::string2params(lyx::to_utf8(cmd.argument()), params_);
+               //lyxerr << "InsetBox::dispatch MODIFY" << endl;
+               InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
                setButtonLabel();
                break;
        }
@@ -296,10 +302,10 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
                        // FIXME UNICODE
                        if (params_.special != "none") {
                                os << "[" << params_.width.value()
-                                  << '\\' << lyx::from_utf8(params_.special)
+                                  << '\\' << from_utf8(params_.special)
                                   << ']';
                        } else
-                               os << '[' << lyx::from_ascii(width_string)
+                               os << '[' << from_ascii(width_string)
                                   << ']';
                        if (params_.hor_pos != 'c')
                                os << "[" << params_.hor_pos << "]";
@@ -330,20 +336,20 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
                os << "[" << params_.pos << "]";
                if (params_.height_special == "none") {
                        // FIXME UNICODE
-                       os << '[' << lyx::from_ascii(params_.height.asLatexString())
+                       os << '[' << from_ascii(params_.height.asLatexString())
                           << ']';
                } else {
                        // Special heights
                        // FIXME UNICODE
                        os << "[" << params_.height.value()
-                          << '\\' << lyx::from_utf8(params_.height_special)
+                          << '\\' << from_utf8(params_.height_special)
                           << ']';
                }
                if (params_.inner_pos != params_.pos)
                        os << "[" << params_.inner_pos << "]";
 
                // FIXME UNICODE
-               os << '{' << lyx::from_ascii(width_string) << '}';
+               os << '{' << from_ascii(width_string) << '}';
 
                if (params_.use_parbox)
                        os << "{";
@@ -383,7 +389,7 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
 }
 
 
-int InsetBox::docbook(Buffer const & buf, lyx::odocstream & os,
+int InsetBox::docbook(Buffer const & buf, odocstream & os,
                      OutputParams const & runparams) const
 {
        return InsetText::docbook(buf, os, runparams);
@@ -631,3 +637,6 @@ void InsetBoxParams::read(LyXLex & lex)
                lex.pushToken(token);
        }
 }
+
+
+} // namespace lyx