-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1998 The LyX Team.
+/**
+ * \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>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "insettheorem.h"
+#include "insets/insettext.h"
+
+#include "debug.h"
+#include "BufferView.h"
#include "gettext.h"
#include "lyxfont.h"
-#include "BufferView.h"
-#include "Painter.h"
#include "lyxtext.h"
-#include "support/LOstream.h"
-#include "debug.h"
-#include "insets/insettext.h"
+#include "metricsinfo.h"
+
+#include "support/std_ostream.h"
-using std::ostream;
using std::endl;
+using std::ostream;
+
/*
The intention is to be able to create arbitrary theorem like environments
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
font.decSize();
- font.setColor(LColor::footnote);
+ font.setColor(LColor::collapsable);
setLabelFont(font);
+#if 0
setAutoCollapse(false);
+#endif
setInsetName("Theorem");
}
-void InsetTheorem::Write(Buffer const * buf, ostream & os) const
+void InsetTheorem::write(Buffer const * buf, ostream & os) const
{
os << getInsetName() << "\n";
- InsetCollapsable::Write(buf, os);
+ InsetCollapsable::write(buf, os);
}
-Inset * InsetTheorem::Clone() const
+InsetBase * InsetTheorem::clone() const
{
+#ifdef WITH_WARNINGS
+#warning Is this inset used? If YES this is WRONG!!! (Jug)
+#endif
InsetTheorem * result = new InsetTheorem;
-
- result->collapsed = collapsed;
+
+ result->collapsed_ = collapsed_;
return result;
}
-
-char const * InsetTheorem::EditMessage() const
+void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
{
- return _("Opened Theorem Inset");
+ InsetCollapsable::metrics(mi, dim);
+ center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+ dim.wid = mi.base.textwidth;
+ dim_ = dim;
}
-int InsetTheorem::Latex(Buffer const * buf,
- ostream & os, bool fragile, bool fp) const
+void InsetTOC::draw(PainterInfo & pi, int x, int y) const
{
- os << "\\begin{theorem}%\n";
-
- int i = inset->Latex(buf, os, fragile, fp);
- os << "\\end{theorem}%\n";
-
- return i + 2;
+ InsetCollapsable::draw(pi, x + center_indent_, y);
}
-bool InsetTheorem::InsertInsetAllowed(Inset * inset) const
+string const InsetTheorem::editMessage() const
{
- lyxerr << "InsetTheorem::InsertInsetAllowed" << endl;
-
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
- return false;
- }
- return true;
+ return _("Opened Theorem Inset");
}
-#if 0
-LyXFont InsetTheorem::GetDrawFont(BufferView * bv,
- LyXParagraph * p, int pos) const
+int InsetTheorem::latex(Buffer const * buf, ostream & os,
+ LatexRunParams const & runparams) const
{
- LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
- fn.decSize().decSize();
- return fn;
+ os << "\\begin{theorem}%\n";
+
+ int i = inset.latex(buf, os, runparams);
+ os << "\\end{theorem}%\n";
+
+ return i + 2;
}
-#endif