]> git.lyx.org Git - lyx.git/blob - src/insets/insetpagebreak.C
* src/insets/insetpagebreak.C:
[lyx.git] / src / insets / insetpagebreak.C
1 /**
2  * \file insetpagebreak.C
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 "LColor.h"
17 #include "lyxtext.h"
18 #include "metricsinfo.h"
19 #include "gettext.h"
20
21 #include "frontends/FontMetrics.h"
22 #include "frontends/Painter.h"
23
24
25 namespace lyx {
26
27 using frontend::Painter;
28
29 using std::endl;
30 using std::ostream;
31
32
33 void InsetPagebreak::read(Buffer const &, LyXLex &)
34 {
35         /* Nothing to read */
36 }
37
38
39 void InsetPagebreak::write(Buffer const &, ostream & os) const
40 {
41         os << "\n" << getCmdName() << '\n';
42 }
43
44
45 void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         dim.asc = defaultRowHeight();
48         dim.des = defaultRowHeight();
49         dim.wid = mi.base.textwidth;
50         dim_ = dim;
51 }
52
53
54 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
55 {
56         LyXFont font;
57         font.setColor(LColor::pagebreak);
58         font.decSize();
59
60         int w = 0;
61         int a = 0;
62         int d = 0;
63         theFontMetrics(font).rectText(insetLabel(), w, a, d);
64
65         int const text_start = int(x + (dim_.wid - w) / 2);
66         int const text_end = text_start + w;
67
68         pi.pain.rectText(text_start, y + d, insetLabel(), font,
69                 LColor::none, LColor::none);
70
71         pi.pain.line(x, y, text_start, y,
72                    LColor::pagebreak, Painter::line_onoffdash);
73         pi.pain.line(text_end, y, int(x + dim_.wid), y,
74                    LColor::pagebreak, Painter::line_onoffdash);
75 }
76
77
78 int InsetPagebreak::latex(Buffer const &, odocstream & os,
79                           OutputParams const &) const
80 {
81         os << from_ascii(getCmdName()) << "{}";
82         return 0;
83 }
84
85
86 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
87                           OutputParams const &) const
88 {
89         os << '\n';
90         return 0;
91 }
92
93
94 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
95                             OutputParams const &) const
96 {
97         os << '\n';
98         return 0;
99 }
100
101
102 } // namespace lyx