]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTheorem.cpp
Fix text frame drawing.
[lyx.git] / src / insets / InsetTheorem.cpp
1 /**
2  * \file Inset.heorem.cpp
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 "Inset.heorem.h"
14 #include "insets/InsetText.h"
15
16 #include "debug.h"
17 #include "gettext.h"
18 #include "Font.h"
19 #include "Text.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 Inset.heorem::InsetTheorem()
39         : InsetCollapsable()
40 {
41         setLabel(_("theorem"));
42         Font font(Font::ALL_SANE);
43         font.decSize();
44         font.decSize();
45         font.setColor(Color::collapsable);
46         setLabelFont(font);
47 #if 0
48         setAutoCollapse(false);
49 #endif
50         setInsetName("Theorem");
51 }
52
53
54 void Inset.heorem::write(Buffer const * buf, ostream & os) const
55 {
56         os << name() << "\n";
57         InsetCollapsable::write(buf, os);
58 }
59
60
61 Inset * InsetTheorem::clone() const
62 {
63         // FIXME: Is this inset used? If YES this is WRONG!!! (Jug)
64         InsetTheorem * result = new InsetTheorem;
65         result->setCollapsed(!isOpen());
66         return result;
67 }
68
69
70 bool Inset.heorem::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         bool const changed = dim_ != dim;
76         dim_ = dim;
77         return changed;
78 }
79
80
81 void InsetTOC::draw(PainterInfo & pi, int x, int y) const
82 {
83         InsetCollapsable::draw(pi, x + center_indent_, y);
84 }
85
86
87 string const Inset.heorem::editMessage() const
88 {
89         return _("Opened Theorem Inset");
90 }
91
92
93 int Inset.heorem::latex(Buffer const * buf, odocstream & os,
94                         OutputParams const & runparams) const
95 {
96         os << "\\begin{theorem}%\n";
97
98         int i = inset.latex(buf, os, runparams);
99         os << "\\end{theorem}%\n";
100
101         return i + 2;
102 }
103
104
105 } // namespace lyx