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"
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);
40 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
43 case LFUN_MOUSE_RELEASE:
44 if (cmd.button() == mouse_button::button3) {
45 lyxerr << "trying to goto ref" << cell(0) << "\n";
46 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
49 if (cmd.button() == mouse_button::button1) {
50 lyxerr << "trying to open ref" << cell(0) << "\n";
51 // Eventually trigger dialog with button 3 not 1
52 // cmd.view()->owner()->getDialogs()->showRef(this);
56 case LFUN_MOUSE_PRESS:
57 case LFUN_MOUSE_MOTION:
58 // eat other mouse commands
61 return CommandInset::dispatch(cmd, idx, pos);
68 string RefInset::screenLabel() const
71 for (int i = 0; !types[i].latex_name.empty(); ++i)
72 if (name_ == types[i].latex_name) {
73 str = _(types[i].short_gui_name);
76 str += asString(cell(0));
78 //if (/* !isLatex && */ !cell(0).empty()) {
80 // str += asString(cell(1));
86 void RefInset::validate(LaTeXFeatures & features) const
88 if (name_ == "vref" || name_ == "vpageref")
89 features.require("varioref");
90 else if (name_ == "prettyref")
91 features.require("prettyref");
95 int RefInset::ascii(std::ostream & os, int) const
97 os << '[' << asString(cell(0)) << ']';
102 int RefInset::linuxdoc(std::ostream & os) const
104 os << "<ref id=\"" << asString(cell(0))
105 << "\" name=\"" << asString(cell(1)) << "\" >";
110 int RefInset::docbook(std::ostream & os, bool) const
112 if (cell(1).empty()) {
113 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
115 os << "<link linkend=\"" << asString(cell(0))
116 << "\">" << asString(cell(1)) << "</link>";
123 RefInset::ref_type_info RefInset::types[] = {
124 { "ref", N_("Standard"), N_("Ref: ")},
125 { "pageref", N_("Page Number"), N_("Page: ")},
126 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
127 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
128 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},