]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inset.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / inset.C
index 628f853aae602fd8c454ce512e4988c2f6f6ed66..5f0b633794979a5e7b0c6f9fb2c615067bc68579 100644 (file)
-/* 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 "inset.h"
 
-#include "lyxinset.h"
-#include "debug.h"
 #include "BufferView.h"
-#include "support/lstrings.h"
-
-/* Insets default methods */
-
-bool Inset::Deletable() const
-{
-  return true;
-}
-
-
-bool Inset::DirectWrite() const
-{
-  return false;
-}
-
-
-unsigned char Inset::Editable() const
-{
-  return 0;
-}
-
-
-void Inset::Validate(LaTeXFeatures &) const
-{
-}
-
-
-bool Inset::AutoDelete() const
-{
-  return false;
-}
+#include "debug.h"
+#include "gettext.h"
+#include "lyxtext.h"
+#include "LColor.h"
+#include "metricsinfo.h"
+#include "coordcache.h"
 
 
-void Inset::Edit(BufferView *, int, int, unsigned int)
-{
-}
+namespace lyx {
 
+using std::string;
 
-LyXFont Inset::ConvertFont(LyXFont font)
-{
-  return font;
-}
 
+InsetOld::InsetOld()
+       : //background_color_(LColor::inherit)
+         background_color_(LColor::background)
+{}
 
- /* some stuff for inset locking */
 
-void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
-{
-       lyxerr.debug() << "Inset Button Press x=" << x
-                      << ", y=" << y << ", button=" << button << endl;
-}
+InsetOld::InsetOld(InsetOld const & in)
+       : InsetBase(in), name_(in.name_),
+         background_color_(in.background_color_)
+{}
 
 
-void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
+void InsetOld::setBackgroundColor(LColor_color color)
 {
-       lyxerr.debug() << "Inset Button Release x=" << x
-                      << ", y=" << y << ", button=" << button << endl;
+       background_color_ = color;
 }
 
 
-void UpdatableInset::InsetKeyPress(XKeyEvent *)
+LColor_color InsetOld::backgroundColor() const
 {
-       lyxerr.debug() << "Inset Keypress" << endl;
+       return LColor::color(background_color_);
 }
 
 
-void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
+int InsetOld::ascent() const
 {
-       lyxerr.debug() << "Inset Motion Notify x=" << x
-                      << ", y=" << y << ", state=" << state << endl;
+       return dim_.asc;
 }
 
 
-void UpdatableInset::InsetUnlock(BufferView *)
+int InsetOld::descent() const
 {
-       lyxerr.debug() << "Inset Unlock" << endl;
+       return dim_.des;
 }
 
 
-// An updatable inset is highly editable by definition
-unsigned char UpdatableInset::Editable() const
+int InsetOld::width() const
 {
-       return 2; // and what does "2" siginify? (Lgb)
+       return dim_.wid;
 }
 
 
-void UpdatableInset::ToggleInsetCursor(BufferView *)
+void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const
 {
+       //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
+       pi.base.bv->coordCache().insets().add(this, x, y);
 }
 
-void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
-{
-    LyXFont
-       font;
-//    bview = bv;
-    scx = 0;
-
-    mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth())/2);
-}
 
-
-void UpdatableInset::draw(Painter &, LyXFont const &,
-                         int baseline, float & x) const
-{
-    if (scx) x += float(scx);
-    top_x = int(x);
-    top_baseline = baseline;
-}
-
-
-void UpdatableInset::SetFont(LyXFont const &, bool )
-{
-}
-
-///  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; 
-}
+} // namespace lyx