4 #include "funcrequest.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"
21 RefInset::RefInset(string const & data)
26 MathInset * RefInset::clone() const
28 return new RefInset(*this);
32 void RefInset::infoize(std::ostream & os) const
34 os << "Ref: " << cell(0);
38 MathInset::result_type
39 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
42 case LFUN_MOUSE_RELEASE:
43 if (cmd.button() == mouse_button::button3) {
44 lyxerr << "trying to goto ref" << cell(0) << "\n";
45 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
48 if (cmd.button() == mouse_button::button1) {
49 lyxerr << "trying to open ref" << cell(0) << "\n";
50 // Eventually trigger dialog with button 3 not 1
51 // cmd.view()->owner()->getDialogs()->showRef(this);
55 case LFUN_MOUSE_PRESS:
56 case LFUN_MOUSE_MOTION:
57 // eat other mouse commands
60 return CommandInset::dispatch(cmd, idx, pos);
67 string RefInset::screenLabel() const
70 for (int i = 0; !types[i].latex_name.empty(); ++i)
71 if (name_ == types[i].latex_name) {
72 str = _(types[i].short_gui_name);
75 str += asString(cell(0));
77 //if (/* !isLatex && */ !cell(0).empty()) {
79 // str += asString(cell(1));
85 void RefInset::validate(LaTeXFeatures & features) const
87 if (name_ == "vref" || name_ == "vpageref")
88 features.require("varioref");
89 else if (name_ == "prettyref")
90 features.require("prettyref");
94 int RefInset::ascii(std::ostream & os, int) const
96 os << "[" << asString(cell(0)) << "]";
101 int RefInset::linuxdoc(std::ostream & os) const
103 os << "<ref id=\"" << asString(cell(0))
104 << "\" name=\"" << asString(cell(1)) << "\" >";
109 int RefInset::docbook(std::ostream & os, bool) const
111 if (cell(1).empty()) {
112 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
114 os << "<link linkend=\"" << asString(cell(0))
115 << "\">" << asString(cell(1)) << "</link>";
122 RefInset::type_info RefInset::types[] = {
123 { "ref", N_("Standard"), N_("Ref: ")},
124 { "pageref", N_("Page Number"), N_("Page: ")},
125 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
126 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
127 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},