5 #include "math_factory.h"
7 #include "BufferView.h"
9 #include "funcrequest.h"
11 #include "LaTeXFeatures.h"
13 #include "frontends/LyXView.h"
14 #include "frontends/Dialogs.h"
16 #include "support/LOstream.h"
24 RefInset::RefInset(string const & data)
29 MathInset * RefInset::clone() const
31 return new RefInset(*this);
35 void RefInset::infoize(std::ostream & os) const
37 os << "Ref: " << cell(0);
42 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
45 case LFUN_MOUSE_RELEASE:
46 if (cmd.button() == mouse_button::button3) {
47 lyxerr << "trying to goto ref" << cell(0) << "\n";
48 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
51 if (cmd.button() == mouse_button::button1) {
52 // Eventually trigger dialog with button 3
54 string const data = createDialogStr("ref");
55 cmd.view()->owner()->getDialogs().
56 show("ref", data, this);
60 case LFUN_MOUSE_PRESS:
61 case LFUN_MOUSE_MOTION:
62 // eat other mouse commands
65 return CommandInset::dispatch(cmd, idx, pos);
72 string RefInset::screenLabel() const
75 for (int i = 0; !types[i].latex_name.empty(); ++i)
76 if (name_ == types[i].latex_name) {
77 str = _(types[i].short_gui_name);
80 str += asString(cell(0));
82 //if (/* !isLatex && */ !cell(0).empty()) {
84 // str += asString(cell(1));
90 void RefInset::validate(LaTeXFeatures & features) const
92 if (name_ == "vref" || name_ == "vpageref")
93 features.require("varioref");
94 else if (name_ == "prettyref")
95 features.require("prettyref");
99 int RefInset::ascii(std::ostream & os, int) const
101 os << '[' << asString(cell(0)) << ']';
106 int RefInset::linuxdoc(std::ostream & os) const
108 os << "<ref id=\"" << asString(cell(0))
109 << "\" name=\"" << asString(cell(1)) << "\" >";
114 int RefInset::docbook(std::ostream & os, bool) const
116 if (cell(1).empty()) {
117 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
119 os << "<link linkend=\"" << asString(cell(0))
120 << "\">" << asString(cell(1)) << "</link>";
127 dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
129 if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref")
133 if (!createMathInset_fromDialogStr(cmd.argument, ar))
136 *this = *ar[0].nucleus()->asRefInset();
138 // // This does not compile because updateInset expects
139 // // an Inset* and 'this' isn't.
140 // cmd.view()->updateInset(this, true);
145 RefInset::ref_type_info RefInset::types[] = {
146 { "ref", N_("Standard"), N_("Ref: ")},
147 { "pageref", N_("Page Number"), N_("Page: ")},
148 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
149 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
150 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},