]> git.lyx.org Git - lyx.git/blob - src/insets/insetnote.C
f07462f0f35da9313a80e60c908b04bddc07f860
[lyx.git] / src / insets / insetnote.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 "insetnote.h"
18 #include "gettext.h"
19 #include "lyxfont.h"
20 #include "language.h"
21 #include "buffer.h"
22 #include "BufferView.h"
23 #include "lyxtext.h"
24 #include "insets/insettext.h"
25 #include "support/LOstream.h"
26 #include "support/lstrings.h"
27 #include "debug.h"
28
29 using std::ostream;
30
31 void InsetNote::init()
32 {
33         LyXFont font(LyXFont::ALL_SANE);
34         font.decSize();
35         font.setColor(LColor::note);
36         setLabelFont(font);
37         setBackgroundColor(LColor::note);
38         setLabel(_("note"));
39         setInsetName("Note");
40 }
41
42
43 InsetNote::InsetNote()
44         : InsetCollapsable()
45 {
46         init();
47 }
48
49
50 InsetNote::InsetNote(InsetNote const & in, bool same_id)
51         : InsetCollapsable(in, same_id)
52 {
53         init();
54 }
55
56
57 Inset * InsetNote::clone(Buffer const &, bool same_id) const
58 {
59         return new InsetNote(*const_cast<InsetNote *>(this), same_id);
60 }
61
62
63 // This constructor is used for reading old InsetInfo
64 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
65                      bool collapsed)
66         : InsetCollapsable(collapsed)
67 {
68         init();
69
70         Paragraph * par = inset.paragraph();
71         Paragraph::pos_type pos = 0;
72         LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);
73
74         // Since XForms doesn't support RTL, we can assume that old notes
75         // in RTL documents are written in English.
76         if (font.language()->RightToLeft())
77                 font.setLanguage(default_language);
78
79         buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
80 }
81
82
83 string const InsetNote::editMessage() const 
84 {
85         return _("Opened Note Inset");
86 }
87
88
89 void InsetNote::write(Buffer const *buf, ostream & os) const
90 {
91         os << getInsetName() << "\n";
92         InsetCollapsable::write(buf, os);
93 }