2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-29 13:39:47 +00:00
|
|
|
|
* \file Inset.heorem.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
#include "Inset.heorem.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetText.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFont.h"
|
|
|
|
|
#include "LyXText.h"
|
|
|
|
|
#include "MetricsInfo.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset.heorem::InsetTheorem()
|
2000-07-04 19:16:35 +00:00
|
|
|
|
: InsetCollapsable()
|
|
|
|
|
{
|
|
|
|
|
setLabel(_("theorem"));
|
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
2007-04-26 17:34:20 +00:00
|
|
|
|
font.setColor(Color::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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
void Inset.heorem::write(Buffer const * buf, ostream & os) const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
os << insetName() << "\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
|
InsetCollapsable::write(buf, os);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> Inset.heorem::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
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset.heorem> 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;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
bool Inset.heorem::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
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
string const Inset.heorem::editMessage() const
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
|
|
|
|
return _("Opened Theorem Inset");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
int Inset.heorem::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
|