]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
use the new sstream return non-pods as const, use string instead of char * in a lot...
[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::footnote);
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() const
58 {
59         InsetTheorem * result = new InsetTheorem;
60         
61         result->collapsed = collapsed;
62         return result;
63 }
64
65
66 string const InsetTheorem::EditMessage() const
67 {
68         return _("Opened Theorem Inset");
69 }
70
71
72 int InsetTheorem::Latex(Buffer const * buf,
73                         ostream & os, bool fragile, bool fp) const
74 {
75         os << "\\begin{theorem}%\n";
76         
77         int i = inset->Latex(buf, os, fragile, fp);
78         os << "\\end{theorem}%\n";
79         
80         return i + 2;
81 }
82
83
84 bool InsetTheorem::InsertInsetAllowed(Inset * inset) const
85 {
86         lyxerr << "InsetTheorem::InsertInsetAllowed" << endl;
87         
88         if ((inset->LyxCode() == Inset::FOOT_CODE) ||
89             (inset->LyxCode() == Inset::MARGIN_CODE)) {
90                 return false;
91         }
92         return true;
93 }