]> git.lyx.org Git - lyx.git/blob - src/insets/InsetHFill.cpp
* Inset: Prepare for an eventual merge of updateLabels() and addToToc()
[lyx.git] / src / insets / InsetHFill.cpp
1 /**
2  * \file InsetHFill.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 "InsetHFill.h"
14
15 #include "MetricsInfo.h"
16
17 #include "frontends/Painter.h"
18
19 #include "support/gettext.h"
20
21 #include <ostream>
22
23 using namespace std;
24
25 namespace lyx {
26
27
28 InsetHFill::InsetHFill()
29         : InsetCommand(InsetCommandParams(HFILL_CODE), string())
30 {}
31
32
33 CommandInfo const * InsetHFill::findInfo(string const & /* cmdName */)
34 {
35         static const char * const paramnames[] = {""};
36         static const CommandInfo info = {0, paramnames, 0};
37         return &info;
38 }
39
40
41 Inset * InsetHFill::clone() const
42 {
43         return new InsetHFill;
44 }
45
46
47 void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
48 {
49         // The metrics for this inset are calculated externally in
50         // \c TextMetrics::computeRowMetrics. Those are dummy value:
51         dim = Dimension(10, 10, 10);
52 }
53
54
55 void InsetHFill::draw(PainterInfo & pi, int x, int y) const
56 {
57         Dimension const dim = Inset::dimension(*pi.base.bv);
58         int const x0 = x + 1;
59         int const x1 = x + dim.wid - 2;
60         int const y0 = y + dim.des - 1;
61         int const y1 = y - dim.asc + 1;
62
63         pi.pain.line(x0, y1, x0, y0, Color_added_space);
64         pi.pain.line(x0, y, x1, y, Color_added_space,
65                 frontend::Painter::line_onoffdash);
66         pi.pain.line(x1, y1, x1, y0, Color_added_space);
67 }
68
69
70 docstring const InsetHFill::getScreenLabel(Buffer const &) const
71 {
72         return _("Horizontal Fill");
73 }
74
75
76 int InsetHFill::plaintext(Buffer const &, odocstream & os,
77                           OutputParams const &) const
78 {
79         os << "     ";
80         return 5;
81 }
82
83
84 int InsetHFill::docbook(Buffer const &, odocstream & os,
85                         OutputParams const &) const
86 {
87         os << '\n';
88         return 0;
89 }
90
91
92 void InsetHFill::write(Buffer const &, ostream & os) const
93 {
94         os << "\n\\hfill\n";
95 }
96
97
98 bool InsetHFill::isSpace() const
99 {
100         return true;
101 }
102
103
104 } // namespace lyx