]> git.lyx.org Git - features.git/blob - src/insets/insetfoot.C
several changes and some new insets, read the Changelog
[features.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 "lyxtext.h"
22 #include "support/LOstream.h"
23
24 using std::ostream;
25 using std::endl;
26
27 InsetFoot::InsetFoot() : InsetCollapsable()
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     setInsetName("Foot");
37 }
38
39
40 void InsetFoot::Write(Buffer const * buf, ostream & os) const 
41 {
42         os << getInsetName() << "\n";
43         InsetCollapsable::Write(buf, os);
44 }
45
46
47 Inset * InsetFoot::Clone() const
48 {
49     InsetFoot * result = new InsetFoot;
50     result->init(this);
51
52     result->collapsed = collapsed;
53     return result;
54 }
55
56
57 char const * InsetFoot::EditMessage() const
58 {
59     return _("Opened Footnote Inset");
60 }
61
62
63 int InsetFoot::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
64 {
65     os << "\\footnote{%\n";
66     
67     int i = InsetText::Latex(buf, os, fragile, fp);
68     os << "}%\n";
69     
70     return i + 2;
71 }
72
73
74 bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
75 {
76     if (!InsertInsetAllowed(inset))
77         return false;
78
79     return InsetText::InsertInset(bv, inset);
80 }
81
82
83 bool InsetFoot::InsertInsetAllowed(Inset * inset) const
84 {
85     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
86         (inset->LyxCode() == Inset::MARGIN_CODE)) {
87         return false;
88     }
89     return true;
90 }
91
92
93 LyXFont InsetFoot::GetDrawFont(BufferView * bv,LyXParagraph * p, int pos) const
94 {
95     LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
96     fn.decSize().decSize();
97     return fn;
98 }