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