2 * \file InsetMathCases.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathCases.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "FuncStatus.h"
18 #include "LaTeXFeatures.h"
19 #include "support/std_ostream.h"
21 #include "FuncRequest.h"
25 #include "support/lstrings.h"
30 using support::bformat;
35 InsetMathCases::InsetMathCases(row_type n)
36 : InsetMathGrid(2, n, 'c', from_ascii("ll"))
40 Inset * InsetMathCases::clone() const
42 return new InsetMathCases(*this);
46 void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
48 InsetMathGrid::metrics(mi, dim);
53 Dimension const InsetMathCases::dimension(BufferView const & bv) const
55 Dimension dim = InsetMathGrid::dimension(bv);
61 void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
63 Dimension const dim = dimension(*pi.base.bv);
64 mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
65 InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
66 setPosCache(pi, x, y);
70 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
72 //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
74 case LFUN_TABULAR_FEATURE: {
76 docstring const & s = cmd.argument();
77 if (s == "add-vline-left" || s == "add-vline-right") {
83 InsetMathGrid::doDispatch(cur, cmd);
88 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
89 FuncStatus & flag) const
92 case LFUN_TABULAR_FEATURE: {
93 docstring const & s = cmd.argument();
94 if (s == "add-vline-left" || s == "add-vline-right") {
97 from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
103 return InsetMathGrid::getStatus(cur, cmd, flag);
108 void InsetMathCases::write(WriteStream & os) const
112 os << "\\begin{cases}\n";
113 InsetMathGrid::write(os);
116 os << "\\end{cases}";
120 void InsetMathCases::normalize(NormalStream & os) const
123 InsetMathGrid::normalize(os);
128 void InsetMathCases::maple(MapleStream & os) const
131 InsetMathGrid::maple(os);
136 void InsetMathCases::infoize(odocstream & os) const
142 void InsetMathCases::validate(LaTeXFeatures & features) const
144 features.require("amsmath");
145 InsetMathGrid::validate(features);