]> git.lyx.org Git - lyx.git/blob - src/insets/insetnote.C
remove lowercase, better layout handling and some variable renameing
[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
32 void InsetNote::init()
33 {
34         LyXFont font(LyXFont::ALL_SANE);
35         font.decSize();
36         font.setColor(LColor::note);
37         setLabelFont(font);
38         setBackgroundColor(LColor::notebg);
39         setLabel(_("note"));
40         setInsetName("Note");
41 }
42
43
44 InsetNote::InsetNote(BufferParams const & bp)
45         : InsetCollapsable(bp)
46 {
47         init();
48 }
49
50
51 InsetNote::InsetNote(InsetNote const & in, bool same_id)
52         : InsetCollapsable(in, same_id)
53 {
54         init();
55 }
56
57
58 Inset * InsetNote::clone(Buffer const &, bool same_id) const
59 {
60         return new InsetNote(*const_cast<InsetNote *>(this), same_id);
61 }
62
63
64 // This constructor is used for reading old InsetInfo
65 InsetNote::InsetNote(Buffer const * buf, string const & contents, 
66                      bool collapsed)
67         : InsetCollapsable(buf->params, collapsed)
68 {
69         init();
70
71         Paragraph * par = inset.paragraph();
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         lyx::pos_type pos = 0;
80         buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
81 }
82
83
84 string const InsetNote::editMessage() const 
85 {
86         return _("Opened Note Inset");
87 }
88
89
90 void InsetNote::write(Buffer const *buf, ostream & os) const
91 {
92         os << getInsetName() << "\n";
93         InsetCollapsable::write(buf, os);
94 }