]> git.lyx.org Git - lyx.git/blobdiff - src/insets/updatableinset.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / updatableinset.C
index 783f3c5dd03655129bb908f3330c197761fdbb7d..e65b4f92909b88416ce8a034579de4624c1a24f0 100644 (file)
@@ -4,11 +4,11 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  * \author Matthias Ettrich
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 #include "lyxtext.h"
 #include "support/lstrings.h"
 
+using namespace lyx::support;
 
 // some stuff for inset locking
 
 UpdatableInset::UpdatableInset()
-       : Inset(), cursor_visible_(false), block_drawing_(false)
+       : InsetOld()
 {}
 
 
-UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
-       : Inset(in, same_id), cursor_visible_(false), block_drawing_(false)
+UpdatableInset::UpdatableInset(UpdatableInset const & in)
+       : InsetOld(in)
 {}
 
 
@@ -42,49 +43,27 @@ void UpdatableInset::insetUnlock(BufferView *)
 
 
 // An updatable inset is highly editable by definition
-Inset::EDITABLE UpdatableInset::editable() const
+InsetOld::EDITABLE UpdatableInset::editable() const
 {
        return HIGHLY_EDITABLE;
 }
 
 
-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) 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;
 }
 
 
 void UpdatableInset::scroll(BufferView * bv, float s) const
 {
-       LyXFont font;
+       //LyXFont font;
 
        if (!s) {
                scx = 0;
@@ -94,24 +73,19 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
        int const workW = bv->workWidth();
        int const tmp_top_x = top_x - scx;
 
-       if (tmp_top_x > 0 &&
-           (tmp_top_x + width(bv, font)) < workW)
+       if (tmp_top_x > 0 && tmp_top_x + width() < workW)
                return;
        if (s > 0 && top_x > 0)
                return;
 
-       // int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
-       //int const save_scx = scx;
-
        scx = int(s * workW / 2);
        // if (!display())
        // scx += 20;
 
-       if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
-               scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
+#warning metrics?
+       if (tmp_top_x + scx + width() < workW / 2) {
+               scx += workW / 2 - (tmp_top_x + scx + width());
        }
-
-       // bv->updateInset(const_cast<UpdatableInset *>(this), false);
 }
 
 void UpdatableInset::scroll(BufferView * bv, int offset) const
@@ -125,21 +99,20 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
                else
                        scx += offset;
        } else {
-               LyXFont const font;
-               if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20))
+#warning metrics?
+               if (!scx && top_x + width() < bv->workWidth() - 20)
                        return;
-               if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) {
-                       scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
+               if (top_x - scx + offset + width() < bv->workWidth() - 20) {
+                       scx += bv->workWidth() - width() - top_x - 20;
                } else {
                        scx += offset;
                }
        }
-//     bv->updateInset(const_cast<UpdatableInset *>(this), false);
 }
 
 
 ///  An updatable inset could handle lyx editing commands
-Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
+InsetOld::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
 {
        if (ev.action == LFUN_MOUSE_RELEASE)
                return (editable() == IS_EDITABLE) ? DISPATCHED : UNDISPATCHED;
@@ -152,7 +125,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;
        }
@@ -160,38 +133,7 @@ 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);
-       } else {
-               w = bv->text->workWidth(const_cast<UpdatableInset *>(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
-               w -= 20;
-       }
-       if (w < 10) {
-               w = 10;
-       }
-       return w;
-}
-
-
-LyXCursor const & Inset::cursor(BufferView * bv) const
+LyXCursor const & InsetOld::cursor(BufferView * bv) const
 {
        if (owner())
                return owner()->getLyXText(bv, false)->cursor;