]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLine.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetLine.cpp
1 /**
2  * \file InsetLine.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 "InsetLine.h"
14
15 #include "Dimension.h"
16 #include "Font.h"
17 #include "MetricsInfo.h"
18 #include "LaTeXFeatures.h"
19 #include "OutputParams.h"
20 #include "Text.h"
21
22 #include "frontends/Painter.h"
23
24 #include "support/debug.h"
25 #include "support/docstream.h"
26
27
28
29 using namespace std;
30
31 namespace lyx {
32
33 using frontend::Painter;
34
35
36 void InsetLine::read(Buffer const &, Lexer &)
37 {
38         /* Nothing to read */
39 }
40
41
42 void InsetLine::write(Buffer const &, ostream & os) const
43 {
44         os << "\n\\lyxline\n";
45 }
46
47
48 void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
49 {
50         dim.asc = 3;
51         dim.des = 3;
52         dim.wid = mi.base.textwidth;
53         // Cache the inset dimension. 
54         setDimCache(mi, dim);
55 }
56
57
58 void InsetLine::draw(PainterInfo & pi, int x, int y) const
59 {
60         Dimension const dim = dimension(*pi.base.bv);
61         pi.pain.line(x, y, x + dim.wid, y, Color_topline,
62                 Painter::line_solid, Painter::line_thick);
63 }
64
65
66 int InsetLine::latex(Buffer const &, odocstream & os,
67                      OutputParams const & runparams) const
68 {
69         os << "\\lyxline{\\"
70            << from_ascii(runparams.local_font->latexSize()) << '}';
71         return 0;
72 }
73
74
75 int InsetLine::plaintext(Buffer const &, odocstream & os,
76                          OutputParams const &) const
77 {
78         os << "\n-------------------------------------------\n";
79         return PLAINTEXT_NEWLINE;
80 }
81
82
83 int InsetLine::docbook(Buffer const &, odocstream & os,
84                        OutputParams const &) const
85 {
86         os << '\n';
87         return 0;
88 }
89
90
91 void InsetLine::validate(LaTeXFeatures & features) const
92 {
93         features.require("lyxline");
94 }
95
96
97 } // namespace lyx