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) {}
- };
-
- Events.h
-
- #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;
-
- static bool putback_pending; // a buffer to store a put-back event
- static EventRecord putback_event; // (to be retrieved later)
-
- public:
- // A wrap around WaitNextEvent() to take care
- // of put-back events, and to transparently
- // process high-level events
- static bool wait_next_event(EventRecord& event, const int timeout);
- static void flush_side_events(void); // Take care of a SIOUX console if any
-
-
- EventHandler(ScreenWindow& window_to_serve, const long _event_timeout=5)
- : serviced_window(window_to_serve), event_timeout(_event_timeout) {}
- void loop(void);
-
- enum { mykind = 128 }; // The kind of _my_ events
- enum { zoom_requested, resize_requested, start_requested, open_picture,
- quit_requested }; // My event modifiers
-
- // putting an event back into the "event queue"
- static void put_back(const EventRecord& event);
- static void put_back_my_event(const EventModifiers modifiers, const UInt32 message, const Point where);
- static void put_back_my_event(const EventModifiers modifiers, const UInt32 message = 0);
- };
-
-
-