]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
818db8b97ad19cda82f78262f251092c1d46d4be
[lyx.git] / src / insets / insetfoot.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1998 The LyX Team.
7  *
8  * ======================================================
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insetfoot.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "BufferView.h"
21 #include "Painter.h"
22 #include "lyxtext.h"
23 #include "support/LOstream.h"
24
25 using std::ostream;
26 using std::endl;
27
28 InsetFoot::InsetFoot() : InsetCollapsable()
29 {
30     setLabel(_("foot"));
31     LyXFont font(LyXFont::ALL_SANE);
32     font.decSize();
33     font.decSize();
34     font.setColor(LColor::footnote);
35     setLabelFont(font);
36     setAutoCollapse(false);
37     setInsetName("Foot");
38 }
39
40
41 void InsetFoot::Write(Buffer const * buf, ostream & os) const 
42 {
43     os << getInsetName() << "\n";
44     InsetCollapsable::Write(buf, os);
45 }
46
47
48 Inset * InsetFoot::Clone() const
49 {
50     InsetFoot * result = new InsetFoot;
51     result->init(this);
52
53     result->collapsed = collapsed;
54     return result;
55 }
56
57
58 char const * InsetFoot::EditMessage() const
59 {
60     return _("Opened Footnote Inset");
61 }
62
63
64 int InsetFoot::Latex(Buffer const * buf,
65                      ostream & os, bool fragile, bool fp) const
66 {
67     os << "\\footnote{%\n";
68     
69     int i = InsetText::Latex(buf, os, fragile, fp);
70     os << "}%\n";
71     
72     return i + 2;
73 }
74
75
76 bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
77 {
78     if (!InsertInsetAllowed(inset))
79         return false;
80
81     return InsetText::InsertInset(bv, inset);
82 }
83
84
85 bool InsetFoot::InsertInsetAllowed(Inset * inset) const
86 {
87     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
88         (inset->LyxCode() == Inset::MARGIN_CODE)) {
89         return false;
90     }
91     return true;
92 }
93
94
95 LyXFont InsetFoot::GetDrawFont(BufferView * bv,
96                                LyXParagraph * p, int pos) const
97 {
98     LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
99     fn.decSize().decSize();
100     return fn;
101 }