3 #include "math_cursor.h"
4 #include "commandtags.h"
5 #include "formulabase.h"
6 #include "BufferView.h"
7 #include "frontends/LyXView.h"
8 #include "frontends/Painter.h"
9 #include "frontends/Dialogs.h"
12 #include "LaTeXFeatures.h"
19 RefInset::RefInset(string const & data)
24 MathInset * RefInset::clone() const
26 return new RefInset(*this);
30 void RefInset::infoize(std::ostream & os) const
32 os << "Ref: " << cell(0);
36 int RefInset::dispatch(string const & cmd, idx_type, pos_type)
38 if (cmd == "mouse 3") {
39 cerr << "trying to goto ref" << cell(0) << "\n";
40 mathcursor->formula()->view()->owner()->getLyXFunc()->
41 dispatch(LFUN_REF_GOTO, asString(cell(0)));
42 return 1; // dispatched
45 if (cmd == "mouse 1") {
46 cerr << "trying to open ref" << cell(0) << "\n";
47 // Eventually trigger dialog with button 3 not 1
48 // mathcursor->formula()->view()->owner()->getDialogs()
50 return 1; // dispatched
53 return 0; // undispatched
57 string RefInset::screenLabel() const
60 for (int i = 0; !types[i].latex_name.empty(); ++i)
61 if (name_ == types[i].latex_name) {
62 str = _(types[i].short_gui_name);
65 str += asString(cell(0));
67 //if (/* !isLatex && */ !cell(0).empty()) {
69 // str += asString(cell(1));
75 void RefInset::validate(LaTeXFeatures & features) const
77 if (name_ == "vref" || name_ == "vpageref")
78 features.require("varioref");
79 else if (name_ == "prettyref")
80 features.require("prettyref");
84 int RefInset::ascii(std::ostream & os, int) const
86 os << "[" << asString(cell(0)) << "]";
91 int RefInset::linuxdoc(std::ostream & os) const
93 os << "<ref id=\"" << asString(cell(0))
94 << "\" name=\"" << asString(cell(1)) << "\" >";
99 int RefInset::docbook(std::ostream & os, bool) const
101 if (cell(1).empty()) {
102 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
104 os << "<link linkend=\"" << asString(cell(0))
105 << "\">" << asString(cell(1)) << "</link>";
111 RefInset::type_info RefInset::types[] = {
112 { "ref", N_("Standard"), N_("Ref: ")},
113 { "pageref", N_("Page Number"), N_("Page: ")},
114 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
115 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
116 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},