]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSubstack.cpp
more latin1..utf8 schanges. all of src/* should be utf8 now
[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 "InsetMathSubstack.h"
14
15 #include "LaTeXFeatures.h"
16 #include "MathData.h"
17 #include "MathStream.h"
18
19 #include "FuncRequest.h"
20 #include "FuncStatus.h"
21 #include "support/gettext.h"
22
23 #include "support/lstrings.h"
24
25 #include <ostream>
26
27 using namespace std;
28
29 namespace lyx {
30
31 using support::bformat;
32
33
34 InsetMathSubstack::InsetMathSubstack()
35         : InsetMathGrid(1, 1)
36 {}
37
38
39 Inset * InsetMathSubstack::clone() const
40 {
41         return 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 }
54
55
56 void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
57 {
58         InsetMathGrid::draw(pi, x + 1, y);
59 }
60
61
62 bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
63                 FuncStatus & flag) const
64 {
65         switch (cmd.action) {
66         case LFUN_TABULAR_FEATURE: {
67                 string const name = "substack";
68                 docstring const & s = cmd.argument();
69                 if (s == "add-vline-left" || s == "add-vline-right") {
70                         flag.message(bformat(
71                                 from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
72                                 from_utf8(name)));
73                         flag.setEnabled(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         MathEnsurer ensurer(os);
93         os << "\\substack{";
94         InsetMathGrid::write(os);
95         os << "}\n";
96 }
97
98
99 void InsetMathSubstack::normalize(NormalStream & os) const
100 {
101         os << "[substack ";
102         InsetMathGrid::normalize(os);
103         os << ']';
104 }
105
106
107 void InsetMathSubstack::maple(MapleStream & os) const
108 {
109         os << "substack(";
110         InsetMathGrid::maple(os);
111         os << ')';
112 }
113
114
115 void InsetMathSubstack::validate(LaTeXFeatures & features) const
116 {
117         features.require("amsmath");
118         InsetMathGrid::validate(features);
119 }
120
121
122 } // namespace lyx