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>
31 class QDragEnterEvent;
42 /// for emulating triple click
47 Qt::MouseButton state;
50 bool operator==(QMouseEvent const & e) {
51 return x == e.x() && y == e.y()
52 && state == e.button();
56 : x(0), y(0), state(Qt::NoButton), active(false) {}
58 double_click(QMouseEvent * e)
59 : x(e->x()), y(e->y()),
60 state(e->button()), active(true) {}
63 /** Qt only emits mouse events when the mouse is being moved, but
64 * we want to generate 'pseudo' mouse events when the mouse button is
65 * pressed and the mouse cursor is below the bottom, or above the top
66 * of the work area. In this way, we'll be able to continue scrolling
67 * (and selecting) the text.
69 * This class stores all the parameters needed to make this happen.
71 class SyntheticMouseEvent
74 SyntheticMouseEvent();
81 double scrollbar_value_old;
85 * Qt-specific implementation of the work area
89 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
95 GuiWorkArea(int width, int height, int id, LyXView & lyx_view);
97 /// return the width of the content pane
98 virtual int width() const { return viewport()->width(); }
99 /// return the height of the content pane
100 virtual int height() const { return viewport()->height(); }
102 virtual void setScrollbarParams(int height, int pos, int line_height);
104 /// update the passed area.
105 void update(int x, int y, int w, int h);
107 /// copies specified area of pixmap to screen
108 virtual void expose(int x, int y, int exp_width, int exp_height);
110 /// paint the cursor and store the background
111 virtual void showCursor(int x, int y, int h, CursorShape shape);
114 virtual void removeCursor();
117 void doGreyOut(QLPainter & pain);
119 void dragEnterEvent(QDragEnterEvent * ev);
121 void dropEvent(QDropEvent * ev);
123 void focusInEvent(QFocusEvent *);
125 void focusOutEvent(QFocusEvent *);
126 /// repaint part of the widget
127 void paintEvent(QPaintEvent * ev);
128 /// widget has been resized
129 void resizeEvent(QResizeEvent * ev);
130 /// mouse button press
131 void mousePressEvent(QMouseEvent * ev);
132 /// mouse button release
133 void mouseReleaseEvent(QMouseEvent * ev);
134 /// mouse double click of button
135 void mouseDoubleClickEvent(QMouseEvent * ev);
137 void mouseMoveEvent(QMouseEvent * ev);
139 void wheelEvent(QWheelEvent * ev);
141 void keyPressEvent(QKeyEvent * ev);
143 void inputMethodEvent(QInputMethodEvent * ev);
146 /// Timeout event Slot for keyboard bufferring.
147 /// \todo This is not used currently in the code, remove?
148 void keyeventTimeout();
150 /// Adjust the LyX buffer view with the position of the scrollbar.
152 * The action argument is not used in the the code, it is there
153 * only for the connection to the vertical srollbar signal which
154 * emits an 'int' action.
156 void adjustViewWithScrollBar(int action = 0);
159 /// The slot connected to SyntheticMouseEvent::timeout.
160 void generateSyntheticMouseEvent();
163 SyntheticMouseEvent synthetic_mouse_event_;
167 std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
169 double_click dc_event_;
172 CursorWidget * cursor_;
177 } // namespace frontend