]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetPagebreak.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetPagebreak.cpp
index 0a45f394b3ce431e8135d021e92860253099fc84..0ee79aa6c2bc611b2d4ff701d415ef73b7ff56d7 100644 (file)
@@ -14,8 +14,8 @@
 
 #include "debug.h"
 #include "gettext.h"
-#include "LColor.h"
-#include "LyXText.h"
+#include "Color.h"
+#include "Text.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
 #include "TextMetrics.h"
@@ -28,59 +28,57 @@ namespace lyx {
 
 using frontend::Painter;
 
-using std::endl;
-using std::ostream;
 
-
-void InsetPagebreak::read(Buffer const &, LyXLex &)
+void InsetPagebreak::read(Buffer const &, Lexer &)
 {
        /* Nothing to read */
 }
 
 
-void InsetPagebreak::write(Buffer const &, ostream & os) const
+void InsetPagebreak::write(Buffer const &, std::ostream & os) const
 {
        os << "\n" << getCmdName() << '\n';
 }
 
 
-bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
+void 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;
+       // Cache the inset dimension. 
+       setDimCache(mi, dim);
 }
 
 
 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
 {
-       LyXFont font;
-       font.setColor(LColor::pagebreak);
+       Font font;
+       font.setColor(Color::pagebreak);
        font.decSize();
 
+       Dimension const dim = dimension(*pi.base.bv);
+
        int w = 0;
        int a = 0;
        int d = 0;
        theFontMetrics(font).rectText(insetLabel(), w, a, d);
 
-       int const text_start = int(x + (dim_.wid - w) / 2);
+       int const text_start = int(x + (dim.wid - w) / 2);
        int const text_end = text_start + w;
 
        pi.pain.rectText(text_start, y + d, insetLabel(), font,
-               LColor::none, LColor::none);
+               Color::none, Color::none);
 
        pi.pain.line(x, y, text_start, y,
-                  LColor::pagebreak, Painter::line_onoffdash);
-       pi.pain.line(text_end, y, int(x + dim_.wid), y,
-                  LColor::pagebreak, Painter::line_onoffdash);
+                  Color::pagebreak, Painter::line_onoffdash);
+       pi.pain.line(text_end, y, int(x + dim.wid), y,
+                  Color::pagebreak, Painter::line_onoffdash);
 }
 
 
 int InsetPagebreak::latex(Buffer const &, odocstream & os,
-                          OutputParams const &) const
+                         OutputParams const &) const
 {
        os << from_ascii(getCmdName()) << "{}";
        return 0;
@@ -88,7 +86,7 @@ int InsetPagebreak::latex(Buffer const &, odocstream & os,
 
 
 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
-                              OutputParams const &) const
+                             OutputParams const &) const
 {
        os << '\n';
        return PLAINTEXT_NEWLINE;
@@ -96,7 +94,7 @@ int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
 
 
 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
-                            OutputParams const &) const
+                           OutputParams const &) const
 {
        os << '\n';
        return 0;