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"
17 #include "FuncRequest.h"
26 CommandInset::CommandInset(Buffer
* buf
, docstring
const & name
, bool needs_math_mode
)
27 : InsetMathNest(buf
, 2), name_(name
), needs_math_mode_(needs_math_mode
),
34 Inset
* CommandInset::clone() const
36 return new CommandInset(*this);
40 void CommandInset::metrics(MetricsInfo
& mi
, Dimension
& dim
) const
44 button_
.update(screenLabel(), true);
46 button_
.metrics(mi
, dim
);
47 // Cache the inset dimension.
52 Inset
* CommandInset::editXY(Cursor
& 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 MathEnsurer
ensurer(os
, needs_math_mode_
);
69 os
<< '\\' << name_
.c_str();
71 os
<< '[' << cell(1) << ']';
72 os
<< '{' << cell(0) << '}';
76 docstring
const CommandInset::screenLabel() const