]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloatlist.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetfloatlist.C
index 6562e74bd2a59ef8ad587cb5ad724f7a42af00b4..72289b435c5df1a19ec6b8d04914cb61a4d26e6b 100644 (file)
@@ -1,21 +1,31 @@
-#include <config.h>
+/**
+ * \file insetfloatlist.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "insetfloatlist.h"
 #include "FloatList.h"
+#include "metricsinfo.h"
 #include "LaTeXFeatures.h"
 #include "lyxlex.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
 #include "BufferView.h"
+#include "funcrequest.h"
 #include "buffer.h"
 #include "toc.h"
 #include "gettext.h"
 #include "debug.h"
+#include "Lsstream.h"
 
+#include "support/lstrings.h"
+
+using namespace lyx::support;
 
 using std::ostream;
 using std::endl;
@@ -23,8 +33,7 @@ using std::endl;
 
 InsetFloatList::InsetFloatList()
        : InsetCommand(InsetCommandParams())
-{
-}
+{}
 
 
 InsetFloatList::InsetFloatList(string const & type)
@@ -34,9 +43,16 @@ InsetFloatList::InsetFloatList(string const & type)
 }
 
 
-string const InsetFloatList::getScreenLabel(Buffer const * buf) const
+InsetFloatList::~InsetFloatList()
+{
+       InsetCommandMailer mailer("toc", *this);
+       mailer.hideDialog();
+}
+
+
+string const InsetFloatList::getScreenLabel(Buffer const & buf) const
 {
-       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList const & floats = buf.params.getLyXTextClass().floats();
        FloatList::const_iterator it = floats[getCmdName()];
        if (it != floats.end())
                return _(it->second.listName());
@@ -45,21 +61,21 @@ string const InsetFloatList::getScreenLabel(Buffer const * buf) const
 }
 
 
-Inset::Code InsetFloatList::lyxCode() const
+InsetOld::Code InsetFloatList::lyxCode() const
 {
-       return Inset::FLOAT_LIST_CODE;
+       return InsetOld::FLOAT_LIST_CODE;
 }
 
 
-void InsetFloatList::write(Buffer const *, ostream & os) const
+void InsetFloatList::write(Buffer const &, ostream & os) const
 {
        os << "FloatList " << getCmdName() << "\n";
 }
 
 
-void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
+void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
 {
-       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList const & floats = buf.params.getLyXTextClass().floats();
        string token;
 
        if (lex.eatLine()) {
@@ -82,21 +98,37 @@ void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
 }
 
 
-void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetFloatList::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       bv->owner()->getDialogs().showTOC(this);
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
 }
 
 
-void InsetFloatList::edit(BufferView * bv, bool)
+void InsetFloatList::draw(PainterInfo & pi, int x, int y) const
 {
-       edit(bv, 0, 0, mouse_button::none);
+       InsetCommand::draw(pi, x + center_indent_, y);
+}
+
+
+dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
+{
+       switch (cmd.action) {
+               case LFUN_INSET_EDIT:
+                       InsetCommandMailer("toc", *this).showDialog(cmd.view());
+                       return DISPATCHED;
+               default:
+                       return InsetCommand::localDispatch(cmd);
+       }
 }
 
 
-int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
+int InsetFloatList::latex(Buffer const & buf, ostream & os,
+                         LatexRunParams const &) const
 {
-       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList const & floats = buf.params.getLyXTextClass().floats();
        FloatList::const_iterator cit = floats[getCmdName()];
 
        if (cit != floats.end()) {
@@ -116,17 +148,18 @@ int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
                }
        } else {
                os << "%%\\listof{" << getCmdName() << "}{"
-                  << _("List of ") << cit->second.name() << "}\n";
+                  << bformat(_("List of %1$s"), cit->second.name())
+                  << "}\n";
        }
        return 1;
 }
 
 
-int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
+int InsetFloatList::ascii(Buffer const & buffer, ostream & os, int) const
 {
        os << getScreenLabel(buffer) << "\n\n";
 
-       toc::asciiTocList(getCmdName(), buffer, os);
+       lyx::toc::asciiTocList(getCmdName(), buffer, os);
 
        os << "\n";
        return 0;