]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/evtloop.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxEventLoop and related classes 
   4 // Author:      Vadim Zeitlin 
   5 // Copyright:   (C) 2008 Vadim Zeitlin 
   7 // Licence:     wxWindows license 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11     @class wxEventLoopBase 
  13     Base class for all event loop implementations. 
  15     An object of this class is created by wxAppTraits::CreateEventLoop() and 
  16     used by wxApp to run the main application event loop. 
  19     @category{appmanagement} 
  27         Return the currently active (running) event loop. 
  29         May return @NULL if there is no active event loop (e.g. during 
  30         application startup or shutdown). 
  32     static wxEventLoopBase 
*GetActive(); 
  35         Set currently active (running) event loop. 
  37         Called by wxEventLoopActivator, use an instance of this class instead 
  38         of calling this method directly to ensure that the previously active 
  39         event loop is restored. 
  41     static void SetActive(wxEventLoopBase
* loop
); 
  45         Use this to check whether the event loop was successfully created 
  48     virtual bool IsOk() const; 
  51         Start the event loop, return the exit code when it is finished. 
  53         Logically, this method calls Dispatch() in a loop until it returns 
  54         @false and also takes care of generating idle events during each loop 
  55         iteration. However not all implementations of this class really 
  56         implement it like this (e.g. wxGTK does not) so you shouldn't rely on 
  57         Dispatch() being called from inside this function. 
  59         @return The argument passed to Exit() which terminated this event loop. 
  61     virtual int Run() = 0; 
  64         Exit from the loop with the given exit code. 
  66     virtual void Exit(int rc 
= 0) = 0; 
  69         Return true if any events are available. 
  71         If this method returns @true, calling Dispatch() will not block. 
  73     virtual bool Pending() const = 0; 
  76         Dispatch a single event. 
  78         If there are currently no events in the queue, blocks until an event 
  81         @return @false only if the event loop should terminate. 
  83     virtual bool Dispatch() = 0; 
  86         Return true if this event loop is currently running. 
  88         Notice that even if this event loop hasn't terminated yet but has just 
  89         spawned a nested (e.g. modal) event loop, this method would return 
  92     bool IsRunning() const; 
  95         Called by wxWidgets to wake up the event loop even if it is currently 
  96         blocked inside Dispatch(). 
  98     virtual void WakeUp() = 0; 
 102         This function is called before the event loop terminates, whether this 
 103         happens normally (because of Exit() call) or abnormally (because of an 
 104         exception thrown from inside the loop). 
 106         Default version does nothing. 
 108     virtual void OnExit(); 
 112     @class wxEventLoopActivator 
 114     Makes an event loop temporarily active. 
 116     This class is used to make the event loop active during its life-time, 
 119         class MyEventLoop : public wxEventLoopBase { ... }; 
 124             wxEventLoopActivator activate(&loop); 
 127         } // the previously active event loop restored here 
 131     @category{appmanagement} 
 135 class wxEventLoopActivator
 
 139         Makes the loop passed as the parameter currently active. 
 141         This saves the current return value of wxEventLoopBase::GetActive() and 
 142         then calls wxEventLoopBase::SetActive() with the given @a loop. 
 144     wxEventLoopActivator(wxEventLoopBase 
*loop
); 
 147         Restores the previously active event loop stored by the constructor. 
 149     ~wxEventLoopActivator();