* \author Angus Leeming
* \author Lars Gullik Bjønnes
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insetcommand.h"
+
#include "BufferView.h"
-#include "debug.h"
#include "funcrequest.h"
#include "lyxlex.h"
+#include "metricsinfo.h"
-#include "frontends/Painter.h"
-
-#include "support/lstrings.h"
+#include "support/std_sstream.h"
-#include "Lsstream.h"
+using std::string;
+using std::istringstream;
using std::ostream;
+using std::ostringstream;
InsetCommand::InsetCommand(InsetCommandParams const & p)
- : p_(p.getCmdName(), p.getContents(), p.getOptions())
+ : p_(p.getCmdName(), p.getContents(), p.getOptions()),
+ set_label_(false)
{}
-// InsetCommand::InsetCommand(InsetCommandParams const & p, bool)
-// : p_(p.getCmdName(), p.getContents(), p.getOptions())
-// {}
+void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ if (!set_label_) {
+ set_label_ = true;
+ button_.update(getScreenLabel(*mi.base.bv->buffer()),
+ editable() != NOT_EDITABLE);
+ }
+ button_.metrics(mi, dim);
+ dim_ = dim;
+}
+
+
+void InsetCommand::draw(PainterInfo & pi, int x, int y) const
+{
+ button_.draw(pi, x, y);
+}
void InsetCommand::setParams(InsetCommandParams const & p)
{
- p_.setCmdName(p.getCmdName());
- p_.setContents(p.getContents());
- p_.setOptions(p.getOptions());
+ p_ = p;
+ set_label_ = false;
}
-int InsetCommand::latex(Buffer const *, ostream & os,
+int InsetCommand::latex(Buffer const &, ostream & os,
LatexRunParams const &) const
{
os << getCommand();
}
-int InsetCommand::ascii(Buffer const *, ostream &, int) const
+int InsetCommand::ascii(Buffer const &, ostream &, int) const
{
return 0;
}
-int InsetCommand::linuxdoc(Buffer const *, ostream &) const
+int InsetCommand::linuxdoc(Buffer const &, ostream &) const
{
return 0;
}
-int InsetCommand::docbook(Buffer const *, ostream &, bool) const
+int InsetCommand::docbook(Buffer const &, ostream &, bool) const
{
return 0;
}
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
{
- lyxerr << "InsetCommand::localDispatch: " << cmd.action << "\n";
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
{}
-string const InsetCommandMailer::inset2string() const
+string const InsetCommandMailer::inset2string(Buffer const &) const
{
return params2string(name(), inset_.params());
}
void InsetCommandMailer::string2params(string const & in,
InsetCommandParams & params)
{
- params.setCmdName(string());
- params.setContents(string());
- params.setOptions(string());
+ params = InsetCommandParams();
if (in.empty())
return;
- istringstream data(STRCONV(in));
+ istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
data << name << ' ';
params.write(data);
data << "\\end_inset\n";
- return STRCONV(data.str());
+ return data.str();
}