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 "BufferView.h"
16 #include "funcrequest.h"
18 #include "metricsinfo.h"
20 #include "frontends/LyXView.h"
21 #include "frontends/Dialogs.h"
28 InsetTOC::InsetTOC(InsetCommandParams const & p)
35 InsetCommandMailer mailer("toc", *this);
40 string const InsetTOC::getScreenLabel(Buffer const &) const
42 string const cmdname(getCmdName());
44 if (cmdname == "tableofcontents")
45 return _("Table of Contents");
46 return _("Unknown toc list");
50 InsetOld::Code InsetTOC::lyxCode() const
52 string const cmdname(getCmdName());
53 if (cmdname == "tableofcontents")
54 return InsetOld::TOC_CODE;
55 return InsetOld::NO_CODE;
59 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
61 InsetCommand::metrics(mi, dim);
62 int center_indent = (mi.base.textwidth - dim.wid) / 2;
63 Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
66 dim.wid = mi.base.textwidth;
71 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
73 InsetCommand::draw(pi, x + button().box().x1, y);
77 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
80 case LFUN_MOUSE_RELEASE:
81 if (button().box().contains(cmd.x, cmd.y))
82 InsetCommandMailer("toc", *this).showDialog(cmd.view());
85 case LFUN_INSET_DIALOG_SHOW:
86 InsetCommandMailer("toc", *this).showDialog(cmd.view());
90 return InsetCommand::localDispatch(cmd);
95 int InsetTOC::ascii(Buffer const & buffer, ostream & os, int) const
97 os << getScreenLabel(buffer) << "\n\n";
99 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
106 int InsetTOC::linuxdoc(Buffer const &, ostream & os) const
108 if (getCmdName() == "tableofcontents")
114 int InsetTOC::docbook(Buffer const &, ostream & os, bool) const
116 if (getCmdName() == "tableofcontents")