4 #include "math_factory.h"
6 #include "BufferView.h"
8 #include "funcrequest.h"
9 #include "math_support.h"
11 #include "LaTeXFeatures.h"
13 #include "frontends/LyXView.h"
14 #include "frontends/Dialogs.h"
16 #include "support/LOstream.h"
27 RefInset::RefInset(string const & data)
32 auto_ptr<InsetBase> RefInset::clone() const
34 return auto_ptr<InsetBase>(new RefInset(*this));
38 void RefInset::infoize(std::ostream & os) const
40 os << "Ref: " << cell(0);
45 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
48 case LFUN_MOUSE_RELEASE:
49 if (cmd.button() == mouse_button::button3) {
50 lyxerr << "trying to goto ref" << cell(0) << endl;
51 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
54 if (cmd.button() == mouse_button::button1) {
55 // Eventually trigger dialog with button 3
57 string const data = createDialogStr("ref");
58 cmd.view()->owner()->getDialogs().
59 show("ref", data, this);
63 case LFUN_MOUSE_PRESS:
64 case LFUN_MOUSE_MOTION:
65 // eat other mouse commands
68 return CommandInset::dispatch(cmd, idx, pos);
75 string const RefInset::screenLabel() const
78 for (int i = 0; !types[i].latex_name.empty(); ++i)
79 if (commandname() == types[i].latex_name) {
80 str = _(types[i].short_gui_name);
83 str += asString(cell(0));
85 //if (/* !isLatex && */ !cell(0).empty()) {
87 // str += asString(cell(1));
93 void RefInset::validate(LaTeXFeatures & features) const
95 if (commandname() == "vref" || commandname() == "vpageref")
96 features.require("varioref");
97 else if (commandname() == "prettyref")
98 features.require("prettyref");
102 int RefInset::ascii(std::ostream & os, int) const
104 os << '[' << asString(cell(0)) << ']';
109 int RefInset::linuxdoc(std::ostream & os) const
111 os << "<ref id=\"" << asString(cell(0))
112 << "\" name=\"" << asString(cell(1)) << "\" >";
117 int RefInset::docbook(std::ostream & os, bool) const
119 if (cell(1).empty()) {
120 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
122 os << "<link linkend=\"" << asString(cell(0))
123 << "\">" << asString(cell(1)) << "</link>";
130 dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
132 if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref")
136 if (!createMathInset_fromDialogStr(cmd.argument, ar))
139 *this = *ar[0].nucleus()->asRefInset();
141 // // This does not compile because updateInset expects
142 // // an Inset* and 'this' isn't.
143 // cmd.view()->updateInset(this);
148 RefInset::ref_type_info RefInset::types[] = {
149 { "ref", N_("Standard"), N_("Ref: ")},
150 { "eqref", N_("Equation"), N_("EqRef: ")},
151 { "pageref", N_("Page Number"), N_("Page: ")},
152 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
153 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
154 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},