]> git.lyx.org Git - features.git/blob - src/insets/insetmarginal.C
9a592c972bf0433454772bd0b8875ba0548c7d9a
[features.git] / src / insets / insetmarginal.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 "insetmarginal.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 InsetMarginal::InsetMarginal() : InsetCollapsable()
28 {
29         setLabel(_("margin"));
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("Marginal");
37 }
38
39
40 Inset * InsetMarginal::Clone() const
41 {
42         InsetMarginal * result = new InsetMarginal;
43         result->init(this);
44
45         result->collapsed = collapsed;
46         return result;
47 }
48
49
50 char const * InsetMarginal::EditMessage() const
51 {
52         return _("Opened Marginal Note Inset");
53 }
54
55
56 int InsetMarginal::Latex(Buffer const * buf,
57                          ostream & os, bool fragile, bool fp) const
58 {
59     os << "\\marginpar{%" << endl;
60     
61     int i = InsetText::Latex(buf, os, fragile, fp);
62     os << "}%" << endl;
63     
64     return i + 2;
65 }
66
67
68 bool InsetMarginal::InsertInset(BufferView * bv, Inset * inset)
69 {
70     if (!InsertInsetAllowed(inset))
71         return false;
72
73     return InsetText::InsertInset(bv, inset);
74 }
75
76
77 bool InsetMarginal::InsertInsetAllowed(Inset * inset) const
78 {
79     if ((inset->LyxCode() == Inset::FOOT_CODE) ||
80         (inset->LyxCode() == Inset::MARGIN_CODE)) {
81         return false;
82     }
83     return true;
84 }
85
86
87 LyXFont InsetMarginal::GetDrawFont(BufferView * bv,
88                                    LyXParagraph * p, int pos) const
89 {
90     LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
91     fn.decSize().decSize();
92     return fn;
93 }