4 #include "math_cursor.h"
5 #include "commandtags.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"
22 RefInset::RefInset(string const & data)
27 MathInset * RefInset::clone() const
29 return new RefInset(*this);
33 void RefInset::infoize(std::ostream & os) const
35 os << "Ref: " << cell(0);
39 int RefInset::dispatch(string const & cmd, idx_type, pos_type)
41 if (cmd == "mouse 3") {
42 lyxerr << "trying to goto ref" << cell(0) << "\n";
43 mathcursor->formula()->view()->owner()->getLyXFunc()->
44 dispatch(LFUN_REF_GOTO, asString(cell(0)));
45 return 1; // dispatched
48 if (cmd == "mouse 1") {
49 lyxerr << "trying to open ref" << cell(0) << "\n";
50 // Eventually trigger dialog with button 3 not 1
51 // mathcursor->formula()->view()->owner()->getDialogs()
53 return 1; // dispatched
56 return 0; // undispatched
60 string RefInset::screenLabel() const
63 for (int i = 0; !types[i].latex_name.empty(); ++i)
64 if (name_ == types[i].latex_name) {
65 str = _(types[i].short_gui_name);
68 str += asString(cell(0));
70 //if (/* !isLatex && */ !cell(0).empty()) {
72 // str += asString(cell(1));
78 void RefInset::validate(LaTeXFeatures & features) const
80 if (name_ == "vref" || name_ == "vpageref")
81 features.require("varioref");
82 else if (name_ == "prettyref")
83 features.require("prettyref");
87 int RefInset::ascii(std::ostream & os, int) const
89 os << "[" << asString(cell(0)) << "]";
94 int RefInset::linuxdoc(std::ostream & os) const
96 os << "<ref id=\"" << asString(cell(0))
97 << "\" name=\"" << asString(cell(1)) << "\" >";
102 int RefInset::docbook(std::ostream & os, bool) const
104 if (cell(1).empty()) {
105 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
107 os << "<link linkend=\"" << asString(cell(0))
108 << "\">" << asString(cell(1)) << "</link>";
115 RefInset::type_info RefInset::types[] = {
116 { "ref", N_("Standard"), N_("Ref: ")},
117 { "pageref", N_("Page Number"), N_("Page: ")},
118 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
119 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
120 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},