3 * \file GuiWorkArea_Private.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
12 #ifndef WORKAREA_PRIVATE_H
13 #define WORKAREA_PRIVATE_H
15 #include "FuncRequest.h"
17 #include "support/FileName.h"
18 #include "support/Timeout.h"
20 #include <QMouseEvent>
32 /// for emulating triple click
36 DoubleClick() : state(Qt::NoButton), active(false) {}
38 DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
40 bool operator==(QMouseEvent const & e) { return state == e.button(); }
44 Qt::MouseButton state;
49 /** Qt only emits mouse events when the mouse is being moved, but
50 * we want to generate 'pseudo' mouse events when the mouse button is
51 * pressed and the mouse cursor is below the bottom, or above the top
52 * of the work area. In this way, we'll be able to continue scrolling
53 * (and selecting) the text.
55 * This class stores all the parameters needed to make this happen.
57 class SyntheticMouseEvent
60 SyntheticMouseEvent();
69 * Implementation of the work area (buffer view GUI)
72 struct GuiWorkArea::Private
75 Private(GuiWorkArea *);
81 void resizeBufferView();
84 void dispatch(FuncRequest const & cmd0);
85 /// Make caret visible and signal that its geometry needs to be updated
87 /// recompute the shape and position of the caret
88 void updateCaretGeometry();
89 /// show the caret if it is not visible
91 /// hide the caret if it is visible
93 /* Draw the caret. Parameter \c horiz_offset is not 0 when there
94 * has been horizontal scrolling in current row
96 void drawCaret(QPainter & painter, int horiz_offset) const;
97 /// Set the range and value of the scrollbar and connect to its valueChanged
99 void updateScrollbar();
100 /// Change the cursor when the mouse hovers over a clickable inset
101 void updateCursorShape();
103 void paintPreeditText(GuiPainter & pain);
105 /// Prepare screen for next painting
107 /// Where painting takes place
108 QPaintDevice * screenDevice();
109 /// Put backingstore to screen if necessary
110 void updateScreen(QRectF const & rc);
113 GuiWorkArea * p = nullptr;
115 BufferView * buffer_view_ = nullptr;
117 GuiView * lyx_view_ = nullptr;
119 /// Do we need an intermediate image when painting (for now macOS and Wayland)
120 bool use_backingstore_ = false;
124 /// is the caret currently displayed
125 bool caret_visible_ = false;
127 bool needs_caret_geometry_update_ = true;
129 QTimer caret_timeout_;
132 SyntheticMouseEvent synthetic_mouse_event_;
134 DoubleClick dc_event_;
137 bool need_resize_ = false;
139 /// the current preedit text of the input method
140 docstring preedit_string_;
141 /// Number of lines used by preedit text
142 int preedit_lines_ = 1;
143 /// the attributes of the preedit text
144 QList<QInputMethodEvent::Attribute> preedit_attr_;
146 /// Ratio between physical pixels and device-independent pixels
147 /// We save the last used value to detect changes of the
148 /// current pixel_ratio of the viewport.
149 double last_pixel_ratio_ = 1.0;
151 GuiCompleter * completer_;
153 /// Special mode in which Esc and Enter (with or without Shift)
155 bool dialog_mode_ = false;
156 /// store the name of the context menu when the mouse is
157 /// pressed. This is used to get the correct context menu
158 /// when the menu is actually shown (after releasing on Windows)
159 /// and after the DEPM has done its job.
160 std::string context_menu_name_;
162 /// stuff related to window title
164 support::FileName file_name_;
166 bool shell_escape_ = false;
168 bool read_only_ = false;
170 docstring vc_status_;
174 bool externally_modified_ = false;
178 } // namespace frontend