2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 16:11:45 +00:00
|
|
|
|
* \file CommandInset.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.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 16:11:45 +00:00
|
|
|
|
#include "CommandInset.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"
|
|
|
|
|
#include "FuncRequest.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
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
CommandInset::CommandInset(docstring const & name)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathNest(2), name_(name), set_label_(false)
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
lock_ = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * CommandInset::clone() const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
|
return new CommandInset(*this);
|
2002-06-24 15:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-06-12 08:52:36 +00:00
|
|
|
|
{
|
|
|
|
|
if (!set_label_) {
|
|
|
|
|
set_label_ = true;
|
|
|
|
|
button_.update(screenLabel(), true);
|
|
|
|
|
}
|
|
|
|
|
button_.metrics(mi, dim);
|
2007-09-23 22:39:49 +00:00
|
|
|
|
// Cache the inset dimension.
|
|
|
|
|
setDimCache(mi, dim);
|
2003-06-12 08:52:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * CommandInset::editXY(Cursor & cur, int /*x*/, int /*y*/)
|
2005-11-22 13:52:25 +00:00
|
|
|
|
{
|
|
|
|
|
edit(cur, true);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
void CommandInset::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
button_.draw(pi, x, y);
|
2004-04-07 16:54:15 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
2003-06-12 08:52:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
|
2002-06-24 15:51:35 +00:00
|
|
|
|
void CommandInset::write(WriteStream & os) const
|
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '\\' << name_.c_str();
|
2002-06-24 15:51:35 +00:00
|
|
|
|
if (cell(1).size())
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << cell(1) << ']';
|
|
|
|
|
os << '{' << cell(0) << '}';
|
2002-06-24 15:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const CommandInset::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
|