]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Buffer: Rename function names:
[lyx.git] / src / BufferView.cpp
index b58a980ecc6bf2c945118a05dc9ff74e0309b682..338a55aa5c3f9a1ce7e7fdeba159fec447ab9e83 100644 (file)
@@ -58,9 +58,9 @@
 #include "insets/InsetCommand.h" // ChangeRefs
 #include "insets/InsetExternal.h"
 #include "insets/InsetGraphics.h"
+#include "insets/InsetNote.h"
 #include "insets/InsetRef.h"
 #include "insets/InsetText.h"
-#include "insets/InsetNote.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -220,7 +220,8 @@ struct BufferView::Private
        Private(BufferView & bv): wh_(0), cursor_(bv),
                anchor_pit_(0), anchor_ypos_(0),
                inlineCompletionUniqueChars_(0),
-               last_inset_(0), mouse_position_cache_(),
+               last_inset_(0), clickable_inset_(false), 
+               mouse_position_cache_(),
                bookmark_edit_position_(-1), gui_(0)
        {}
 
@@ -263,6 +264,8 @@ struct BufferView::Private
          * Not owned, so don't delete.
          */
        Inset * last_inset_;
+       /// are we hovering something that we can click
+       bool clickable_inset_;
 
        /// position of the mouse at the time of the last mouse move
        /// This is used to update the hovering status of inset in
@@ -1959,8 +1962,12 @@ Inset const * BufferView::getCoveringInset(Text const & text,
 void BufferView::updateHoveredInset() const
 {
        // Get inset under mouse, if there is one.
-       Inset const * covering_inset = getCoveringInset(buffer_.text(),
-                       d->mouse_position_cache_.x_, d->mouse_position_cache_.y_);
+       int const x = d->mouse_position_cache_.x_;
+       int const y = d->mouse_position_cache_.y_;
+       Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
+
+       d->clickable_inset_ = covering_inset && covering_inset->clickable(x, y);
+
        if (covering_inset == d->last_inset_)
                // Same inset, no need to do anything...
                return;
@@ -2500,7 +2507,7 @@ void BufferView::insertLyXFile(FileName const & fname)
 
        docstring res;
        Buffer buf("", false);
-       if (buf.loadLyXFile(filename)) {
+       if (buf.loadLyXFile(filename) == Buffer::ReadSuccess) {
                ErrorList & el = buffer_.errorList("Parse");
                // Copy the inserted document error list into the current buffer one.
                el = buf.errorList("Parse");
@@ -2888,4 +2895,10 @@ void BufferView::setInlineCompletion(Cursor & cur, DocIterator const & pos,
        }
 }
 
+
+bool BufferView::clickableInset() const
+{ 
+       return d->clickable_inset_; 
+}
+
 } // namespace lyx