]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inset.C
Rename LatexRunParams::fragile as moving_arg.
[lyx.git] / src / insets / inset.C
index 8216147c35c0e6492cf74b230a923a48fec57769..51f655cf47a02b39e07583a65d34699a30c8374a 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 "BufferView.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "lyxtext.h"
+#include "dimension.h"
+
+#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
 
-#include "lyxinset.h"
-#include "debug.h"
 #include "support/lstrings.h"
 
-/* Insets default methods */
+using std::endl;
 
-bool Inset::Deletable() const
-{
-  return true;
-}
 
+// 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)
+{}
 
-bool Inset::DirectWrite() const
+
+Inset::Inset(Inset const & in, bool same_id)
+       : InsetBase(),
+       top_x(0), top_baseline(0), scx(0), owner_(0),
+       name_(in.name_), background_color_(in.background_color_)
 {
-  return false;
+       if (same_id)
+               id_ = in.id();
+       else
+               id_ = inset_id++;
 }
 
 
-unsigned char Inset::Editable() const
+bool Inset::directWrite() const
 {
-  return 0;
+       return false;
 }
 
-void Inset::Validate(LaTeXFeatures &) const
+
+Inset::EDITABLE Inset::editable() const
 {
-       // nothing by default
+       return NOT_EDITABLE;
 }
 
 
+void Inset::validate(LaTeXFeatures &) const
+{}
+
 
-bool Inset::AutoDelete() const
+bool Inset::autoDelete() const
 {
-  return false;
+       return false;
 }
 
 
-void Inset::Edit(int, int)
+#if 0
+LyXFont const Inset::convertFont(LyXFont const & font) const
 {
+#if 1
+       return font;
+#else
+       return LyXFont(font);
+#endif
 }
+#endif
 
 
-LyXFont Inset::ConvertFont(LyXFont font)
+string const Inset::editMessage() const
 {
-  return font;
+       return _("Opened inset");
 }
 
 
-// Inset::Code Inset::LyxCode() const
-// {
-//   return Inset::NO_CODE;
-// }
-
- /* some stuff for inset locking */
+LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
+{
+       if (owner())
+               return owner()->getLyXText(bv, false);
+       else
+               return bv->text;
+}
 
 
-void UpdatableInset::InsetButtonPress(int x, int y, int button)
+void Inset::setBackgroundColor(LColor::color color)
 {
-       lyxerr.debug() << "Inset Button Press x=" << x
-                      << ", y=" << y << ", button=" << button << endl;
+       background_color_ = color;
 }
 
 
-void UpdatableInset::InsetButtonRelease(int x, int y, int button)
+LColor::color Inset::backgroundColor() const
 {
-       lyxerr.debug() << "Inset Button Release x=" << x
-                      << ", y=" << y << ", button=" << button << endl;
+       if (background_color_ == LColor::inherit) {
+               if (owner())
+                       return owner()->backgroundColor();
+               else
+                       return LColor::background;
+       } else
+               return background_color_;
 }
 
 
-void UpdatableInset::InsetKeyPress(XKeyEvent *)
+int Inset::id() const
+{
+       return id_;
+}
+
+void Inset::id(int id_arg)
 {
-       lyxerr.debug() << "Inset Keypress" << endl;
+       id_ = id_arg;
 }
 
+void Inset::setFont(BufferView *, LyXFont const &, bool, bool)
+{}
 
-void UpdatableInset::InsetMotionNotify(int x, int y, int state)
+
+bool Inset::forceDefaultParagraphs(Inset const * inset) const
 {
-       lyxerr.debug() << "Inset Motion Notify x=" << x
-                      << ", y=" << y << ", state=" << state << endl;
+       if (owner())
+               return owner()->forceDefaultParagraphs(inset);
+       return false;
 }
 
+int Inset::latexTextWidth(BufferView * bv) const
+{
+       if (owner())
+               return (owner()->latexTextWidth(bv));
+       return bv->workWidth();
+}
 
-void UpdatableInset::InsetUnlock()
+
+int Inset::ascent(BufferView * bv, LyXFont const & font) const
 {
-       lyxerr.debug() << "Inset Unlock" << endl;
+       Dimension dim;
+       dimension(bv, font, dim);
+       return dim.ascent();
 }
 
 
-// An updatable inset is highly editable by definition
-unsigned char UpdatableInset::Editable() const
+int Inset::descent(BufferView * bv, LyXFont const & font) const
 {
-       return 2; // and what does "2" siginify? (Lgb)
+       Dimension dim;
+       dimension(bv, font, dim);
+       return dim.descent();
 }
 
 
-void UpdatableInset::ToggleInsetCursor()
+int Inset::width(BufferView * bv, LyXFont const & font) const
 {
-  // nothing
+       Dimension dim;
+       dimension(bv, font, dim);
+       return dim.width();
 }
+