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