]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPagebreak.cpp
Make listings dialog translatable (mostly strings from InsetListingsParams), fix...
[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 using std::endl;
32 using std::ostream;
33
34
35 void InsetPagebreak::read(Buffer const &, Lexer &)
36 {
37         /* Nothing to read */
38 }
39
40
41 void InsetPagebreak::write(Buffer const &, ostream & os) const
42 {
43         os << "\n" << getCmdName() << '\n';
44 }
45
46
47 bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         dim.asc = defaultRowHeight();
50         dim.des = defaultRowHeight();
51         dim.wid = mi.base.textwidth;
52         bool const changed = dim_ != dim;
53         dim_ = dim;
54         return changed;
55 }
56
57
58 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
59 {
60         Font font;
61         font.setColor(Color::pagebreak);
62         font.decSize();
63
64         int w = 0;
65         int a = 0;
66         int d = 0;
67         theFontMetrics(font).rectText(insetLabel(), w, a, d);
68
69         int const text_start = int(x + (dim_.wid - w) / 2);
70         int const text_end = text_start + w;
71
72         pi.pain.rectText(text_start, y + d, insetLabel(), font,
73                 Color::none, Color::none);
74
75         pi.pain.line(x, y, text_start, y,
76                    Color::pagebreak, Painter::line_onoffdash);
77         pi.pain.line(text_end, y, int(x + dim_.wid), y,
78                    Color::pagebreak, Painter::line_onoffdash);
79 }
80
81
82 int InsetPagebreak::latex(Buffer const &, odocstream & os,
83                           OutputParams const &) const
84 {
85         os << from_ascii(getCmdName()) << "{}";
86         return 0;
87 }
88
89
90 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
91                               OutputParams const &) const
92 {
93         os << '\n';
94         return PLAINTEXT_NEWLINE;
95 }
96
97
98 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
99                             OutputParams const &) const
100 {
101         os << '\n';
102         return 0;
103 }
104
105
106 } // namespace lyx