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