]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiWorkArea_Private.h
Do the actual drawing in the paint event
[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 #include "LyXRC.h"
17
18 #include "support/FileName.h"
19 #include "support/Timeout.h"
20
21 #include <QMouseEvent>
22 #include <QImage>
23 #include <QPixmap>
24 #include <QTimer>
25
26 class QContextMenuEvent;
27 class QDragEnterEvent;
28 class QDropEvent;
29 class QKeyEvent;
30 class QPaintEvent;
31 class QResizeEvent;
32 class QToolButton;
33 class QWheelEvent;
34 class QWidget;
35
36 #ifdef CursorShape
37 #undef CursorShape
38 #endif
39
40 namespace lyx {
41
42 class Buffer;
43
44 namespace frontend {
45
46 class GuiCompleter;
47 class GuiView;
48 class GuiWorkArea;
49
50 /// for emulating triple click
51 class DoubleClick {
52 public:
53         ///
54         DoubleClick() : state(Qt::NoButton), active(false) {}
55         ///
56         DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
57         ///
58         bool operator==(QMouseEvent const & e) { return state == e.button(); }
59         ///
60 public:
61         ///
62         Qt::MouseButton state;
63         ///
64         bool active;
65 };
66
67 /** Qt only emits mouse events when the mouse is being moved, but
68  *  we want to generate 'pseudo' mouse events when the mouse button is
69  *  pressed and the mouse cursor is below the bottom, or above the top
70  *  of the work area. In this way, we'll be able to continue scrolling
71  *  (and selecting) the text.
72  *
73  *  This class stores all the parameters needed to make this happen.
74  */
75 class SyntheticMouseEvent
76 {
77 public:
78         SyntheticMouseEvent();
79
80         FuncRequest cmd;
81         Timeout timeout;
82         bool restart_timeout;
83 };
84
85
86 /**
87  * Implementation of the work area (buffer view GUI)
88 */
89 class CursorWidget;
90
91 struct GuiWorkArea::Private
92 {
93         Private(GuiWorkArea *);
94
95         ///
96         void resizeBufferView();
97
98         /// paint the cursor and store the background
99         void showCursor(int x, int y, int h,
100                 bool l_shape, bool rtl, bool completable);
101
102         /// hide the cursor
103         void removeCursor();
104         ///
105         void dispatch(FuncRequest const & cmd0);
106         /// hide the visible cursor, if it is visible
107         void hideCursor();
108         /// show the cursor if it is not visible
109         void showCursor();
110         /// Set the range and value of the scrollbar and connect to its valueChanged
111         /// signal.
112         void updateScrollbar();
113         /// Change the cursor when the mouse hovers over a clickable inset
114         void updateCursorShape();
115         ///
116         void setCursorShape(Qt::CursorShape shape);
117
118         bool needResize() const {
119                 return need_resize_ || p->pixelRatio() != pixel_ratio_;
120         }
121
122         ///
123         GuiWorkArea * p;
124         ///
125         BufferView * buffer_view_;
126         ///
127         GuiView * lyx_view_;
128         /// is the cursor currently displayed
129         bool cursor_visible_;
130
131         ///
132         QTimer cursor_timeout_;
133         ///
134         SyntheticMouseEvent synthetic_mouse_event_;
135         ///
136         DoubleClick dc_event_;
137
138         ///
139         CursorWidget * cursor_;
140         ///
141         bool need_resize_;
142         ///
143         bool schedule_redraw_;
144         ///
145         int preedit_lines_;
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 pixel_ratio_;
150         ///
151         GuiCompleter * completer_;
152
153         /// Special mode in which Esc and Enter (with or without Shift)
154         /// are ignored
155         bool dialog_mode_;
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_;
161
162         /// stuff related to window title
163         ///
164         support::FileName file_name_;
165         ///
166         bool shell_escape_;
167         ///
168         bool read_only_;
169         ///
170         docstring vc_status_;
171         ///
172         bool clean_;
173         ///
174         bool externally_modified_;
175
176 }; // GuiWorkArea
177
178 } // namespace frontend
179 } // namespace lyx
180
181 #endif // WORKAREA_H