]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/ref_inset.C
rename commandtags.h to lfuns.h and renumber/cleanup. Rebuild the tree !
[lyx.git] / src / mathed / ref_inset.C
index c1130d455ccd4a4352176063c84b3bedac16e311..abc6a215bbc8efe71850277de5f6742ce8084054 100644 (file)
@@ -1,16 +1,19 @@
+
 #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()
@@ -35,29 +38,31 @@ void RefInset::infoize(std::ostream & os) const
 }
 
 
-MathInset::result_type
-RefInset::dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+dispatch_result
+RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
                case LFUN_MOUSE_RELEASE:
-                       if (cmd.extra == 3) {
+                       if (cmd.button() == mouse_button::button3) {
                                lyxerr << "trying to goto ref" << cell(0) << "\n";
                                cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
                                return DISPATCHED;
                        }
-                       if (cmd.extra == 1) {
-                               lyxerr << "trying to open ref" << cell(0) << "\n";
-                               // Eventually trigger dialog with button 3 not 1
-               //      cmd.view()->owner()->getDialogs()->showRef(this);
+                       if (cmd.button() == mouse_button::button1) {
+                               // Eventually trigger dialog with button 3
+                               // not 1
+                               string const data = createDialogStr("ref");
+                               cmd.view()->owner()->getDialogs().
+                                       show("ref", data, this);
                                return DISPATCHED;
                        }
                        break;
-               case LFUN_MOUSE_PRESS:  
+               case LFUN_MOUSE_PRESS:
                case LFUN_MOUSE_MOTION:
                        // eat other mouse commands
                        return DISPATCHED;
                default:
-                       break;
+                       return CommandInset::dispatch(cmd, idx, pos);
        }
        // not our business
        return UNDISPATCHED;
@@ -93,7 +98,7 @@ void RefInset::validate(LaTeXFeatures & features) const
 
 int RefInset::ascii(std::ostream & os, int) const
 {
-       os << "[" << asString(cell(0)) << "]";
+       os << '[' << asString(cell(0)) << ']';
        return 0;
 }
 
@@ -119,7 +124,25 @@ int RefInset::docbook(std::ostream & os, bool) const
 }
 
 
-RefInset::type_info RefInset::types[] = {
+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: ")},
        { "vpageref",   N_("Textual Page Number"),      N_("TextPage: ")},