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