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(Buffer & buffer, LyXView & lv);
94 bool hasFocus() const { return QAbstractScrollArea::hasFocus(); }
95 bool isVisible() const { return QAbstractScrollArea::isVisible(); }
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 virtual void scheduleRedraw() { schedule_redraw_ = true; }
106 /// update the passed area.
107 void update(int x, int y, int w, int h);
109 /// copies specified area of pixmap to screen
110 virtual void expose(int x, int y, int exp_width, int exp_height);
112 /// paint the cursor and store the background
113 virtual void showCursor(int x, int y, int h, CursorShape shape);
116 virtual void removeCursor();
119 void doGreyOut(QLPainter & pain);
121 void focusInEvent(QFocusEvent *);
123 void focusOutEvent(QFocusEvent *);
124 /// repaint part of the widget
125 void paintEvent(QPaintEvent * ev);
126 /// widget has been resized
127 void resizeEvent(QResizeEvent * ev);
128 /// mouse button press
129 void mousePressEvent(QMouseEvent * ev);
130 /// mouse button release
131 void mouseReleaseEvent(QMouseEvent * ev);
132 /// mouse double click of button
133 void mouseDoubleClickEvent(QMouseEvent * ev);
135 void mouseMoveEvent(QMouseEvent * ev);
137 void wheelEvent(QWheelEvent * ev);
139 void keyPressEvent(QKeyEvent * ev);
141 void inputMethodEvent(QInputMethodEvent * ev);
143 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
146 /// Adjust the LyX buffer view with the position of the scrollbar.
148 * The action argument is not used in the the code, it is there
149 * only for the connection to the vertical srollbar signal which
150 * emits an 'int' action.
152 void adjustViewWithScrollBar(int action = 0);
153 /// timer to limit triple clicks
154 void doubleClickTimeout();
157 /// The slot connected to SyntheticMouseEvent::timeout.
158 void generateSyntheticMouseEvent();
161 SyntheticMouseEvent synthetic_mouse_event_;
163 double_click dc_event_;
166 CursorWidget * cursor_;
174 bool schedule_redraw_;
179 } // namespace frontend