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"
19 #include "support/std_ostream.h"
25 InsetTOC::InsetTOC(InsetCommandParams const & p)
32 InsetCommandMailer mailer("toc", *this);
37 string const InsetTOC::getScreenLabel(Buffer const &) const
39 string const cmdname(getCmdName());
41 if (cmdname == "tableofcontents")
42 return _("Table of Contents");
43 return _("Unknown toc list");
47 InsetOld::Code InsetTOC::lyxCode() const
49 string const cmdname(getCmdName());
50 if (cmdname == "tableofcontents")
51 return InsetOld::TOC_CODE;
52 return InsetOld::NO_CODE;
56 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
58 InsetCommand::metrics(mi, dim);
59 int center_indent = (mi.base.textwidth - dim.wid) / 2;
60 Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
63 dim.wid = mi.base.textwidth;
68 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
70 InsetCommand::draw(pi, x + button().box().x1, y);
74 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
77 case LFUN_MOUSE_RELEASE:
78 if (button().box().contains(cmd.x, cmd.y))
79 InsetCommandMailer("toc", *this).showDialog(cmd.view());
82 case LFUN_INSET_DIALOG_SHOW:
83 InsetCommandMailer("toc", *this).showDialog(cmd.view());
87 return InsetCommand::localDispatch(cmd);
92 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
94 os << getScreenLabel(buffer) << "\n\n";
96 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
103 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
105 if (getCmdName() == "tableofcontents")
111 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
113 if (getCmdName() == "tableofcontents")