]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/screen.C
include sys/time.h
[lyx.git] / src / frontends / screen.C
index 2ef231de7f61d56fd5e3dddaa3a57aad6a561916..030539845a2cbec20b17c805e9f082d63e465b5e 100644 (file)
@@ -1,21 +1,21 @@
 /**
  * \file screen.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  *
  * Splash screen code added by Angus Leeming
  */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include <config.h>
 
 #include "screen.h"
 #include "lyxtext.h"
+#include "lyxrc.h"
 #include "lyxrow.h"
 #include "BufferView.h"
 #include "buffer.h"
@@ -49,7 +49,7 @@ public:
        /// This is a singleton class. Get the instance.
        static SplashScreen const & get();
        ///
-       grfx::GImage const * image() const { return loader_.image(); }
+       grfx::Image const * image() const { return loader_.image(); }
        ///
        string const & text() const { return text_; }
        ///
@@ -80,7 +80,10 @@ SplashScreen const & SplashScreen::get()
 SplashScreen::SplashScreen()
        : text_(lyx_version ? lyx_version : "unknown")
 {
-       string const file = LibFileSearch("images", "banner", "xpm");
+       if (!lyxrc.show_banner)
+               return;
+
+       string const file = LibFileSearch("images", "banner", "ppm");
        if (file.empty())
                return;
 
@@ -94,8 +97,8 @@ SplashScreen::SplashScreen()
        loader_.reset(file);
        // We aren't interested here in when the image is loaded.
        // If it isn't ready when we want it, then we ignore it.
-//     loader_->statusChanged.connect(
-//                     boost::bind(&SplashScreen::statusChanged, this));
+//     loader_->statusChanged.connect(
+//                     boost::bind(&SplashScreen::statusChanged, this));
        if (loader_.status() == grfx::WaitingToLoad)
                loader_.startLoading();
 }
@@ -165,6 +168,7 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
                text->first_y = newtop;
                return true;
        }
+
        return false;
 }
 
@@ -189,8 +193,7 @@ unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
        if (!row)
                return max(newtop, 0);
 
-       if (cursor.y() - row->baseline() + row->height()
-           - top_y >= vheight) {
+       if (cursor.y() - row->baseline() + row->height() - top_y >= vheight) {
                if (row->height() < vheight
                    && row->height() > vheight / 4) {
                        newtop = cursor.y()
@@ -225,8 +228,10 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
        // Is a change necessary?
        int const newtop = topCursorVisible(text->cursor, text->first_y);
        bool const result = (newtop != text->first_y);
-       if (result)
+       if (result) {
                draw(text, bv, newtop);
+       }
+
        return result;
 }
 
@@ -376,19 +381,19 @@ void LyXScreen::greyOut()
 
        // Add a splash screen to the centre of the work area
        SplashScreen const & splash = SplashScreen::get();
-       grfx::GImage const * const splash_image = splash.image();
+       grfx::Image const * const splash_image = splash.image();
        if (splash_image) {
                int const w = splash_image->getWidth();
                int const h = splash_image->getHeight();
 
-               int x = 0.5 * (workarea().workWidth() - w);
-               int y = 0.5 * (workarea().workHeight() - h);
+               int x = (workarea().workWidth() - w) / 2;
+               int y = (workarea().workHeight() - h) / 2;
 
                workarea().getPainter().image(x, y, w, h, *splash_image);
 
                string const & splash_text  = splash.text();
                LyXFont const & splash_font = splash.font();
-               
+
                x += 260;
                y += 265;
 
@@ -401,7 +406,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
        int y1, int y2, int yo, int xo,
        bool internal)
 {
-       lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << "-" << y2 << endl;
+       lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << '-' << y2 << endl;
 
        int y_text = text->first_y + y1;
 
@@ -431,7 +436,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
        force_clear_ = false;
 
        // maybe we have to clear the screen at the bottom
-       if ((y < y2) && text->bv_owner) {
+       if ((y < y2) && text->isTopLevel()) {
                workarea().getPainter().fillRectangle(0, y,
                        workarea().workWidth(), y2 - y,
                        LColor::bottomarea);