4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef QCONTENTPANE_H
13 #define QCONTENTPANE_H
19 #include "funcrequest.h"
20 #include "frontends/Timeout.h"
25 #include <boost/scoped_ptr.hpp>
29 /// for emulating triple click
34 Qt::ButtonState state;
37 bool operator==(QMouseEvent const & e) {
38 return x == e.x() && y == e.y()
39 && state == e.button();
43 : x(0), y(0), state(Qt::NoButton), active(false) {}
45 double_click(QMouseEvent * e)
46 : x(e->x()), y(e->y()),
47 state(e->button()), active(true) {}
51 /** Qt only emits mouse events when the mouse is being moved, but
52 * we want to generate 'pseudo' mouse events when the mouse button is
53 * pressed and the mouse cursor is below the bottom, or above the top
54 * of the work area. In this way, we'll be able to continue scrolling
55 * (and selecting) the text.
57 * This class stores all the parameters needed to make this happen.
59 class SyntheticMouseEvent
62 SyntheticMouseEvent();
69 double scrollbar_value_old;
74 * Widget for actually drawing the document on
76 class QContentPane : public QWidget {
79 QContentPane(QWorkArea * parent);
81 /// return the backing pixmap
82 QPixmap * pixmap() const { return pixmap_.get(); }
83 /// track scrollbar signals?
84 void trackScrollbar(bool track_on);
87 /// repaint part of the widget
88 void paintEvent(QPaintEvent * e);
89 /// widget has been resized
90 void resizeEvent(QResizeEvent * e);
92 /// mouse button press
93 void mousePressEvent(QMouseEvent * e);
94 /// mouse button release
95 void mouseReleaseEvent(QMouseEvent * e);
96 /// mouse double click of button
97 void mouseDoubleClickEvent(QMouseEvent * e);
99 void mouseMoveEvent(QMouseEvent * e);
101 void wheelEvent(QWheelEvent * e);
103 void keyPressEvent(QKeyEvent * e);
105 void doubleClickTimeout();
107 void scrollBarChanged(int);
109 /// The slot connected to SyntheticMouseEvent::timeout.
110 void generateSyntheticMouseEvent();
111 SyntheticMouseEvent synthetic_mouse_event_;
114 bool track_scrollbar_;
118 /// the double buffered pixmap
119 boost::scoped_ptr<QPixmap> pixmap_;
121 double_click dc_event_;
124 #endif // QCONTENTPANE_H