]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetindex.C
ws changes only
[lyx.git] / src / insets / insetindex.C
index 7f8cbe6f00690123055e3b7a1acfe3bd26bd39ab..deaac12f606a2e052914ef92cc420f0ec6e45216 100644 (file)
+/**
+ * \file insetindex.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.
+ */
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "insetindex.h"
-#include "BufferView.h"
-#include "LyXView.h"
-#include "frontends/Dialogs.h"
+
+#include "funcrequest.h"
+#include "gettext.h"
 #include "LaTeXFeatures.h"
+#include "metricsinfo.h"
+
+#include "support/std_ostream.h"
+
+using std::string;
+using std::ostream;
+
 
 InsetIndex::InsetIndex(InsetCommandParams const & p)
        : InsetCommand(p)
 {}
 
 
-string const InsetIndex::getScreenLabel() const
+// InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
+//     : InsetCommand(p, false)
+// {}
+
+
+InsetIndex::~InsetIndex()
+{
+       InsetCommandMailer mailer("index", *this);
+       mailer.hideDialog();
+}
+
+
+string const InsetIndex::getScreenLabel(Buffer const &) const
 {
        return _("Idx");
 }
 
 
-void InsetIndex::Edit(BufferView * bv, int, int, unsigned int)
+void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       bv->owner()->getDialogs()->showIndex( this );
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
 }
 
 
+void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
+{
+                   InsetCommand::draw(pi, x + center_indent_, y);
+}
+
+
+dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd)
+{
+       switch (cmd.action) {
+               case LFUN_INSET_EDIT:
+                       InsetCommandMailer("index", *this).showDialog(cmd.view());
+                       return DISPATCHED;
+
+               default:
+                       return InsetCommand::localDispatch(cmd);
+       }
+}
+
+
+int InsetIndex::docbook(Buffer const &, ostream & os, bool) const
+{
+       os << "<indexterm><primary>" << getContents()
+          << "</primary></indexterm>";
+       return 0;
+}
+
+
+InsetOld::Code InsetIndex::lyxCode() const
+{
+       return InsetOld::INDEX_CODE;
+}
+
+
+
 InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
        : InsetCommand(p)
 {}
 
-string const InsetPrintIndex::getScreenLabel() const
+
+// InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
+//     : InsetCommand(p, false)
+// {}
+
+
+InsetPrintIndex::~InsetPrintIndex()
+{}
+
+
+string const InsetPrintIndex::getScreenLabel(Buffer const &) const
 {
        return _("Index");
 }
 
 
-void InsetPrintIndex::Validate(LaTeXFeatures & features) const
+void InsetPrintIndex::validate(LaTeXFeatures & features) const
 {
-       features.makeidx = true;
+       features.require("makeidx");
 }
 
 
-Inset::Code InsetPrintIndex::LyxCode() const
+InsetOld::Code InsetPrintIndex::lyxCode() const
 {
-       return Inset::INDEX_CODE;
+       return InsetOld::INDEX_PRINT_CODE;
 }