]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSubstack.cpp
19021f2ce0c9138668e7062cbe8f62dc39c23e5e
[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 bool 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         if (dim_ == dim)
52                 return false;
53         dim_ = dim;
54         return true;
55 }
56
57
58 void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
59 {
60         InsetMathGrid::draw(pi, x + 1, y);
61 }
62
63
64 bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
65                 FuncStatus & flag) const
66 {
67         switch (cmd.action) {
68         case LFUN_TABULAR_FEATURE: {
69                 string const name = "substack";
70                 docstring const & s = cmd.argument();
71                 if (s == "add-vline-left" || s == "add-vline-right") {
72                         flag.message(bformat(
73                                 from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
74                                 from_utf8(name)));
75                         flag.enabled(false);
76                         return true;
77                 }
78                 return InsetMathGrid::getStatus(cur, cmd, flag);
79         }
80         default:
81                 return InsetMathGrid::getStatus(cur, cmd, flag);
82         }
83 }
84
85
86 void InsetMathSubstack::infoize(odocstream & os) const
87 {
88         os << "Substack ";
89 }
90
91
92 void InsetMathSubstack::write(WriteStream & os) const
93 {
94         os << "\\substack{";
95         InsetMathGrid::write(os);
96         os << "}\n";
97 }
98
99
100 void InsetMathSubstack::normalize(NormalStream & os) const
101 {
102         os << "[substack ";
103         InsetMathGrid::normalize(os);
104         os << ']';
105 }
106
107
108 void InsetMathSubstack::maple(MapleStream & os) const
109 {
110         os << "substack(";
111         InsetMathGrid::maple(os);
112         os << ')';
113 }
114
115
116 void InsetMathSubstack::validate(LaTeXFeatures & features) const
117 {
118         features.require("amsmath");
119         InsetMathGrid::validate(features);
120 }
121
122
123 } // namespace lyx