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);
54 void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
56 mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 6, dim_.height(), from_ascii("{"));
57 InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
58 setPosCache(pi, x, y);
62 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
64 //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
66 case LFUN_TABULAR_FEATURE: {
68 docstring const & s = cmd.argument();
69 if (s == "add-vline-left" || s == "add-vline-right") {
75 InsetMathGrid::doDispatch(cur, cmd);
80 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
81 FuncStatus & flag) const
84 case LFUN_TABULAR_FEATURE: {
85 docstring const & s = cmd.argument();
86 if (s == "add-vline-left" || s == "add-vline-right") {
89 from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
95 return InsetMathGrid::getStatus(cur, cmd, flag);
100 void InsetMathCases::write(WriteStream & os) const
104 os << "\\begin{cases}\n";
105 InsetMathGrid::write(os);
108 os << "\\end{cases}";
112 void InsetMathCases::normalize(NormalStream & os) const
115 InsetMathGrid::normalize(os);
120 void InsetMathCases::maple(MapleStream & os) const
123 InsetMathGrid::maple(os);
128 void InsetMathCases::infoize(odocstream & os) const
134 void InsetMathCases::validate(LaTeXFeatures & features) const
136 features.require("amsmath");
137 InsetMathGrid::validate(features);