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 "support/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 focusInEvent(QFocusEvent *);
122 void focusOutEvent(QFocusEvent *);
123 /// repaint part of the widget
124 void paintEvent(QPaintEvent * ev);
125 /// widget has been resized
126 void resizeEvent(QResizeEvent * ev);
127 /// mouse button press
128 void mousePressEvent(QMouseEvent * ev);
129 /// mouse button release
130 void mouseReleaseEvent(QMouseEvent * ev);
131 /// mouse double click of button
132 void mouseDoubleClickEvent(QMouseEvent * ev);
134 void mouseMoveEvent(QMouseEvent * ev);
136 void wheelEvent(QWheelEvent * ev);
138 void keyPressEvent(QKeyEvent * ev);
140 void inputMethodEvent(QInputMethodEvent * ev);
142 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
145 /// Adjust the LyX buffer view with the position of the scrollbar.
147 * The action argument is not used in the the code, it is there
148 * only for the connection to the vertical srollbar signal which
149 * emits an 'int' action.
151 void adjustViewWithScrollBar(int action = 0);
152 /// timer to limit triple clicks
153 void doubleClickTimeout();
156 /// The slot connected to SyntheticMouseEvent::timeout.
157 void generateSyntheticMouseEvent();
160 SyntheticMouseEvent synthetic_mouse_event_;
162 double_click dc_event_;
165 CursorWidget * cursor_;
173 bool schedule_redraw_;
178 } // namespace frontend