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"
24 #include "support/lstrings.h"
29 using support::bformat;
34 InsetMathCases::InsetMathCases(row_type n)
35 : InsetMathGrid(2, n, 'c', from_ascii("ll"))
39 Inset * InsetMathCases::clone() const
41 return new InsetMathCases(*this);
45 void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
47 InsetMathGrid::metrics(mi, dim);
52 Dimension const InsetMathCases::dimension(BufferView const & bv) const
54 Dimension dim = InsetMathGrid::dimension(bv);
60 void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
62 Dimension const dim = dimension(*pi.base.bv);
63 mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
64 InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
65 setPosCache(pi, x, y);
69 void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
71 //lyxerr << "*** InsetMathCases: request: " << cmd << endl;
73 case LFUN_TABULAR_FEATURE: {
75 docstring const & s = cmd.argument();
76 if (s == "add-vline-left" || s == "add-vline-right") {
82 InsetMathGrid::doDispatch(cur, cmd);
87 bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
88 FuncStatus & flag) const
91 case LFUN_TABULAR_FEATURE: {
92 docstring const & s = cmd.argument();
93 if (s == "add-vline-left" || s == "add-vline-right") {
96 from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
102 return InsetMathGrid::getStatus(cur, cmd, flag);
107 void InsetMathCases::write(WriteStream & os) const
111 os << "\\begin{cases}\n";
112 InsetMathGrid::write(os);
115 os << "\\end{cases}";
119 void InsetMathCases::normalize(NormalStream & os) const
122 InsetMathGrid::normalize(os);
127 void InsetMathCases::maple(MapleStream & os) const
130 InsetMathGrid::maple(os);
135 void InsetMathCases::infoize(odocstream & os) const
141 void InsetMathCases::validate(LaTeXFeatures & features) const
143 features.require("amsmath");
144 InsetMathGrid::validate(features);