]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
3d7e76806207cbe7504e11e8976b984731760e09
[lyx.git] / src / insets / insetfoot.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright (C) 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 "lyxscreen.h"
21 #include "Painter.h"
22
23
24 InsetFoot::InsetFoot(Buffer * bf): InsetCollapsable(bf)
25 {
26     setLabel(_("foot"));
27     LyXFont font(LyXFont::ALL_SANE);
28     font.decSize();
29     font.decSize();
30     font.setColor(LColor::footnote);
31     setLabelFont(font);
32     setAutoCollapse(false);
33 }
34
35
36 InsetFoot * InsetFoot::Clone() const
37 {
38     InsetFoot * result = new InsetFoot(buffer);
39     return result;
40 }
41
42
43 const char * InsetFoot::EditMessage() const
44 {
45     return _("Opened Footnote Inset");
46 }
47
48 #ifndef USE_OSTREAM_ONLY
49 int InsetFoot::Latex(string & l, signed char fragile) const
50 {
51     int i;
52     
53     if (fragile) 
54         l += "\\footnotetext{";
55     else 
56         l += "\\footnote{";
57
58     i = InsetText::Latex(l, fragile);
59     l += "}";
60
61     return i;
62 }
63 #endif
64
65 int InsetFoot::Latex(ostream & os, signed char fragile, bool fp) const
66 {
67     int i;
68     
69     if (fragile) 
70         os << "\\footnotetext{";
71     else 
72         os << "\\footnote{";
73
74     i = InsetText::Latex(os, fragile, fp);
75     os << "}";
76
77     return i;
78 }
79
80 void InsetFoot::Write(ostream & os) const
81 {
82     os << "Foot\n";
83     os << "\ncollapsed ";
84     if (display())
85         os << "false";
86     else
87         os << "true";
88     os << "\n";
89     WriteParagraphData(os);
90 }
91
92 void InsetFoot::Read(LyXLex & lex)
93 {
94     if (lex.IsOK()) {
95         string token, tmptok;
96         
97         lex.next();
98         token = lex.GetString();
99         if (token == "collapsed") {
100             lex.next();
101             collapsed = lex.GetBool();
102         }
103     }
104     InsetText::Read(lex);
105 }
106
107 bool InsetFoot::InsertInset(BufferView *bv, Inset * inset)
108 {
109     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
110         (inset->LyxCode() == Inset::MARGIN_CODE)) {
111         return false;
112     }
113     return InsetText::InsertInset(bv, inset);
114 }