4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
16 #include "frontends/WorkArea.h"
18 #include "funcrequest.h"
19 #include "frontends/Timeout.h"
21 #include <QAbstractScrollArea>
22 #include <QMouseEvent>
23 #include <QResizeEvent>
30 class QDragEnterEvent;
41 /// for emulating triple click
46 Qt::MouseButton state;
49 bool operator==(QMouseEvent const & e) {
50 return x == e.x() && y == e.y()
51 && state == e.button();
55 : x(0), y(0), state(Qt::NoButton), active(false) {}
57 double_click(QMouseEvent * e)
58 : x(e->x()), y(e->y()),
59 state(e->button()), active(true) {}
62 /** Qt only emits mouse events when the mouse is being moved, but
63 * we want to generate 'pseudo' mouse events when the mouse button is
64 * pressed and the mouse cursor is below the bottom, or above the top
65 * of the work area. In this way, we'll be able to continue scrolling
66 * (and selecting) the text.
68 * This class stores all the parameters needed to make this happen.
70 class SyntheticMouseEvent
73 SyntheticMouseEvent();
80 double scrollbar_value_old;
84 * Qt-specific implementation of the work area
88 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
94 GuiWorkArea(int width, int height, int id, LyXView & lyx_view);
96 /// return the width of the content pane
97 virtual int width() const { return viewport()->width(); }
98 /// return the height of the content pane
99 virtual int height() const { return viewport()->height(); }
101 virtual void setScrollbarParams(int height, int pos, int line_height);
103 /// update the passed area.
104 void update(int x, int y, int w, int h);
106 /// copies specified area of pixmap to screen
107 virtual void expose(int x, int y, int exp_width, int exp_height);
109 /// paint the cursor and store the background
110 virtual void showCursor(int x, int y, int h, CursorShape shape);
113 virtual void removeCursor();
116 void doGreyOut(QLPainter & pain);
118 void dragEnterEvent(QDragEnterEvent * ev);
120 void dropEvent(QDropEvent * ev);
122 void focusInEvent(QFocusEvent *);
124 void focusOutEvent(QFocusEvent *);
125 /// repaint part of the widget
126 void paintEvent(QPaintEvent * ev);
127 /// widget has been resized
128 void resizeEvent(QResizeEvent * ev);
129 /// mouse button press
130 void mousePressEvent(QMouseEvent * ev);
131 /// mouse button release
132 void mouseReleaseEvent(QMouseEvent * ev);
133 /// mouse double click of button
134 void mouseDoubleClickEvent(QMouseEvent * ev);
136 void mouseMoveEvent(QMouseEvent * ev);
138 void wheelEvent(QWheelEvent * ev);
140 void keyPressEvent(QKeyEvent * ev);
142 void inputMethodEvent(QInputMethodEvent * ev);
145 /// Timeout event Slot for keyboard bufferring.
146 /// \todo This is not used currently in the code, remove?
147 void keyeventTimeout();
149 /// Adjust the LyX buffer view with the position of the scrollbar.
151 * The action argument is not used in the the code, it is there
152 * only for the connection to the vertical srollbar signal which
153 * emits an 'int' action.
155 void adjustViewWithScrollBar(int action = 0);
158 /// The slot connected to SyntheticMouseEvent::timeout.
159 void generateSyntheticMouseEvent();
162 SyntheticMouseEvent synthetic_mouse_event_;
166 std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
168 double_click dc_event_;
177 QColor cursor_color_;
179 CursorShape cursor_shape_;
181 CursorWidget * cursor_;
184 } // namespace frontend