]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettheorem.C
Rename ascii to plaintext and LatexRunParams to OutputParams.
[lyx.git] / src / insets / insettheorem.C
index 637e4933c7ba011ef69175275d33bf3bf7f39330..9f1ee9f0a023ccf97ffa404393e4c370e895b8dc 100644 (file)
@@ -1,30 +1,30 @@
-/* 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 "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
@@ -40,54 +40,61 @@ InsetTheorem::InsetTheorem()
        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(Buffer const &) const
+auto_ptr<InsetBase> InsetTheorem::clone() const
 {
-       InsetTheorem * result = new InsetTheorem;
-       
-       result->collapsed = collapsed;
+#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;
 }
 
+void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCollapsable::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
 
-string const InsetTheorem::EditMessage() const
+void InsetTOC::draw(PainterInfo & pi, int x, int y) const
 {
-       return _("Opened Theorem Inset");
+       InsetCollapsable::draw(pi, x + center_indent_, y);
 }
 
 
-int InsetTheorem::Latex(Buffer const * buf,
-                       ostream & os, bool fragile, bool fp) const
+string const InsetTheorem::editMessage() const
 {
-       os << "\\begin{theorem}%\n";
-       
-       int i = inset.Latex(buf, os, fragile, fp);
-       os << "\\end{theorem}%\n";
-       
-       return i + 2;
+       return _("Opened Theorem Inset");
 }
 
 
-bool InsetTheorem::InsertInsetAllowed(Inset * inset) const
+int InsetTheorem::latex(Buffer const * buf, ostream & os,
+                       OutputParams const & runparams) const
 {
-       lyxerr << "InsetTheorem::InsertInsetAllowed" << endl;
-       
-       if ((inset->LyxCode() == Inset::FOOT_CODE) ||
-           (inset->LyxCode() == Inset::MARGIN_CODE)) {
-               return false;
-       }
-       return true;
+       os << "\\begin{theorem}%\n";
+
+       int i = inset.latex(buf, os, runparams);
+       os << "\\end{theorem}%\n";
+
+       return i + 2;
 }