]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbox.C
more cleanup:
[lyx.git] / src / insets / insetbox.C
index 7d0a0ad35ea511970d95e92d6ae9da663bb0a6e7..e5be700ae43f1b8afa81e8e50e1c9fa91cb4ee8f 100644 (file)
@@ -30,6 +30,9 @@
 
 #include <sstream>
 
+
+namespace lyx {
+
 using std::auto_ptr;
 using std::string;
 using std::istringstream;
@@ -42,7 +45,8 @@ namespace {
 
 typedef Translator<std::string, InsetBox::BoxType> BoxTranslator;
 
-BoxTranslator const init_boxtranslator() {
+BoxTranslator const init_boxtranslator()
+{
        BoxTranslator translator("Boxed", InsetBox::Boxed);
        translator.addPair("Frameless", InsetBox::Frameless);
        translator.addPair("ovalbox", InsetBox::ovalbox);
@@ -53,24 +57,28 @@ BoxTranslator const init_boxtranslator() {
 }
 
 
-BoxTranslator const init_boxtranslator_loc() {
-       BoxTranslator 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);
+BoxTranslator const init_boxtranslator_loc()
+{
+       // FIXME UNICODE
+       BoxTranslator translator(to_utf8(_("Boxed")), InsetBox::Boxed);
+       translator.addPair(to_utf8(_("Frameless")), InsetBox::Frameless);
+       translator.addPair(to_utf8(_("ovalbox")), InsetBox::ovalbox);
+       translator.addPair(to_utf8(_("Ovalbox")), InsetBox::Ovalbox);
+       translator.addPair(to_utf8(_("Shadowbox")), InsetBox::Shadowbox);
+       translator.addPair(to_utf8(_("Doublebox")), InsetBox::Doublebox);
        return translator;
 }
 
 
-BoxTranslator const & boxtranslator() {
+BoxTranslator const & boxtranslator()
+{
        static BoxTranslator translator = init_boxtranslator();
        return translator;
 }
 
 
-BoxTranslator const & boxtranslator_loc() {
+BoxTranslator const & boxtranslator_loc()
+{
        static BoxTranslator translator = init_boxtranslator_loc();
        return translator;
 }
@@ -80,7 +88,7 @@ BoxTranslator const & boxtranslator_loc() {
 
 void InsetBox::init()
 {
-       setInsetName("Box");
+       setInsetName(from_ascii("Box"));
        setButtonLabel();
 }
 
@@ -111,7 +119,7 @@ auto_ptr<InsetBase> InsetBox::doClone() const
 }
 
 
-string const InsetBox::editMessage() const
+docstring const InsetBox::editMessage() const
 {
        return _("Opened Box Inset");
 }
@@ -139,13 +147,21 @@ void InsetBox::setButtonLabel()
        font.decSize();
 
        BoxType btype = boxtranslator().find(params_.type);
+
+       docstring label;
+       label += _("Box");
+       label += " (";
        if (btype == Frameless) {
                if (params_.use_parbox)
-                       setLabel(_("Box") + " (" + _("Parbox") + ")");
+                       label += _("Parbox");
                else
-                       setLabel(_("Box") + " (" + _("Minipage") + ")");
+                       label += _("Minipage");
        } else
-               setLabel(_("Box") + " (" + boxtranslator_loc().find(btype) + ")");
+               // FIXME UNICODE
+               label += from_utf8(boxtranslator_loc().find(btype));
+       label += ")";
+
+       setLabel(label);
 
        font.setColor(LColor::foreground);
        setBackgroundColor(LColor::background);
@@ -153,13 +169,15 @@ void InsetBox::setButtonLabel()
 }
 
 
-void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
+bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
 {
        MetricsInfo mi = m;
        if (params_.inner_box || params_.special != "width")
                mi.base.textwidth = params_.width.inPixels(m.base.textwidth);
        InsetCollapsable::metrics(mi, dim);
+       bool const changed = dim_ != dim;
        dim_ = dim;
+       return changed;
 }
 
 
@@ -181,8 +199,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;
        }
@@ -198,13 +216,6 @@ void InsetBox::doDispatch(LCursor & cur, FuncRequest & cmd)
                }
                InsetCollapsable::doDispatch(cur, cmd);
                break;
-       case LFUN_PASTE:
-       case LFUN_CLIPBOARD_PASTE:
-       case LFUN_PRIMARY_SELECTION_PASTE:
-               InsetCollapsable::doDispatch(cur, cmd);
-               if (!params_.inner_box)
-                       forceParagraphsToDefault(cur);
-               break;
 
        default:
                InsetCollapsable::doDispatch(cur, cmd);
@@ -236,7 +247,7 @@ bool InsetBox::getStatus(LCursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetBox::latex(Buffer const & buf, ostream & os,
+int InsetBox::latex(Buffer const & buf, odocstream & os,
                                OutputParams const & runparams) const
 {
        BoxType btype = boxtranslator().find(params_.type);
@@ -283,11 +294,14 @@ int InsetBox::latex(Buffer const & buf, ostream & os,
                if (!params_.inner_box) {
                        os << "{\\makebox";
                        // Special widths, see usrguide ยง3.5
+                       // FIXME UNICODE
                        if (params_.special != "none") {
                                os << "[" << params_.width.value()
-                                  << "\\" << params_.special << "]";
+                                  << '\\' << from_utf8(params_.special)
+                                  << ']';
                        } else
-                               os << "[" << width_string << "]";
+                               os << '[' << from_ascii(width_string)
+                                  << ']';
                        if (params_.hor_pos != 'c')
                                os << "[" << params_.hor_pos << "]";
                }
@@ -316,16 +330,21 @@ int InsetBox::latex(Buffer const & buf, ostream & os,
 
                os << "[" << params_.pos << "]";
                if (params_.height_special == "none") {
-                       os << "[" << params_.height.asLatexString() << "]";
+                       // FIXME UNICODE
+                       os << '[' << from_ascii(params_.height.asLatexString())
+                          << ']';
                } else {
                        // Special heights
+                       // FIXME UNICODE
                        os << "[" << params_.height.value()
-                          << "\\" << params_.height_special << "]";
+                          << '\\' << from_utf8(params_.height_special)
+                          << ']';
                }
                if (params_.inner_pos != params_.pos)
                        os << "[" << params_.inner_pos << "]";
 
-               os << "{" << width_string << "}";
+               // FIXME UNICODE
+               os << '{' << from_ascii(width_string) << '}';
 
                if (params_.use_parbox)
                        os << "{";
@@ -365,14 +384,14 @@ int InsetBox::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetBox::docbook(Buffer const & buf, std::ostream & os,
+int InsetBox::docbook(Buffer const & buf, odocstream & os,
                      OutputParams const & runparams) const
 {
        return InsetText::docbook(buf, os, runparams);
 }
 
 
-int InsetBox::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBox::plaintext(Buffer const & buf, odocstream & os,
                    OutputParams const & runparams) const
 {
        BoxType const btype = boxtranslator().find(params_.type);
@@ -613,3 +632,6 @@ void InsetBoxParams::read(LyXLex & lex)
                lex.pushToken(token);
        }
 }
+
+
+} // namespace lyx