]> 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 889743d2a5cdc9a12e4a77729e1cc3926e39148e..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"
-
-using std::ostream;
-using std::endl;
-
-InsetMarginal::InsetMarginal() : InsetCollapsable()
-{
-    setLabel(_("margin"));
-    LyXFont font(LyXFont::ALL_SANE);
-    font.decSize();
-    font.decSize();
-    font.setColor(LColor::footnote);
-    setLabelFont(font);
-    setAutoCollapse(false);
-    setInsetName("Marginal");
-}
-
-
-void InsetMarginal::Write(Buffer const * buf, ostream & os) const
-{
-    os << getInsetName() << "\n";
-    InsetCollapsable::Write(buf, os);
-}
+#include "debug.h"
 
 
-Inset * InsetMarginal::Clone() const
-{
-    InsetMarginal * result = new InsetMarginal;
-    result->init(this);
-    
-    result->collapsed = collapsed;
-    return result;
-}
+using std::ostream;
 
 
-char const * InsetMarginal::EditMessage() const
+InsetMarginal::InsetMarginal()
+       : InsetFootlike()
 {
-    return _("Opened Marginal Note Inset");
+       setLabel(_("margin"));
+       setInsetName("Marginal");
 }
 
 
-int InsetMarginal::Latex(Buffer const * buf,
-                        ostream & os, bool fragile, bool fp) const
+InsetMarginal::InsetMarginal(InsetMarginal const & in, bool same_id)
+       : InsetFootlike(in, same_id)
 {
-    os << "\\marginpar{%\n";
-    
-    int i = InsetText::Latex(buf, os, fragile, fp);
-    os << "}%\n";
-    
-    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;
 }