X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetbox.C;h=2af61d15e5f8c4343bb0e4a04d02b8b7be3cc14b;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=634c6b46b975d65598cd9a3bd5d18d6967ae2e46;hpb=023fb5433c3028ec87042d9f2a7d2d4ed4d70eee;p=lyx.git diff --git a/src/insets/insetbox.C b/src/insets/insetbox.C index 634c6b46b9..2af61d15e5 100644 --- a/src/insets/insetbox.C +++ b/src/insets/insetbox.C @@ -30,7 +30,8 @@ #include -using lyx::docstring; + +namespace lyx { using std::auto_ptr; using std::string; @@ -43,6 +44,7 @@ using std::endl; namespace { typedef Translator BoxTranslator; +typedef Translator BoxTranslatorLoc; BoxTranslator const init_boxtranslator() { @@ -56,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; } @@ -76,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; } @@ -87,7 +88,7 @@ BoxTranslator const & boxtranslator_loc() void InsetBox::init() { - setInsetName("Box"); + setInsetName(from_ascii("Box")); setButtonLabel(); } @@ -147,15 +148,14 @@ void InsetBox::setButtonLabel() BoxType btype = boxtranslator().find(params_.type); - string label; - // FIXME UNICODE - label += lyx::to_utf8(_("Box")); + docstring label; + label += _("Box"); label += " ("; if (btype == Frameless) { if (params_.use_parbox) - label += lyx::to_utf8(_("Parbox")); + label += _("Parbox"); else - label += lyx::to_utf8(_("Minipage")); + label += _("Minipage"); } else label += boxtranslator_loc().find(btype); label += ")"; @@ -168,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; } @@ -196,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; } @@ -244,7 +252,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); @@ -291,11 +299,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 << "]"; } @@ -324,16 +335,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 << "{"; @@ -373,14 +389,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); @@ -621,3 +637,6 @@ void InsetBoxParams::read(LyXLex & lex) lex.pushToken(token); } } + + +} // namespace lyx