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"
22 InsetTOC::InsetTOC(InsetCommandParams const & p)
29 InsetCommandMailer mailer("toc", *this);
34 string const InsetTOC::getScreenLabel(Buffer const &) const
36 string const cmdname(getCmdName());
38 if (cmdname == "tableofcontents")
39 return _("Table of Contents");
40 return _("Unknown toc list");
44 InsetOld::Code InsetTOC::lyxCode() const
46 string const cmdname(getCmdName());
47 if (cmdname == "tableofcontents")
48 return InsetOld::TOC_CODE;
49 return InsetOld::NO_CODE;
53 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
55 InsetCommand::metrics(mi, dim);
56 int center_indent = (mi.base.textwidth - dim.wid) / 2;
57 Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
60 dim.wid = mi.base.textwidth;
65 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
67 InsetCommand::draw(pi, x + button().box().x1, y);
71 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
74 case LFUN_MOUSE_RELEASE:
75 if (button().box().contains(cmd.x, cmd.y))
76 InsetCommandMailer("toc", *this).showDialog(cmd.view());
79 case LFUN_INSET_DIALOG_SHOW:
80 InsetCommandMailer("toc", *this).showDialog(cmd.view());
84 return InsetCommand::localDispatch(cmd);
89 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
91 os << getScreenLabel(buffer) << "\n\n";
93 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
100 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
102 if (getCmdName() == "tableofcontents")
108 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
110 if (getCmdName() == "tableofcontents")