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
33 Qt::ButtonState state;
36 bool operator==(QMouseEvent const & e) {
37 return x == e.x() && y == e.y()
38 && state == e.button();
42 : x(0), y(0), state(Qt::NoButton), active(false) {}
44 double_click(QMouseEvent * e)
45 : x(e->x()), y(e->y()),
46 state(e->button()), active(true) {}
50 /** Qt only emits mouse events when the mouse is being moved, but
51 * we want to generate 'pseudo' mouse events when the mouse button is
52 * pressed and the mouse cursor is below the bottom, or above the top
53 * of the work area. In this way, we'll be able to continue scrolling
54 * (and selecting) the text.
56 * This struct stores all the parameters needed to make this happen.
58 struct SyntheticMouseEvent
60 SyntheticMouseEvent();
67 double scrollbar_value_old;
72 * Widget for actually drawing the document on
74 class QContentPane : public QWidget {
77 QContentPane(QWorkArea * parent);
79 /// return the backing pixmap
80 QPixmap * pixmap() const { return pixmap_.get(); }
81 /// track scrollbar signals?
82 void trackScrollbar(bool track_on);
85 /// repaint part of the widget
86 void paintEvent(QPaintEvent * e);
87 /// widget has been resized
88 void resizeEvent(QResizeEvent * e);
90 /// mouse button press
91 void mousePressEvent(QMouseEvent * e);
92 /// mouse button release
93 void mouseReleaseEvent(QMouseEvent * e);
94 /// mouse double click of button
95 void mouseDoubleClickEvent(QMouseEvent * e);
97 void mouseMoveEvent(QMouseEvent * e);
99 void wheelEvent(QWheelEvent * e);
101 void keyPressEvent(QKeyEvent * e);
103 void doubleClickTimeout();
105 void scrollBarChanged(int);
107 /// The slot connected to SyntheticMouseEvent::timeout.
108 void generateSyntheticMouseEvent();
109 SyntheticMouseEvent synthetic_mouse_event_;
112 bool track_scrollbar_;
116 /// the double buffered pixmap
117 boost::scoped_ptr<QPixmap> pixmap_;
119 double_click dc_event_;
122 #endif // QCONTENTPANE_H