X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetert.C;h=795ca2c042dc54fcc1bba3c0fe4e049364f9b779;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=83a9a81e836daf56642c6cba4500c7d015004832;hpb=d6fa7c567c47f1af95f026174a83bf75dde08f84;p=lyx.git diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 83a9a81e83..795ca2c042 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -3,7 +3,7 @@ * * LyX, The Document Processor * - * Copyright (C) 1998 The LyX Team. + * Copyright 1998 The LyX Team. * *======================================================*/ @@ -17,175 +17,62 @@ #include "gettext.h" #include "lyxfont.h" #include "Painter.h" +#include "buffer.h" +#include "support/LOstream.h" #include "lyx_gui_misc.h" +using std::ostream; -InsetERT::InsetERT(Buffer * bf): InsetText(bf) +InsetERT::InsetERT(Buffer * bf) + : InsetCollapsable(bf) { - closed = true; - nomotion = false; + setLabel(_("ERT")); + LyXFont font(LyXFont::ALL_SANE); + font.setLatex (LyXFont::ON); + real_current_font = current_font = font; + LyXFont labelfont(LyXFont::ALL_SANE); + labelfont.decSize(); + labelfont.decSize(); + labelfont.setColor(LColor::ert); + setLabelFont(labelfont); + setAutoCollapse(false); + setInsetName("ERT"); } -InsetERT * InsetERT::Clone() const +Inset * InsetERT::Clone() const { InsetERT * result = new InsetERT(buffer); - return result; -} - - -void InsetERT::Write(ostream & os) const -{ - os << "ERT\n"; - WriteParagraphData(os); -} - - -int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const -{ - int width, ascent, descent; - LyXFont font(LyXFont::ALL_SANE); - font.setSize(f.size()); - font.decSize(); - font.decSize(); - pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent); - return ascent; -} - - -int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const -{ - int width, ascent, descent; - LyXFont font(LyXFont::ALL_SANE); - font.setSize(f.size()); - font.decSize(); - font.decSize(); - pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent); - return descent; -} - - -int InsetERT::width_closed(Painter & pain, LyXFont const & f) const -{ - int width, ascent, descent; - LyXFont font(LyXFont::ALL_SANE); - font.setSize(f.size()); - font.decSize(); - font.decSize(); - pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false, - width, ascent, descent); - return width + (2*TEXT_TO_INSET_OFFSET); -} - - -int InsetERT::ascent(Painter & pain, LyXFont const & font) const -{ - if (closed) - return ascent_closed(pain, font); - else - return InsetText::ascent(pain, font); -} - - -int InsetERT::descent(Painter & pain, LyXFont const & font) const -{ + result->init(buffer, this); - if (closed) - return descent_closed(pain, font); - else - return InsetText::descent(pain, font); -} - - -int InsetERT::width(Painter & pain, LyXFont const & font) const -{ - if (closed) - return width_closed(pain, font); - else - return InsetText::width(pain, font); -} - - -void InsetERT::draw_closed(Painter & pain, LyXFont const & f, - int baseline, float & x) const -{ - LyXFont font(LyXFont::ALL_SANE); - font.setSize(f.size()); - font.decSize(); - font.decSize(); - font.setColor(LColor::ert); - int width; - pain.buttonText(int(x)+TEXT_TO_INSET_OFFSET, baseline, _("ERT"), font, - true, width); - x += width + (2*TEXT_TO_INSET_OFFSET); -} - - -void InsetERT::draw(Painter & pain, LyXFont const & f, int baseline, float & x) const -{ - if (closed) { - top_x = int(x); - top_baseline = baseline; - draw_closed(pain, f, baseline, x); - } else { - InsetText::draw(pain, f, baseline, x); - } -// resetPos(bv); + result->collapsed = collapsed; + return result; } -void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button) +char const * InsetERT::EditMessage() const { - nomotion = false; - InsetText::InsetButtonRelease(bv, x, y, button); + return _("Opened ERT Inset"); } -void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button) +bool InsetERT::InsertInset(BufferView *, Inset *) { - nomotion = false; - InsetText::InsetButtonPress(bv, x, y, button); + return false; } -void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button) +void InsetERT::SetFont(BufferView *, LyXFont const &, bool) { - if (nomotion) - return; - InsetText::InsetMotionNotify(bv, x, y, button); + WriteAlert(_("Impossible Operation!"), + _("Not permitted to change font-types inside ERT-insets!"), + _("Sorry.")); } - void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button) { - closed = false; - nomotion = true; + InsetCollapsable::Edit(bv, x, y, button); LyXFont font(LyXFont::ALL_SANE); font.setLatex (LyXFont::ON); - InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ? - width(bv->getPainter(), font) : 0), y, button); - real_current_font = current_font = font; - bv->updateInset(this, false); -} - - -void InsetERT::InsetUnlock(BufferView * bv) -{ - closed = true; - InsetText::InsetUnlock(bv); - bv->updateInset(this, false); -} - - -bool InsetERT::InsertInset(Inset *) -{ - return false; -} - - -void InsetERT::SetFont(LyXFont const &, bool) -{ - WriteAlert(_("Impossible Operation!"), - _("Not permitted to change font-types inside ERT-insets!"), - _("Sorry.")); + current_font = real_current_font = font; }