home *** CD-ROM | disk | FTP | other *** search
- /*
- ***********************************************************************
- *
- *
- * Event Handler Classes
- *
- *
- ***********************************************************************
- */
-
- #if 0
- // Registering handler for the null events
- // It's an abstract class. You need to subclass
- // it and define your own null event handler
- class NullEventHandler
- {
- friend class EventHandler;
- const long event_timeout; // For WaitNextEvent, set pacing for null events
- static NullEventHandler * first_handler;
- // NullEventHandler * prev_handler; // We don't chain null event handlers at
- // present. But this is in case we will
- // in the future
-
- // Takes the time (in ticks) when the null
- // event was received. Return FALSE to
- // quit
- virtual Boolean handle_null_event(const long event_time) = 0;
-
- public:
- // No chaining at the moment
- NullEventHandler(void) : first_handler(this) {}
- ~NullEventHandler(void) : first_handler(nil) {}
- };
-
- #endif
-
- // Obviously this event handler assumes that an
- // application has the _only_ one window
- // to handle events for.
- // It's a very primitive case, but that'll be
- // enough
- // It's kind of silly to define a class for the
- // sake of only one method, loop(), which may well
- // be just a regular function. It'll pay off later
- // when we're going to have more than one window
- // to take care of
- class ScreenWindow;
- class EventHandler
- {
- EventRecord the_event;
- const long event_timeout; // waiting for the next event
- ScreenWindow& serviced_window;
- public:
- EventHandler(ScreenWindow& window_to_serve, const long _event_timeout=5)
- : serviced_window(window_to_serve), event_timeout(_event_timeout) {}
- void loop(void);
- };
-