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"
18 #include "support/FileName.h"
19 #include "support/Timeout.h"
21 #include <QMouseEvent>
26 class QContextMenuEvent;
27 class QDragEnterEvent;
50 /// for emulating triple click
54 DoubleClick() : state(Qt::NoButton), active(false) {}
56 DoubleClick(QMouseEvent * e) : state(e->button()), active(true) {}
58 bool operator==(QMouseEvent const & e) { return state == e.button(); }
62 Qt::MouseButton state;
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.
73 * This class stores all the parameters needed to make this happen.
75 class SyntheticMouseEvent
78 SyntheticMouseEvent();
87 * Implementation of the work area (buffer view GUI)
91 struct GuiWorkArea::Private
93 Private(GuiWorkArea *);
95 /// update the passed area.
96 void update(int x, int y, int w, int h);
100 void resizeBufferView();
102 /// paint the cursor and store the background
103 void showCursor(int x, int y, int h,
104 bool l_shape, bool rtl, bool completable);
109 void dispatch(FuncRequest const & cmd0);
110 /// hide the visible cursor, if it is visible
112 /// show the cursor if it is not visible
115 void updateScrollbar();
116 /// Change the cursor when the mouse hovers over a clickable inset
117 void updateCursorShape();
119 void setCursorShape(Qt::CursorShape shape);
121 bool needResize() const {
122 return need_resize_ || p->pixelRatio() != pixel_ratio_;
128 pixel_ratio_ = p->pixelRatio();
129 if (lyxrc.use_qimage) {
131 new QImage(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
132 static_cast<int>(pixel_ratio_ * p->viewport()->height()),
133 QImage::Format_ARGB32_Premultiplied);
134 #if QT_VERSION >= 0x050000
135 x->setDevicePixelRatio(pixel_ratio_);
140 new QPixmap(static_cast<int>(pixel_ratio_ * p->viewport()->width()),
141 static_cast<int>(pixel_ratio_ * p->viewport()->height()));
142 #if QT_VERSION >= 0x050000
143 x->setDevicePixelRatio(pixel_ratio_);
151 QPaintDevice * screen_;
153 BufferView * buffer_view_;
156 /// is the cursor currently displayed
157 bool cursor_visible_;
160 QTimer cursor_timeout_;
162 SyntheticMouseEvent synthetic_mouse_event_;
164 DoubleClick dc_event_;
167 CursorWidget * cursor_;
171 bool schedule_redraw_;
174 /// Ratio between physical pixels and device-independent pixels
175 /// We save the last used value to detect changes of the
176 /// current pixel_ratio of the viewport.
179 GuiCompleter * completer_;
181 /// Special mode in which Esc and Enter (with or without Shift)
184 /// store the name of the context menu when the mouse is
185 /// pressed. This is used to get the correct context menu
186 /// when the menu is actually shown (after releasing on Windows)
187 /// and after the DEPM has done its job.
188 std::string context_menu_name_;
190 /// stuff related to window title
192 support::FileName file_name_;
196 docstring vc_status_;
202 } // namespace frontend