]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPagebreak.cpp
* Inset:
[lyx.git] / src / insets / InsetPagebreak.cpp
1 /**
2  * \file InsetPagebreak.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetPagebreak.h"
14
15 #include "debug.h"
16 #include "gettext.h"
17 #include "Color.h"
18 #include "Text.h"
19 #include "MetricsInfo.h"
20 #include "OutputParams.h"
21 #include "TextMetrics.h"
22
23 #include "frontends/FontMetrics.h"
24 #include "frontends/Painter.h"
25
26
27 namespace lyx {
28
29 using frontend::Painter;
30
31
32 void InsetPagebreak::read(Buffer const &, Lexer &)
33 {
34         /* Nothing to read */
35 }
36
37
38 void InsetPagebreak::write(Buffer const &, std::ostream & os) const
39 {
40         os << "\n" << getCmdName() << '\n';
41 }
42
43
44 void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         dim.asc = defaultRowHeight();
47         dim.des = defaultRowHeight();
48         dim.wid = mi.base.textwidth;
49 }
50
51
52 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
53 {
54         Font font;
55         font.setColor(Color::pagebreak);
56         font.decSize();
57
58         int w = 0;
59         int a = 0;
60         int d = 0;
61         theFontMetrics(font).rectText(insetLabel(), w, a, d);
62
63         int const text_start = int(x + (pi.base.textwidth - w) / 2);
64         int const text_end = text_start + w;
65
66         pi.pain.rectText(text_start, y + d, insetLabel(), font,
67                 Color::none, Color::none);
68
69         pi.pain.line(x, y, text_start, y,
70                    Color::pagebreak, Painter::line_onoffdash);
71         pi.pain.line(text_end, y, int(x + pi.base.textwidth), y,
72                    Color::pagebreak, Painter::line_onoffdash);
73 }
74
75
76 int InsetPagebreak::latex(Buffer const &, odocstream & os,
77                           OutputParams const &) const
78 {
79         os << from_ascii(getCmdName()) << "{}";
80         return 0;
81 }
82
83
84 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
85                               OutputParams const &) const
86 {
87         os << '\n';
88         return PLAINTEXT_NEWLINE;
89 }
90
91
92 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
93                             OutputParams const &) const
94 {
95         os << '\n';
96         return 0;
97 }
98
99
100 } // namespace lyx