]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / insets / InsetIndex.cpp
index eb0084ecda230262b7b399f4845fd77581b9a0ca..4fdbfc502ef028667e99fbcf04f76d88be367bdd 100644 (file)
@@ -24,6 +24,7 @@
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
+#include "output_latex.h"
 #include "sgml.h"
 #include "TocBackend.h"
 
@@ -48,14 +49,17 @@ namespace lyx {
 ///////////////////////////////////////////////////////////////////////
 
 
-InsetIndex::InsetIndex(Buffer const & buf, InsetIndexParams const & params)
+InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
        : InsetCollapsable(buf), params_(params)
 {}
 
 
 int InsetIndex::latex(odocstream & os,
-                     OutputParams const & runparams) const
+                     OutputParams const & runparams_in) const
 {
+       OutputParams runparams(runparams_in);
+       runparams.inIndexEntry = true;
+
        if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
            && params_.index != "idx") {
                os << "\\sindex[";
@@ -171,6 +175,12 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
+docstring InsetIndex::xhtml(XHTMLStream &, OutputParams const &) const
+{
+       return docstring();
+}
+
+
 bool InsetIndex::showInsetDialog(BufferView * bv) const
 {
        bv->showDialog("index", params2string(params_),
@@ -186,13 +196,11 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                if (cmd.getArg(0) == "changetype") {
                        params_.index = from_utf8(cmd.getArg(1));
-                       setLayout(cur.buffer()->params());
                        break;
                }
                InsetIndexParams params;
                InsetIndex::string2params(to_utf8(cmd.argument()), params);
                params_.index = params.index;
-               setLayout(cur.buffer()->params());
                break;
        }
 
@@ -238,13 +246,15 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-docstring const InsetIndex::buttonLabel(BufferView const & bv) const
+ColorCode InsetIndex::labelColor() const
 {
-       docstring s = _("Idx");
-       if (decoration() == InsetLayout::CLASSIC)
-               return isOpen(bv) ? s : getNewLabel(s);
-       else
-               return getNewLabel(s);
+       if (params_.index.empty() || params_.index == from_ascii("idx"))
+               return InsetCollapsable::labelColor();
+       // FIXME UNICODE
+       ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
+       if (c == Color_none)
+               c = InsetCollapsable::labelColor();
+       return c;
 }
 
 
@@ -267,10 +277,7 @@ docstring InsetIndex::toolTip(BufferView const &, int, int) const
        odocstringstream ods;
        InsetText::plaintext(ods, rp);
        tip += ods.str();
-       // shorten it if necessary
-       if (tip.size() > 200)
-               tip = tip.substr(0, 200) + "...";
-       return tip;
+       return wrapParas(tip);
 }
 
 
@@ -380,8 +387,8 @@ void InsetIndexParams::read(Lexer & lex)
 //
 ///////////////////////////////////////////////////////////////////////
 
-InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
-       : InsetCommand(p, "index_print")
+InsetPrintIndex::InsetPrintIndex(Buffer * buf, InsetCommandParams const & p)
+       : InsetCommand(buf, p, "index_print")
 {}
 
 
@@ -545,4 +552,9 @@ bool InsetPrintIndex::hasSettings() const
 }
 
 
+docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const &) const
+{
+       return docstring();
+}
+
 } // namespace lyx