]> git.lyx.org Git - lyx.git/blob - src/insets/insettheorem.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[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
25 namespace lyx {
26
27 using std::endl;
28 using std::ostream;
29
30
31 /*
32   The intention is to be able to create arbitrary theorem like environments
33    sing this class and some helper/container classes. It should be possible
34    to create these theorems both from layout file and interactively by the
35    user.
36 */
37
38 InsetTheorem::InsetTheorem()
39         : InsetCollapsable()
40 {
41         setLabel(_("theorem"));
42         LyXFont font(LyXFont::ALL_SANE);
43         font.decSize();
44         font.decSize();
45         font.setColor(LColor::collapsable);
46         setLabelFont(font);
47 #if 0
48         setAutoCollapse(false);
49 #endif
50         setInsetName("Theorem");
51 }
52
53
54 void InsetTheorem::write(Buffer const * buf, ostream & os) const
55 {
56         os << getInsetName() << "\n";
57         InsetCollapsable::write(buf, os);
58 }
59
60
61 auto_ptr<InsetBase> InsetTheorem::doClone() const
62 {
63 #ifdef WITH_WARNINGS
64 #warning Is this inset used? If YES this is WRONG!!! (Jug)
65 #endif
66         auto_ptr<InsetTheorem> result(new InsetTheorem);
67         result->setCollapsed(!isOpen());
68
69         return result;
70 }
71
72 bool InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
73 {
74         InsetCollapsable::metrics(mi, dim);
75         center_indent_ = (mi.base.textwidth - dim.wid) / 2;
76         dim.wid = mi.base.textwidth;
77         bool const changed = dim_ != dim;
78         dim_ = dim;
79         return changed;
80 }
81
82
83 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
84 {
85         InsetCollapsable::draw(pi, x + center_indent_, y);
86 }
87
88
89 string const InsetTheorem::editMessage() const
90 {
91         return _("Opened Theorem Inset");
92 }
93
94
95 int InsetTheorem::latex(Buffer const * buf, odocstream & os,
96                         OutputParams const & runparams) const
97 {
98         os << "\\begin{theorem}%\n";
99
100         int i = inset.latex(buf, os, runparams);
101         os << "\\end{theorem}%\n";
102
103         return i + 2;
104 }
105
106
107 } // namespace lyx