/****************************************************************************
**
** Copyright (C) 1992-2004 Trolltech AS. All rights reserved.
**
** This file is part of the gui module of the Qt Toolkit.
**
** Licensees holding valid Qt Preview licenses may use this file in
** accordance with the Qt Preview License Agreement provided with the
** Software.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef QGUIEVENTLOOP_H
#define QGUIEVENTLOOP_H

#include <qeventloop.h>
#include <qwindowdefs.h>

class QGuiEventLoopPrivate;

class QGuiEventLoop : public QEventLoop
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QGuiEventLoop)
public:
    QGuiEventLoop(QObject *parent = 0);
    ~QGuiEventLoop();

    virtual bool processEvents(ProcessEventsFlags flags);

#if defined(Q_WS_X11) || defined(Q_WS_QWS)
    virtual bool hasPendingEvents() const;
#elif defined(Q_WS_MAC)
    int registerTimer(int interval, QObject *obj);
    bool unregisterTimer(int id);
    bool unregisterTimers(QObject *obj);
    void registerSocketNotifier(QSocketNotifier *notifier);
    void unregisterSocketNotifier(QSocketNotifier *notifier);
    bool hasPendingEvents() const;
    int  activateTimers();
    void wakeUp();
#elif defined(Q_WS_WIN)
    void winProcessEvent(void *message);
#endif

    void flush();

protected:
#if defined(Q_WS_X11)
    virtual void appStartingUp();
    virtual void appClosingDown();
#endif
private:
    // internal initialization/cleanup - implemented in various platform specific files
    void init();
    void cleanup();

#if defined(Q_WS_MAC)
    friend class QApplicationPrivate;
    friend void qt_mac_select_timer_callbk(EventLoopTimerRef, void *);
#endif
};


#endif
