]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCommand.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetCommand.cpp
index 1cd38b469a67d160e9f4c103b90629bb8f1d9fa2..f50d33c124e6d1ed806fb36482a58fc782c5fbec 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "InsetCommand.h"
 
+#include "Buffer.h"
 #include "BufferView.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
@@ -28,7 +29,6 @@ namespace lyx {
 
 using std::string;
 using std::istringstream;
-using std::ostream;
 using std::ostringstream;
 
 
@@ -48,17 +48,14 @@ InsetCommand::~InsetCommand()
 }
 
 
-bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (updateButtonLabel_) {
                updateButtonLabel_ = false;
-               button_.update(getScreenLabel(*mi.base.bv->buffer()),
+               button_.update(getScreenLabel(mi.base.bv->buffer()),
                               editable() != NOT_EDITABLE);
        }
        button_.metrics(mi, dim);
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
 }
 
 
@@ -71,7 +68,6 @@ bool InsetCommand::setMouseHover(bool mouse_hover)
 
 void InsetCommand::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
        button_.setRenderState(mouse_hover_);
        button_.draw(pi, x, y);
 }
@@ -85,24 +81,24 @@ void InsetCommand::setParams(InsetCommandParams const & p)
 
 
 int InsetCommand::latex(Buffer const &, odocstream & os,
-                        OutputParams const &) const
+                       OutputParams const &) const
 {
        os << getCommand();
        return 0;
 }
 
 
-int InsetCommand::plaintext(Buffer const &, odocstream & os,
-                            OutputParams const &) const
+int InsetCommand::plaintext(Buffer const & buf, odocstream & os,
+                           OutputParams const &) const
 {
-       docstring const str = "[" + _("LaTeX Command: ") + from_utf8(getCmdName()) + "]";
+       docstring const str = "[" + buf.B_("LaTeX Command: ") + from_utf8(getCmdName()) + "]";
        os << str;
        return str.size();
 }
 
 
 int InsetCommand::docbook(Buffer const &, odocstream &,
-                          OutputParams const &) const
+                         OutputParams const &) const
 {
        return 0;
 }
@@ -132,8 +128,8 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_MOUSE_RELEASE: {
-               if (!mailer_name_.empty())
-                       InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv());
+               if (!cur.selection())
+                       edit(cur, true);
                break;
        }
 
@@ -165,6 +161,13 @@ bool InsetCommand::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
+void InsetCommand::edit(Cursor & cur, bool)
+{
+       if (!mailer_name_.empty())
+               InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv());
+}
+
+
 void InsetCommand::replaceContents(std::string const & from, string const & to)
 {
        if (getContents() == from)
@@ -205,7 +208,7 @@ void InsetCommandMailer::string2params(string const & name,
        // by Text::readInset
        string id;
        lex >> id;
-       if (!lex || id != "LatexCommand")
+       if (!lex || id != "CommandInset")
                return print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
 
        params.read(lex);