]> git.lyx.org Git - lyx.git/blobdiff - src/insets/updatableinset.C
Enable the external inset to handle unknown templates gracefully.
[lyx.git] / src / insets / updatableinset.C
index 7df76d7676d7354abdeff0a34f00a903676ff9f1..ec6fa2ba81464e6a406acbb7fabf416cd48bd908 100644 (file)
@@ -1,3 +1,17 @@
+/**
+ * \file updatableinset.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>
 
 #include "updatableinset.h"
 #include "BufferView.h"
 // some stuff for inset locking
 
 UpdatableInset::UpdatableInset()
-       : Inset(), cursor_visible_(false), block_drawing_(false)
+       : Inset(), block_drawing_(false)
 {}
 
 
-UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
-       : Inset(in, same_id), cursor_visible_(false), block_drawing_(false)
+UpdatableInset::UpdatableInset(UpdatableInset const & in)
+       : Inset(in), block_drawing_(false)
 {}
 
 
 void UpdatableInset::insetUnlock(BufferView *)
 {
-       lyxerr[Debug::INFO] << "Inset Unlock" << endl;
+       lyxerr[Debug::INFO] << "Inset Unlock" << std::endl;
 }
 
 
@@ -34,38 +48,15 @@ Inset::EDITABLE UpdatableInset::editable() const
 }
 
 
-void UpdatableInset::toggleInsetCursor(BufferView *)
-{}
-
-
-void UpdatableInset::showInsetCursor(BufferView *, bool)
-{}
-
-
-void UpdatableInset::hideInsetCursor(BufferView *)
-{}
-
-
 void UpdatableInset::fitInsetCursor(BufferView *) const
 {}
 
 
-void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
-{}
-
-
-void UpdatableInset::edit(BufferView *, bool)
-{}
-
-
-void UpdatableInset::draw(BufferView *, LyXFont const &,
-                         int /* baseline */, float & x,
-                         bool/*cleared*/) const
+void UpdatableInset::draw(PainterInfo &, int, int) const
 {
-       x += float(scx);
        // ATTENTION: don't do the following here!!!
-       //    top_x = int(x);
-       //    top_baseline = baseline;
+       //    top_x = x;
+       //    top_baseline = y;
 }
 
 
@@ -97,8 +88,6 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
        if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
                scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
        }
-
-       // bv->updateInset(const_cast<UpdatableInset *>(this), false);
 }
 
 void UpdatableInset::scroll(BufferView * bv, int offset) const
@@ -121,7 +110,6 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
                        scx += offset;
                }
        }
-//     bv->updateInset(const_cast<UpdatableInset *>(this), false);
 }
 
 
@@ -139,7 +127,7 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
                        int const xx = strToInt(ev.argument);
                        scroll(ev.view(), xx);
                }
-               ev.view()->updateInset(this, false);
+               ev.view()->updateInset(this);
 
                return DISPATCHED;
        }
@@ -150,27 +138,26 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
 int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
 {
        int w;
+
        if (owner()) {
-               w = static_cast<UpdatableInset*>
-                       (owner())->getMaxWidth(bv, this);
+               w = static_cast<UpdatableInset *>(owner())->getMaxWidth(bv, this);
        } else {
-               w = bv->text->workWidth(bv, const_cast<UpdatableInset *>(this));
+               w = bv->text->workWidth(this);
        }
        if (w < 0) {
                return -1;
        }
        // check for margins left/right and extra right margin "const 5"
-       if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
-               w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
-       if (topx_set && owner()) {
-               w -= top_x;
-               w += owner()->x();
-       } else if (owner()) {
-               // this is needed as otherwise we might have a too large inset if
-               // its top_x afterwards changes to LeftMargin so we try to put at
-               // least the default margin as top_x
+       if ((w - (2 * TEXT_TO_INSET_OFFSET + 5)) >= 0)
+               w -= 2 * TEXT_TO_INSET_OFFSET + 5;
+
+       // Deep magic. I don't understand this either.
+       if (owner() && owner()->owner()) {
+               // add the right paper margin
                w -= 20;
        }
+
+       // FIXME: why ?
        if (w < 10) {
                w = 10;
        }
@@ -203,7 +190,7 @@ bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &)
        return false;
 }
 
+
 bool UpdatableInset::searchForward(BufferView * bv, string const &,
                                   bool, bool)
 {