]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSubstack.C
This commit cleans up everything related to singleton. The other important change...
[lyx.git] / src / mathed / InsetMathSubstack.C
1 /**
2  * \file InsetMathSubstack.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 "InsetMathSubstack.h"
15 #include "MathData.h"
16 #include "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 InsetMathSubstack::InsetMathSubstack()
33         : InsetMathGrid(1, 1)
34 {}
35
36
37 auto_ptr<InsetBase> InsetMathSubstack::doClone() const
38 {
39         return auto_ptr<InsetBase>(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         dim_ = dim;
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(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                                 lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")), lyx::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(std::ostream & 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 }