]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
ed2fb66624d185d1956d5e0fe38848fd1ca7a9ef
[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 #include "support/LOstream.h"
23
24 using std::ostream;
25
26 InsetFoot::InsetFoot(Buffer * bf)
27                 : InsetCollapsable(bf)
28 {
29     setLabel(_("foot"));
30     LyXFont font(LyXFont::ALL_SANE);
31     font.decSize();
32     font.decSize();
33     font.setColor(LColor::footnote);
34     setLabelFont(font);
35     setAutoCollapse(false);
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 void InsetFoot::Write(ostream & os) const
70 {
71         os << "Foot\n"
72            << "\ncollapsed ";
73         if (display())
74                 os << "false\n";
75         else
76                 os << "true\n";
77         WriteParagraphData(os);
78 }
79
80
81 void InsetFoot::Read(LyXLex & lex)
82 {
83     if (lex.IsOK()) {
84         lex.next();
85         string token = lex.GetString();
86         if (token == "collapsed") {
87             lex.next();
88             collapsed = lex.GetBool();
89         }
90     }
91     InsetText::Read(lex);
92 }
93
94
95 bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
96 {
97     if (!InsertInsetAllowed(inset))
98         return false;
99
100     return InsetText::InsertInset(bv, inset);
101 }
102
103 bool InsetFoot::InsertInsetAllowed(Inset * inset) const
104 {
105     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
106         (inset->LyxCode() == Inset::MARGIN_CODE)) {
107         return false;
108     }
109     return true;
110 }
111
112 LyXFont InsetFoot::GetDrawFont(LyXParagraph * par, int pos) const
113 {
114     LyXFont fn = InsetCollapsable::GetDrawFont(par, pos);
115     fn.decSize();
116     fn.decSize();
117     return fn;
118 }