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 Inset * InsetIndex::clone() const
55 return new InsetIndex(*this);
59 void InsetIndex::write(Buffer const & buf, std::ostream & os) const
61 os << to_utf8(name()) << "\n";
62 InsetCollapsable::write(buf, os);
66 void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const
68 FontInfo tmpfont = mi.base.font;
69 getDrawFont(mi.base.font);
70 mi.base.font.realize(tmpfont);
71 InsetCollapsable::metrics(mi, dim);
72 mi.base.font = tmpfont;
76 void InsetIndex::draw(PainterInfo & pi, int x, int y) const
78 FontInfo tmpfont = pi.base.font;
79 getDrawFont(pi.base.font);
80 pi.base.font.realize(tmpfont);
81 InsetCollapsable::draw(pi, x, y);
82 pi.base.font = tmpfont;
86 void InsetIndex::getDrawFont(FontInfo & font) const
89 font.realize(layout_.font);
93 bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
94 FuncStatus & status) const
97 // paragraph breaks not allowed
98 case LFUN_BREAK_PARAGRAPH:
99 case LFUN_BREAK_PARAGRAPH_SKIP:
100 status.enabled(false);
104 return InsetCollapsable::getStatus(cur, cmd, status);
110 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
111 : InsetCommand(p, string())
115 CommandInfo const * InsetPrintIndex::findInfo(std::string const & /* cmdName */)
117 static const char * const paramnames[] = {"name", ""};
118 static const bool isoptional[] = {false};
119 static const CommandInfo info = {1, paramnames, isoptional};
124 docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const
130 void InsetPrintIndex::validate(LaTeXFeatures & features) const
132 features.require("makeidx");
136 InsetCode InsetPrintIndex::lyxCode() const
138 return INDEX_PRINT_CODE;