]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcommand.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insetcommand.C
index 9b2e873ee470ddc7c84728cdfaddc728e083bb2c..0392743e4c40f2db7ff183a40911b6ffa4394f5b 100644 (file)
@@ -16,6 +16,7 @@
 #include "debug.h"
 #include "funcrequest.h"
 #include "lyxlex.h"
+#include "metricsinfo.h"
 
 #include "frontends/Painter.h"
 
@@ -27,13 +28,32 @@ using std::ostream;
 
 
 InsetCommand::InsetCommand(InsetCommandParams const & p)
-       : p_(p.getCmdName(), p.getContents(), p.getOptions())
+       : p_(p.getCmdName(), p.getContents(), p.getOptions()),
+         set_label_(false)
 {}
 
 
-InsetCommand::InsetCommand(InsetCommand const & ic)
-       : p_(ic.p_)
+BufferView * InsetCommand::view() const
 {
+       return button_.view();
+}
+
+
+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);
 }
 
 
@@ -42,6 +62,7 @@ void InsetCommand::setParams(InsetCommandParams const & p)
        p_.setCmdName(p.getCmdName());
        p_.setContents(p.getContents());
        p_.setOptions(p.getOptions());
+       set_label_ = false;
 }
 
 
@@ -93,7 +114,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
                return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
 
        default:
-               return UNDISPATCHED;
+               return InsetOld::localDispatch(cmd);
        }
 
 }
@@ -105,7 +126,7 @@ InsetCommandMailer::InsetCommandMailer(string const & name,
 {}
 
 
-string const InsetCommandMailer::inset2string() const
+string const InsetCommandMailer::inset2string(Buffer const &) const
 {
        return params2string(name(), inset_.params());
 }