]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPagebreak.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[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         // Cache the inset dimension. 
50         setDimCache(mi, dim);
51 }
52
53
54 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
55 {
56         Font font;
57         font.setColor(Color::pagebreak);
58         font.decSize();
59
60         Dimension const dim = dimension(*pi.base.bv);
61
62         int w = 0;
63         int a = 0;
64         int d = 0;
65         theFontMetrics(font).rectText(insetLabel(), w, a, d);
66
67         int const text_start = int(x + (dim.wid - w) / 2);
68         int const text_end = text_start + w;
69
70         pi.pain.rectText(text_start, y + d, insetLabel(), font,
71                 Color::none, Color::none);
72
73         pi.pain.line(x, y, text_start, y,
74                    Color::pagebreak, Painter::line_onoffdash);
75         pi.pain.line(text_end, y, int(x + dim.wid), y,
76                    Color::pagebreak, Painter::line_onoffdash);
77 }
78
79
80 int InsetPagebreak::latex(Buffer const &, odocstream & os,
81                           OutputParams const &) const
82 {
83         os << from_ascii(getCmdName()) << "{}";
84         return 0;
85 }
86
87
88 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
89                               OutputParams const &) const
90 {
91         os << '\n';
92         return PLAINTEXT_NEWLINE;
93 }
94
95
96 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
97                             OutputParams const &) const
98 {
99         os << '\n';
100         return 0;
101 }
102
103
104 } // namespace lyx