home *** CD-ROM | disk | FTP | other *** search
- /*
- * machandler.c
- *
- * Handles all IO events directed to us by the operating system, and passes them on to specialised
- * procedures.
- *
- */
-
- #include <MacHeaders>
- #include <Controls.h>
- #include <Events.h>
- #include <Dialogs.h>
- #include "geom.h"
- #include "macmenus.h"
- #include "maceditor.h"
-
- extern WindowPtr imageWindow, informationWindow;
- extern DialogPtr editorDialog ;
- extern struct menuinfo menuInfo ;
-
- void HandleMouseDown (EventRecord *theEvent);
- void HandleEvent(void);
-
- Rect dragRect = { 0, 0, 1024, 1024 };
-
- void HandleEditorEvent(EventRecord *theEvent) ;
- extern ControlHandle SnatchHandle(DialogPtr thebox, short theGetItem) ;
-
-
- /*
- * HandleEvent()
- *
- * The main event dispatcher. This routine should be called
- * repeatedly (it handles only one event).
- *
- */
-
- void HandleEvent(void)
- {
- DialogPtr theDialog;
- short dialogItem ;
- int ok;
- EventRecord theEvent;
-
- SystemTask(); /* Handle desk accessories */
- ok = GetNextEvent(everyEvent, &theEvent);
- if (ok) {
- if (IsDialogEvent(&theEvent)) {
- HandleEditorEvent(&theEvent) ;
- }
- else {
- switch (theEvent.what) {
- case mouseDown:
- HandleMouseDown(&theEvent);
- break;
- case keyDown:
- case autoKey:
- if ((theEvent.modifiers & cmdKey) != 0) {
- AdjustMenus();
- HandleMenu(MenuKey((char) (theEvent.message & charCodeMask)));
- }
- break;
- case updateEvt:
- UpdateWind() ;
- UpdateEditor() ;
- break;
- case activateEvt:
- break;
- default:
- break ;
- }
- }
- }
- }
-
- /*
- * HandleMouseDown (theEvent)
- *
- * Take care of mouseDown events.
- *
- */
-
- void HandleMouseDown (EventRecord *theEvent)
-
- {
- WindowPtr theWindow;
- int windowCode ;
-
- windowCode = FindWindow(theEvent->where, &theWindow);
- switch (windowCode) {
- case inSysWindow:
- SystemClick (theEvent, theWindow);
- break;
- case inMenuBar:
- HandleMenu(MenuSelect(theEvent->where));
- AdjustMenus();
- HiliteMenu(0);
- break;
- case inDrag:
- DragWindow(theWindow, theEvent->where, &dragRect);
- break;
- case inContent:
- if (theWindow != FrontWindow()) ;
- SelectWindow(theWindow);
- break;
- case inGoAway:
- if (theWindow && (theWindow == imageWindow) && !menuInfo.rendering) {
- if (TrackGoAway(theWindow, theEvent->where))
- CloseMacWindow() ;
- }
- break;
- case inGrow:
- if(theWindow && (theWindow == imageWindow) && !menuInfo.rendering)
- SizeImage(theEvent->where) ;
- break ;
- default:
- break ;
- }
- }
- /* end HandleMouseDown */
-