2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2017-07-05 12:31:28 +00:00
|
|
|
* \file InsetMathCommand.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
#include "InsetMathCommand.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
2002-06-24 15:51:35 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
InsetMathCommand::InsetMathCommand(Buffer * buf, docstring const & name, bool needs_math_mode)
|
2009-11-08 11:45:46 +00:00
|
|
|
: InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode),
|
2008-06-16 01:21:17 +00:00
|
|
|
set_label_(false)
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
|
|
|
lock_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
Inset * InsetMathCommand::clone() const
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
2017-07-05 12:31:28 +00:00
|
|
|
return new InsetMathCommand(*this);
|
2002-06-24 15:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
void InsetMathCommand::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-06-12 08:52:36 +00:00
|
|
|
{
|
|
|
|
if (!set_label_) {
|
|
|
|
set_label_ = true;
|
2017-05-24 09:28:08 +00:00
|
|
|
button_.update(screenLabel(), true, false);
|
2003-06-12 08:52:36 +00:00
|
|
|
}
|
|
|
|
button_.metrics(mi, dim);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
Inset * InsetMathCommand::editXY(Cursor & cur, int /*x*/, int /*y*/)
|
2005-11-22 13:52:25 +00:00
|
|
|
{
|
|
|
|
edit(cur, true);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
void InsetMathCommand::draw(PainterInfo & pi, int x, int y) const
|
2003-06-12 08:52:36 +00:00
|
|
|
{
|
|
|
|
button_.draw(pi, x, y);
|
|
|
|
}
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
2020-12-26 19:04:36 +00:00
|
|
|
void InsetMathCommand::write(TeXMathStream & os) const
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
2010-02-04 23:03:48 +00:00
|
|
|
ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
|
2008-06-17 11:10:43 +00:00
|
|
|
MathEnsurer ensurer(os, needs_math_mode_);
|
2010-02-04 19:08:17 +00:00
|
|
|
os << '\\' << name_;
|
2012-10-21 19:14:16 +00:00
|
|
|
if (!cell(1).empty())
|
2002-11-27 10:30:28 +00:00
|
|
|
os << '[' << cell(1) << ']';
|
|
|
|
os << '{' << cell(0) << '}';
|
2002-06-24 15:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
docstring const InsetMathCommand::screenLabel() const
|
2002-06-24 15:51:35 +00:00
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
return name_;
|
2002-06-24 15:51:35 +00:00
|
|
|
}
|
2003-03-04 16:39:13 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|