-
#include "command_inset.h"
#include "math_mathmlstream.h"
#include "funcrequest.h"
+#include "Lsstream.h"
+
+using std::auto_ptr;
-CommandInset::CommandInset(string const & data)
+CommandInset::CommandInset(string const & name)
+ : MathNestInset(2),
+ name_(name),
+ set_label_(false)
{
lock_ = true;
+}
+
- string::size_type idx0 = data.find("|++|");
- name_ = data.substr(0, idx0);
- if (idx0 == string::npos)
- return;
- idx0 += 4;
- string::size_type idx1 = data.find("|++|", idx0);
- cell(0) = asArray(data.substr(idx0, idx1 - idx0));
- if (idx1 == string::npos)
- return;
- cell(1) = asArray(data.substr(idx1 + 4));
+auto_ptr<InsetBase> CommandInset::clone() const
+{
+ return auto_ptr<InsetBase>(new CommandInset(*this));
}
-MathInset * CommandInset::clone() const
+void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
- return new CommandInset(*this);
+ if (!set_label_) {
+ set_label_ = true;
+ button_.update(screenLabel(), true);
+ }
+ button_.metrics(mi, dim);
}
+void CommandInset::draw(PainterInfo & pi, int x, int y) const
+{
+ button_.draw(pi, x, y);
+}
+
dispatch_result
CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
default:
- return ButtonInset::dispatch(cmd, idx, pos);
+ return MathNestInset::dispatch(cmd, idx, pos);
}
return UNDISPATCHED;
}
}
-string CommandInset::screenLabel() const
+string const CommandInset::screenLabel() const
+{
+ return name_;
+}
+
+
+string const CommandInset::createDialogStr(string const & name) const
{
- return name_;
+ ostringstream data;
+ data << name << " LatexCommand ";
+ WriteStream wsdata(data);
+ write(wsdata);
+ wsdata << "\n\\end_inset\n\n";
+ return STRCONV(data.str());
}