added untested implementation of wxEvtLoop for GTK+
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
117
src/gtk/evtloop.cpp
Normal file
117
src/gtk/evtloop.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gtk/evtloop.cpp
|
||||
// Purpose: implements wxEventLoop for GTK+
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 10.07.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "evtloop.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoopImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxEventLoopImpl
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
wxEventLoopImpl() { SetExitCode(0); }
|
||||
|
||||
// set/get the exit code
|
||||
void SetExitCode(int exitcode) { m_exitcode = exitcode; }
|
||||
int GetExitCode() const { return m_exitcode; }
|
||||
|
||||
private:
|
||||
// the exit code of the event loop
|
||||
int m_exitcode;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// wxEventLoop implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop running and exiting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxEventLoop::~wxEventLoop()
|
||||
{
|
||||
wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
|
||||
}
|
||||
|
||||
bool wxEventLoop::IsRunning() const
|
||||
{
|
||||
return m_impl != NULL;
|
||||
}
|
||||
|
||||
int wxEventLoop::Run()
|
||||
{
|
||||
// event loops are not recursive, you need to create another loop!
|
||||
wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
|
||||
|
||||
m_impl = new wxEventLoopImpl;
|
||||
|
||||
gtk_main();
|
||||
|
||||
int exitcode = m_impl->GetExitCode();
|
||||
delete m_impl;
|
||||
m_impl = NULL;
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
void wxEventLoop::Exit(int rc)
|
||||
{
|
||||
wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
|
||||
|
||||
m_impl->SetExitCode(rc);
|
||||
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop message processing dispatching
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxEventLoop::Pending() const
|
||||
{
|
||||
return gtk_events_pending() > 0;
|
||||
}
|
||||
|
||||
bool wxEventLoop::Dispatch()
|
||||
{
|
||||
wxCHECK_MSG( IsRunning(), FALSE, _T("can't call Dispatch() if not running") );
|
||||
|
||||
gtk_main_iteration();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
117
src/gtk1/evtloop.cpp
Normal file
117
src/gtk1/evtloop.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gtk/evtloop.cpp
|
||||
// Purpose: implements wxEventLoop for GTK+
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 10.07.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "evtloop.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoopImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxEventLoopImpl
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
wxEventLoopImpl() { SetExitCode(0); }
|
||||
|
||||
// set/get the exit code
|
||||
void SetExitCode(int exitcode) { m_exitcode = exitcode; }
|
||||
int GetExitCode() const { return m_exitcode; }
|
||||
|
||||
private:
|
||||
// the exit code of the event loop
|
||||
int m_exitcode;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// wxEventLoop implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop running and exiting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxEventLoop::~wxEventLoop()
|
||||
{
|
||||
wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
|
||||
}
|
||||
|
||||
bool wxEventLoop::IsRunning() const
|
||||
{
|
||||
return m_impl != NULL;
|
||||
}
|
||||
|
||||
int wxEventLoop::Run()
|
||||
{
|
||||
// event loops are not recursive, you need to create another loop!
|
||||
wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
|
||||
|
||||
m_impl = new wxEventLoopImpl;
|
||||
|
||||
gtk_main();
|
||||
|
||||
int exitcode = m_impl->GetExitCode();
|
||||
delete m_impl;
|
||||
m_impl = NULL;
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
void wxEventLoop::Exit(int rc)
|
||||
{
|
||||
wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
|
||||
|
||||
m_impl->SetExitCode(rc);
|
||||
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop message processing dispatching
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxEventLoop::Pending() const
|
||||
{
|
||||
return gtk_events_pending() > 0;
|
||||
}
|
||||
|
||||
bool wxEventLoop::Dispatch()
|
||||
{
|
||||
wxCHECK_MSG( IsRunning(), FALSE, _T("can't call Dispatch() if not running") );
|
||||
|
||||
gtk_main_iteration();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user