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"
16 #include "FuncRequest.h"
17 #include "FuncStatus.h"
18 #include "support/gettext.h"
19 #include "LaTeXFeatures.h"
21 #include "MathStream.h"
22 #include "MathSupport.h"
23 #include "MetricsInfo.h"
25 #include "support/lstrings.h"
33 using support::bformat;
36 InsetMathCases::InsetMathCases(row_type n)
37 : InsetMathGrid(2, n, 'c', from_ascii("ll"))
41 Inset * InsetMathCases::clone() const
43 return new InsetMathCases(*this);
47 void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
49 InsetMathGrid::metrics(mi, dim);
54 Dimension const InsetMathCases::dimension(BufferView const & bv) const
56 Dimension dim = InsetMathGrid::dimension(bv);
62 void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
64 Dimension const dim = dimension(*pi.base.bv);
65 mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
66 InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
67 setPosCache(pi, x, y);
71 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
73 //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
75 case LFUN_TABULAR_FEATURE: {
77 docstring const & s = cmd.argument();
78 if (s == "add-vline-left" || s == "add-vline-right") {
84 InsetMathGrid::doDispatch(cur, cmd);
89 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
90 FuncStatus & flag) const
93 case LFUN_TABULAR_FEATURE: {
94 docstring const & s = cmd.argument();
95 if (s == "add-vline-left" || s == "add-vline-right") {
98 from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
104 return InsetMathGrid::getStatus(cur, cmd, flag);
109 void InsetMathCases::write(WriteStream & os) const
113 os << "\\begin{cases}\n";
114 InsetMathGrid::write(os);
117 os << "\\end{cases}";
121 void InsetMathCases::normalize(NormalStream & os) const
124 InsetMathGrid::normalize(os);
129 void InsetMathCases::maple(MapleStream & os) const
132 InsetMathGrid::maple(os);
137 void InsetMathCases::infoize(odocstream & os) const
143 void InsetMathCases::validate(LaTeXFeatures & features) const
145 features.require("amsmath");
146 InsetMathGrid::validate(features);