]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetmarginal.C
Don't remove cell selections after fontchange.
[lyx.git] / src / insets / insetmarginal.C
index 9a592c972bf0433454772bd0b8875ba0548c7d9a..1a0eb1b5bece05e73a06a2be8b4033ca650be9d9 100644 (file)
@@ -5,7 +5,8 @@
  *      
  *          Copyright 1998 The LyX Team.
  *
- *======================================================*/
+ * ======================================================
+ */
 
 #include <config.h>
 
 #include "gettext.h"
 #include "lyxfont.h"
 #include "BufferView.h"
-#include "Painter.h"
 #include "lyxtext.h"
+#include "insets/insettext.h"
 #include "support/LOstream.h"
+#include "debug.h"
+
 
 using std::ostream;
-using std::endl;
 
-InsetMarginal::InsetMarginal() : InsetCollapsable()
+
+InsetMarginal::InsetMarginal()
+       : InsetFootlike()
 {
        setLabel(_("margin"));
-       LyXFont font(LyXFont::ALL_SANE);
-       font.decSize();
-       font.decSize();
-       font.setColor(LColor::footnote);
-       setLabelFont(font);
-       setAutoCollapse(false);
        setInsetName("Marginal");
 }
 
 
-Inset * InsetMarginal::Clone() const
-{
-       InsetMarginal * result = new InsetMarginal;
-       result->init(this);
-
-       result->collapsed = collapsed;
-       return result;
-}
-
-
-char const * InsetMarginal::EditMessage() const
+InsetMarginal::InsetMarginal(InsetMarginal const & in, bool same_id)
+       : InsetFootlike(in, same_id)
 {
-       return _("Opened Marginal Note Inset");
-}
-
-
-int InsetMarginal::Latex(Buffer const * buf,
-                        ostream & os, bool fragile, bool fp) const
-{
-    os << "\\marginpar{%" << endl;
-    
-    int i = InsetText::Latex(buf, os, fragile, fp);
-    os << "}%" << endl;
-    
-    return i + 2;
+       setLabel(_("margin"));
+       setInsetName("Marginal");
 }
 
 
-bool InsetMarginal::InsertInset(BufferView * bv, Inset * inset)
+Inset * InsetMarginal::clone(Buffer const &, bool same_id) const
 {
-    if (!InsertInsetAllowed(inset))
-       return false;
-
-    return InsetText::InsertInset(bv, inset);
+       return new InsetMarginal(*const_cast<InsetMarginal *>(this), same_id);
 }
 
 
-bool InsetMarginal::InsertInsetAllowed(Inset * inset) const
+string const InsetMarginal::editMessage() const
 {
-    if ((inset->LyxCode() == Inset::FOOT_CODE) ||
-       (inset->LyxCode() == Inset::MARGIN_CODE)) {
-       return false;
-    }
-    return true;
+       return _("Opened Marginal Note Inset");
 }
 
 
-LyXFont InsetMarginal::GetDrawFont(BufferView * bv,
-                                  LyXParagraph * p, int pos) const
+int InsetMarginal::latex(Buffer const * buf,
+                        ostream & os, bool fragile, bool fp) const
 {
-    LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
-    fn.decSize().decSize();
-    return fn;
+       os << "%\n\\marginpar{";
+       
+       int const i = inset.latex(buf, os, fragile, fp);
+       os << "%\n}";
+       
+       return i + 2;
 }