]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/command_inset.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / command_inset.C
index 70fac8e236e4dea6810bc0df9318f73f2f219c1b..fcfa79d16a326288eff6da2e1787351dfa7c6ee0 100644 (file)
@@ -15,8 +15,8 @@
 #include "math_mathmlstream.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
-#include "support/std_sstream.h"
 
+#include <sstream>
 
 using std::string;
 using std::auto_ptr;
@@ -24,15 +24,13 @@ using std::ostringstream;
 
 
 CommandInset::CommandInset(string const & name)
-       : MathNestInset(2),
-         name_(name),
-         set_label_(false)
+       : MathNestInset(2), name_(name), set_label_(false)
 {
        lock_ = true;
 }
 
 
-auto_ptr<InsetBase> CommandInset::clone() const
+auto_ptr<InsetBase> CommandInset::doClone() const
 {
        return auto_ptr<InsetBase>(new CommandInset(*this));
 }
@@ -45,24 +43,21 @@ void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
                button_.update(screenLabel(), true);
        }
        button_.metrics(mi, dim);
+       dim_ = dim;
 }
 
 
-void CommandInset::draw(PainterInfo & pi, int x, int y) const
+InsetBase * CommandInset::editXY(LCursor & cur, int /*x*/, int /*y*/)
 {
-       button_.draw(pi, x, y);
+       edit(cur, true);
+       return this;
 }
 
 
-DispatchResult
-CommandInset::priv_dispatch(FuncRequest const & cmd,
-                           idx_type & idx, pos_type & pos)
+void CommandInset::draw(PainterInfo & pi, int x, int y) const
 {
-       switch (cmd.action) {
-               default:
-                       return MathNestInset::priv_dispatch(cmd, idx, pos);
-       }
-       return DispatchResult(UNDISPATCHED);
+       button_.draw(pi, x, y);
+       setPosCache(pi, x, y);
 }
 
 
@@ -77,16 +72,16 @@ void CommandInset::write(WriteStream & os) const
 
 string const CommandInset::screenLabel() const
 {
-       return name_;
+       return name_;
 }
 
 
 string const CommandInset::createDialogStr(string const & name) const
 {
-       ostringstream data;
-       data << name << " LatexCommand ";
-       WriteStream wsdata(data);
-       write(wsdata);
-       wsdata << "\n\\end_inset\n\n";
-       return data.str();
+       ostringstream os;
+       os << name << " LatexCommand ";
+       WriteStream ws(os);
+       write(ws);
+       ws << "\n\\end_inset\n\n";
+       return os.str();
 }