]> git.lyx.org Git - lyx.git/blob - src/insets/insetmarginal.C
Some more changes for updating text-insets.
[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
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insetmarginal.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "BufferView.h"
21 #include "Painter.h"
22 #include "lyxtext.h"
23 #include "insets/insettext.h"
24 #include "support/LOstream.h"
25
26 using std::ostream;
27 using std::endl;
28
29 InsetMarginal::InsetMarginal()
30         : InsetCollapsable()
31 {
32     setLabel(_("margin"));
33     LyXFont font(LyXFont::ALL_SANE);
34     font.decSize();
35     font.decSize();
36     font.setColor(LColor::footnote);
37     setLabelFont(font);
38     setAutoCollapse(false);
39     setInsetName("Marginal");
40 }
41
42
43 void InsetMarginal::Write(Buffer const * buf, ostream & os) const
44 {
45     os << getInsetName() << "\n";
46     InsetCollapsable::Write(buf, os);
47 }
48
49
50 Inset * InsetMarginal::Clone() const
51 {
52     InsetMarginal * result = new InsetMarginal;
53     result->inset->init(inset);
54     
55     result->collapsed = collapsed;
56     return result;
57 }
58
59
60 char const * InsetMarginal::EditMessage() const
61 {
62     return _("Opened Marginal Note Inset");
63 }
64
65
66 int InsetMarginal::Latex(Buffer const * buf,
67                          ostream & os, bool fragile, bool fp) const
68 {
69     os << "\\marginpar{%\n";
70     
71     int i = inset->Latex(buf, os, fragile, fp);
72     os << "}%\n";
73     
74     return i + 2;
75 }
76
77
78 bool InsetMarginal::InsertInset(BufferView * bv, Inset * in)
79 {
80     if (!InsertInsetAllowed(in))
81         return false;
82
83     return inset->InsertInset(bv, in);
84 }
85
86
87 bool InsetMarginal::InsertInsetAllowed(Inset * in) const
88 {
89     if ((in->LyxCode() == Inset::FOOT_CODE) ||
90         (in->LyxCode() == Inset::MARGIN_CODE)) {
91         return false;
92     }
93     return true;
94 }
95
96 #if 0
97 LyXFont InsetMarginal::GetDrawFont(BufferView * bv,
98                                    LyXParagraph * p, int pos) const
99 {
100     LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
101     fn.decSize().decSize();
102     return fn;
103 }
104 #endif