Made QExposeEvent public and added exposeEvent() in QWindow.

This is needed for applications that use QBackingStore directly.
This commit is contained in:
Samuel Rødal 2011-06-21 17:00:25 +02:00
parent dc40eaba1f
commit 18c1d67137
8 changed files with 51 additions and 14 deletions

View File

@ -38,8 +38,6 @@ Window::Window(QWindow *parent)
m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());
m_lastPos = QPoint(-1, -1); m_lastPos = QPoint(-1, -1);
render();
} }
void Window::mousePressEvent(QMouseEvent *event) void Window::mousePressEvent(QMouseEvent *event)
@ -71,6 +69,11 @@ void Window::mouseReleaseEvent(QMouseEvent *event)
render(); render();
} }
void Window::exposeEvent(QExposeEvent *)
{
render();
}
void Window::resizeEvent(QResizeEvent *) void Window::resizeEvent(QResizeEvent *)
{ {
QImage old = m_image; QImage old = m_image;

View File

@ -13,6 +13,7 @@ protected:
void keyPressEvent(QKeyEvent *); void keyPressEvent(QKeyEvent *);
void exposeEvent(QExposeEvent *);
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
private: private:

View File

@ -126,6 +126,7 @@ QT_BEGIN_NAMESPACE
\value Enter Mouse enters widget's boundaries. \value Enter Mouse enters widget's boundaries.
\value EnterEditFocus An editor widget gains focus for editing. \value EnterEditFocus An editor widget gains focus for editing.
\value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode. \value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode.
\value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.
\value FileOpen File open request (QFileOpenEvent). \value FileOpen File open request (QFileOpenEvent).
\value FocusIn Widget gains keyboard focus (QFocusEvent). \value FocusIn Widget gains keyboard focus (QFocusEvent).
\value FocusOut Widget loses keyboard focus (QFocusEvent). \value FocusOut Widget loses keyboard focus (QFocusEvent).

View File

@ -1145,6 +1145,29 @@ QMoveEvent::~QMoveEvent()
Returns the old position of the widget. Returns the old position of the widget.
*/ */
/*!
\class QExposeEvent
\brief The QExposeEvent class contains event parameters for expose events.
\ingroup events
Expose events are sent to widgets when an area of the widget is invalidated
and needs to be flushed from the backing store.
The event handler QWindow::exposeEvent() receives expose events.
*/
QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
: QEvent(Expose)
, rgn(exposeRegion)
{
}
/*!
\internal
*/
QExposeEvent::~QExposeEvent()
{
}
/*! /*!
\class QResizeEvent \class QResizeEvent

View File

@ -300,6 +300,17 @@ protected:
friend class QCoreApplication; friend class QCoreApplication;
}; };
class Q_GUI_EXPORT QExposeEvent : public QEvent
{
public:
QExposeEvent(const QRegion &rgn);
~QExposeEvent();
inline const QRegion &region() const { return rgn; }
protected:
QRegion rgn;
};
class Q_GUI_EXPORT QResizeEvent : public QEvent class Q_GUI_EXPORT QResizeEvent : public QEvent
{ {

View File

@ -167,18 +167,6 @@ public:
QScrollEvent::ScrollState state; QScrollEvent::ScrollState state;
}; };
class QExposeEvent : public QEvent
{
public:
inline QExposeEvent(const QRegion &rgn)
: QEvent(Expose)
, region(rgn)
{
}
QRegion region;
};
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QEVENT_P_H #endif // QEVENT_P_H

View File

@ -454,6 +454,10 @@ bool QWindow::close()
return true; return true;
} }
void QWindow::exposeEvent(QExposeEvent *)
{
}
void QWindow::resizeEvent(QResizeEvent *) void QWindow::resizeEvent(QResizeEvent *)
{ {
} }
@ -510,6 +514,10 @@ bool QWindow::event(QEvent *event)
destroy(); destroy();
break; break;
case QEvent::Expose:
exposeEvent(static_cast<QExposeEvent *>(event));
break;
default: default:
return QObject::event(event); return QObject::event(event);
} }

View File

@ -57,6 +57,7 @@ QT_MODULE(Gui)
class QWindowPrivate; class QWindowPrivate;
class QExposeEvent;
class QResizeEvent; class QResizeEvent;
class QShowEvent; class QShowEvent;
class QHideEvent; class QHideEvent;
@ -179,6 +180,7 @@ Q_SIGNALS:
void backBufferReady(); void backBufferReady();
protected: protected:
virtual void exposeEvent(QExposeEvent *);
virtual void resizeEvent(QResizeEvent *); virtual void resizeEvent(QResizeEvent *);
virtual void showEvent(QShowEvent *); virtual void showEvent(QShowEvent *);