1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        gtk/evtloop.cpp 
   3 // Purpose:     implements wxEventLoop for GTK+ 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> 
   9 // License:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 // For compilers that support precompilation, includes "wx.h". 
  21 #include "wx/wxprec.h" 
  27 #include "wx/evtloop.h" 
  32 // ---------------------------------------------------------------------------- 
  34 // ---------------------------------------------------------------------------- 
  36 class WXDLLEXPORT wxEventLoopImpl
 
  40     wxEventLoopImpl() { SetExitCode(0); } 
  42     // set/get the exit code 
  43     void SetExitCode(int exitcode
) { m_exitcode 
= exitcode
; } 
  44     int GetExitCode() const { return m_exitcode
; } 
  47     // the exit code of the event loop 
  51 // ============================================================================ 
  52 // wxEventLoop implementation 
  53 // ============================================================================ 
  55 // ---------------------------------------------------------------------------- 
  56 // wxEventLoop running and exiting 
  57 // ---------------------------------------------------------------------------- 
  59 wxEventLoop::~wxEventLoop() 
  61     wxASSERT_MSG( !m_impl
, _T("should have been deleted in Run()") ); 
  64 int wxEventLoop::Run() 
  66     // event loops are not recursive, you need to create another loop! 
  67     wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") ); 
  69     wxEventLoopActivator 
activate(this); 
  71     m_impl 
= new wxEventLoopImpl
; 
  75     int exitcode 
= m_impl
->GetExitCode(); 
  82 void wxEventLoop::Exit(int rc
) 
  84     wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") ); 
  86     m_impl
->SetExitCode(rc
); 
  91 // ---------------------------------------------------------------------------- 
  92 // wxEventLoop message processing dispatching 
  93 // ---------------------------------------------------------------------------- 
  95 bool wxEventLoop::Pending() const 
  99         // We need to remove idle callbacks or gtk_events_pending will 
 100         // never return false. 
 101         wxTheApp
->RemoveIdleTag(); 
 104     return gtk_events_pending(); 
 107 bool wxEventLoop::Dispatch() 
 109     wxCHECK_MSG( IsRunning(), FALSE
, _T("can't call Dispatch() if not running") ); 
 111     gtk_main_iteration();