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);
98 bool hasFocus() const { return QAbstractScrollArea::hasFocus(); }
100 /// return the width of the content pane
101 virtual int width() const { return viewport()->width(); }
102 /// return the height of the content pane
103 virtual int height() const { return viewport()->height(); }
105 virtual void setScrollbarParams(int height, int pos, int line_height);
107 /// update the passed area.
108 void update(int x, int y, int w, int h);
110 /// copies specified area of pixmap to screen
111 virtual void expose(int x, int y, int exp_width, int exp_height);
113 /// paint the cursor and store the background
114 virtual void showCursor(int x, int y, int h, CursorShape shape);
117 virtual void removeCursor();
120 void doGreyOut(QLPainter & pain);
122 void dragEnterEvent(QDragEnterEvent * ev);
124 void dropEvent(QDropEvent * ev);
126 void focusInEvent(QFocusEvent *);
128 void focusOutEvent(QFocusEvent *);
129 /// repaint part of the widget
130 void paintEvent(QPaintEvent * ev);
131 /// widget has been resized
132 void resizeEvent(QResizeEvent * ev);
133 /// mouse button press
134 void mousePressEvent(QMouseEvent * ev);
135 /// mouse button release
136 void mouseReleaseEvent(QMouseEvent * ev);
137 /// mouse double click of button
138 void mouseDoubleClickEvent(QMouseEvent * ev);
140 void mouseMoveEvent(QMouseEvent * ev);
142 void wheelEvent(QWheelEvent * ev);
144 void keyPressEvent(QKeyEvent * ev);
146 void inputMethodEvent(QInputMethodEvent * ev);
149 /// Timeout event Slot for keyboard bufferring.
150 /// \todo This is not used currently in the code, remove?
151 void keyeventTimeout();
153 /// Adjust the LyX buffer view with the position of the scrollbar.
155 * The action argument is not used in the the code, it is there
156 * only for the connection to the vertical srollbar signal which
157 * emits an 'int' action.
159 void adjustViewWithScrollBar(int action = 0);
162 /// The slot connected to SyntheticMouseEvent::timeout.
163 void generateSyntheticMouseEvent();
166 SyntheticMouseEvent synthetic_mouse_event_;
170 std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
172 double_click dc_event_;
175 CursorWidget * cursor_;
180 } // namespace frontend