]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QContentPane.h
Joao latest bits
[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 #include <qwidget.h>
16 #include <qpixmap.h>
17
18 #include <boost/scoped_ptr.hpp>
19
20 class QWorkArea;
21
22 /// for emulating triple click
23 struct double_click {
24         int x;
25         int y;
26         Qt::ButtonState state;
27         bool active;
28
29         bool operator==(QMouseEvent const & e) {
30                 return x == e.x() && y == e.y()
31                         && state == e.button();
32         }
33
34         double_click()
35                 : x(0), y(0), state(Qt::NoButton), active(false) {}
36
37         double_click(QMouseEvent * e)
38                 : x(e->x()), y(e->y()),
39                 state(e->button()), active(true) {}
40 };
41
42
43 /**
44  * Widget for actually drawing the document on
45  */
46 class QContentPane : public QWidget {
47         Q_OBJECT
48 public:
49         QContentPane(QWorkArea * parent);
50
51         /// return the backing pixmap
52         QPixmap * pixmap() const { return pixmap_.get(); }
53 protected:
54         /// repaint part of the widget
55         void paintEvent(QPaintEvent * e);
56         /// widget has been resized
57         void resizeEvent(QResizeEvent * e);
58
59         /// mouse button press
60         void mousePressEvent(QMouseEvent * e);
61         /// mouse button release
62         void mouseReleaseEvent(QMouseEvent * e);
63         /// mouse double click of button
64         void mouseDoubleClickEvent(QMouseEvent * e);
65         /// mouse motion
66         void mouseMoveEvent(QMouseEvent * e);
67         /// wheel event
68         void wheelEvent(QWheelEvent * e);
69         /// key press
70         void keyPressEvent(QKeyEvent * e);
71 public slots:
72         void doubleClickTimeout();
73
74         void scrollBarChanged(int);
75 private:
76         /// owning widget
77         QWorkArea * wa_;
78
79         /// the double buffered pixmap
80         boost::scoped_ptr<QPixmap> pixmap_;
81
82         double_click dc_event_;
83 };
84
85 #endif // QCONTENTPANE_H