-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+/**
+ * \file inset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ====================================================== */
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ *
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation "lyxinset.h"
-#endif
-
-#include "lyxinset.h"
-#include "debug.h"
+#include "inset.h"
#include "BufferView.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "lyxtext.h"
+#include "dimension.h"
+#include "metricsinfo.h"
+
+#include "insets/updatableinset.h"
+
+#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
+
#include "support/lstrings.h"
-/* Insets default methods */
-bool Inset::Deletable() const
-{
- return true;
-}
+#include "debug.h"
+// Initialization of the counter for the inset id's,
+unsigned int InsetOld::inset_id = 0;
-bool Inset::DirectWrite() const
-{
- return false;
-}
+InsetOld::InsetOld()
+ : InsetBase(),
+ top_x(0), top_baseline(0), scx(0),
+ id_(inset_id++), owner_(0), par_owner_(0),
+ background_color_(LColor::inherit)
+{}
-unsigned char Inset::Editable() const
+InsetOld::InsetOld(InsetOld const & in)
+ : InsetBase(),
+ top_x(0), top_baseline(0), scx(0), id_(in.id_), owner_(0),
+ name_(in.name_), background_color_(in.background_color_)
{
- return 0;
}
-void Inset::Validate(LaTeXFeatures &) const
+bool InsetOld::directWrite() const
{
+ return false;
}
-bool Inset::AutoDelete() const
+InsetOld::EDITABLE InsetOld::editable() const
{
- return false;
+ return NOT_EDITABLE;
}
-void Inset::Edit(BufferView *, int, int, unsigned int)
+bool InsetOld::autoDelete() const
{
+ return false;
}
-LyXFont Inset::ConvertFont(LyXFont font)
+#if 0
+LyXFont const InsetOld::convertFont(LyXFont const & font) const
{
- return font;
+#if 1
+ return font;
+#else
+ return LyXFont(font);
+#endif
}
+#endif
- /* some stuff for inset locking */
-
-void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
+string const InsetOld::editMessage() const
{
- lyxerr.debug() << "Inset Button Press x=" << x
- << ", y=" << y << ", button=" << button << endl;
+ return _("Opened inset");
}
-void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
+LyXText * InsetOld::getLyXText(BufferView const * bv, bool /*recursive*/) const
{
- lyxerr.debug() << "Inset Button Release x=" << x
- << ", y=" << y << ", button=" << button << endl;
+ if (owner())
+ return owner()->getLyXText(bv, false);
+ else
+ return bv->text;
}
-void UpdatableInset::InsetKeyPress(XKeyEvent *)
+void InsetOld::setBackgroundColor(LColor::color color)
{
- lyxerr.debug() << "Inset Keypress" << endl;
+ background_color_ = color;
}
-void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
+LColor::color InsetOld::backgroundColor() const
{
- lyxerr.debug() << "Inset Motion Notify x=" << x
- << ", y=" << y << ", state=" << state << endl;
+ if (background_color_ == LColor::inherit) {
+ if (owner())
+ return owner()->backgroundColor();
+ else
+ return LColor::background;
+ } else
+ return background_color_;
}
-void UpdatableInset::InsetUnlock(BufferView *)
+int InsetOld::id() const
{
- lyxerr.debug() << "Inset Unlock" << endl;
+ return id_;
}
-
-// An updatable inset is highly editable by definition
-unsigned char UpdatableInset::Editable() const
+void InsetOld::id(int id_arg)
{
- return 2; // and what does "2" siginify? (Lgb)
+ id_ = id_arg;
}
+void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
+{}
+
-void UpdatableInset::ToggleInsetCursor(BufferView *)
+bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
{
+ if (owner())
+ return owner()->forceDefaultParagraphs(inset);
+ return false;
}
-void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
+int InsetOld::latexTextWidth(BufferView * bv) const
{
- LyXFont
- font;
-// bview = bv;
- scx = 0;
-
- mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth())/2);
+ if (owner())
+ return (owner()->latexTextWidth(bv));
+ return bv->workWidth();
}
-void UpdatableInset::draw(Painter &, LyXFont const &,
- int baseline, float & x) const
+int InsetOld::ascent() const
{
- if (scx) x += float(scx);
- top_x = int(x);
- top_baseline = baseline;
+ return dim_.asc;
}
-void UpdatableInset::SetFont(LyXFont const &, bool )
+int InsetOld::descent() const
{
+ return dim_.des;
}
-/// An updatable inset could handle lyx editing commands
-#ifdef SCROLL_INSET
-UpdatableInset::RESULT UpdatableInset::LocalDispatch(BufferView *,
- int action, string arg)
-#else
-UpdatableInset::RESULT UpdatableInset::LocalDispatch(BufferView *, int, string)
-#endif
-{
-#ifdef SCROLL_INSET
- if (action==LFUN_SCROLL_INSET)
- {
- float xx;
- sscanf(arg.c_str(), "%f", &xx);
- scroll(xx);
- return DISPATCHED;
- }
-#endif
- return UNDISPATCHED;
+int InsetOld::width() const
+{
+ return dim_.wid;
}