#include <config.h>
#include "InsetMathCases.h"
+
+#include "Cursor.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "support/gettext.h"
+#include "LaTeXFeatures.h"
#include "MathData.h"
#include "MathStream.h"
#include "MathSupport.h"
-#include "FuncStatus.h"
-#include "LaTeXFeatures.h"
-#include "support/std_ostream.h"
-#include "cursor.h"
-#include "funcrequest.h"
-#include "gettext.h"
-#include "undo.h"
+#include "MetricsInfo.h"
#include "support/lstrings.h"
+#include <ostream>
-namespace lyx {
-
-using support::bformat;
+using namespace std;
+using namespace lyx::support;
-using std::endl;
-using std::max;
-using std::min;
-using std::swap;
-using std::auto_ptr;
+namespace lyx {
InsetMathCases::InsetMathCases(row_type n)
{}
-auto_ptr<InsetBase> InsetMathCases::doClone() const
+Inset * InsetMathCases::clone() const
+{
+ return new InsetMathCases(*this);
+}
+
+
+void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
{
- return auto_ptr<InsetBase>(new InsetMathCases(*this));
+ InsetMathGrid::metrics(mi, dim);
+ dim.wid += 8;
}
-bool InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
+Dimension const InsetMathCases::dimension(BufferView const & bv) const
{
- dim = dim_;
- InsetMathGrid::metrics(mi);
- dim_.wid += 8;
-
- if (dim_ == dim)
- return false;
- dim = dim_;
- return true;
+ Dimension dim = InsetMathGrid::dimension(bv);
+ dim.wid += 8;
+ return dim;
}
void InsetMathCases::draw(PainterInfo & pi, int x, int y) const
{
- mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 6, dim_.height(), from_ascii("{"));
+ Dimension const dim = dimension(*pi.base.bv);
+ mathed_draw_deco(pi, x + 1, y - dim.ascent(), 6, dim.height(), from_ascii("{"));
InsetMathGrid::drawWithMargin(pi, x, y, 8, 0);
setPosCache(pi, x, y);
}
-void InsetMathCases::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetMathCases::doDispatch(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "*** InsetMathCases: request: " << cmd << endl;
switch (cmd.action) {
case LFUN_TABULAR_FEATURE: {
- recordUndo(cur);
+ cur.recordUndo();
docstring const & s = cmd.argument();
if (s == "add-vline-left" || s == "add-vline-right") {
cur.undispatched();
}
-bool InsetMathCases::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetMathCases::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
switch (cmd.action) {
if (s == "add-vline-left" || s == "add-vline-right") {
flag.enabled(false);
flag.message(bformat(
- from_utf8(N_("No vertical grid lines in '%1$s'")),
+ from_utf8(N_("No vertical grid lines in 'cases': feature %1$s")),
s));
return true;
}