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" << std::endl;
45 lyxerr << "dispatching " << cmd.argument << "\n";
47 case LFUN_MOUSE_RELEASE:
48 if (cmd.button() == mouse_button::button3) {
49 lyxerr << "trying to goto ref" << cell(0) << "\n";
50 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
53 if (cmd.button() == mouse_button::button1) {
54 lyxerr << "trying to open ref" << cell(0) << "\n";
55 // Eventually trigger dialog with button 3
58 WriteStream wsdata(data);
61 lyxerr << "ref_inset dispatch.\n"
62 << "this " << this << "\n"
63 << "The data is "<< data.str()
66 cmd.view()->owner()->getDialogs().
67 show("ref", data.str(), this);
71 case LFUN_MOUSE_PRESS:
72 case LFUN_MOUSE_MOTION:
73 // eat other mouse commands
76 return CommandInset::dispatch(cmd, idx, pos);
83 string RefInset::screenLabel() const
86 for (int i = 0; !types[i].latex_name.empty(); ++i)
87 if (name_ == types[i].latex_name) {
88 str = _(types[i].short_gui_name);
91 str += asString(cell(0));
93 //if (/* !isLatex && */ !cell(0).empty()) {
95 // str += asString(cell(1));
101 void RefInset::validate(LaTeXFeatures & features) const
103 if (name_ == "vref" || name_ == "vpageref")
104 features.require("varioref");
105 else if (name_ == "prettyref")
106 features.require("prettyref");
110 int RefInset::ascii(std::ostream & os, int) const
112 os << '[' << asString(cell(0)) << ']';
117 int RefInset::linuxdoc(std::ostream & os) const
119 os << "<ref id=\"" << asString(cell(0))
120 << "\" name=\"" << asString(cell(1)) << "\" >";
125 int RefInset::docbook(std::ostream & os, bool) const
127 if (cell(1).empty()) {
128 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
130 os << "<link linkend=\"" << asString(cell(0))
131 << "\">" << asString(cell(1)) << "</link>";
138 RefInset::ref_type_info RefInset::types[] = {
139 { "ref", N_("Standard"), N_("Ref: ")},
140 { "pageref", N_("Page Number"), N_("Page: ")},
141 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
142 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
143 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},