]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insettheorem.C
1 /**
2  * \file insettheorem.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "insettheorem.h"
15 #include "metricsinfo.h"
16 #include "gettext.h"
17 #include "lyxfont.h"
18 #include "BufferView.h"
19 #include "lyxtext.h"
20 #include "support/LOstream.h"
21 #include "debug.h"
22 #include "insets/insettext.h"
23
24 using std::ostream;
25 using std::endl;
26
27 /*
28   The intention is to be able to create arbitrary theorem like environments
29    sing this class and some helper/container classes. It should be possible
30    to create these theorems both from layout file and interactively by the
31    user.
32 */
33
34 InsetTheorem::InsetTheorem()
35         : InsetCollapsable()
36 {
37         setLabel(_("theorem"));
38         LyXFont font(LyXFont::ALL_SANE);
39         font.decSize();
40         font.decSize();
41         font.setColor(LColor::collapsable);
42         setLabelFont(font);
43 #if 0
44         setAutoCollapse(false);
45 #endif
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 InsetBase * InsetTheorem::clone() const
58 {
59 #ifdef WITH_WARNINGS
60 #warning Is this inset used? If YES this is WRONG!!! (Jug)
61 #endif
62         InsetTheorem * result = new InsetTheorem;
63
64         result->collapsed_ = collapsed_;
65         return result;
66 }
67
68 void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
69 {
70         InsetCollapsable::metrics(mi, dim);
71         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
72         dim.wid = mi.base.textwidth;
73         dim_ = dim;
74 }
75
76
77 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
78 {
79         InsetCollapsable::draw(pi, x + center_indent_, y);
80 }
81
82
83 string const InsetTheorem::editMessage() const
84 {
85         return _("Opened Theorem Inset");
86 }
87
88
89 int InsetTheorem::latex(Buffer const * buf, ostream & os,
90                         LatexRunParams const & runparams) const
91 {
92         os << "\\begin{theorem}%\n";
93
94         int i = inset.latex(buf, os, runparams);
95         os << "\\end{theorem}%\n";
96
97         return i + 2;
98 }