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