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.
15 #include "funcrequest.h"
17 #include "metricsinfo.h"
20 #include "support/std_ostream.h"
27 InsetTOC::InsetTOC(InsetCommandParams const & p)
34 InsetCommandMailer("toc", *this).hideDialog();
38 std::auto_ptr<InsetBase> InsetTOC::clone() const
40 return std::auto_ptr<InsetBase>(new InsetTOC(*this));
44 string const InsetTOC::getScreenLabel(Buffer const &) const
46 if (getCmdName() == "tableofcontents")
47 return _("Table of Contents");
48 return _("Unknown toc list");
52 InsetOld::Code InsetTOC::lyxCode() const
54 if (getCmdName() == "tableofcontents")
55 return InsetOld::TOC_CODE;
56 return InsetOld::NO_CODE;
60 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
62 InsetCommand::metrics(mi, dim);
63 int const x1 = (mi.base.textwidth - dim.wid) / 2;
64 button().setBox(Box(x1, x1 + dim.wid, -dim.asc, dim.des));
65 dim.wid = mi.base.textwidth;
70 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
72 InsetCommand::draw(pi, button().box().x1, y);
77 InsetTOC::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
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::priv_dispatch(cmd, idx, pos);
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")