X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetnewline.C;h=302dda77690d1ddf2c260625c51bbd11e48653de;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=cdea8f9d5b8249a3402be6aa584c60a45888aa6a;hpb=3b9620ae6ddbda098402d3169b465f529455217e;p=lyx.git diff --git a/src/insets/insetnewline.C b/src/insets/insetnewline.C index cdea8f9d5b..302dda7769 100644 --- a/src/insets/insetnewline.C +++ b/src/insets/insetnewline.C @@ -5,100 +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 "BufferView.h" -#include "paragraph.h" -#include "lyxtext.h" #include "insetnewline.h" -#include "support/LOstream.h" -#include "frontends/Painter.h" -#include "frontends/font_metrics.h" #include "debug.h" +#include "LColor.h" +#include "lyxtext.h" +#include "metricsinfo.h" +#include "paragraph.h" +#include "paragraph_funcs.h" -using std::ostream; -using std::endl; - -InsetNewline::InsetNewline() - : Inset() -{} - +#include "frontends/FontMetrics.h" +#include "frontends/Painter.h" -void InsetNewline::read(Buffer const *, LyXLex &) -{ - /* Nothing to read */ -} +namespace lyx { -void InsetNewline::write(Buffer const *, ostream & os) const -{ - os << "\n\\newline \n"; -} +using std::endl; +using std::ostream; -int InsetNewline::ascent(BufferView *, LyXFont const & font) const +void InsetNewline::read(Buffer const &, LyXLex &) { - return font_metrics::maxAscent(font); + /* Nothing to read */ } -int InsetNewline::descent(BufferView *, LyXFont const & font) const +void InsetNewline::write(Buffer const &, ostream & os) const { - return font_metrics::maxDescent(font); + os << "\n\\newline\n"; } -int InsetNewline::width(BufferView *, LyXFont const & font) const +bool InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const { - return 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]; @@ -107,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); @@ -117,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); @@ -133,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