X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetspecialchar.C;h=7ed1ea8489cbae9250b301601e10480647e119c3;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=edf1053557a04802525faf7cd1ff7d6fac15f4c1;hpb=00edcc582ff7cfe9cbbc8f7458ea29649bd642d9;p=lyx.git diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index edf1053557..7ed1ea8489 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -20,12 +20,11 @@ #include "lyxlex.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" -using lyx::docstring; + +namespace lyx { using std::string; using std::auto_ptr; @@ -43,10 +42,10 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const } -void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(mi.base.font); + frontend::FontMetrics const & fm = + theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); @@ -62,7 +61,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = fm.width(ds); if (kind_ == HYPHENATION && dim.wid > 5) dim.wid -= 2; // to make it look shorter + bool const changed = dim_ != dim; dim_ = dim; + return changed; } @@ -74,19 +75,19 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const case HYPHENATION: { font.setColor(LColor::special); - pi.pain.text(x, y, lyx::char_type('-'), font); + pi.pain.text(x, y, char_type('-'), font); break; } case LIGATURE_BREAK: { font.setColor(LColor::special); - pi.pain.text(x, y, lyx::char_type('|'), font); + pi.pain.text(x, y, char_type('|'), font); break; } case END_OF_SENTENCE: { font.setColor(LColor::special); - pi.pain.text(x, y, lyx::char_type('.'), font); + pi.pain.text(x, y, char_type('.'), font); break; } case LDOTS: @@ -99,13 +100,13 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const } case MENU_SEPARATOR: { - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + frontend::FontMetrics const & fm = + theFontMetrics(font); // A triangle the width and height of an 'x' - int w = fm.width(lyx::char_type('x')); - int ox = fm.width(lyx::char_type(' ')) + x; - int h = fm.ascent(lyx::char_type('x')); + int w = fm.width(char_type('x')); + int ox = fm.width(char_type(' ')) + x; + int h = fm.ascent(char_type('x')); int xp[4], yp[4]; xp[0] = ox; yp[0] = y; @@ -166,7 +167,7 @@ void InsetSpecialChar::read(Buffer const &, LyXLex & lex) } -int InsetSpecialChar::latex(Buffer const &, ostream & os, +int InsetSpecialChar::latex(Buffer const &, odocstream & os, OutputParams const &) const { switch (kind_) { @@ -190,7 +191,7 @@ int InsetSpecialChar::latex(Buffer const &, ostream & os, } -int InsetSpecialChar::plaintext(Buffer const &, ostream & os, +int InsetSpecialChar::plaintext(Buffer const &, odocstream & os, OutputParams const &) const { switch (kind_) { @@ -211,7 +212,7 @@ int InsetSpecialChar::plaintext(Buffer const &, ostream & os, } -int InsetSpecialChar::docbook(Buffer const &, ostream & os, +int InsetSpecialChar::docbook(Buffer const &, odocstream & os, OutputParams const &) const { switch (kind_) { @@ -232,7 +233,7 @@ int InsetSpecialChar::docbook(Buffer const &, ostream & os, } -int InsetSpecialChar::textString(Buffer const & buf, ostream & os, +int InsetSpecialChar::textString(Buffer const & buf, odocstream & os, OutputParams const & op) const { return plaintext(buf, os, op); @@ -277,3 +278,6 @@ bool InsetSpecialChar::isLineSeparator() const return false; #endif } + + +} // namespace lyx