]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
Rename ascii to plaintext and LatexRunParams to OutputParams.
[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 "BufferView.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "lyxtext.h"
21 #include "metricsinfo.h"
22
23 #include "support/std_ostream.h"
24
25 using std::endl;
26 using std::ostream;
27
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 #if 0
46         setAutoCollapse(false);
47 #endif
48         setInsetName("Theorem");
49 }
50
51
52 void InsetTheorem::write(Buffer const * buf, ostream & os) const
53 {
54         os << getInsetName() << "\n";
55         InsetCollapsable::write(buf, os);
56 }
57
58
59 auto_ptr<InsetBase> InsetTheorem::clone() const
60 {
61 #ifdef WITH_WARNINGS
62 #warning Is this inset used? If YES this is WRONG!!! (Jug)
63 #endif
64         auto_ptr<InsetTheorem> result(new InsetTheorem);
65         result->setCollapsed(!isOpen());
66
67         return result;
68 }
69
70 void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
71 {
72         InsetCollapsable::metrics(mi, dim);
73         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
74         dim.wid = mi.base.textwidth;
75         dim_ = dim;
76 }
77
78
79 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
80 {
81         InsetCollapsable::draw(pi, x + center_indent_, y);
82 }
83
84
85 string const InsetTheorem::editMessage() const
86 {
87         return _("Opened Theorem Inset");
88 }
89
90
91 int InsetTheorem::latex(Buffer const * buf, ostream & os,
92                         OutputParams const & runparams) const
93 {
94         os << "\\begin{theorem}%\n";
95
96         int i = inset.latex(buf, os, runparams);
97         os << "\\end{theorem}%\n";
98
99         return i + 2;
100 }