#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()
RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
- lyxerr << "dispatching " << cmd.argument << "\n";
case LFUN_MOUSE_RELEASE:
if (cmd.button() == mouse_button::button3) {
lyxerr << "trying to goto ref" << cell(0) << "\n";
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;
}
+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: ")},