]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QContentPane.h
Some string(widget->text()) fixes. Weirdness
[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
23 #include <boost/scoped_ptr.hpp>
24
25 class QWorkArea;
26
27 /// for emulating triple click
28 struct double_click {
29         int x;
30         int y;
31         Qt::ButtonState state;
32         bool active;
33
34         bool operator==(QMouseEvent const & e) {
35                 return x == e.x() && y == e.y()
36                         && state == e.button();
37         }
38
39         double_click()
40                 : x(0), y(0), state(Qt::NoButton), active(false) {}
41
42         double_click(QMouseEvent * e)
43                 : x(e->x()), y(e->y()),
44                 state(e->button()), active(true) {}
45 };
46
47
48 /**
49  * Widget for actually drawing the document on
50  */
51 class QContentPane : public QWidget {
52         Q_OBJECT
53 public:
54         QContentPane(QWorkArea * parent);
55
56         /// return the backing pixmap
57         QPixmap * pixmap() const { return pixmap_.get(); }
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         /// wheel event
73         void wheelEvent(QWheelEvent * e);
74         /// key press
75         void keyPressEvent(QKeyEvent * e);
76 public slots:
77         void doubleClickTimeout();
78
79         void scrollBarChanged(int);
80 private:
81         /// owning widget
82         QWorkArea * wa_;
83
84         /// the double buffered pixmap
85         boost::scoped_ptr<QPixmap> pixmap_;
86
87         double_click dc_event_;
88 };
89
90 #endif // QCONTENTPANE_H