]> git.lyx.org Git - features.git/commitdiff
the environment insets. not active yet.
authorAndré Pönitz <poenitz@gmx.net>
Thu, 13 Mar 2003 10:06:11 +0000 (10:06 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 13 Mar 2003 10:06:11 +0000 (10:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6477 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Makefile.am
src/insets/inset.h
src/insets/insetenv.C [new file with mode: 0644]
src/insets/insetenv.h [new file with mode: 0644]

index 911a3f1d7cd8ae0ba9f549744ecbd74ebfbd44b6..ff82b7183b1d72a0a6900b801b01248fd2357334 100644 (file)
@@ -37,6 +37,8 @@ libinsets_la_SOURCES = \
        insetcommand.h \
        insetcommandparams.C \
        insetcommandparams.h \
+       insetenv.C \
+       insetenv.h \
        inseterror.C \
        inseterror.h \
        insetert.C \
index 42220642559a3082b15144b90a110576a4b76940..d75ac50cf64683a15122bed386f4ca44ee32bb2c 100644 (file)
@@ -125,6 +125,8 @@ public:
                ///
                OPTARG_CODE,
                ///
+               ENVIRONMENT_CODE, 
+               ///
                HFILL_CODE,
                ///
                NEWLINE_CODE
diff --git a/src/insets/insetenv.C b/src/insets/insetenv.C
new file mode 100644 (file)
index 0000000..74c200c
--- /dev/null
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+/**
+ * \file insetenv.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include "insetenv.h"
+#include "gettext.h"
+#include "lyxtextclass.h"
+#include "lyxlayout.h"
+#include "bufferparams.h"
+#include "support/LOstream.h"
+#include "debug.h"
+
+
+using std::ostream;
+using std::endl;
+
+
+InsetEnvironment::InsetEnvironment
+               (BufferParams const & bp, string const & name)
+       : InsetCollapsable(bp)
+{
+       setLabel(name);
+       setInsetName(name);
+       // needs more stuff in lyxlayout. coming in later patches.
+       //LyXTextClass const & tc = bp.getLyXTextClass();
+       //LyXLayout_ptr const & layout = tc.getEnv(name);
+       //header_ = layout->latexheader;
+       //footer_ = layout->latexfooter;
+}
+
+
+InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
+       : InsetCollapsable(in, same_id), header_(in.header_), footer_(in.footer_)
+{}
+
+
+Inset * InsetEnvironment::clone(Buffer const &, bool same_id) const
+{
+       return new InsetEnvironment(*this, same_id);
+}
+
+
+void InsetEnvironment::write(Buffer const * buf, ostream & os) const
+{
+       os << "Environment" << getInsetName() << "\"\n";
+       InsetCollapsable::write(buf, os);
+}
+
+
+void InsetEnvironment::read(Buffer const * buf, LyXLex & lex)
+{
+       InsetCollapsable::read(buf, lex);
+}
+
+
+string const InsetEnvironment::editMessage() const
+{
+       return _("Opened Environment Inset: ") + getInsetName();
+}
+
+
+int InsetEnvironment::latex(Buffer const * buf,
+                        ostream & os, bool fragile, bool fp) const
+{
+       os << header_;
+       int i = inset.latex(buf, os, fragile, fp);
+       os << footer_;
+       return i;
+}
diff --git a/src/insets/insetenv.h b/src/insets/insetenv.h
new file mode 100644 (file)
index 0000000..9eb4db1
--- /dev/null
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+/**
+ * \file insetenv.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef INSETENVIRONMENT_H
+#define INSETENVIRONMENT_H
+
+#include "insetcollapsable.h"
+
+
+class InsetEnvironment : public InsetCollapsable {
+public:
+       ///
+       InsetEnvironment(BufferParams const &, string const & name);
+       ///
+       InsetEnvironment(InsetEnvironment const &, bool same_id = false);
+       ///
+       void write(Buffer const * buf, std::ostream & os) const;
+       ///
+       void read(Buffer const * buf, LyXLex & lex);
+       ///
+       Inset * clone(Buffer const &, bool same_id = false) const;
+       ///
+       Inset::Code lyxCode() const { return Inset::ENVIRONMENT_CODE; }
+       ///
+       int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+       ///
+       string const editMessage() const;
+       ///
+       bool needFullRow() const { return true; }
+       /** returns true if, when outputing LaTeX, font changes should
+            be closed before generating this inset. This is needed for
+            insets that may contain several paragraphs */
+       bool noFontChange() const { return true; }
+
+private:
+       /// LaTeX footer
+       string header_;
+       /// LaTeX footer
+       string footer_;
+};
+
+#endif