]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QContentPane.h
Get rid of the static_casts.
[lyx.git] / src / frontends / qt2 / QContentPane.h
1 // -*- C++ -*-
2 /**
3  * \file QContentPane.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef QCONTENTPANE_H
13 #define QCONTENTPANE_H
14
15
16 #include <qwidget.h>
17 #include <qevent.h>
18 #include <qpixmap.h>
19
20 #include <boost/scoped_ptr.hpp>
21
22 class QWorkArea;
23
24 /// for emulating triple click
25 struct double_click {
26         int x;
27         int y;
28         Qt::ButtonState state;
29         bool active;
30
31         bool operator==(QMouseEvent const & e) {
32                 return x == e.x() && y == e.y()
33                         && state == e.button();
34         }
35
36         double_click()
37                 : x(0), y(0), state(Qt::NoButton), active(false) {}
38
39         double_click(QMouseEvent * e)
40                 : x(e->x()), y(e->y()),
41                 state(e->button()), active(true) {}
42 };
43
44
45 /**
46  * Widget for actually drawing the document on
47  */
48 class QContentPane : public QWidget {
49         Q_OBJECT
50 public:
51         QContentPane(QWorkArea * parent);
52
53         /// return the backing pixmap
54         QPixmap * pixmap() const { return pixmap_.get(); }
55 protected:
56         /// repaint part of the widget
57         void paintEvent(QPaintEvent * e);
58         /// widget has been resized
59         void resizeEvent(QResizeEvent * e);
60
61         /// mouse button press
62         void mousePressEvent(QMouseEvent * e);
63         /// mouse button release
64         void mouseReleaseEvent(QMouseEvent * e);
65         /// mouse double click of button
66         void mouseDoubleClickEvent(QMouseEvent * e);
67         /// mouse motion
68         void mouseMoveEvent(QMouseEvent * e);
69         /// wheel event
70         void wheelEvent(QWheelEvent * e);
71         /// key press
72         void keyPressEvent(QKeyEvent * e);
73 public slots:
74         void doubleClickTimeout();
75
76         void scrollBarChanged(int);
77 private:
78         /// owning widget
79         QWorkArea * wa_;
80
81         /// the double buffered pixmap
82         boost::scoped_ptr<QPixmap> pixmap_;
83
84         double_click dc_event_;
85 };
86
87 #endif // QCONTENTPANE_H