]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/ref_inset.C
fix #1073
[lyx.git] / src / mathed / ref_inset.C
index 5002cb5eea95b7b09fca2e289413dd8dec480cbd..abc6a215bbc8efe71850277de5f6742ce8084054 100644 (file)
@@ -2,16 +2,18 @@
 #include <config.h>
 
 #include "ref_inset.h"
-#include "funcrequest.h"
-#include "formulabase.h"
+#include "math_factory.h"
+
 #include "BufferView.h"
-#include "frontends/LyXView.h"
-#include "frontends/Painter.h"
-#include "frontends/Dialogs.h"
-#include "lyxfunc.h"
+#include "debug.h"
+#include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
-#include "debug.h"
+
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+
+#include "support/LOstream.h"
 
 
 RefInset::RefInset()
@@ -36,7 +38,7 @@ void RefInset::infoize(std::ostream & os) const
 }
 
 
-MathInset::result_type
+dispatch_result
 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
@@ -47,9 +49,11 @@ RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
                                return DISPATCHED;
                        }
                        if (cmd.button() == mouse_button::button1) {
-                               lyxerr << "trying to open ref" << cell(0) << "\n";
-                               // Eventually trigger dialog with button 3 not 1
-               //      cmd.view()->owner()->getDialogs()->showRef(this);
+                               // Eventually trigger dialog with button 3
+                               // not 1
+                               string const data = createDialogStr("ref");
+                               cmd.view()->owner()->getDialogs().
+                                       show("ref", data, this);
                                return DISPATCHED;
                        }
                        break;
@@ -120,6 +124,24 @@ int RefInset::docbook(std::ostream & os, bool) const
 }
 
 
+dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
+{
+       if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref")
+               return UNDISPATCHED;
+
+       MathArray ar;
+       if (!createMathInset_fromDialogStr(cmd.argument, ar))
+               return UNDISPATCHED;
+
+       *this = *ar[0].nucleus()->asRefInset();
+//     if (cmd.view())
+//                 // This does not compile because updateInset expects
+//                 // an Inset* and 'this' isn't.
+//             cmd.view()->updateInset(this);
+       return DISPATCHED;
+}
+
+
 RefInset::ref_type_info RefInset::types[] = {
        { "ref",        N_("Standard"),                 N_("Ref: ")},
        { "pageref",    N_("Page Number"),              N_("Page: ")},