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
15 #include "funcrequest.h"
18 #include "frontends/Timeout.h"
21 #include "frontends/Timeout.h"
28 #include <boost/scoped_ptr.hpp>
32 #if (defined(Q_WS_X11) && QT_VERSION >= 0x030200)
33 #define USE_INPUT_METHODS 1
37 /// for emulating triple click
42 Qt::ButtonState state;
45 bool operator==(QMouseEvent const & e) {
46 return x == e.x() && y == e.y()
47 && state == e.button();
51 : x(0), y(0), state(Qt::NoButton), active(false) {}
53 double_click(QMouseEvent * e)
54 : x(e->x()), y(e->y()),
55 state(e->button()), active(true) {}
64 /** Qt only emits mouse events when the mouse is being moved, but
65 * we want to generate 'pseudo' mouse events when the mouse button is
66 * pressed and the mouse cursor is below the bottom, or above the top
67 * of the work area. In this way, we'll be able to continue scrolling
68 * (and selecting) the text.
70 * This class stores all the parameters needed to make this happen.
72 class SyntheticMouseEvent
75 SyntheticMouseEvent();
82 double scrollbar_value_old;
87 * Widget for actually drawing the document on
89 class QContentPane : public QWidget {
92 QContentPane(QWorkArea * parent);
94 /// return the backing pixmap
95 QPixmap * pixmap() const { return pixmap_.get(); }
96 /// track scrollbar signals?
97 void trackScrollbar(bool track_on);
100 /// repaint part of the widget
101 void paintEvent(QPaintEvent * e);
102 /// widget has been resized
103 void resizeEvent(QResizeEvent * e);
105 /// mouse button press
106 void mousePressEvent(QMouseEvent * e);
107 /// mouse button release
108 void mouseReleaseEvent(QMouseEvent * e);
109 /// mouse double click of button
110 void mouseDoubleClickEvent(QMouseEvent * e);
112 void mouseMoveEvent(QMouseEvent * e);
114 void wheelEvent(QWheelEvent * e);
116 void keyPressEvent(QKeyEvent * e);
117 #if USE_INPUT_METHODS
119 void imStartEvent(QIMEvent *);
120 void imComposeEvent(QIMEvent *);
121 void imEndEvent(QIMEvent *);
124 void doubleClickTimeout();
126 void scrollBarChanged(int);
127 void keyeventTimeout();
130 /// The slot connected to SyntheticMouseEvent::timeout.
131 void generateSyntheticMouseEvent();
132 SyntheticMouseEvent synthetic_mouse_event_;
135 bool track_scrollbar_;
140 std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
142 /// the double buffered pixmap
143 boost::scoped_ptr<QPixmap> pixmap_;
145 double_click dc_event_;
148 } // namespace frontend
151 #endif // QCONTENTPANE_H