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"
24 InsetTOC::InsetTOC(InsetCommandParams const & p)
31 InsetCommandMailer mailer("toc", *this);
36 string const InsetTOC::getScreenLabel(Buffer const &) const
38 string const cmdname(getCmdName());
40 if (cmdname == "tableofcontents")
41 return _("Table of Contents");
42 return _("Unknown toc list");
46 InsetOld::Code InsetTOC::lyxCode() const
48 string const cmdname(getCmdName());
49 if (cmdname == "tableofcontents")
50 return InsetOld::TOC_CODE;
51 return InsetOld::NO_CODE;
55 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
57 InsetCommand::metrics(mi, dim);
58 int center_indent = (mi.base.textwidth - dim.wid) / 2;
59 Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
62 dim.wid = mi.base.textwidth;
67 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
69 InsetCommand::draw(pi, x + button().box().x1, y);
73 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
76 case LFUN_MOUSE_RELEASE:
77 if (button().box().contains(cmd.x, cmd.y))
78 InsetCommandMailer("toc", *this).showDialog(cmd.view());
81 case LFUN_INSET_DIALOG_SHOW:
82 InsetCommandMailer("toc", *this).showDialog(cmd.view());
86 return InsetCommand::localDispatch(cmd);
91 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
93 os << getScreenLabel(buffer) << "\n\n";
95 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
102 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
104 if (getCmdName() == "tableofcontents")
110 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
112 if (getCmdName() == "tableofcontents")