]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
388d876ccdabbf7bb7ff6c5a4f093705d74f0de7
[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 "Painter.h"
22 #include "lyxtext.h"
23 #include "support/LOstream.h"
24 #include "debug.h"
25 #include "insets/insettext.h"
26
27 using std::ostream;
28 using std::endl;
29
30 /*
31   The intention is to be able to create arbitrary theorem like environments
32    sing this class and some helper/container classes. It should be possible
33    to create these theorems both from layout file and interactively by the
34    user.
35 */
36
37 InsetTheorem::InsetTheorem()
38         : InsetCollapsable()
39 {
40         setLabel(_("theorem"));
41         LyXFont font(LyXFont::ALL_SANE);
42         font.decSize();
43         font.decSize();
44         font.setColor(LColor::footnote);
45         setLabelFont(font);
46         setAutoCollapse(false);
47         setInsetName("Theorem");
48 }
49
50
51 void InsetTheorem::Write(Buffer const * buf, ostream & os) const 
52 {
53         os << getInsetName() << "\n";
54         InsetCollapsable::Write(buf, os);
55 }
56
57
58 Inset * InsetTheorem::Clone() const
59 {
60         InsetTheorem * result = new InsetTheorem;
61         
62         result->collapsed = collapsed;
63         return result;
64 }
65
66
67 char 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 }
83
84
85 bool InsetTheorem::InsertInsetAllowed(Inset * inset) const
86 {
87         lyxerr << "InsetTheorem::InsertInsetAllowed" << endl;
88         
89         if ((inset->LyxCode() == Inset::FOOT_CODE) ||
90             (inset->LyxCode() == Inset::MARGIN_CODE)) {
91                 return false;
92         }
93         return true;
94 }
95
96
97 #if 0
98 LyXFont InsetTheorem::GetDrawFont(BufferView * bv,
99                                   LyXParagraph * p, int pos) const
100 {
101         LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
102         fn.decSize().decSize();
103         return fn;
104 }
105 #endif