]> git.lyx.org Git - lyx.git/blob - src/insets/insetindex.C
Enable convertDefault.sh to run even if its executable bit is not set.
[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
13 #include "insetindex.h"
14 #include "metricsinfo.h"
15 #include "BufferView.h"
16 #include "funcrequest.h"
17 #include "frontends/LyXView.h"
18 #include "frontends/Dialogs.h"
19 #include "LaTeXFeatures.h"
20 #include "gettext.h"
21 #include "support/LOstream.h"
22
23 using std::ostream;
24
25 InsetIndex::InsetIndex(InsetCommandParams const & p)
26         : InsetCommand(p)
27 {}
28
29
30 // InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
31 //      : InsetCommand(p, false)
32 // {}
33
34
35 InsetIndex::~InsetIndex()
36 {
37         InsetCommandMailer mailer("index", *this);
38         mailer.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 dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd)
64 {
65         switch (cmd.action) {
66                 case LFUN_INSET_EDIT:
67                         InsetCommandMailer("index", *this).showDialog(cmd.view());
68                         return DISPATCHED;
69
70                 default:
71                         return InsetCommand::localDispatch(cmd);
72         }
73 }
74
75
76 int InsetIndex::docbook(Buffer const &, ostream & os, bool) const
77 {
78         os << "<indexterm><primary>" << getContents()
79            << "</primary></indexterm>";
80         return 0;
81 }
82
83
84 InsetOld::Code InsetIndex::lyxCode() const
85 {
86         return InsetOld::INDEX_CODE;
87 }
88
89
90
91 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
92         : InsetCommand(p)
93 {}
94
95
96 // InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
97 //      : InsetCommand(p, false)
98 // {}
99
100
101 InsetPrintIndex::~InsetPrintIndex()
102 {}
103
104
105 string const InsetPrintIndex::getScreenLabel(Buffer const &) const
106 {
107         return _("Index");
108 }
109
110
111 void InsetPrintIndex::validate(LaTeXFeatures & features) const
112 {
113         features.require("makeidx");
114 }
115
116
117 InsetOld::Code InsetPrintIndex::lyxCode() const
118 {
119         return InsetOld::INDEX_PRINT_CODE;
120 }