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.
14 #include "funcrequest.h"
16 #include "metricsinfo.h"
23 InsetTOC::InsetTOC(InsetCommandParams const & p)
30 InsetCommandMailer mailer("toc", *this);
35 string const InsetTOC::getScreenLabel(Buffer const &) const
37 string const cmdname(getCmdName());
39 if (cmdname == "tableofcontents")
40 return _("Table of Contents");
41 return _("Unknown toc list");
45 InsetOld::Code InsetTOC::lyxCode() const
47 string const cmdname(getCmdName());
48 if (cmdname == "tableofcontents")
49 return InsetOld::TOC_CODE;
50 return InsetOld::NO_CODE;
54 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
56 InsetCommand::metrics(mi, dim);
57 int center_indent = (mi.base.textwidth - dim.wid) / 2;
58 Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
61 dim.wid = mi.base.textwidth;
66 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
68 InsetCommand::draw(pi, x + button().box().x1, y);
72 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
75 case LFUN_MOUSE_RELEASE:
76 if (button().box().contains(cmd.x, cmd.y))
77 InsetCommandMailer("toc", *this).showDialog(cmd.view());
80 case LFUN_INSET_DIALOG_SHOW:
81 InsetCommandMailer("toc", *this).showDialog(cmd.view());
85 return InsetCommand::localDispatch(cmd);
90 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
92 os << getScreenLabel(buffer) << "\n\n";
94 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
101 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
103 if (getCmdName() == "tableofcontents")
109 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
111 if (getCmdName() == "tableofcontents")