X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetnewline.C;h=302dda77690d1ddf2c260625c51bbd11e48653de;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=1becea0d8ed87afc23cb2a2c48ddf89ee4107f39;hpb=723ee136ba0f980346de93289b278c3a544f3e71;p=lyx.git diff --git a/src/insets/insetnewline.C b/src/insets/insetnewline.C index 1becea0d8e..302dda7769 100644 --- a/src/insets/insetnewline.C +++ b/src/insets/insetnewline.C @@ -5,87 +5,83 @@ * * \author John Levon * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include #include "insetnewline.h" -#include "BufferView.h" #include "debug.h" -#include "dimension.h" -#include "paragraph.h" +#include "LColor.h" #include "lyxtext.h" -#include "support/LOstream.h" +#include "metricsinfo.h" +#include "paragraph.h" +#include "paragraph_funcs.h" + +#include "frontends/FontMetrics.h" #include "frontends/Painter.h" -#include "frontends/font_metrics.h" -using std::ostream; + +namespace lyx { + using std::endl; +using std::ostream; -void InsetNewline::read(Buffer const *, LyXLex &) +void InsetNewline::read(Buffer const &, LyXLex &) { /* Nothing to read */ } -void InsetNewline::write(Buffer const *, ostream & os) const +void InsetNewline::write(Buffer const &, ostream & os) const { - os << "\n\\newline \n"; + os << "\n\\newline\n"; } -void InsetNewline::dimension(BufferView *, LyXFont const & font, - Dimension & dim) const +bool InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const { - dim.a = font_metrics::maxAscent(font); - dim.d = font_metrics::maxDescent(font); - dim.w = font_metrics::width('n', font); + frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); + dim.asc = fm.maxAscent(); + dim.des = fm.maxDescent(); + dim.wid = fm.width('n'); + bool const changed = dim_ != dim; + dim_ = dim; + return changed; } -int InsetNewline::latex(Buffer const *, ostream &, bool, bool) const +int InsetNewline::latex(Buffer const &, odocstream &, + OutputParams const &) const { lyxerr << "Eek, calling InsetNewline::latex !" << endl; return 0; } -int InsetNewline::ascii(Buffer const *, ostream & os, int) const +int InsetNewline::plaintext(Buffer const &, odocstream & os, + OutputParams const &) const { os << '\n'; return 0; } -int InsetNewline::linuxdoc(Buffer const *, std::ostream &) const -{ - /* FIXME */ - return 0; -} - - -int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const +int InsetNewline::docbook(Buffer const &, odocstream & os, + OutputParams const &) const { - /* FIXME */ + os << '\n'; return 0; } -void InsetNewline::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x) const +void InsetNewline::draw(PainterInfo & pi, int x, int y) const { - Painter & pain(bv->painter()); - - int const wid = font_metrics::width('n', font); - int const asc = font_metrics::maxAscent(font); - int const y = baseline; - - // hack, and highly dubious - lyx::pos_type pos = parOwner()->getPositionOfInset(this); - bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0); + frontend::FontMetrics const & fm = theFontMetrics(pi.base.font); + int const wid = fm.width('n'); + int const asc = fm.maxAscent(); int xp[3]; int yp[3]; @@ -94,7 +90,7 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font, yp[1] = int(y - 0.500 * asc * 0.75); yp[2] = int(y - 0.125 * asc * 0.75); - if (ltr_pos) { + if (pi.ltr_pos) { xp[0] = int(x + wid * 0.375); xp[1] = int(x); xp[2] = int(x + wid * 0.375); @@ -104,13 +100,13 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font, xp[2] = int(x + wid * 0.625); } - pain.lines(xp, yp, 3, LColor::eolmarker); + pi.pain.lines(xp, yp, 3, LColor::eolmarker); yp[0] = int(y - 0.500 * asc * 0.75); yp[1] = int(y - 0.500 * asc * 0.75); yp[2] = int(y - asc * 0.75); - if (ltr_pos) { + if (pi.ltr_pos) { xp[0] = int(x); xp[1] = int(x + wid); xp[2] = int(x + wid); @@ -120,7 +116,14 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font, xp[2] = int(x); } - pain.lines(xp, yp, 3, LColor::eolmarker); + pi.pain.lines(xp, yp, 3, LColor::eolmarker); +} + - x += wid; +bool InsetNewline::isSpace() const +{ + return true; } + + +} // namespace lyx