3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
12 #include "InsetIndex.h"
14 #include "DispatchResult.h"
15 #include "FuncRequest.h"
16 #include "FuncStatus.h"
18 #include "LaTeXFeatures.h"
19 #include "MetricsInfo.h"
22 #include "support/std_ostream.h"
31 InsetIndex::InsetIndex(BufferParams const & bp)
32 : InsetCollapsable(bp)
38 InsetIndex::InsetIndex(InsetIndex const & in)
39 : InsetCollapsable(in)
43 int InsetIndex::docbook(Buffer const & buf, odocstream & os,
44 OutputParams const & runparams) const
46 os << "<indexterm><primary>";
47 int const i = InsetText::docbook(buf, os, runparams);
48 os << "</primary></indexterm>";
53 InsetCode InsetIndex::lyxCode() const
59 Inset * InsetIndex::clone() const
61 return new InsetIndex(*this);
65 void InsetIndex::write(Buffer const & buf, std::ostream & os) const
67 os << to_utf8(name()) << "\n";
68 InsetCollapsable::write(buf, os);
72 void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const
74 Font tmpfont = mi.base.font;
75 getDrawFont(mi.base.font);
76 mi.base.font.realize(tmpfont);
77 InsetCollapsable::metrics(mi, dim);
78 mi.base.font = tmpfont;
82 void InsetIndex::draw(PainterInfo & pi, int x, int y) const
84 Font tmpfont = pi.base.font;
85 getDrawFont(pi.base.font);
86 pi.base.font.realize(tmpfont);
87 InsetCollapsable::draw(pi, x, y);
88 pi.base.font = tmpfont;
92 void InsetIndex::getDrawFont(Font & font) const
94 font = Font(Font::ALL_INHERIT);
95 font.realize(layout_.font);
99 bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
100 FuncStatus & status) const
102 switch (cmd.action) {
103 // paragraph breaks not allowed
104 case LFUN_BREAK_PARAGRAPH:
105 case LFUN_BREAK_PARAGRAPH_SKIP:
106 status.enabled(false);
110 return InsetCollapsable::getStatus(cur, cmd, status);
116 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
117 : InsetCommand(p, string())
121 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
127 void InsetPrintIndex::validate(LaTeXFeatures & features) const
129 features.require("makeidx");
133 InsetCode InsetPrintIndex::lyxCode() const
135 return INDEX_PRINT_CODE;