2002-06-19 03:38:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file QContentPane.h
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 03:38:44 +00:00
|
|
|
*
|
2002-09-24 13:57:09 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-19 03:38:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QCONTENTPANE_H
|
|
|
|
#define QCONTENTPANE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <qwidget.h>
|
|
|
|
#include <qevent.h>
|
2002-09-24 13:57:09 +00:00
|
|
|
#include <qpixmap.h>
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
class QWorkArea;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
2002-08-29 01:25:41 +00:00
|
|
|
/// for emulating triple click
|
|
|
|
struct double_click {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
Qt::ButtonState state;
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
bool operator==(QMouseEvent const & e) {
|
|
|
|
return x == e.x() && y == e.y()
|
|
|
|
&& state == e.button();
|
|
|
|
}
|
|
|
|
|
|
|
|
double_click()
|
|
|
|
: x(0), y(0), state(Qt::NoButton), active(false) {}
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-08-29 01:25:41 +00:00
|
|
|
double_click(QMouseEvent * e)
|
|
|
|
: x(e->x()), y(e->y()),
|
|
|
|
state(e->button()), active(true) {}
|
|
|
|
};
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/**
|
|
|
|
* Widget for actually drawing the document on
|
|
|
|
*/
|
|
|
|
class QContentPane : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QContentPane(QWorkArea * parent);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// return the backing pixmap
|
2002-09-24 13:57:09 +00:00
|
|
|
QPixmap * pixmap() const { return pixmap_.get(); }
|
2002-06-19 03:38:44 +00:00
|
|
|
protected:
|
|
|
|
/// repaint part of the widget
|
|
|
|
void paintEvent(QPaintEvent * e);
|
|
|
|
/// widget has been resized
|
|
|
|
void resizeEvent(QResizeEvent * e);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// mouse button press
|
|
|
|
void mousePressEvent(QMouseEvent * e);
|
2002-09-24 13:57:09 +00:00
|
|
|
/// mouse button release
|
2002-06-19 03:38:44 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent * e);
|
2002-09-24 13:57:09 +00:00
|
|
|
/// mouse double click of button
|
2002-06-19 03:38:44 +00:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent * e);
|
|
|
|
/// mouse motion
|
|
|
|
void mouseMoveEvent(QMouseEvent * e);
|
2002-10-21 04:46:26 +00:00
|
|
|
/// wheel event
|
|
|
|
void wheelEvent(QWheelEvent * e);
|
2002-06-19 03:38:44 +00:00
|
|
|
/// key press
|
|
|
|
void keyPressEvent(QKeyEvent * e);
|
|
|
|
public slots:
|
2002-08-29 01:25:41 +00:00
|
|
|
void doubleClickTimeout();
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
void scrollBarChanged(int);
|
|
|
|
private:
|
|
|
|
/// owning widget
|
|
|
|
QWorkArea * wa_;
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
/// the double buffered pixmap
|
|
|
|
boost::scoped_ptr<QPixmap> pixmap_;
|
2002-08-29 01:25:41 +00:00
|
|
|
|
|
|
|
double_click dc_event_;
|
2002-06-19 03:38:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QCONTENTPANE_H
|