]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
4b09114c098ee7930528626d548f36da176c1711
[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 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "insetfoot.h"
17 #include "gettext.h"
18 #include "lyxfont.h"
19 #include "BufferView.h"
20 #include "Painter.h"
21 #include "support/LOstream.h"
22
23 using std::ostream;
24
25 InsetFoot::InsetFoot(Buffer * bf)
26                 : InsetCollapsable(bf)
27 {
28     setLabel(_("foot"));
29     LyXFont font(LyXFont::ALL_SANE);
30     font.decSize();
31     font.decSize();
32     font.setColor(LColor::footnote);
33     setLabelFont(font);
34     setAutoCollapse(false);
35     setInsetName("Foot");
36 }
37
38
39 Inset * InsetFoot::Clone() const
40 {
41     InsetFoot * result = new InsetFoot(buffer);
42     result->init(buffer, this);
43
44     result->collapsed = collapsed;
45     return result;
46 }
47
48
49 char const * InsetFoot::EditMessage() const
50 {
51     return _("Opened Footnote Inset");
52 }
53
54
55 int InsetFoot::Latex(ostream & os, bool fragile, bool fp) const
56 {
57     if (fragile) 
58         os << "\\footnote{"; // was footnotemark but that won't work
59     else 
60         os << "\\footnote{";
61     
62     int i = InsetText::Latex(os, fragile, fp);
63     os << "}";
64     
65     return i;
66 }
67
68
69 bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
70 {
71     if (!InsertInsetAllowed(inset))
72         return false;
73
74     return InsetText::InsertInset(bv, inset);
75 }
76
77 bool InsetFoot::InsertInsetAllowed(Inset * inset) const
78 {
79     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
80         (inset->LyxCode() == Inset::MARGIN_CODE)) {
81         return false;
82     }
83     return true;
84 }
85
86 LyXFont InsetFoot::GetDrawFont(LyXParagraph * par, int pos) const
87 {
88     LyXFont fn = InsetCollapsable::GetDrawFont(par, pos);
89     fn.decSize();
90     fn.decSize();
91     return fn;
92 }