2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \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<EFBFBD>nnes
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insetindex.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-05-16 07:44:00 +00:00
|
|
|
|
#include "funcrequest.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
|
#include "gettext.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
|
#include "metricsinfo.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-10 21:08:55 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
2001-11-03 11:43:23 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetIndex::InsetIndex(InsetCommandParams const & p)
|
2000-08-03 12:56:25 +00:00
|
|
|
|
: InsetCommand(p)
|
2000-07-15 23:51:46 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
// InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
|
|
|
|
|
// : InsetCommand(p, false)
|
|
|
|
|
// {}
|
|
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
InsetIndex::~InsetIndex()
|
|
|
|
|
{
|
|
|
|
|
InsetCommandMailer mailer("index", *this);
|
|
|
|
|
mailer.hideDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
string const InsetIndex::getScreenLabel(Buffer const &) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
return _("Idx");
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-26 10:33:59 +00:00
|
|
|
|
|
|
|
|
|
void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
{
|
2003-10-22 10:22:09 +00:00
|
|
|
|
InsetCommand::draw(pi, x + center_indent_, y);
|
2003-08-26 10:33:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
|
DispatchResult InsetIndex::priv_dispatch(FuncRequest const & cmd,
|
|
|
|
|
idx_type & idx, pos_type & pos)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-05-16 07:44:00 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-11-04 12:36:59 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
2003-05-16 07:44:00 +00:00
|
|
|
|
InsetCommandMailer("index", *this).showDialog(cmd.view());
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2003-05-26 09:13:55 +00:00
|
|
|
|
|
2003-05-16 07:44:00 +00:00
|
|
|
|
default:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
return InsetCommand::priv_dispatch(cmd, idx, pos);
|
2003-05-16 07:44:00 +00:00
|
|
|
|
}
|
2001-07-20 14:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetIndex::docbook(Buffer const &, ostream & os,
|
|
|
|
|
LatexRunParams const &) const
|
2001-11-02 16:11:19 +00:00
|
|
|
|
{
|
2002-05-01 22:17:09 +00:00
|
|
|
|
os << "<indexterm><primary>" << getContents()
|
|
|
|
|
<< "</primary></indexterm>";
|
|
|
|
|
return 0;
|
2001-11-02 16:11:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code InsetIndex::lyxCode() const
|
2001-07-23 09:11:14 +00:00
|
|
|
|
{
|
2003-07-25 21:20:24 +00:00
|
|
|
|
return InsetOld::INDEX_CODE;
|
2001-07-23 09:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-16 07:44:00 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
|
2000-08-03 12:56:25 +00:00
|
|
|
|
: InsetCommand(p)
|
2000-07-15 23:51:46 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-05-01 22:17:09 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
// InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
|
|
|
|
|
// : InsetCommand(p, false)
|
|
|
|
|
// {}
|
|
|
|
|
|
|
|
|
|
|
2003-05-16 07:44:00 +00:00
|
|
|
|
InsetPrintIndex::~InsetPrintIndex()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
string const InsetPrintIndex::getScreenLabel(Buffer const &) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-08-03 12:56:25 +00:00
|
|
|
|
return _("Index");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetPrintIndex::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-11-19 15:34:11 +00:00
|
|
|
|
features.require("makeidx");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code InsetPrintIndex::lyxCode() const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-07-25 21:20:24 +00:00
|
|
|
|
return InsetOld::INDEX_PRINT_CODE;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|