X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathCommand.cpp;h=deac6c3711e4fa193dce8279d12295b621a5c519;hb=9296344b9a26191a2092d175a51e357ecc35145d;hp=23de2c5d527359e17412a8d5a8bfad31de666d80;hpb=6e3a75969b97a5db4c80c46be49d4deb122abfe7;p=lyx.git diff --git a/src/mathed/InsetMathCommand.cpp b/src/mathed/InsetMathCommand.cpp index 23de2c5d52..deac6c3711 100644 --- a/src/mathed/InsetMathCommand.cpp +++ b/src/mathed/InsetMathCommand.cpp @@ -1,80 +1,76 @@ /** - * \file CommandInset.cpp + * \file InsetMathCommand.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ #include -#include "CommandInset.h" -#include "MathArray.h" +#include "InsetMathCommand.h" +#include "MathData.h" #include "MathStream.h" -#include "dispatchresult.h" -#include "funcrequest.h" +#include "DispatchResult.h" #include +using namespace std; namespace lyx { -using std::auto_ptr; -using std::string; -CommandInset::CommandInset(docstring const & name) - : InsetMathNest(2), name_(name), set_label_(false) +InsetMathCommand::InsetMathCommand(Buffer * buf, docstring const & name, bool needs_math_mode) + : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode), + set_label_(false) { lock_ = true; } -auto_ptr CommandInset::doClone() const +Inset * InsetMathCommand::clone() const { - return auto_ptr(new CommandInset(*this)); + return new InsetMathCommand(*this); } -bool CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathCommand::metrics(MetricsInfo & mi, Dimension & dim) const { if (!set_label_) { set_label_ = true; - button_.update(screenLabel(), true); + button_.update(screenLabel(), true, false); } button_.metrics(mi, dim); - if (dim_ == dim) - return false; - dim_ = dim; - return true; } -InsetBase * CommandInset::editXY(LCursor & cur, int /*x*/, int /*y*/) +Inset * InsetMathCommand::editXY(Cursor & cur, int /*x*/, int /*y*/) { edit(cur, true); return this; } -void CommandInset::draw(PainterInfo & pi, int x, int y) const +void InsetMathCommand::draw(PainterInfo & pi, int x, int y) const { button_.draw(pi, x, y); - setPosCache(pi, x, y); } -void CommandInset::write(WriteStream & os) const +void InsetMathCommand::write(WriteStream & os) const { - os << '\\' << name_.c_str(); - if (cell(1).size()) + ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly()); + MathEnsurer ensurer(os, needs_math_mode_); + os << '\\' << name_; + if (!cell(1).empty()) os << '[' << cell(1) << ']'; os << '{' << cell(0) << '}'; } -docstring const CommandInset::screenLabel() const +docstring const InsetMathCommand::screenLabel() const { return name_; }