mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 23:15:19 +00:00
e24bf64c68
* InsetBase and all derivates: - metrics(MetricsInfo & mi, Dimension & dim) now returns a bool (true if metrics changed). * MathData and all derivates: - metrics(MetricsInfo & mi, Dimension & dim): ditto. * RenderBase and all derivates: - metrics(MetricsInfo & mi, Dimension & dim): ditto. * lyxtext.h/text.C: - LyXText::metrics(MetricsInfo & mi, Dimension & dim): ditto. - LyXText::redoParagraph(): take into account potential change in inset metrics. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16091 a592a061-630c-0410-9148-cb99ea01b6c8
108 lines
2.1 KiB
C
108 lines
2.1 KiB
C
/**
|
|
* \file insettheorem.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>
|
|
|
|
#include "insettheorem.h"
|
|
#include "insets/insettext.h"
|
|
|
|
#include "debug.h"
|
|
#include "gettext.h"
|
|
#include "lyxfont.h"
|
|
#include "lyxtext.h"
|
|
#include "metricsinfo.h"
|
|
|
|
#include "support/std_ostream.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
using std::endl;
|
|
using std::ostream;
|
|
|
|
|
|
/*
|
|
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();
|
|
font.setColor(LColor::collapsable);
|
|
setLabelFont(font);
|
|
#if 0
|
|
setAutoCollapse(false);
|
|
#endif
|
|
setInsetName("Theorem");
|
|
}
|
|
|
|
|
|
void InsetTheorem::write(Buffer const * buf, ostream & os) const
|
|
{
|
|
os << getInsetName() << "\n";
|
|
InsetCollapsable::write(buf, os);
|
|
}
|
|
|
|
|
|
auto_ptr<InsetBase> InsetTheorem::doClone() const
|
|
{
|
|
#ifdef WITH_WARNINGS
|
|
#warning Is this inset used? If YES this is WRONG!!! (Jug)
|
|
#endif
|
|
auto_ptr<InsetTheorem> result(new InsetTheorem);
|
|
result->setCollapsed(!isOpen());
|
|
|
|
return result;
|
|
}
|
|
|
|
bool InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
InsetCollapsable::metrics(mi, dim);
|
|
center_indent_ = (mi.base.textwidth - dim.wid) / 2;
|
|
dim.wid = mi.base.textwidth;
|
|
bool const changed = dim_ != dim;
|
|
dim_ = dim;
|
|
return changed;
|
|
}
|
|
|
|
|
|
void InsetTOC::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
InsetCollapsable::draw(pi, x + center_indent_, y);
|
|
}
|
|
|
|
|
|
string const InsetTheorem::editMessage() const
|
|
{
|
|
return _("Opened Theorem Inset");
|
|
}
|
|
|
|
|
|
int InsetTheorem::latex(Buffer const * buf, odocstream & os,
|
|
OutputParams const & runparams) const
|
|
{
|
|
os << "\\begin{theorem}%\n";
|
|
|
|
int i = inset.latex(buf, os, runparams);
|
|
os << "\\end{theorem}%\n";
|
|
|
|
return i + 2;
|
|
}
|
|
|
|
|
|
} // namespace lyx
|