]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea_Private.h
Upstreaming compilation patch needed for Gentoo.
[lyx.git] / src / frontends / qt4 / GuiWorkArea_Private.h
index 133a6cdbec8fd3ba257472f965c323a86f0e069b..76b05c0d36bb1f5327f8f8544db6ca3f7e0a8ab1 100644 (file)
 #ifndef WORKAREA_PRIVATE_H
 #define WORKAREA_PRIVATE_H
 
-// Comment out to use QImage backend instead of QPixmap. This won't have any
-// effect on Windows, MacOSX and most X11 environment when running locally.
-// When running remotely on X11, this may have a big performance penalty.
-//#define USE_QIMAGE
-
 #include "FuncRequest.h"
-#include "qt_helpers.h"
+#include "LyXRC.h"
 
-#include "support/docstring.h"
+#include "support/FileName.h"
 #include "support/Timeout.h"
 
-#include <QAbstractScrollArea>
 #include <QMouseEvent>
-#ifdef USE_QIMAGE
 #include <QImage>
-#else
 #include <QPixmap>
-#endif
 #include <QTimer>
 
 class QContextMenuEvent;
@@ -109,47 +100,58 @@ struct GuiWorkArea::Private
        void resizeBufferView();
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h,
+       void showCursor(int x, int y, int h,
                bool l_shape, bool rtl, bool completable);
 
        /// hide the cursor
-       virtual void removeCursor();
+       void removeCursor();
        ///
-       void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
+       void dispatch(FuncRequest const & cmd0);
        /// hide the visible cursor, if it is visible
        void hideCursor();
        /// show the cursor if it is not visible
        void showCursor();
-       ///
+       /// Set the range and value of the scrollbar and connect to its valueChanged
+       /// signal.
        void updateScrollbar();
        /// Change the cursor when the mouse hovers over a clickable inset
        void updateCursorShape();
        ///
        void setCursorShape(Qt::CursorShape shape);
 
-#ifdef USE_QIMAGE
-       void resetScreen()
-       {
-               screen_ = QImage(p->viewport()->width(), p->viewport()->height(),
-                       QImage::Format_ARGB32_Premultiplied);
+       bool needResize() const {
+               return need_resize_ || p->pixelRatio() != pixel_ratio_;
        }
 
-       QImage screen_;
-#else
        void resetScreen()
        {
-               screen_ = QPixmap(p->viewport()->width(), p->viewport()->height());
-       }
-
-       QPixmap screen_;
+               delete screen_;
+               pixel_ratio_ = p->pixelRatio();
+               if (lyxrc.use_qimage) {
+                       QImage *x =
+                               new QImage(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
+                                                  static_cast<int>(pixel_ratio_ * p->viewport()->height()),
+                                                  QImage::Format_ARGB32_Premultiplied);
+#if QT_VERSION >= 0x050000
+                       x->setDevicePixelRatio(pixel_ratio_);
+#endif
+                       screen_ = x;
+               } else {
+                       QPixmap *x =
+                               new QPixmap(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
+                                                       static_cast<int>(pixel_ratio_ * p->viewport()->height()));
+#if QT_VERSION >= 0x050000
+                       x->setDevicePixelRatio(pixel_ratio_);
 #endif
+                       screen_ = x;
+               }
+       }
        ///
        GuiWorkArea * p;
-
+       ///
+       QPaintDevice * screen_;
        ///
        BufferView * buffer_view_;
-       /// Read only Buffer status cache.
-       bool read_only_;
        ///
        GuiView * lyx_view_;
        /// is the cursor currently displayed
@@ -170,7 +172,10 @@ struct GuiWorkArea::Private
        bool schedule_redraw_;
        ///
        int preedit_lines_;
-
+       /// Ratio between physical pixels and device-independent pixels
+       /// We save the last used value to detect changes of the
+       /// current pixel_ratio of the viewport.
+       double pixel_ratio_;
        ///
        GuiCompleter * completer_;
 
@@ -178,10 +183,25 @@ struct GuiWorkArea::Private
        /// are ignored
        bool dialog_mode_;
        /// store the name of the context menu when the mouse is
-       /// pressed. This is used to get the correct context menu 
+       /// pressed. This is used to get the correct context menu
        /// when the menu is actually shown (after releasing on Windows)
        /// and after the DEPM has done its job.
        std::string context_menu_name_;
+
+       /// stuff related to window title
+       ///
+       support::FileName file_name_;
+       ///
+       bool shell_escape_;
+       ///
+       bool read_only_;
+       ///
+       docstring vc_status_;
+       ///
+       bool clean_;
+       ///
+       bool externally_modified_;
+
 }; // GuiWorkArea
 
 } // namespace frontend