]> git.lyx.org Git - lyx.git/blob - src/mathed/math_substackinset.C
Fix bug 2251 (from G Baum)
[lyx.git] / src / mathed / math_substackinset.C
1 /**
2  * \file math_substackinset.C
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 "math_substackinset.h"
15 #include "math_data.h"
16 #include "math_mathmlstream.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 using lyx::docstring;
27 using lyx::support::bformat;
28 using std::string;
29 using std::auto_ptr;
30
31
32 MathSubstackInset::MathSubstackInset()
33         : MathGridInset(1, 1)
34 {}
35
36
37 auto_ptr<InsetBase> MathSubstackInset::doClone() const
38 {
39         return auto_ptr<InsetBase>(new MathSubstackInset(*this));
40 }
41
42
43 void MathSubstackInset::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         if (mi.base.style == LM_ST_DISPLAY) {
46                 StyleChanger dummy(mi.base, LM_ST_TEXT);
47                 MathGridInset::metrics(mi, dim);
48         } else {
49                 MathGridInset::metrics(mi, dim);
50         }
51         dim_ = dim;
52 }
53
54
55 void MathSubstackInset::draw(PainterInfo & pi, int x, int y) const
56 {
57         MathGridInset::draw(pi, x + 1, y);
58 }
59
60
61 bool MathSubstackInset::getStatus(LCursor & 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                         N_("Can't add vertical grid lines in '%1$s'"), name));
71                         flag.enabled(false);
72                         return true;
73                 }
74                 return MathGridInset::getStatus(cur, cmd, flag);
75         }
76         default:
77                 return MathGridInset::getStatus(cur, cmd, flag);
78         }
79 }
80
81
82 void MathSubstackInset::infoize(std::ostream & os) const
83 {
84         os << "Substack ";
85 }
86
87
88 void MathSubstackInset::write(WriteStream & os) const
89 {
90         os << "\\substack{";
91         MathGridInset::write(os);
92         os << "}\n";
93 }
94
95
96 void MathSubstackInset::normalize(NormalStream & os) const
97 {
98         os << "[substack ";
99         MathGridInset::normalize(os);
100         os << ']';
101 }
102
103
104 void MathSubstackInset::maple(MapleStream & os) const
105 {
106         os << "substack(";
107         MathGridInset::maple(os);
108         os << ')';
109 }
110
111
112 void MathSubstackInset::validate(LaTeXFeatures & features) const
113 {
114         features.require("amsmath");
115         MathGridInset::validate(features);
116 }