]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWorkArea_Private.h
Use QFontMetrics information for underlines (and friends) width and position
[lyx.git] / src / frontends / qt4 / GuiWorkArea_Private.h
index 3058047f024016afafe98a2c833d1a869e1332e4..5320c5c7133ce9faeeaeeb5478049306c2a1355a 100644 (file)
 #define WORKAREA_PRIVATE_H
 
 #include "FuncRequest.h"
-#include "qt_helpers.h"
+#include "LyXRC.h"
 
-#include "support/docstring.h"
 #include "support/Timeout.h"
 
-#include <QAbstractScrollArea>
 #include <QMouseEvent>
+#include <QImage>
 #include <QPixmap>
 #include <QTimer>
 
@@ -100,14 +99,11 @@ 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();
-
-       /// This function should be called to update the buffer readonly status.
-       void setReadOnly(bool);
+       void removeCursor();
        ///
        void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
        /// hide the visible cursor, if it is visible
@@ -120,9 +116,38 @@ struct GuiWorkArea::Private
        void updateCursorShape();
        ///
        void setCursorShape(Qt::CursorShape shape);
+
+       bool needResize() const {
+               return need_resize_ || p->pixelRatio() != pixel_ratio_;
+       }
+
+       void resetScreen()
+       {
+               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.
@@ -142,14 +167,15 @@ struct GuiWorkArea::Private
        ///
        CursorWidget * cursor_;
        ///
-       QPixmap screen_;
-       ///
        bool need_resize_;
        ///
        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_;
 
@@ -160,7 +186,7 @@ struct GuiWorkArea::Private
        /// 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.
-       docstring context_menu_name_;
+       std::string context_menu_name_;
 }; // GuiWorkArea
 
 } // namespace frontend