]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/screen.C
namespace grfx -> lyx::graphics
[lyx.git] / src / frontends / screen.C
index 0ec0a0daee28bb867f5362bd379ae41b176baaf0..e902141367a6a4e15baef8d9840cabbd9eded099 100644 (file)
@@ -27,6 +27,7 @@
 #include "rowpainter.h"
 #include "insets/updatableinset.h"
 #include "mathed/formulabase.h"
+#include "lyx_gui.h"
 
 // Splash screen-specific stuff
 #include "lyxfont.h"
 #include <boost/bind.hpp>
 #include <boost/signals/trackable.hpp>
 
+using namespace lyx::support;
+
 using std::min;
 using std::max;
 using std::endl;
 
+namespace grfx = lyx::graphics;
+
 namespace {
 
 class SplashScreen : boost::noncopyable, boost::signals::trackable {
@@ -131,6 +136,10 @@ LyXScreen::~LyXScreen()
 
 void LyXScreen::showCursor(BufferView & bv)
 {
+       // this is needed to make sure we copy back the right
+       // pixmap on the hide for the Qt frontend
+       lyx_gui::sync_events();
+
        if (cursor_visible_)
                return;
 
@@ -189,9 +198,8 @@ void LyXScreen::showCursor(BufferView & bv)
        if (y < 0 || y + h > workarea().workHeight())
                return;
 
-       showCursor(x, y, h, shape);
-
        cursor_visible_ = true;
+       showCursor(x, y, h, shape);
 }
 
 
@@ -200,8 +208,8 @@ void LyXScreen::hideCursor()
        if (!cursor_visible_)
                return;
 
-       removeCursor();
        cursor_visible_ = false;
+       removeCursor();
 }
 
 
@@ -239,12 +247,14 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
 }
 
 
-unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
+unsigned int LyXScreen::topCursorVisible(LyXText * text)
 {
-       int const vheight = workarea().workHeight();
+       LyXCursor const & cursor = text->cursor;
+       int top_y = text->top_y();
        int newtop = top_y;
+       int const vheight = workarea().workHeight();
 
-       RowList::iterator row = cursor.row();
+       RowList::iterator row = text->cursorRow();
 
 #warning SUPER HACK DISABLED (Lgb)
 #if 0
@@ -259,9 +269,8 @@ unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
                                + row->height()
                                - row->baseline() - vheight;
                } else {
-                       // scroll down
-                       newtop = cursor.y()
-                               - vheight / 2;   /* the scroll region must be so big!! */
+                       // scroll down, the scroll region must be so big!!
+                       newtop = cursor.y() - vheight / 2;
                }
 
        } else if (static_cast<int>((cursor.y()) - row->baseline()) <
@@ -285,7 +294,7 @@ unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
 bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 {
        // Is a change necessary?
-       int const newtop = topCursorVisible(text->cursor, text->top_y());
+       int const newtop = topCursorVisible(text);
        bool const result = (newtop != text->top_y());
        if (result) {
                draw(text, bv, newtop);
@@ -344,13 +353,13 @@ void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
 
        int const bottom = min(
                max(static_cast<int>(text->selection.end.y()
-                                    - text->selection.end.row()->baseline()
-                                    + text->selection.end.row()->height()),
+                                    - text->getRow(text->selection.end)->baseline()
+                                    + text->getRow(text->selection.end)->height()),
                    text->top_y()),
                static_cast<int>(text->top_y() + workarea().workHeight()));
        int const top = min(
                max(static_cast<int>(text->selection.start.y() -
-                                    text->selection.start.row()->baseline()),
+                                    text->getRow(text->selection.start)->baseline()),
                    text->top_y()),
                static_cast<int>(text->top_y() + workarea().workHeight()));
 
@@ -377,10 +386,10 @@ void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
                return;
 
        int const top_tmp = text->toggle_cursor.y()
-               - text->toggle_cursor.row()->baseline();
+               - text->getRow(text->toggle_cursor)->baseline();
        int const bottom_tmp = text->toggle_end_cursor.y()
-               - text->toggle_end_cursor.row()->baseline()
-               + text->toggle_end_cursor.row()->height();
+               - text->getRow(text->toggle_end_cursor)->baseline()
+               + text->getRow(text->toggle_end_cursor)->height();
 
        int const offset = yo < 0 ? yo : 0;
        int const bottom = min(max(bottom_tmp, text->top_y()),