X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetmarginal.C;h=1a0eb1b5bece05e73a06a2be8b4033ca650be9d9;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=9a592c972bf0433454772bd0b8875ba0548c7d9a;hpb=0811126012a57f06705ec2eac6f5b40c054aff28;p=lyx.git diff --git a/src/insets/insetmarginal.C b/src/insets/insetmarginal.C index 9a592c972b..1a0eb1b5be 100644 --- a/src/insets/insetmarginal.C +++ b/src/insets/insetmarginal.C @@ -5,7 +5,8 @@ * * Copyright 1998 The LyX Team. * - *======================================================*/ + * ====================================================== + */ #include @@ -17,77 +18,50 @@ #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(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; }