]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSubstack.cpp
433f7cca59cb65c633c5e97e04bcf20e65a20141
[lyx.git] / src / mathed / InsetMathSubstack.cpp
1 /**
2  * \file InsetMathSubstack.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 "InsetMathSubstack.h"
14
15 #include "LaTeXFeatures.h"
16 #include "MathData.h"
17 #include "MathStream.h"
18
19 #include "FuncRequest.h"
20 #include "FuncStatus.h"
21 #include "support/gettext.h"
22
23 #include "support/lstrings.h"
24
25 #include <ostream>
26
27 namespace lyx {
28
29 using support::bformat;
30
31 using std::string;
32
33 InsetMathSubstack::InsetMathSubstack()
34         : InsetMathGrid(1, 1)
35 {}
36
37
38 Inset * InsetMathSubstack::clone() const
39 {
40         return new InsetMathSubstack(*this);
41 }
42
43
44 void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         if (mi.base.style == LM_ST_DISPLAY) {
47                 StyleChanger dummy(mi.base, LM_ST_TEXT);
48                 InsetMathGrid::metrics(mi, dim);
49         } else {
50                 InsetMathGrid::metrics(mi, dim);
51         }
52 }
53
54
55 void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
56 {
57         InsetMathGrid::draw(pi, x + 1, y);
58 }
59
60
61 bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
62                 FuncStatus & flag) const
63 {
64         switch (cmd.action) {
65         case LFUN_TABULAR_FEATURE: {
66                 string const name = "substack";
67                 docstring const & s = cmd.argument();
68                 if (s == "add-vline-left" || s == "add-vline-right") {
69                         flag.message(bformat(
70                                 from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
71                                 from_utf8(name)));
72                         flag.enabled(false);
73                         return true;
74                 }
75                 return InsetMathGrid::getStatus(cur, cmd, flag);
76         }
77         default:
78                 return InsetMathGrid::getStatus(cur, cmd, flag);
79         }
80 }
81
82
83 void InsetMathSubstack::infoize(odocstream & os) const
84 {
85         os << "Substack ";
86 }
87
88
89 void InsetMathSubstack::write(WriteStream & os) const
90 {
91         os << "\\substack{";
92         InsetMathGrid::write(os);
93         os << "}\n";
94 }
95
96
97 void InsetMathSubstack::normalize(NormalStream & os) const
98 {
99         os << "[substack ";
100         InsetMathGrid::normalize(os);
101         os << ']';
102 }
103
104
105 void InsetMathSubstack::maple(MapleStream & os) const
106 {
107         os << "substack(";
108         InsetMathGrid::maple(os);
109         os << ')';
110 }
111
112
113 void InsetMathSubstack::validate(LaTeXFeatures & features) const
114 {
115         features.require("amsmath");
116         InsetMathGrid::validate(features);
117 }
118
119
120 } // namespace lyx