2 * \file CommandInset.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 "CommandInset.h"
15 #include "MathStream.h"
16 #include "DispatchResult.h"
25 CommandInset::CommandInset(Buffer * buf, docstring const & name, bool needs_math_mode)
26 : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode),
33 Inset * CommandInset::clone() const
35 return new CommandInset(*this);
39 void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
43 button_.update(screenLabel(), true);
45 button_.metrics(mi, dim);
46 // Cache the inset dimension.
51 Inset * CommandInset::editXY(Cursor & cur, int /*x*/, int /*y*/)
58 void CommandInset::draw(PainterInfo & pi, int x, int y) const
60 button_.draw(pi, x, y);
61 setPosCache(pi, x, y);
65 void CommandInset::write(WriteStream & os) const
67 ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
68 MathEnsurer ensurer(os, needs_math_mode_);
71 os << '[' << cell(1) << ']';
72 os << '{' << cell(0) << '}';
76 docstring const CommandInset::screenLabel() const