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
45 Qt::MouseButton state;
48 bool operator==(QMouseEvent const & e) {
49 return state == e.button();
53 : state(Qt::NoButton), active(false) {}
55 double_click(QMouseEvent * e)
56 : state(e->button()), active(true) {}
59 /** Qt only emits mouse events when the mouse is being moved, but
60 * we want to generate 'pseudo' mouse events when the mouse button is
61 * pressed and the mouse cursor is below the bottom, or above the top
62 * of the work area. In this way, we'll be able to continue scrolling
63 * (and selecting) the text.
65 * This class stores all the parameters needed to make this happen.
67 class SyntheticMouseEvent
70 SyntheticMouseEvent();
77 double scrollbar_value_old;
81 * Qt-specific implementation of the work area
85 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
91 GuiWorkArea(int width, int height, int id, LyXView & lyx_view);
94 bool hasFocus() const { return QAbstractScrollArea::hasFocus(); }
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 virtual void scheduleRedraw() { schedule_redraw_ = true; }
105 /// update the passed area.
106 void update(int x, int y, int w, int h);
108 /// copies specified area of pixmap to screen
109 virtual void expose(int x, int y, int exp_width, int exp_height);
111 /// paint the cursor and store the background
112 virtual void showCursor(int x, int y, int h, CursorShape shape);
115 virtual void removeCursor();
118 void doGreyOut(QLPainter & pain);
120 void dragEnterEvent(QDragEnterEvent * ev);
122 void dropEvent(QDropEvent * ev);
124 void focusInEvent(QFocusEvent *);
126 void focusOutEvent(QFocusEvent *);
127 /// repaint part of the widget
128 void paintEvent(QPaintEvent * ev);
129 /// widget has been resized
130 void resizeEvent(QResizeEvent * ev);
131 /// mouse button press
132 void mousePressEvent(QMouseEvent * ev);
133 /// mouse button release
134 void mouseReleaseEvent(QMouseEvent * ev);
135 /// mouse double click of button
136 void mouseDoubleClickEvent(QMouseEvent * ev);
138 void mouseMoveEvent(QMouseEvent * ev);
140 void wheelEvent(QWheelEvent * ev);
142 void keyPressEvent(QKeyEvent * ev);
144 void inputMethodEvent(QInputMethodEvent * ev);
146 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
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);
156 /// timer to limit triple clicks
157 void doubleClickTimeout();
160 /// The slot connected to SyntheticMouseEvent::timeout.
161 void generateSyntheticMouseEvent();
164 SyntheticMouseEvent synthetic_mouse_event_;
166 double_click dc_event_;
169 CursorWidget * cursor_;
177 bool schedule_redraw_;
182 } // namespace frontend