]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetnote.C
index 778917944e3d58d6ceaac2fdeb8468cae7de827e..ad66b0f92c8f430cd9c70545ecfd6a0cbf8759a6 100644 (file)
@@ -7,7 +7,7 @@
  * \author Martin Vermeer
  * \author Jürgen Spitzmüller
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
@@ -15,6 +15,7 @@
 #include "Lsstream.h"
 
 #include "insetnote.h"
+#include "metricsinfo.h"
 #include "gettext.h"
 #include "lyxfont.h"
 #include "language.h"
@@ -73,14 +74,14 @@ string const InsetNote::editMessage() const
 }
 
 
-void InsetNote::write(Buffer const * buf, ostream & os) const
+void InsetNote::write(Buffer const & buf, ostream & os) const
 {
        params_.write(os);
        InsetCollapsable::write(buf, os);
 }
 
 
-void InsetNote::read(Buffer const * buf, LyXLex & lex)
+void InsetNote::read(Buffer const & buf, LyXLex & lex)
 {
        InsetCollapsable::read(buf, lex);
        setButtonLabel();
@@ -110,6 +111,18 @@ void InsetNote::setButtonLabel()
 }
 
 
+void InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCollapsable::metrics(mi, dim);
+       // Contrary to Greyedout, these cannot be construed as part of the
+       // running text: make them stand on their own
+       if (params_.type == "Note" || params_.type == "Comment")
+               if (!collapsed_)
+                       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
 bool InsetNote::showInsetDialog(BufferView * bv) const
 {
        InsetNoteMailer("note", const_cast<InsetNote &>(*this)).showDialog(bv);
@@ -128,7 +141,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd)
                InsetNoteMailer::string2params(cmd.argument, params);
                params_.type = params.type;
                setButtonLabel();
-               bv->updateInset();
+               bv->updateInset(this);
                return DISPATCHED;
        }
 
@@ -154,7 +167,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd)
 }
 
 
-int InsetNote::latex(Buffer const * buf, ostream & os,
+int InsetNote::latex(Buffer const & buf, ostream & os,
                                                LatexRunParams const & runparams) const
 {
        string const pt = params_.type;
@@ -172,16 +185,16 @@ int InsetNote::latex(Buffer const * buf, ostream & os,
 
        if (pt == "Comment") {
                os << "%\n\\end{comment}\n";
-               i += 3;
+               i += 4;
        } else if (pt == "Greyedout") {
                os << "%\n\\end{lyxgreyedout}\n";
-               i += 2;
-       }
+               i += 4;
+       } 
        return i;
 }
 
 
-int InsetNote::linuxdoc(Buffer const * buf, std::ostream & os) const
+int InsetNote::linuxdoc(Buffer const & buf, std::ostream & os) const
 {
        string const pt = params_.type;
 
@@ -200,7 +213,7 @@ int InsetNote::linuxdoc(Buffer const * buf, std::ostream & os) const
 }
 
 
-int InsetNote::docbook(Buffer const * buf, std::ostream & os, bool mixcont) const
+int InsetNote::docbook(Buffer const & buf, std::ostream & os, bool mixcont) const
 {
        string const pt = params_.type;
 
@@ -219,7 +232,7 @@ int InsetNote::docbook(Buffer const * buf, std::ostream & os, bool mixcont) cons
 }
 
 
-int InsetNote::ascii(Buffer const * buf, std::ostream & os, int ll) const
+int InsetNote::ascii(Buffer const & buf, std::ostream & os, int ll) const
 {
        int i = 0;
        string const pt = params_.type;