]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLine.cpp
Move the StartTag, EndTag, and CompTag classes into the html namespace.
[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 "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19 #include "OutputParams.h"
20 #include "output_xhtml.h"
21 #include "Text.h"
22
23 #include "frontends/Painter.h"
24
25 #include "support/debug.h"
26 #include "support/docstream.h"
27
28
29
30 using namespace std;
31
32 namespace lyx {
33
34 using frontend::Painter;
35
36
37 void InsetLine::read(Lexer &)
38 {
39         /* Nothing to read */
40 }
41
42
43 void InsetLine::write(ostream & os) const
44 {
45         os << "\n\\lyxline\n";
46 }
47
48
49 void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51         dim.asc = 3;
52         dim.des = 3;
53         dim.wid = mi.base.textwidth;
54         // Cache the inset dimension. 
55         setDimCache(mi, dim);
56 }
57
58
59 void InsetLine::draw(PainterInfo & pi, int x, int y) const
60 {
61         Dimension const dim = dimension(*pi.base.bv);
62         pi.pain.line(x, y, x + dim.wid, y, Color_topline,
63                 Painter::line_solid, Painter::line_thick);
64 }
65
66
67 int InsetLine::latex(odocstream & os, 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(odocstream & os, OutputParams const &) const
76 {
77         os << "\n-------------------------------------------\n";
78         return PLAINTEXT_NEWLINE;
79 }
80
81
82 int InsetLine::docbook(odocstream & os, OutputParams const &) const
83 {
84         os << '\n';
85         return 0;
86 }
87
88
89 docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
90 {
91         xs << html::CompTag("hr");
92         xs.cr();
93         return docstring();
94 }
95
96
97 void InsetLine::validate(LaTeXFeatures & features) const
98 {
99         features.require("lyxline");
100 }
101
102
103 } // namespace lyx