]> git.lyx.org Git - lyx.git/blob - src/insets/insetindex.C
17d3e9efaae6ca403037bcb1fe2c870b901e5389
[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 "funcrequest.h"
15 #include "gettext.h"
16 #include "LaTeXFeatures.h"
17 #include "metricsinfo.h"
18
19
20 using std::string;
21 using std::ostream;
22
23
24 InsetIndex::InsetIndex(InsetCommandParams const & p)
25         : InsetCommand(p)
26 {}
27
28
29 // InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
30 //      : InsetCommand(p, false)
31 // {}
32
33
34 InsetIndex::~InsetIndex()
35 {
36         InsetCommandMailer mailer("index", *this);
37         mailer.hideDialog();
38 }
39
40
41 string const InsetIndex::getScreenLabel(Buffer const &) const
42 {
43         return _("Idx");
44 }
45
46
47 void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         InsetCommand::metrics(mi, dim);
50         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
51         dim.wid = mi.base.textwidth;
52         dim_ = dim;
53 }
54
55
56 void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
57 {
58                     InsetCommand::draw(pi, x + center_indent_, y);
59 }
60
61
62 dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd)
63 {
64         switch (cmd.action) {
65                 case LFUN_INSET_EDIT:
66                         InsetCommandMailer("index", *this).showDialog(cmd.view());
67                         return DISPATCHED;
68
69                 default:
70                         return InsetCommand::localDispatch(cmd);
71         }
72 }
73
74
75 int InsetIndex::docbook(Buffer const &, ostream & os, bool) const
76 {
77         os << "<indexterm><primary>" << getContents()
78            << "</primary></indexterm>";
79         return 0;
80 }
81
82
83 InsetOld::Code InsetIndex::lyxCode() const
84 {
85         return InsetOld::INDEX_CODE;
86 }
87
88
89
90 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
91         : InsetCommand(p)
92 {}
93
94
95 // InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
96 //      : InsetCommand(p, false)
97 // {}
98
99
100 InsetPrintIndex::~InsetPrintIndex()
101 {}
102
103
104 string const InsetPrintIndex::getScreenLabel(Buffer const &) const
105 {
106         return _("Index");
107 }
108
109
110 void InsetPrintIndex::validate(LaTeXFeatures & features) const
111 {
112         features.require("makeidx");
113 }
114
115
116 InsetOld::Code InsetPrintIndex::lyxCode() const
117 {
118         return InsetOld::INDEX_PRINT_CODE;
119 }