3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ref_inset.h"
14 #include "math_data.h"
15 #include "math_factory.h"
17 #include "BufferView.h"
20 #include "funcrequest.h"
21 #include "math_support.h"
23 #include "LaTeXFeatures.h"
25 #include "frontends/LyXView.h"
26 #include "frontends/Dialogs.h"
39 RefInset::RefInset(string const & data)
44 auto_ptr<InsetBase> RefInset::clone() const
46 return auto_ptr<InsetBase>(new RefInset(*this));
50 void RefInset::infoize(std::ostream & os) const
52 os << "Ref: " << cell(0);
56 void RefInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
59 case LFUN_INSET_MODIFY:
60 if (cmd.getArg(0) == "ref") {
62 if (createMathInset_fromDialogStr(cmd.argument, ar)) {
63 *this = *ar[0].nucleus()->asRefInset();
70 case LFUN_MOUSE_RELEASE:
71 if (cmd.button() == mouse_button::button3) {
72 lyxerr << "trying to goto ref" << cell(0) << endl;
73 cur.bv().dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
76 if (cmd.button() == mouse_button::button1) {
77 // Eventually trigger dialog with button 3, not 1
78 string const data = createDialogStr("ref");
79 cur.bv().owner()->getDialogs().show("ref", data, this);
85 case LFUN_MOUSE_PRESS:
86 case LFUN_MOUSE_MOTION:
87 // eat other mouse commands
91 CommandInset::priv_dispatch(cur, cmd);
97 string const RefInset::screenLabel() const
100 for (int i = 0; !types[i].latex_name.empty(); ++i)
101 if (commandname() == types[i].latex_name) {
102 str = _(types[i].short_gui_name);
105 str += asString(cell(0));
107 //if (/* !isLatex && */ !cell(0).empty()) {
109 // str += asString(cell(1));
115 void RefInset::validate(LaTeXFeatures & features) const
117 if (commandname() == "vref" || commandname() == "vpageref")
118 features.require("varioref");
119 else if (commandname() == "prettyref")
120 features.require("prettyref");
124 int RefInset::plaintext(std::ostream & os, OutputParams const &) const
126 os << '[' << asString(cell(0)) << ']';
131 int RefInset::linuxdoc(std::ostream & os, OutputParams const &) const
133 os << "<ref id=\"" << asString(cell(0))
134 << "\" name=\"" << asString(cell(1)) << "\" >";
139 int RefInset::docbook(std::ostream & os, OutputParams const &) const
141 if (cell(1).empty()) {
142 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
144 os << "<link linkend=\"" << asString(cell(0))
145 << "\">" << asString(cell(1)) << "</link>";
154 RefInset::ref_type_info RefInset::types[] = {
155 { "ref", N_("Standard"), N_("Ref: ")},
156 { "eqref", N_("Equation"), N_("EqRef: ")},
157 { "pageref", N_("Page Number"), N_("Page: ")},
158 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
159 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
160 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},