// Created: 01.11.02
// RCS-ID: $Id$
// Copyright: (c) 2002 Mattia Barbon
-// License: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// headers
// ----------------------------------------------------------------------------
-#ifdef __VMS
-#define XtParent XTPARENT
-#define XtDisplay XTDISPLAY
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
+ #include "wx/event.h"
+ #include "wx/app.h"
+ #include "wx/window.h"
+ #include "wx/module.h"
#endif //WX_PRECOMP
#include "wx/evtloop.h"
-#include "wx/event.h"
-#include "wx/app.h"
-#include "wx/window.h"
+#include "wx/thread.h"
#ifdef __VMS__
-#pragma message disable nosimpint
+ #pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/Xlib.h>
#ifdef __VMS__
-#pragma message enable nosimpint
+ #pragma message enable nosimpint
#endif
#include "wx/unix/private.h"
#include "wx/motif/private.h"
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+
static bool CheckForKeyUp(XEvent* event);
static bool CheckForKeyDown(XEvent* event);
static bool CheckForAccelerator(XEvent* event);
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
-wxEventLoop::~wxEventLoop()
+wxGUIEventLoop::~wxGUIEventLoop()
{
- wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
+ wxASSERT_MSG( !m_impl, wxT("should have been deleted in Run()") );
}
-int wxEventLoop::Run()
+int wxGUIEventLoop::Run()
{
// event loops are not recursive, you need to create another loop!
- wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
+ wxCHECK_MSG( !IsRunning(), -1, wxT("can't reenter a message loop") );
wxEventLoopActivator activate(this);
break;
}
+ OnExit();
+
int exitcode = m_impl->GetExitCode();
- delete m_impl;
- m_impl = NULL;
+ wxDELETE(m_impl);
return exitcode;
}
-void wxEventLoop::Exit(int rc)
+void wxGUIEventLoop::Exit(int rc)
{
- wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
+ wxCHECK_RET( IsRunning(), wxT("can't call Exit() if not running") );
m_impl->SetExitCode(rc);
m_impl->SetKeepGoing( false );
::wxBreakDispatch();
}
+bool wxGUIEventLoop::YieldFor(long eventsToProcess)
+{
+ m_isInsideYield = true;
+ m_eventsToProcessInsideYield = eventsToProcess;
+
+ while (wxTheApp && wxTheApp->Pending())
+ // TODO: implement event filtering using the eventsToProcess mask
+ wxTheApp->Dispatch();
+
+ m_isInsideYield = false;
+
+ return true;
+}
+
// ----------------------------------------------------------------------------
// wxEventLoop message processing dispatching
// ----------------------------------------------------------------------------
-bool wxEventLoop::Pending() const
+bool wxGUIEventLoop::Pending() const
{
return XtAppPending( (XtAppContext)wxTheApp->GetAppContext() ) != 0;
}
-bool wxEventLoop::Dispatch()
+bool wxGUIEventLoop::Dispatch()
{
XEvent event;
XtAppContext context = (XtAppContext)wxTheApp->GetAppContext();
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, event);
- return win->GetEventHandler()->ProcessEvent( keyEvent );
+ return win->HandleWindowEvent( keyEvent );
}
return false;
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, event);
- return win->GetEventHandler()->ProcessEvent( keyEvent );
+ return win->HandleWindowEvent( keyEvent );
}
return false;
// executes one main loop iteration (declared in include/wx/motif/private.h)
// ----------------------------------------------------------------------------
-bool wxDoEventLoopIteration( wxEventLoop& evtLoop )
+bool wxDoEventLoopIteration( wxGUIEventLoop& evtLoop )
{
bool moreRequested, pendingEvents;
// also wxEventLoop::Exit is implemented that way, so that exiting an
// event loop won't require an event being in the queue
-#include "wx/module.h"
-
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
return true;
}
-