]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
delete unneeded BufferView.h declaration.
[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 #include "insettheorem.h"
14 #include "insets/insettext.h"
15
16 #include "debug.h"
17 #include "gettext.h"
18 #include "lyxfont.h"
19 #include "lyxtext.h"
20 #include "metricsinfo.h"
21
22 #include "support/std_ostream.h"
23
24 using std::endl;
25 using std::ostream;
26
27
28 /*
29   The intention is to be able to create arbitrary theorem like environments
30    sing this class and some helper/container classes. It should be possible
31    to create these theorems both from layout file and interactively by the
32    user.
33 */
34
35 InsetTheorem::InsetTheorem()
36         : InsetCollapsable()
37 {
38         setLabel(_("theorem"));
39         LyXFont font(LyXFont::ALL_SANE);
40         font.decSize();
41         font.decSize();
42         font.setColor(LColor::collapsable);
43         setLabelFont(font);
44 #if 0
45         setAutoCollapse(false);
46 #endif
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 auto_ptr<InsetBase> InsetTheorem::doClone() const
59 {
60 #ifdef WITH_WARNINGS
61 #warning Is this inset used? If YES this is WRONG!!! (Jug)
62 #endif
63         auto_ptr<InsetTheorem> result(new InsetTheorem);
64         result->setCollapsed(!isOpen());
65
66         return result;
67 }
68
69 void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
70 {
71         InsetCollapsable::metrics(mi, dim);
72         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
73         dim.wid = mi.base.textwidth;
74         dim_ = dim;
75 }
76
77
78 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
79 {
80         InsetCollapsable::draw(pi, x + center_indent_, y);
81 }
82
83
84 string const InsetTheorem::editMessage() const
85 {
86         return _("Opened Theorem Inset");
87 }
88
89
90 int InsetTheorem::latex(Buffer const * buf, ostream & os,
91                         OutputParams const & runparams) const
92 {
93         os << "\\begin{theorem}%\n";
94
95         int i = inset.latex(buf, os, runparams);
96         os << "\\end{theorem}%\n";
97
98         return i + 2;
99 }