5 #include "math_factory.h"
7 #include "BufferView.h"
9 #include "funcrequest.h"
10 #include "math_support.h"
12 #include "LaTeXFeatures.h"
14 #include "frontends/LyXView.h"
15 #include "frontends/Dialogs.h"
17 #include "support/LOstream.h"
25 RefInset::RefInset(string const & data)
30 InsetBase * RefInset::clone() const
32 return new RefInset(*this);
36 void RefInset::infoize(std::ostream & os) const
38 os << "Ref: " << cell(0);
43 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
46 case LFUN_MOUSE_RELEASE:
47 if (cmd.button() == mouse_button::button3) {
48 lyxerr << "trying to goto ref" << cell(0) << "\n";
49 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
52 if (cmd.button() == mouse_button::button1) {
53 // Eventually trigger dialog with button 3
55 string const data = createDialogStr("ref");
56 cmd.view()->owner()->getDialogs().
57 show("ref", data, this);
61 case LFUN_MOUSE_PRESS:
62 case LFUN_MOUSE_MOTION:
63 // eat other mouse commands
66 return CommandInset::dispatch(cmd, idx, pos);
73 string const RefInset::screenLabel() const
76 for (int i = 0; !types[i].latex_name.empty(); ++i)
77 if (commandname() == types[i].latex_name) {
78 str = _(types[i].short_gui_name);
81 str += asString(cell(0));
83 //if (/* !isLatex && */ !cell(0).empty()) {
85 // str += asString(cell(1));
91 void RefInset::validate(LaTeXFeatures & features) const
93 if (commandname() == "vref" || commandname() == "vpageref")
94 features.require("varioref");
95 else if (commandname() == "prettyref")
96 features.require("prettyref");
100 int RefInset::ascii(std::ostream & os, int) const
102 os << '[' << asString(cell(0)) << ']';
107 int RefInset::linuxdoc(std::ostream & os) const
109 os << "<ref id=\"" << asString(cell(0))
110 << "\" name=\"" << asString(cell(1)) << "\" >";
115 int RefInset::docbook(std::ostream & os, bool) const
117 if (cell(1).empty()) {
118 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
120 os << "<link linkend=\"" << asString(cell(0))
121 << "\">" << asString(cell(1)) << "</link>";
128 dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
130 if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref")
134 if (!createMathInset_fromDialogStr(cmd.argument, ar))
137 *this = *ar[0].nucleus()->asRefInset();
139 // // This does not compile because updateInset expects
140 // // an Inset* and 'this' isn't.
141 // cmd.view()->updateInset(this);
146 RefInset::ref_type_info RefInset::types[] = {
147 { "ref", N_("Standard"), N_("Ref: ")},
148 { "eqref", N_("Equation"), N_("EqRef: ")},
149 { "pageref", N_("Page Number"), N_("Page: ")},
150 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
151 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
152 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},