]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiWorkArea_Private.h
Cleanup and simplify WorkArea code
[lyx.git] / src / frontends / qt4 / 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 GuiView;
31 class GuiWorkArea;
32
33 /// for emulating triple click
34 class DoubleClick {
35 public:
36         ///
37         DoubleClick() : state(Qt::NoButton), active(false) {}
38         ///
39         DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
40         ///
41         bool operator==(QMouseEvent const & e) { return state == e.button(); }
42         ///
43 public:
44         ///
45         Qt::MouseButton state;
46         ///
47         bool active;
48 };
49
50 /** Qt only emits mouse events when the mouse is being moved, but
51  *  we want to generate 'pseudo' mouse events when the mouse button is
52  *  pressed and the mouse cursor is below the bottom, or above the top
53  *  of the work area. In this way, we'll be able to continue scrolling
54  *  (and selecting) the text.
55  *
56  *  This class stores all the parameters needed to make this happen.
57  */
58 class SyntheticMouseEvent
59 {
60 public:
61         SyntheticMouseEvent();
62
63         FuncRequest cmd;
64         Timeout timeout;
65         bool restart_timeout;
66 };
67
68
69 /**
70  * Implementation of the work area (buffer view GUI)
71 */
72 class CaretWidget;
73
74 struct GuiWorkArea::Private
75 {
76         ///
77         Private(GuiWorkArea *);
78
79         ///
80         ~Private();
81
82         ///
83         void resizeBufferView();
84
85         ///
86         void dispatch(FuncRequest const & cmd0);
87         /// hide the visible cursor, if it is visible
88         void hideCaret();
89         /// show the cursor if it is not visible
90         void showCaret();
91         /// Set the range and value of the scrollbar and connect to its valueChanged
92         /// signal.
93         void updateScrollbar();
94         /// Change the cursor when the mouse hovers over a clickable inset
95         void updateCursorShape();
96
97         bool needResize() const {
98                 return need_resize_ || p->pixelRatio() != pixel_ratio_;
99         }
100
101         ///
102         GuiWorkArea * p;
103         ///
104         BufferView * buffer_view_;
105         ///
106         GuiView * lyx_view_;
107
108         ///
109         CaretWidget * caret_;
110         /// is the cursor currently displayed
111         bool caret_visible_;
112         ///
113         QTimer caret_timeout_;
114
115         ///
116         SyntheticMouseEvent synthetic_mouse_event_;
117         ///
118         DoubleClick dc_event_;
119
120         ///
121         bool need_resize_;
122         ///
123         bool schedule_redraw_;
124         ///
125         int preedit_lines_;
126         /// Ratio between physical pixels and device-independent pixels
127         /// We save the last used value to detect changes of the
128         /// current pixel_ratio of the viewport.
129         double pixel_ratio_;
130         ///
131         GuiCompleter * completer_;
132
133         /// Special mode in which Esc and Enter (with or without Shift)
134         /// are ignored
135         bool dialog_mode_;
136         /// store the name of the context menu when the mouse is
137         /// pressed. This is used to get the correct context menu
138         /// when the menu is actually shown (after releasing on Windows)
139         /// and after the DEPM has done its job.
140         std::string context_menu_name_;
141
142         /// stuff related to window title
143         ///
144         support::FileName file_name_;
145         ///
146         bool shell_escape_;
147         ///
148         bool read_only_;
149         ///
150         docstring vc_status_;
151         ///
152         bool clean_;
153         ///
154         bool externally_modified_;
155
156 }; // GuiWorkArea
157
158 } // namespace frontend
159 } // namespace lyx
160
161 #endif // WORKAREA_H