]> git.lyx.org Git - lyx.git/blob - src/insets/insetindex.C
47a7e56d33884dd1cc0dcc5421e7dca8776c29de
[lyx.git] / src / insets / insetindex.C
1 /**
2  * \file insetindex.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10 #include <config.h>
11
12 #include "insetindex.h"
13
14 #include "dispatchresult.h"
15 #include "funcrequest.h"
16 #include "gettext.h"
17 #include "LaTeXFeatures.h"
18 #include "metricsinfo.h"
19
20 #include "support/std_ostream.h"
21
22 using std::string;
23 using std::ostream;
24
25
26 InsetIndex::InsetIndex(InsetCommandParams const & p)
27         : InsetCommand(p)
28 {}
29
30
31 // InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
32 //      : InsetCommand(p, false)
33 // {}
34
35
36 InsetIndex::~InsetIndex()
37 {
38         InsetCommandMailer mailer("index", *this);
39         mailer.hideDialog();
40 }
41
42
43 string const InsetIndex::getScreenLabel(Buffer const &) const
44 {
45         return _("Idx");
46 }
47
48
49 void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51         InsetCommand::metrics(mi, dim);
52         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
53         dim.wid = mi.base.textwidth;
54         dim_ = dim;
55 }
56
57
58 void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
59 {
60         InsetCommand::draw(pi, x + center_indent_, y);
61 }
62
63
64 DispatchResult
65 InsetIndex::priv_dispatch(FuncRequest const & cmd,
66                           idx_type & idx, pos_type & pos)
67 {
68         switch (cmd.action) {
69                 case LFUN_INSET_EDIT:
70                         InsetCommandMailer("index", *this).showDialog(cmd.view());
71                         return DispatchResult(DISPATCHED);
72
73                 default:
74                         return InsetCommand::priv_dispatch(cmd, idx, pos);
75         }
76 }
77
78
79 int InsetIndex::docbook(Buffer const &, ostream & os,
80                         LatexRunParams const &) const
81 {
82         os << "<indexterm><primary>" << getContents()
83            << "</primary></indexterm>";
84         return 0;
85 }
86
87
88 InsetOld::Code InsetIndex::lyxCode() const
89 {
90         return InsetOld::INDEX_CODE;
91 }
92
93
94
95 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
96         : InsetCommand(p)
97 {}
98
99
100 // InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
101 //      : InsetCommand(p, false)
102 // {}
103
104
105 InsetPrintIndex::~InsetPrintIndex()
106 {}
107
108
109 string const InsetPrintIndex::getScreenLabel(Buffer const &) const
110 {
111         return _("Index");
112 }
113
114
115 void InsetPrintIndex::validate(LaTeXFeatures & features) const
116 {
117         features.require("makeidx");
118 }
119
120
121 InsetOld::Code InsetPrintIndex::lyxCode() const
122 {
123         return InsetOld::INDEX_PRINT_CODE;
124 }