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 x, 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 if (button().box().contains(cmd.x, cmd.y))
84 InsetCommandMailer("toc", *this).showDialog(cmd.view());
85 return DispatchResult(DISPATCHED);
87 case LFUN_INSET_DIALOG_SHOW:
88 InsetCommandMailer("toc", *this).showDialog(cmd.view());
89 return DispatchResult(DISPATCHED);
92 return InsetCommand::priv_dispatch(cmd, idx, pos);
97 int InsetTOC::ascii(Buffer const & buffer, ostream & os,
98 LatexRunParams const &) const
100 os << getScreenLabel(buffer) << "\n\n";
102 lyx::toc::asciiTocList(lyx::toc::getType(getCmdName()), buffer, os);
109 int InsetTOC::linuxdoc(Buffer const &, ostream & os,
110 LatexRunParams const &) const
112 if (getCmdName() == "tableofcontents")
118 int InsetTOC::docbook(Buffer const &, ostream & os,
119 LatexRunParams const &) const
121 if (getCmdName() == "tableofcontents")