#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 "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;
-class QDragEnterEvent;
-class QDropEvent;
-class QKeyEvent;
-class QPaintEvent;
-class QResizeEvent;
-class QToolButton;
-class QWheelEvent;
-class QWidget;
-
-#ifdef CursorShape
-#undef CursorShape
+#ifdef Q_OS_MAC
+/* Qt on macOS does not respect the Qt::WA_OpaquePaintEvent attribute
+ * and resets the widget backing store at each update. Therefore, we
+ * use our own backing store in this case */
+#define LYX_BACKINGSTORE 1
+#include <QPainter>
#endif
namespace lyx {
namespace frontend {
class GuiCompleter;
+class GuiPainter;
class GuiView;
class GuiWorkArea;
/**
* Implementation of the work area (buffer view GUI)
*/
-class CursorWidget;
+class CaretWidget;
struct GuiWorkArea::Private
{
+ ///
Private(GuiWorkArea *);
- /// update the passed area.
- void update(int x, int y, int w, int h);
///
- void updateScreen();
+ ~Private();
+
///
void resizeBufferView();
- /// paint the cursor and store the background
- virtual void showCursor(int x, int y, int h,
- bool l_shape, bool rtl, bool completable);
-
- /// hide the cursor
- virtual void removeCursor();
- ///
- void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
- /// hide the visible cursor, if it is visible
- void hideCursor();
- /// show the cursor if it is not visible
- void showCursor();
///
+ void dispatch(FuncRequest const & cmd0);
+ /// recompute the shape and position of the caret
+ void updateCaretGeometry();
+ /// show the caret if it is not visible
+ void showCaret();
+ /// hide the caret if it is visible
+ void hideCaret();
+ /// 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);
+ void paintPreeditText(GuiPainter & pain);
+
+ void resetScreen() {
+#ifdef LYX_BACKINGSTORE
+ int const pr = p->pixelRatio();
+ screen_ = QImage(static_cast<int>(pr * p->viewport()->width()),
+ static_cast<int>(pr * p->viewport()->height()),
+ QImage::Format_ARGB32_Premultiplied);
+# if QT_VERSION >= 0x050000
+ screen_.setDevicePixelRatio(pr);
+# endif
+#endif
}
- QImage screen_;
+ QPaintDevice * screenDevice() {
+#ifdef LYX_BACKINGSTORE
+ return &screen_;
#else
- void resetScreen()
- {
- screen_ = QPixmap(p->viewport()->width(), p->viewport()->height());
+ return p->viewport();
+#endif
}
- QPixmap screen_;
+#ifdef LYX_BACKINGSTORE
+ void updateScreen(QRectF const & rc) {
+ QPainter qpain(p->viewport());
+ double const pr = p->pixelRatio();
+ QRectF const rcs = QRectF(rc.x() * pr, rc.y() * pr,
+ rc.width() * pr, rc.height() * pr);
+ qpain.drawImage(rc, screen_, rcs);
+ }
+#else
+ void updateScreen(QRectF const & ) {}
#endif
+
///
GuiWorkArea * p;
-
///
BufferView * buffer_view_;
- /// Read only Buffer status cache.
- bool read_only_;
///
GuiView * lyx_view_;
- /// is the cursor currently displayed
- bool cursor_visible_;
+#ifdef LYX_BACKINGSTORE
+ ///
+ QImage screen_;
+#endif
///
- QTimer cursor_timeout_;
+ CaretWidget * caret_;
+ /// is the caret currently displayed
+ bool caret_visible_;
+ ///
+ QTimer caret_timeout_;
+
///
SyntheticMouseEvent synthetic_mouse_event_;
///
DoubleClick dc_event_;
- ///
- CursorWidget * cursor_;
///
bool need_resize_;
- ///
- bool schedule_redraw_;
- ///
+
+ /// the current preedit text of the input method
+ docstring preedit_string_;
+ /// Number of lines used by preedit text
int preedit_lines_;
+ /// the attributes of the preedit text
+ QList<QInputMethodEvent::Attribute> preedit_attr_;
+ /// 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 last_pixel_ratio_;
///
GuiCompleter * completer_;
/// 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.
- docstring context_menu_name_;
+ 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