X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finset.C;h=5f0b633794979a5e7b0c6f9fb2c615067bc68579;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=a69f1f8884baa8d348423ed2d986c68b395a71a0;hpb=b625e2038ac37153025f001358a25994e7568588;p=lyx.git diff --git a/src/insets/inset.C b/src/insets/inset.C index a69f1f8884..5f0b633794 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -8,166 +8,74 @@ * \author Lars Gullik Bjønnes * \author Matthias Ettrich * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include #include "inset.h" + #include "BufferView.h" -#include "funcrequest.h" +#include "debug.h" #include "gettext.h" -#include "lyxfont.h" #include "lyxtext.h" -#include "dimension.h" +#include "LColor.h" #include "metricsinfo.h" +#include "coordcache.h" -#include "frontends/Painter.h" -#include "frontends/mouse_state.h" -#include "support/lstrings.h" +namespace lyx { +using std::string; -// Initialization of the counter for the inset id's, -unsigned int Inset::inset_id = 0; -Inset::Inset() - : InsetBase(), - top_x(0), top_baseline(0), scx(0), - id_(inset_id++), owner_(0), par_owner_(0), - background_color_(LColor::inherit) +InsetOld::InsetOld() + : //background_color_(LColor::inherit) + background_color_(LColor::background) {} -Inset::Inset(Inset const & in) - : InsetBase(), - top_x(0), top_baseline(0), scx(0), owner_(0), - name_(in.name_), background_color_(in.background_color_) -{ - id_ = inset_id++; -} - - -bool Inset::directWrite() const -{ - return false; -} - - -Inset::EDITABLE Inset::editable() const -{ - return NOT_EDITABLE; -} - - -bool Inset::autoDelete() const -{ - return false; -} - - -#if 0 -LyXFont const Inset::convertFont(LyXFont const & font) const -{ -#if 1 - return font; -#else - return LyXFont(font); -#endif -} -#endif - - -string const Inset::editMessage() const -{ - return _("Opened inset"); -} - - -LyXText * Inset::getLyXText(BufferView const * bv, bool const) const -{ - if (owner()) - return owner()->getLyXText(bv, false); - else - return bv->text; -} +InsetOld::InsetOld(InsetOld const & in) + : InsetBase(in), name_(in.name_), + background_color_(in.background_color_) +{} -void Inset::setBackgroundColor(LColor::color color) +void InsetOld::setBackgroundColor(LColor_color color) { background_color_ = color; } -LColor::color Inset::backgroundColor() const +LColor_color InsetOld::backgroundColor() const { - if (background_color_ == LColor::inherit) { - if (owner()) - return owner()->backgroundColor(); - else - return LColor::background; - } else - return background_color_; + return LColor::color(background_color_); } -int Inset::id() const +int InsetOld::ascent() const { - return id_; + return dim_.asc; } -void Inset::id(int id_arg) -{ - id_ = id_arg; -} - -void Inset::setFont(BufferView *, LyXFont const &, bool, bool) -{} - -bool Inset::forceDefaultParagraphs(Inset const * inset) const +int InsetOld::descent() const { - if (owner()) - return owner()->forceDefaultParagraphs(inset); - return false; -} - -int Inset::latexTextWidth(BufferView * bv) const -{ - if (owner()) - return (owner()->latexTextWidth(bv)); - return bv->workWidth(); + return dim_.des; } -int Inset::ascent(BufferView * bv, LyXFont const & font) const +int InsetOld::width() const { - Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; - metrics(mi, dim); - return dim.ascent(); + return dim_.wid; } -int Inset::descent(BufferView * bv, LyXFont const & font) const +void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const { - Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; - metrics(mi, dim); - return dim.descent(); + //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl; + pi.base.bv->coordCache().insets().add(this, x, y); } -int Inset::width(BufferView * bv, LyXFont const & font) const -{ - Dimension dim; - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; - metrics(mi, dim); - return dim.width(); -} +} // namespace lyx