X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetspecialchar.C;h=7ed1ea8489cbae9250b301601e10480647e119c3;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=eecfe288f253bd99cfb27c86719dbd3a70c0ed44;hpb=c46b7d89553209b8df4e9de392ee07ef711f092f;p=lyx.git diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index eecfe288f2..7ed1ea8489 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -20,10 +20,11 @@ #include "lyxlex.h" #include "metricsinfo.h" -#include "frontends/font_metrics.h" +#include "frontends/FontMetrics.h" #include "frontends/Painter.h" -using lyx::docstring; + +namespace lyx { using std::string; using std::auto_ptr; @@ -41,11 +42,12 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const } -void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const { - LyXFont & font = mi.base.font; - dim.asc = font_metrics::maxAscent(font); - dim.des = font_metrics::maxDescent(font); + frontend::FontMetrics const & fm = + theFontMetrics(mi.base.font); + dim.asc = fm.maxAscent(); + dim.des = fm.maxDescent(); string s; switch (kind_) { @@ -56,10 +58,12 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const case HYPHENATION: s = "-"; break; } docstring ds(s.begin(), s.end()); - dim.wid = font_metrics::width(ds, font); + 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; } @@ -71,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: @@ -96,10 +100,13 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const } case MENU_SEPARATOR: { + frontend::FontMetrics const & fm = + theFontMetrics(font); + // A triangle the width and height of an 'x' - int w = font_metrics::width(lyx::char_type('x'), font); - int ox = font_metrics::width(lyx::char_type(' '), font) + x; - int h = font_metrics::ascent(lyx::char_type('x'), font); + 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; @@ -160,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_) { @@ -184,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_) { @@ -205,28 +212,7 @@ int InsetSpecialChar::plaintext(Buffer const &, ostream & os, } -int InsetSpecialChar::linuxdoc(Buffer const &, ostream & os, - OutputParams const &) const -{ - switch (kind_) { - case HYPHENATION: - case LIGATURE_BREAK: - break; - case END_OF_SENTENCE: - os << '.'; - break; - case LDOTS: - os << "..."; - break; - case MENU_SEPARATOR: - os << "&lyxarrow;"; - break; - } - return 0; -} - - -int InsetSpecialChar::docbook(Buffer const &, ostream & os, +int InsetSpecialChar::docbook(Buffer const &, odocstream & os, OutputParams const &) const { switch (kind_) { @@ -247,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); @@ -292,3 +278,6 @@ bool InsetSpecialChar::isLineSeparator() const return false; #endif } + + +} // namespace lyx