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.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
12 #ifndef WORKAREA_PRIVATE_H
13 #define WORKAREA_PRIVATE_H
15 #include "FuncRequest.h"
16 #include "qt_helpers.h"
19 #include "support/docstring.h"
20 #include "support/Timeout.h"
22 #include <QAbstractScrollArea>
23 #include <QMouseEvent>
28 class QContextMenuEvent;
29 class QDragEnterEvent;
52 /// for emulating triple click
56 DoubleClick() : state(Qt::NoButton), active(false) {}
58 DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
60 bool operator==(QMouseEvent const & e) { return state == e.button(); }
64 Qt::MouseButton state;
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.
75 * This class stores all the parameters needed to make this happen.
77 class SyntheticMouseEvent
80 SyntheticMouseEvent();
89 * Implementation of the work area (buffer view GUI)
93 struct GuiWorkArea::Private
95 Private(GuiWorkArea *);
97 /// update the passed area.
98 void update(int x, int y, int w, int h);
102 void resizeBufferView();
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);
111 void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
112 /// hide the visible cursor, if it is visible
114 /// show the cursor if it is not visible
117 void updateScrollbar();
118 /// Change the cursor when the mouse hovers over a clickable inset
119 void updateCursorShape();
121 void setCursorShape(Qt::CursorShape shape);
126 if (lyxrc.use_qimage) {
127 screen_ = new QImage(p->viewport()->width(), p->viewport()->height(),
128 QImage::Format_ARGB32_Premultiplied);
130 screen_ = new QPixmap(p->viewport()->width(), p->viewport()->height());
136 QPaintDevice * screen_;
138 BufferView * buffer_view_;
139 /// Read only Buffer status cache.
143 /// is the cursor currently displayed
144 bool cursor_visible_;
147 QTimer cursor_timeout_;
149 SyntheticMouseEvent synthetic_mouse_event_;
151 DoubleClick dc_event_;
154 CursorWidget * cursor_;
158 bool schedule_redraw_;
163 GuiCompleter * completer_;
165 /// Special mode in which Esc and Enter (with or without Shift)
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_;
175 } // namespace frontend