]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnewline.C
Enable the external inset to handle unknown templates gracefully.
[lyx.git] / src / insets / insetnewline.C
index df8f82bd4779942a8e3dd3890f5480ca26425d15..d3cc33a0dba3c719c7eca59f5682c16d1838cc2d 100644 (file)
 
 #include <config.h>
 
+#include "insetnewline.h"
 
 #include "BufferView.h"
+#include "debug.h"
+#include "dimension.h"
 #include "paragraph.h"
 #include "lyxtext.h"
-#include "insetnewline.h"
+#include "metricsinfo.h"
 #include "support/LOstream.h"
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
 
-#include "debug.h"
-
 using std::ostream;
 using std::endl;
 
-InsetNewline::InsetNewline()
-       : Inset()
-{}
-
 
 void InsetNewline::read(Buffer const *, LyXLex &)
 {
@@ -41,25 +38,17 @@ void InsetNewline::write(Buffer const *, ostream & os) const
 }
 
 
-int InsetNewline::ascent(BufferView *, LyXFont const & font) const
-{
-       return font_metrics::maxAscent(font);
-}
-
-
-int InsetNewline::descent(BufferView *, LyXFont const & font) const
-{
-       return font_metrics::maxDescent(font);
-}
-
-
-int InsetNewline::width(BufferView *, LyXFont const & font) const
+void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       return font_metrics::width('n', font);
+       LyXFont & font = mi.base.font;
+       dim.asc = font_metrics::maxAscent(font);
+       dim.des = font_metrics::maxDescent(font);
+       dim.wid = font_metrics::width('n', font);
 }
 
 
-int InsetNewline::latex(Buffer const *, ostream &, bool, bool) const
+int InsetNewline::latex(Buffer const *, ostream &,
+                       LatexRunParams const &) const
 {
        lyxerr << "Eek, calling InsetNewline::latex !" << endl;
        return 0;
@@ -73,32 +62,28 @@ int InsetNewline::ascii(Buffer const *, ostream & os, int) const
 }
 
 
-int InsetNewline::linuxdoc(Buffer const *, std::ostream &) const
+int InsetNewline::linuxdoc(Buffer const *, std::ostream & os) const
 {
-       /* FIXME */
+       os << '\n';
        return 0;
 }
 
 
-int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
+int InsetNewline::docbook(Buffer const *, std::ostream & os, bool) const
 {
-       /* FIXME */
+       os << '\n';
        return 0;
 }
 
 
-void InsetNewline::draw(BufferView * bv, LyXFont const & font,
-                       int baseline, float & x, bool) 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;
+       int const wid = font_metrics::width('n', pi.base.font);
+       int const asc = font_metrics::maxAscent(pi.base.font);
 
        // hack, and highly dubious
        lyx::pos_type pos = parOwner()->getPositionOfInset(this);
-       bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0);
+       bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
 
        int xp[3];
        int yp[3];
@@ -117,7 +102,7 @@ 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);
@@ -133,7 +118,5 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
                xp[2] = int(x);
        }
 
-       pain.lines(xp, yp, 3, LColor::eolmarker);
-
-       x += wid;
+       pi.pain.lines(xp, yp, 3, LColor::eolmarker);
 }