]> git.lyx.org Git - lyx.git/blob - src/insets/insetindex.C
1572347ac16c67b7a9e861b2730cd6634db3da4f
[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("index", *this).hideDialog();
39 }
40
41
42 string const InsetIndex::getScreenLabel(Buffer const &) const
43 {
44         return _("Idx");
45 }
46
47
48 void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
49 {
50         InsetCommand::metrics(mi, dim);
51         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
52         dim.wid = mi.base.textwidth;
53         dim_ = dim;
54 }
55
56
57 void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
58 {
59         InsetCommand::draw(pi, x + center_indent_, y);
60 }
61
62
63 DispatchResult InsetIndex::priv_dispatch(FuncRequest const & cmd,
64         idx_type & idx, pos_type & pos)
65 {
66         switch (cmd.action) {
67                 case LFUN_MOUSE_RELEASE:
68                         InsetCommandMailer("index", *this).showDialog(cmd.view());
69                         return DispatchResult(true, true);
70
71                 default:
72                         return InsetCommand::priv_dispatch(cmd, idx, pos);
73         }
74 }
75
76
77 int InsetIndex::docbook(Buffer const &, ostream & os,
78                         OutputParams const &) const
79 {
80         os << "<indexterm><primary>" << getContents()
81            << "</primary></indexterm>";
82         return 0;
83 }
84
85
86 InsetOld::Code InsetIndex::lyxCode() const
87 {
88         return InsetOld::INDEX_CODE;
89 }
90
91
92
93 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
94         : InsetCommand(p)
95 {}
96
97
98 // InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
99 //      : InsetCommand(p, false)
100 // {}
101
102
103 InsetPrintIndex::~InsetPrintIndex()
104 {}
105
106
107 string const InsetPrintIndex::getScreenLabel(Buffer const &) const
108 {
109         return _("Index");
110 }
111
112
113 void InsetPrintIndex::validate(LaTeXFeatures & features) const
114 {
115         features.require("makeidx");
116 }
117
118
119 InsetOld::Code InsetPrintIndex::lyxCode() const
120 {
121         return InsetOld::INDEX_PRINT_CODE;
122 }