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