]> git.lyx.org Git - lyx.git/blob - src/insets/insetfoot.C
use more explicit on constructors use the pimpl idom to reduce size with about 500k
[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, par);
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, signed char fragile, bool fp) const
56 {
57         if (fragile) 
58                 os << "\\footnotetext{";
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 ((inset->LyxCode() == Inset::FOOT_CODE) ||
98         (inset->LyxCode() == Inset::MARGIN_CODE)) {
99         return false;
100     }
101     return InsetText::InsertInset(bv, inset);
102 }