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"
19 #include "LaTeXFeatures.h"
21 #include "MathStream.h"
22 #include "MathSupport.h"
23 #include "MetricsInfo.h"
25 #include "support/lstrings.h"
32 using support::bformat;
37 InsetMathCases::InsetMathCases(row_type n)
38 : InsetMathGrid(2, n, 'c', from_ascii("ll"))
42 Inset * InsetMathCases::clone() const
44 return new InsetMathCases(*this);
48 void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
50 InsetMathGrid::metrics(mi, dim);
55 Dimension const InsetMathCases::dimension(BufferView const & bv) const
57 Dimension dim = InsetMathGrid::dimension(bv);
63 void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
65 Dimension const dim = dimension(*pi.base.bv);
66 mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
67 InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
68 setPosCache(pi, x, y);
72 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
74 //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
76 case LFUN_TABULAR_FEATURE: {
78 docstring const & s = cmd.argument();
79 if (s == "add-vline-left" || s == "add-vline-right") {
85 InsetMathGrid::doDispatch(cur, cmd);
90 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
91 FuncStatus & flag) const
94 case LFUN_TABULAR_FEATURE: {
95 docstring const & s = cmd.argument();
96 if (s == "add-vline-left" || s == "add-vline-right") {
99 from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
105 return InsetMathGrid::getStatus(cur, cmd, flag);
110 void InsetMathCases::write(WriteStream & os) const
114 os << "\\begin{cases}\n";
115 InsetMathGrid::write(os);
118 os << "\\end{cases}";
122 void InsetMathCases::normalize(NormalStream & os) const
125 InsetMathGrid::normalize(os);
130 void InsetMathCases::maple(MapleStream & os) const
133 InsetMathGrid::maple(os);
138 void InsetMathCases::infoize(odocstream & os) const
144 void InsetMathCases::validate(LaTeXFeatures & features) const
146 features.require("amsmath");
147 InsetMathGrid::validate(features);