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 "dispatchresult.h"
16 #include "funcrequest.h"
18 #include "metricsinfo.h"
21 #include "support/std_ostream.h"
28 InsetTOC::InsetTOC(InsetCommandParams const & p)
35 InsetCommandMailer("toc", *this).hideDialog();
39 std::auto_ptr<InsetBase> InsetTOC::clone() const
41 return std::auto_ptr<InsetBase>(new InsetTOC(*this));
45 string const InsetTOC::getScreenLabel(Buffer const &) const
47 if (getCmdName() == "tableofcontents")
48 return _("Table of Contents");
49 return _("Unknown toc list");
53 InsetOld::Code InsetTOC::lyxCode() const
55 if (getCmdName() == "tableofcontents")
56 return InsetOld::TOC_CODE;
57 return InsetOld::NO_CODE;
61 void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
63 InsetCommand::metrics(mi, dim);
64 int const x1 = (mi.base.textwidth - dim.wid) / 2;
65 button().setBox(Box(x1, x1 + dim.wid, -dim.asc, dim.des));
66 dim.wid = mi.base.textwidth;
71 void InsetTOC::draw(PainterInfo & pi, int, int y) const
73 InsetCommand::draw(pi, button().box().x1, y);
78 InsetTOC::priv_dispatch(FuncRequest const & cmd,
79 idx_type & idx, pos_type & pos)
82 case LFUN_MOUSE_RELEASE:
83 case LFUN_INSET_DIALOG_SHOW:
84 InsetCommandMailer("toc", *this).showDialog(cmd.view());
85 return DispatchResult(true, true);
88 return InsetCommand::priv_dispatch(cmd, idx, pos);
93 int InsetTOC::plaintext(Buffer const & buffer, ostream & os,
94 OutputParams const &) const
96 os << getScreenLabel(buffer) << "\n\n";
98 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
105 int InsetTOC::linuxdoc(Buffer const &, ostream & os,
106 OutputParams const &) const
108 if (getCmdName() == "tableofcontents")
114 int InsetTOC::docbook(Buffer const &, ostream & os,
115 OutputParams const &) const
117 if (getCmdName() == "tableofcontents")