]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNote.cpp
Fix for bug 4135
[lyx.git] / src / insets / InsetNote.cpp
index 9324af15e504b198aca4314d51fef3f46306a272..7e408255f7b38fe3ea16f7916d84351eda594823 100644 (file)
@@ -17,6 +17,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "BufferParams.h"
 #include "Counters.h"
 #include "Cursor.h"
 #include "debug.h"
@@ -111,24 +112,19 @@ void InsetNoteParams::read(Lexer & lex)
 }
 
 
-void InsetNote::init()
-{
-       setButtonLabel();
-}
-
-
 InsetNote::InsetNote(BufferParams const & bp, string const & label)
        : InsetCollapsable(bp)
 {
        params_.type = notetranslator().find(label);
-       init();
+       setLayout(bp);
+       setButtonLabel();
 }
 
 
 InsetNote::InsetNote(InsetNote const & in)
        : InsetCollapsable(in), params_(in.params_)
 {
-       init();
+       setButtonLabel();
 }
 
 
@@ -150,6 +146,12 @@ docstring const InsetNote::editMessage() const
 }
 
 
+docstring InsetNote::name() const 
+{
+       return from_ascii(string("Note") + string(":") + string(notetranslator().find(params_.type)));
+}
+
+
 Inset::DisplayType InsetNote::display() const
 {
        switch (params_.type) {
@@ -173,6 +175,7 @@ void InsetNote::read(Buffer const & buf, Lexer & lex)
 {
        params_.read(lex);
        InsetCollapsable::read(buf, lex);
+       setLayout(buf.params());
        setButtonLabel();
 }
 
@@ -181,31 +184,7 @@ void InsetNote::setButtonLabel()
 {
        docstring const label = notetranslator_loc().find(params_.type);
        setLabel(label);
-
-       Font font(Font::ALL_SANE);
-       font.decSize();
-       font.decSize();
-
-       Color_color c;
-       switch (params_.type) {
-       case InsetNoteParams::Note:
-               c = Color::note;
-               break;
-       case InsetNoteParams::Comment:
-               c = Color::comment;
-               break;
-       case InsetNoteParams::Greyedout:
-               c = Color::greyedout;
-               break;
-       case InsetNoteParams::Framed:
-               c = Color::greyedout;
-               break;
-       case InsetNoteParams::Shaded:
-               c = Color::greyedout;
-               break;
-       }
-       font.setColor(c);
-       setLabelFont(font);
+       setLabelFont(layout_.labelfont);
 }
 
 
@@ -246,6 +225,8 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_INSET_MODIFY:
                InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_);
+               // get a bp from cur:
+               setLayout(cur.buffer().params());
                setButtonLabel();
                break;