4 #include "math_factory.h"
6 #include "BufferView.h"
8 #include "funcrequest.h"
9 #include "math_support.h"
11 #include "LaTeXFeatures.h"
13 #include "frontends/LyXView.h"
14 #include "frontends/Dialogs.h"
16 #include "support/LOstream.h"
26 RefInset::RefInset(string const & data)
31 auto_ptr<InsetBase> RefInset::clone() const
33 return auto_ptr<InsetBase>(new RefInset(*this));
37 void RefInset::infoize(std::ostream & os) const
39 os << "Ref: " << cell(0);
44 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
47 case LFUN_MOUSE_RELEASE:
48 if (cmd.button() == mouse_button::button3) {
49 lyxerr << "trying to goto ref" << cell(0) << "\n";
50 cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
53 if (cmd.button() == mouse_button::button1) {
54 // Eventually trigger dialog with button 3
56 string const data = createDialogStr("ref");
57 cmd.view()->owner()->getDialogs().
58 show("ref", data, this);
62 case LFUN_MOUSE_PRESS:
63 case LFUN_MOUSE_MOTION:
64 // eat other mouse commands
67 return CommandInset::dispatch(cmd, idx, pos);
74 string const RefInset::screenLabel() const
77 for (int i = 0; !types[i].latex_name.empty(); ++i)
78 if (commandname() == types[i].latex_name) {
79 str = _(types[i].short_gui_name);
82 str += asString(cell(0));
84 //if (/* !isLatex && */ !cell(0).empty()) {
86 // str += asString(cell(1));
92 void RefInset::validate(LaTeXFeatures & features) const
94 if (commandname() == "vref" || commandname() == "vpageref")
95 features.require("varioref");
96 else if (commandname() == "prettyref")
97 features.require("prettyref");
101 int RefInset::ascii(std::ostream & os, int) const
103 os << '[' << asString(cell(0)) << ']';
108 int RefInset::linuxdoc(std::ostream & os) const
110 os << "<ref id=\"" << asString(cell(0))
111 << "\" name=\"" << asString(cell(1)) << "\" >";
116 int RefInset::docbook(std::ostream & os, bool) const
118 if (cell(1).empty()) {
119 os << "<xref linkend=\"" << asString(cell(0)) << "\">";
121 os << "<link linkend=\"" << asString(cell(0))
122 << "\">" << asString(cell(1)) << "</link>";
129 dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
131 if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref")
135 if (!createMathInset_fromDialogStr(cmd.argument, ar))
138 *this = *ar[0].nucleus()->asRefInset();
140 // // This does not compile because updateInset expects
141 // // an Inset* and 'this' isn't.
142 // cmd.view()->updateInset(this);
147 RefInset::ref_type_info RefInset::types[] = {
148 { "ref", N_("Standard"), N_("Ref: ")},
149 { "eqref", N_("Equation"), N_("EqRef: ")},
150 { "pageref", N_("Page Number"), N_("Page: ")},
151 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
152 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
153 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},