]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
170dc4ffd4825e9e3e5dc4de7967876cc3bb2ac6
[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 "lyxscreen.h"
21 #include "Painter.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 }
36
37
38 Inset * InsetFoot::Clone() const
39 {
40     InsetFoot * result = new InsetFoot(buffer);
41     result->init(buffer, par);
42
43     result->collapsed = collapsed;
44     return result;
45 }
46
47
48 char const * InsetFoot::EditMessage() const
49 {
50     return _("Opened Footnote Inset");
51 }
52
53
54 int InsetFoot::Latex(ostream & os, signed char fragile, bool fp) const
55 {
56         if (fragile) 
57                 os << "\\footnotetext{";
58         else 
59                 os << "\\footnote{";
60         
61         int i = InsetText::Latex(os, fragile, fp);
62         os << "}";
63         
64         return i;
65 }
66
67
68 void InsetFoot::Write(ostream & os) const
69 {
70         os << "Foot\n"
71            << "\ncollapsed ";
72         if (display())
73                 os << "false\n";
74         else
75                 os << "true\n";
76         WriteParagraphData(os);
77 }
78
79
80 void InsetFoot::Read(LyXLex & lex)
81 {
82     if (lex.IsOK()) {
83         lex.next();
84         string token = lex.GetString();
85         if (token == "collapsed") {
86             lex.next();
87             collapsed = lex.GetBool();
88         }
89     }
90     InsetText::Read(lex);
91 }
92
93
94 bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
95 {
96     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
97         (inset->LyxCode() == Inset::MARGIN_CODE)) {
98         return false;
99     }
100     return InsetText::InsertInset(bv, inset);
101 }