8 #include "funcrequest.h"
9 #include "formulabase.h"
10 #include "BufferView.h"
11 #include "frontends/LyXView.h"
12 #include "frontends/Painter.h"
13 #include "frontends/Dialogs.h"
16 #include "LaTeXFeatures.h"
25 RefInset::RefInset(string const & data)
30 MathInset * RefInset::clone() const
32 return new RefInset(*this);
36 void RefInset::infoize(std::ostream & os) const
38 os << "Ref: " << cell(0);
42 MathInset::result_type
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 lyxerr << "trying to open ref" << cell(0) << "\n";
54 // Eventually trigger dialog with button 3 not 1
55 // cmd.view()->owner()->getDialogs()->showRef(this);
59 case LFUN_MOUSE_PRESS:
60 case LFUN_MOUSE_MOTION:
61 // eat other mouse commands
64 return CommandInset::dispatch(cmd, idx, pos);
71 string RefInset::screenLabel() const
74 for (int i = 0; !types[i].latex_name.empty(); ++i)
75 if (name_ == types[i].latex_name) {
76 str = _(types[i].short_gui_name);
79 str += asString(cell(0));
81 //if (/* !isLatex && */ !cell(0).empty()) {
83 // str += asString(cell(1));
89 void RefInset::validate(LaTeXFeatures & features) const
91 if (name_ == "vref" || name_ == "vpageref")
92 features.require("varioref");
93 else if (name_ == "prettyref")
94 features.require("prettyref");
98 int RefInset::ascii(std::ostream & os, int) const
100 os << '[' << asString(cell(0)) << ']';
105 int RefInset::linuxdoc(std::ostream & os) const
107 os << "<ref id=\"" << asString(cell(0))
108 << "\" name=\"" << asString(cell(1)) << "\" >";
113 int RefInset::docbook(std::ostream & os, bool) const
115 if (cell(1).empty()) {
116 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
118 os << "<link linkend=\"" << asString(cell(0))
119 << "\">" << asString(cell(1)) << "</link>";
126 RefInset::type_info RefInset::types[] = {
127 { "ref", N_("Standard"), N_("Ref: ")},
128 { "pageref", N_("Page Number"), N_("Page: ")},
129 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
130 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
131 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},