]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
Fix crash when running lyx -dbg insets -e ...
[lyx.git] / src / insets / insettheorem.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1998 The LyX Team.
7  *
8  * ======================================================
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insettheorem.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "BufferView.h"
21 #include "lyxtext.h"
22 #include "support/LOstream.h"
23 #include "debug.h"
24 #include "insets/insettext.h"
25
26 using std::ostream;
27 using std::endl;
28
29 /*
30   The intention is to be able to create arbitrary theorem like environments
31    sing this class and some helper/container classes. It should be possible
32    to create these theorems both from layout file and interactively by the
33    user.
34 */
35
36 InsetTheorem::InsetTheorem()
37         : InsetCollapsable()
38 {
39         setLabel(_("theorem"));
40         LyXFont font(LyXFont::ALL_SANE);
41         font.decSize();
42         font.decSize();
43         font.setColor(LColor::collapsable);
44         setLabelFont(font);
45         setAutoCollapse(false);
46         setInsetName("Theorem");
47 }
48
49
50 void InsetTheorem::write(Buffer const * buf, ostream & os) const 
51 {
52         os << getInsetName() << "\n";
53         InsetCollapsable::write(buf, os);
54 }
55
56
57 Inset * InsetTheorem::clone(Buffer const &, bool) const
58 {
59 #warning Is this inset used? If YES this is WRONG!!! (Jug)
60         InsetTheorem * result = new InsetTheorem;
61         
62         result->collapsed_ = collapsed_;
63         return result;
64 }
65
66
67 string const InsetTheorem::editMessage() const
68 {
69         return _("Opened Theorem Inset");
70 }
71
72
73 int InsetTheorem::latex(Buffer const * buf,
74                         ostream & os, bool fragile, bool fp) const
75 {
76         os << "\\begin{theorem}%\n";
77         
78         int i = inset.latex(buf, os, fragile, fp);
79         os << "\\end{theorem}%\n";
80         
81         return i + 2;
82 }