2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insettheorem.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-07-04 19:16:35 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insettheorem.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "lyxfont.h"
|
|
|
|
|
#include "lyxtext.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "metricsinfo.h"
|
|
|
|
|
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
using std::endl;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
The intention is to be able to create arbitrary theorem like environments
|
|
|
|
|
sing this class and some helper/container classes. It should be possible
|
|
|
|
|
to create these theorems both from layout file and interactively by the
|
|
|
|
|
user.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
InsetTheorem::InsetTheorem()
|
|
|
|
|
: InsetCollapsable()
|
|
|
|
|
{
|
|
|
|
|
setLabel(_("theorem"));
|
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
2001-06-05 17:05:51 +00:00
|
|
|
|
font.setColor(LColor::collapsable);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
setLabelFont(font);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#if 0
|
2000-07-04 19:16:35 +00:00
|
|
|
|
setAutoCollapse(false);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#endif
|
2000-07-04 19:16:35 +00:00
|
|
|
|
setInsetName("Theorem");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
void InsetTheorem::write(Buffer const * buf, ostream & os) const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
|
|
|
|
os << getInsetName() << "\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
|
InsetCollapsable::write(buf, os);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetTheorem::doClone() const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
2002-03-19 09:47:34 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2001-07-06 15:57:54 +00:00
|
|
|
|
#warning Is this inset used? If YES this is WRONG!!! (Jug)
|
2002-03-19 09:47:34 +00:00
|
|
|
|
#endif
|
2003-11-03 17:47:28 +00:00
|
|
|
|
auto_ptr<InsetTheorem> result(new InsetTheorem);
|
2003-09-16 15:39:33 +00:00
|
|
|
|
result->setCollapsed(!isOpen());
|
2003-11-03 17:47:28 +00:00
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-08-26 10:33:59 +00:00
|
|
|
|
{
|
|
|
|
|
InsetCollapsable::metrics(mi, dim);
|
|
|
|
|
center_indent_ = (mi.base.textwidth - dim.wid) / 2;
|
|
|
|
|
dim.wid = mi.base.textwidth;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool const changed = dim_ != dim;
|
2003-08-26 10:33:59 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return changed;
|
2003-08-26 10:33:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetTOC::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
InsetCollapsable::draw(pi, x + center_indent_, y);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
string const InsetTheorem::editMessage() const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
|
|
|
|
return _("Opened Theorem Inset");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetTheorem::latex(Buffer const * buf, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
|
|
|
|
os << "\\begin{theorem}%\n";
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-05-23 08:59:47 +00:00
|
|
|
|
int i = inset.latex(buf, os, runparams);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
os << "\\end{theorem}%\n";
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
return i + 2;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|