]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetmarginal.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetmarginal.C
index 546a36c124f93900c37453fa0e4ff792e14974ea..c8f418bcb062c813609ddd6fbb050268e5090c1e 100644 (file)
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *          Copyright 1998 The LyX Team.
+/**
+ * \file insetmarginal.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * ======================================================
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "insetmarginal.h"
+
 #include "gettext.h"
-#include "lyxfont.h"
-#include "BufferView.h"
-#include "Painter.h"
-#include "lyxtext.h"
-#include "support/LOstream.h"
+#include "paragraph.h"
 
-using std::ostream;
-using std::endl;
+#include "support/std_ostream.h"
 
-InsetMarginal::InsetMarginal()
-       : InsetCollapsable()
-{
-    setLabel(_("margin"));
-    LyXFont font(LyXFont::ALL_SANE);
-    font.decSize();
-    font.decSize();
-    font.setColor(LColor::footnote);
-    setLabelFont(font);
-    setAutoCollapse(false);
-    setInsetName("Marginal");
-}
 
+namespace lyx {
 
-void InsetMarginal::Write(Buffer const * buf, ostream & os) const
-{
-    os << getInsetName() << "\n";
-    InsetCollapsable::Write(buf, os);
-}
+using std::string;
+using std::auto_ptr;
+using std::ostream;
 
 
-Inset * InsetMarginal::Clone() const
+InsetMarginal::InsetMarginal(BufferParams const & bp)
+       : InsetFootlike(bp)
 {
-    InsetMarginal * result = new InsetMarginal;
-    result->init(this);
-    
-    result->collapsed = collapsed;
-    return result;
+       setLabel(_("margin"));
+       setInsetName(from_ascii("Marginal"));
 }
 
 
-char const * InsetMarginal::EditMessage() const
+InsetMarginal::InsetMarginal(InsetMarginal const & in)
+       : InsetFootlike(in)
 {
-    return _("Opened Marginal Note Inset");
+       setLabel(_("margin"));
+       setInsetName(from_ascii("Marginal"));
 }
 
 
-int InsetMarginal::Latex(Buffer const * buf,
-                        ostream & os, bool fragile, bool fp) const
+auto_ptr<InsetBase> InsetMarginal::doClone() const
 {
-    os << "\\marginpar{%\n";
-    
-    int i = InsetText::Latex(buf, os, fragile, fp);
-    os << "}%\n";
-    
-    return i + 2;
+       return auto_ptr<InsetBase>(new InsetMarginal(*this));
 }
 
 
-bool InsetMarginal::InsertInset(BufferView * bv, Inset * inset)
+docstring const InsetMarginal::editMessage() const
 {
-    if (!InsertInsetAllowed(inset))
-       return false;
-
-    return InsetText::InsertInset(bv, inset);
+       return _("Opened Marginal Note Inset");
 }
 
 
-bool InsetMarginal::InsertInsetAllowed(Inset * inset) const
+int InsetMarginal::latex(Buffer const & buf, odocstream & os,
+                        OutputParams const & runparams) const
 {
-    if ((inset->LyxCode() == Inset::FOOT_CODE) ||
-       (inset->LyxCode() == Inset::MARGIN_CODE)) {
-       return false;
-    }
-    return true;
+       os << "%\n\\marginpar{";
+       int const i = InsetText::latex(buf, os, runparams);
+       os << "%\n}";
+       return i + 2;
 }
 
-
-LyXFont InsetMarginal::GetDrawFont(BufferView * bv,
-                                  LyXParagraph * p, int pos) const
+int InsetMarginal::docbook(Buffer const & buf, odocstream & os,
+                      OutputParams const & runparams) const
 {
-    LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
-    fn.decSize().decSize();
-    return fn;
+       os << "<note role=\"margin\">";
+       int const i = InsetText::docbook(buf, os, runparams);
+       os << "</note>";
+
+       return i;
 }
+
+
+} // namespace lyx