-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 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 "support/lstrings.h"
-#include "Painter.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "lyxtext.h"
+#include "dimension.h"
+#include "metricsinfo.h"
-using std::endl;
+#include "insets/updatableinset.h"
-/* Insets default methods */
+#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
-bool Inset::Deletable() const
-{
- return true;
-}
-
-
-bool Inset::DirectWrite() const
-{
- return false;
-}
+#include "support/lstrings.h"
-Inset::EDITABLE Inset::Editable() const
-{
- return NOT_EDITABLE;
-}
+#include "debug.h"
+// Initialization of the counter for the inset id's,
+unsigned int InsetOld::inset_id = 0;
-void Inset::Validate(LaTeXFeatures &) const
-{
-}
+InsetOld::InsetOld()
+ : InsetBase(),
+ top_x(0), top_baseline(0), scx(0),
+ id_(inset_id++), owner_(0), par_owner_(0),
+ background_color_(LColor::inherit)
+{}
-bool Inset::AutoDelete() 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 false;
}
-void Inset::Edit(BufferView *, int, int, unsigned int)
+bool InsetOld::directWrite() const
{
+ return false;
}
-LyXFont Inset::ConvertFont(LyXFont font)
+InsetOld::EDITABLE InsetOld::editable() const
{
- return font;
+ return NOT_EDITABLE;
}
-char const * Inset::EditMessage() const
+bool InsetOld::autoDelete() const
{
- return _("Opened inset");
+ return false;
}
- /* some stuff for inset locking */
-void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
+#if 0
+LyXFont const InsetOld::convertFont(LyXFont const & font) const
{
- lyxerr.debug() << "Inset Button Press x=" << x
- << ", y=" << y << ", button=" << button << endl;
-}
-
-
-void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
-{
- lyxerr.debug() << "Inset Button Release x=" << x
- << ", y=" << y << ", button=" << button << endl;
+#if 1
+ return font;
+#else
+ return LyXFont(font);
+#endif
}
+#endif
-void UpdatableInset::InsetKeyPress(XKeyEvent *)
+string const InsetOld::editMessage() const
{
- lyxerr.debug() << "Inset Keypress" << endl;
+ return _("Opened inset");
}
-void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
+LyXText * InsetOld::getLyXText(BufferView const * bv, bool /*recursive*/) const
{
- lyxerr.debug() << "Inset Motion Notify x=" << x
- << ", y=" << y << ", state=" << state << endl;
+ if (owner())
+ return owner()->getLyXText(bv, false);
+ else
+ return bv->text;
}
-void UpdatableInset::InsetUnlock(BufferView *)
+void InsetOld::setBackgroundColor(LColor::color color)
{
- lyxerr.debug() << "Inset Unlock" << endl;
+ background_color_ = color;
}
-// An updatable inset is highly editable by definition
-Inset::EDITABLE UpdatableInset::Editable() const
+LColor::color InsetOld::backgroundColor() const
{
- return HIGHLY_EDITABLE;
+ if (background_color_ == LColor::inherit) {
+ if (owner())
+ return owner()->backgroundColor();
+ else
+ return LColor::background;
+ } else
+ return background_color_;
}
-void UpdatableInset::ToggleInsetCursor(BufferView *)
+int InsetOld::id() const
{
+ return id_;
}
-
-void UpdatableInset::ShowInsetCursor(BufferView *)
+void InsetOld::id(int id_arg)
{
+ id_ = id_arg;
}
-
-void UpdatableInset::HideInsetCursor(BufferView *)
-{
-}
+void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
+{}
-void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
+bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
{
- LyXFont font;
-
- scx = 0;
-
- mx_scx = abs((width(bv->painter(), font) - bv->workWidth()) / 2);
+ if (owner())
+ return owner()->forceDefaultParagraphs(inset);
+ return false;
}
-
-void UpdatableInset::draw(BufferView *, LyXFont const &,
- int /* baseline */, float & x) const
+int InsetOld::latexTextWidth(BufferView * bv) const
{
- if (scx) x += float(scx);
-// ATTENTION: don't do the following here!!!
-// top_x = int(x);
-// top_baseline = baseline;
+ if (owner())
+ return (owner()->latexTextWidth(bv));
+ return bv->workWidth();
}
-void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
+int InsetOld::ascent() const
{
+ return dim_.asc;
}
-/// An updatable inset could handle lyx editing commands
-#ifdef SCROLL_INSET
-UpdatableInset::RESULT
-UpdatableInset::LocalDispatch(BufferView *,
- int action, string const & arg)
-#else
-UpdatableInset::RESULT
-UpdatableInset::LocalDispatch(BufferView *, int, string const &)
-#endif
+int InsetOld::descent() const
{
-#ifdef SCROLL_INSET
- if (action==LFUN_SCROLL_INSET)
- {
- float xx;
- sscanf(arg.c_str(), "%f", &xx);
- scroll(xx);
-
- return DISPATCHED;
- }
-#endif
- return UNDISPATCHED;
+ return dim_.des;
}
-int UpdatableInset::getMaxWidth(Painter & pain, UpdatableInset const *) const
+int InsetOld::width() const
{
- if (owner())
- return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain, this);
- return pain.paperWidth();
+ return dim_.wid;
}