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