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