5 #include "funcrequest.h"
6 #include "formulabase.h"
7 #include "BufferView.h"
8 #include "frontends/LyXView.h"
9 #include "frontends/Painter.h"
10 #include "frontends/Dialogs.h"
13 #include "LaTeXFeatures.h"
15 #include "math_mathmlstream.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)
44 lyxerr << "RefInset::dispatch " << cmd.argument << std::endl;
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
56 WriteStream wsdata(data);
58 wsdata << "\n\\end_inset\n\n";
60 cmd.view()->owner()->getDialogs().
61 show("ref", data.str(), this);
65 case LFUN_MOUSE_PRESS:
66 case LFUN_MOUSE_MOTION:
67 // eat other mouse commands
70 return CommandInset::dispatch(cmd, idx, pos);
77 string RefInset::screenLabel() const
80 for (int i = 0; !types[i].latex_name.empty(); ++i)
81 if (name_ == types[i].latex_name) {
82 str = _(types[i].short_gui_name);
85 str += asString(cell(0));
87 //if (/* !isLatex && */ !cell(0).empty()) {
89 // str += asString(cell(1));
95 void RefInset::validate(LaTeXFeatures & features) const
97 if (name_ == "vref" || name_ == "vpageref")
98 features.require("varioref");
99 else if (name_ == "prettyref")
100 features.require("prettyref");
104 int RefInset::ascii(std::ostream & os, int) const
106 os << '[' << asString(cell(0)) << ']';
111 int RefInset::linuxdoc(std::ostream & os) const
113 os << "<ref id=\"" << asString(cell(0))
114 << "\" name=\"" << asString(cell(1)) << "\" >";
119 int RefInset::docbook(std::ostream & os, bool) const
121 if (cell(1).empty()) {
122 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
124 os << "<link linkend=\"" << asString(cell(0))
125 << "\">" << asString(cell(1)) << "</link>";
132 RefInset::ref_type_info RefInset::types[] = {
133 { "ref", N_("Standard"), N_("Ref: ")},
134 { "pageref", N_("Page Number"), N_("Page: ")},
135 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
136 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
137 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},