2 * \file InsetMathCommand.C
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 "InsetMathCommand.h"
15 #include "MathMLStream.h"
16 #include "dispatchresult.h"
17 #include "funcrequest.h"
25 using std::ostringstream;
28 CommandInset::CommandInset(string const & name)
29 : InsetMathNest(2), name_(name), set_label_(false)
35 auto_ptr<InsetBase> CommandInset::doClone() const
37 return auto_ptr<InsetBase>(new CommandInset(*this));
41 void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
45 button_.update(screenLabel(), true);
47 button_.metrics(mi, dim);
52 InsetBase * CommandInset::editXY(LCursor & cur, int /*x*/, int /*y*/)
59 void CommandInset::draw(PainterInfo & pi, int x, int y) const
61 button_.draw(pi, x, y);
62 setPosCache(pi, x, y);
66 void CommandInset::write(WriteStream & os) const
68 os << '\\' << name_.c_str();
70 os << '[' << cell(1) << ']';
71 os << '{' << cell(0) << '}';
75 docstring const CommandInset::screenLabel() const
77 return lyx::from_ascii(name_);
81 string const CommandInset::createDialogStr(string const & name) const
84 os << name << " LatexCommand ";
87 ws << "\n\\end_inset\n\n";