]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiWorkArea_Private.h
39130162ad0572d1f16ff2a5447ebd902a155bdf
[lyx.git] / src / frontends / qt / GuiWorkArea_Private.h
1 // -*- C++ -*-
2 /**
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.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef WORKAREA_PRIVATE_H
13 #define WORKAREA_PRIVATE_H
14
15 #include "FuncRequest.h"
16
17 #include "support/FileName.h"
18 #include "support/Timeout.h"
19
20 #include <QMouseEvent>
21 #include <QTimer>
22
23 namespace lyx {
24
25 class Buffer;
26
27 namespace frontend {
28
29 class GuiCompleter;
30 class GuiPainter;
31 class GuiView;
32 class GuiWorkArea;
33
34 /// for emulating triple click
35 class DoubleClick {
36 public:
37         ///
38         DoubleClick() : state(Qt::NoButton), active(false) {}
39         ///
40         DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
41         ///
42         bool operator==(QMouseEvent const & e) { return state == e.button(); }
43         ///
44 public:
45         ///
46         Qt::MouseButton state;
47         ///
48         bool active;
49 };
50
51 /** Qt only emits mouse events when the mouse is being moved, but
52  *  we want to generate 'pseudo' mouse events when the mouse button is
53  *  pressed and the mouse cursor is below the bottom, or above the top
54  *  of the work area. In this way, we'll be able to continue scrolling
55  *  (and selecting) the text.
56  *
57  *  This class stores all the parameters needed to make this happen.
58  */
59 class SyntheticMouseEvent
60 {
61 public:
62         SyntheticMouseEvent();
63
64         FuncRequest cmd;
65         Timeout timeout;
66         bool restart_timeout;
67 };
68
69
70 /**
71  * Implementation of the work area (buffer view GUI)
72 */
73 class CaretWidget;
74
75 struct GuiWorkArea::Private
76 {
77         ///
78         Private(GuiWorkArea *);
79
80         ///
81         ~Private();
82
83         ///
84         void resizeBufferView();
85
86         ///
87         void dispatch(FuncRequest const & cmd0);
88         /// Make caret visible and signal that its geometry needs to be updated
89         void resetCaret();
90         /// recompute the shape and position of the caret
91         void updateCaretGeometry();
92         /// show the caret if it is not visible
93         void showCaret();
94         /// hide the caret if it is visible
95         void hideCaret();
96         /// Set the range and value of the scrollbar and connect to its valueChanged
97         /// signal.
98         void updateScrollbar();
99         /// Change the cursor when the mouse hovers over a clickable inset
100         void updateCursorShape();
101
102         void paintPreeditText(GuiPainter & pain);
103
104         /// Prepare screen for next painting
105         void resetScreen();
106         /// Where painting takes place
107         QPaintDevice * screenDevice();
108         /// Put backingstore to screen if necessary
109         void updateScreen(QRectF const & rc);
110
111         ///
112         GuiWorkArea * p;
113         ///
114         BufferView * buffer_view_;
115         ///
116         GuiView * lyx_view_;
117
118         /// Do we need an intermediate image when painting (for now macOS and Wayland)
119         bool use_backingstore_;
120         ///
121         QImage screen_;
122
123         ///
124         CaretWidget * caret_;
125         /// is the caret currently displayed
126         bool caret_visible_;
127         ///
128         QTimer caret_timeout_;
129
130         ///
131         SyntheticMouseEvent synthetic_mouse_event_;
132         ///
133         DoubleClick dc_event_;
134
135         ///
136         bool need_resize_;
137
138         /// the current preedit text of the input method
139         docstring preedit_string_;
140         /// Number of lines used by preedit text
141         int preedit_lines_;
142         /// the attributes of the preedit text
143         QList<QInputMethodEvent::Attribute> preedit_attr_;
144
145         /// Ratio between physical pixels and device-independent pixels
146         /// We save the last used value to detect changes of the
147         /// current pixel_ratio of the viewport.
148         double last_pixel_ratio_;
149         ///
150         GuiCompleter * completer_;
151
152         /// Special mode in which Esc and Enter (with or without Shift)
153         /// are ignored
154         bool dialog_mode_;
155         /// store the name of the context menu when the mouse is
156         /// pressed. This is used to get the correct context menu
157         /// when the menu is actually shown (after releasing on Windows)
158         /// and after the DEPM has done its job.
159         std::string context_menu_name_;
160
161         /// stuff related to window title
162         ///
163         support::FileName file_name_;
164         ///
165         bool shell_escape_;
166         ///
167         bool read_only_;
168         ///
169         docstring vc_status_;
170         ///
171         bool clean_;
172         ///
173         bool externally_modified_;
174         ///
175         bool needs_caret_geometry_update_;
176
177 }; // GuiWorkArea
178
179 } // namespace frontend
180 } // namespace lyx
181
182 #endif // WORKAREA_H