X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetvspace.C;h=afb221aff28cc25295def2fab9f87d1cf48b3e06;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=7a42d5024dc2ad30e211198b38e9ef0cb31b7def;hpb=00edcc582ff7cfe9cbbc8f7458ea29649bd642d9;p=lyx.git diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 7a42d5024d..afb221aff2 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -23,14 +23,13 @@ #include "lyxtext.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" #include -using lyx::docstring; + +namespace lyx { using std::istringstream; using std::ostream; @@ -68,7 +67,7 @@ void InsetVSpace::doDispatch(LCursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: { - InsetVSpaceMailer::string2params(lyx::to_utf8(cmd.argument()), space_); + InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), space_); break; } @@ -105,10 +104,9 @@ void InsetVSpace::write(Buffer const &, ostream & os) const } -string const InsetVSpace::label() const +docstring const InsetVSpace::label() const { - // FIXME UNICODE - static string const label = lyx::to_utf8(_("Vertical Space")); + static docstring const label = _("Vertical Space"); return label + " (" + space_.asGUIName() + ')'; } @@ -118,7 +116,7 @@ int const arrow_size = 4; } -void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const { int height = 3 * arrow_size; if (space_.length().len().value() >= 0.0) @@ -131,16 +129,16 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const int w = 0; int a = 0; int d = 0; - string lab = label(); - docstring dlab(lab.begin(), lab.end()); - theApp->fontLoader().metrics(font).rectText(dlab, w, a, d); + theFontMetrics(font).rectText(label(), w, a, d); height = max(height, a + d); dim.asc = height / 2 + (a - d) / 2; // align cursor with the dim.des = height - dim.asc; // label text dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } @@ -183,13 +181,12 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const font.setColor(LColor::added_space); font.decSize(); font.decSize(); - string lab = label(); - docstring dlab(lab.begin(), lab.end()); - theApp->fontLoader().metrics(font).rectText(dlab, w, a, d); + docstring const lab = label(); + theFontMetrics(font).rectText(lab, w, a, d); pi.pain.rectText(x + 2 * arrow_size + 5, start + (end - start) / 2 + (a - d) / 2, - dlab, font, LColor::none, LColor::none); + lab, font, LColor::none, LColor::none); // top arrow pi.pain.line(x, ty1, midx, ty2, LColor::added_space); @@ -204,15 +201,15 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const } -int InsetVSpace::latex(Buffer const & buf, ostream & os, +int InsetVSpace::latex(Buffer const & buf, odocstream & os, OutputParams const &) const { - os << space_.asLatexCommand(buf.params()) << '\n'; + os << from_ascii(space_.asLatexCommand(buf.params())) << '\n'; return 1; } -int InsetVSpace::plaintext(Buffer const &, ostream & os, +int InsetVSpace::plaintext(Buffer const &, odocstream & os, OutputParams const &) const { os << "\n\n"; @@ -220,7 +217,7 @@ int InsetVSpace::plaintext(Buffer const &, ostream & os, } -int InsetVSpace::docbook(Buffer const &, std::ostream & os, +int InsetVSpace::docbook(Buffer const &, odocstream & os, OutputParams const &) const { os << '\n'; @@ -270,3 +267,6 @@ string const InsetVSpaceMailer::params2string(VSpace const & vspace) data << name_ << ' ' << vspace.asLyXCommand(); return data.str(); } + + +} // namespace lyx