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