]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/ref_inset.C
small up/down tweaking
[lyx.git] / src / mathed / ref_inset.C
index c607d198121245ad87c79ea1065121d092415bf5..6edbae0e8dcf27a15563c8749cd14a8f2a54d841 100644 (file)
@@ -1,7 +1,11 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
 
 #include "ref_inset.h"
-#include "math_cursor.h"
-#include "commandtags.h"
+#include "funcrequest.h"
 #include "formulabase.h"
 #include "BufferView.h"
 #include "frontends/LyXView.h"
@@ -10,6 +14,8 @@
 #include "lyxfunc.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
+#include "debug.h"
+
 
 RefInset::RefInset()
        : CommandInset("ref")
@@ -33,24 +39,32 @@ void RefInset::infoize(std::ostream & os) const
 }
 
 
-int RefInset::dispatch(string const & cmd, idx_type, pos_type) 
+MathInset::result_type
+RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
-       if (cmd == "mouse 3") {
-               cerr << "trying to goto ref" << cell(0) << "\n";
-               mathcursor->formula()->view()->owner()->getLyXFunc()->
-                       dispatch(LFUN_REF_GOTO, asString(cell(0)));
-               return 1; // dispatched
-       }
-       
-       if (cmd == "mouse 1") {
-               cerr << "trying to open ref" << cell(0) << "\n";
-               // Eventually trigger dialog with button 3 not 1
-//             mathcursor->formula()->view()->owner()->getDialogs()
-//                     ->showRef(this);
-               return 1; // dispatched
+       switch (cmd.action) {
+               case LFUN_MOUSE_RELEASE:
+                       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.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);
+                               return DISPATCHED;
+                       }
+                       break;
+               case LFUN_MOUSE_PRESS:
+               case LFUN_MOUSE_MOTION:
+                       // eat other mouse commands
+                       return DISPATCHED;
+               default:
+                       return CommandInset::dispatch(cmd, idx, pos);
        }
-
-       return 0; // undispatched
+       // not our business
+       return UNDISPATCHED;
 }
 
 
@@ -83,7 +97,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;
 }
 
@@ -108,6 +122,7 @@ int RefInset::docbook(std::ostream & os, bool) const
        return 0;
 }
 
+
 RefInset::type_info RefInset::types[] = {
        { "ref",        N_("Standard"),                 N_("Ref: ")},
        { "pageref",    N_("Page Number"),              N_("Page: ")},