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