]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNote.cpp
Fix text frame drawing.
[lyx.git] / src / insets / InsetNote.cpp
index 1406d0c6873d26340279730d7e140fd0fb230d00..50382349bdb20fffcdb944bbcec2e41a440a0777 100644 (file)
 #include "InsetNote.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferView.h"
+#include "BufferParams.h"
+#include "Counters.h"
 #include "Cursor.h"
 #include "debug.h"
 #include "DispatchResult.h"
@@ -37,7 +40,6 @@
 namespace lyx {
 
 using std::string;
-using std::auto_ptr;
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
@@ -109,24 +111,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();
 }
 
 
@@ -136,9 +133,9 @@ InsetNote::~InsetNote()
 }
 
 
-auto_ptr<Inset> InsetNote::doClone() const
+Inset * InsetNote::clone() const
 {
-       return auto_ptr<Inset>(new InsetNote(*this));
+       return new InsetNote(*this);
 }
 
 
@@ -148,6 +145,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) {
@@ -171,6 +174,7 @@ void InsetNote::read(Buffer const & buf, Lexer & lex)
 {
        params_.read(lex);
        InsetCollapsable::read(buf, lex);
+       setLayout(buf.params());
        setButtonLabel();
 }
 
@@ -179,55 +183,6 @@ 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);
-}
-
-
-Color_color InsetNote::backgroundColor() const
-{
-       Color_color c;
-       switch (params_.type) {
-       case InsetNoteParams::Note:
-               c = Color::notebg;
-               break;
-       case InsetNoteParams::Comment:
-               c = Color::commentbg;
-               break;
-       case InsetNoteParams::Greyedout:
-               c = Color::greyedoutbg;
-               break;
-       case InsetNoteParams::Framed:
-               c = Color::greyedoutbg;
-               break;
-       case InsetNoteParams::Shaded:
-               c = Color::shadedbg;
-               break;
-       }
-       return c;
 }
 
 
@@ -244,20 +199,14 @@ 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;
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetNoteMailer(*this).updateDialog(&cur.bv());
                break;
-
-       case LFUN_MOUSE_RELEASE:
-               if (cmd.button() == mouse_button::button3 && hitButton(cmd))
-                       InsetNoteMailer(*this).showDialog(&cur.bv());
-               else
-                       InsetCollapsable::doDispatch(cur, cmd);
-               break;
-
        default:
                InsetCollapsable::doDispatch(cur, cmd);
                break;
@@ -280,6 +229,14 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
 }
 
+void InsetNote::updateLabels(Buffer const & buf, ParIterator const & it)
+{
+       TextClass const & tclass = buf.params().getTextClass();
+       Counters savecnt = tclass.counters();
+       InsetCollapsable::updateLabels(buf, it);
+       tclass.counters() = savecnt;
+}
+
 
 int InsetNote::latex(Buffer const & buf, odocstream & os,
                     OutputParams const & runparams_in) const
@@ -288,23 +245,14 @@ int InsetNote::latex(Buffer const & buf, odocstream & os,
                return 0;
 
        OutputParams runparams(runparams_in);
-       string type;
        if (params_.type == InsetNoteParams::Comment) {
-               type = "comment";
                runparams.inComment = true;
                // Ignore files that are exported inside a comment
                runparams.exportdata.reset(new ExportData);
-       } else if (params_.type == InsetNoteParams::Greyedout)
-               type = "lyxgreyedout";
-       else if (params_.type == InsetNoteParams::Framed)
-               type = "framed";
-       else if (params_.type == InsetNoteParams::Shaded)
-               type = "shaded";
+       } 
 
        odocstringstream ss;
-       ss << "%\n\\begin{" << from_ascii(type) << "}\n";
-       InsetText::latex(buf, ss, runparams);
-       ss << "\n\\end{" << from_ascii(type) << "}\n";
+       InsetCollapsable::latex(buf, ss, runparams);
        // the space after the comment in 'a[comment] b' will be eaten by the
        // comment environment since the space before b is ignored with the
        // following latex output: