]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetpagebreak.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetpagebreak.C
index c15d0702735ba3334384e43e388f0975133d3683..3be10572cf9c11741a68dae83aa3af3cff103325 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * \file insetline.C
+ * \file insetpagebreak.C
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
 #include "insetpagebreak.h"
 
 #include "debug.h"
+#include "gettext.h"
 #include "LColor.h"
 #include "lyxtext.h"
 #include "metricsinfo.h"
-#include "gettext.h"
+#include "TextMetrics.h"
 
+#include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
-#include "frontends/font_metrics.h"
+
+
+namespace lyx {
+
+using frontend::Painter;
 
 using std::endl;
 using std::ostream;
@@ -33,25 +39,23 @@ void InsetPagebreak::read(Buffer const &, LyXLex &)
 
 void InsetPagebreak::write(Buffer const &, ostream & os) const
 {
-       os << "\n\\newpage \n";
+       os << "\n" << getCmdName() << '\n';
 }
 
 
-void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        dim.asc = defaultRowHeight();
        dim.des = defaultRowHeight();
        dim.wid = mi.base.textwidth;
+       bool const changed = dim_ != dim;
        dim_ = dim;
+       return changed;
 }
 
 
 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
 {
-       static std::string const label = _("Page Break");
-       pi.pain.line(x, y, x + dim_.wid, y, LColor::topline, Painter::line_solid,
-                       Painter::line_thick);
-
        LyXFont font;
        font.setColor(LColor::pagebreak);
        font.decSize();
@@ -59,12 +63,12 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
        int w = 0;
        int a = 0;
        int d = 0;
-       font_metrics::rectText(label, font, w, a, d);
+       theFontMetrics(font).rectText(insetLabel(), w, a, d);
 
        int const text_start = int(x + (dim_.wid - w) / 2);
        int const text_end = text_start + w;
 
-       pi.pain.rectText(text_start, y + d, label, font,
+       pi.pain.rectText(text_start, y + d, insetLabel(), font,
                LColor::none, LColor::none);
 
        pi.pain.line(x, y, text_start, y,
@@ -74,30 +78,28 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-int InsetPagebreak::latex(Buffer const &, ostream & os,
-                       LatexRunParams const &) const
+int InsetPagebreak::latex(Buffer const &, odocstream & os,
+                         OutputParams const &) const
 {
-       os << "\\newpage{}";
+       os << from_ascii(getCmdName()) << "{}";
        return 0;
 }
 
 
-int InsetPagebreak::ascii(Buffer const &, ostream & os, int) const
+int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
+                         OutputParams const &) const
 {
-       os << "-------------------------------------------";
+       os << '\n';
        return 0;
 }
 
 
-int InsetPagebreak::linuxdoc(Buffer const &, std::ostream & os) const
+int InsetPagebreak::docbook(Buffer const &, odocstream & os,
+                           OutputParams const &) const
 {
        os << '\n';
        return 0;
 }
 
 
-int InsetPagebreak::docbook(Buffer const &, std::ostream & os, bool) const
-{
-       os << '\n';
-       return 0;
-}
+} // namespace lyx