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