1 line
8.7 KiB
C
1 line
8.7 KiB
C
|
/* ElWhip.c
*
*
* Created by Eric Pooch on 1/26/14.
* Copyright 2014 __MyCompanyName__. All rights reserved.
*
*/
#include <Values.h>
#include <Types.h>
#include <QuickDraw.h>
#include <Fonts.h>
#include <Events.h>
#include <Windows.h>
#include <Menus.h>
#include <Dialogs.h>
#include <Files.h>
#include <Desk.h>
#include <ToolUtils.h>
#include <Memory.h>
#include <SegLoad.h>
#include <OSUtils.h>
#include <OSEvents.h>
#include <Traps.h>
#include "arch/macos_debug.h"
#include <string.h>
#include <stdlib.h>
#include "ElWhip.h"
#include "test.h"
/* GMac is used to hold the result of a SysEnvirons call. This makes
it convenient for any routine to check the environment. */
SysEnvRec gMac; /* set up by Initialize */
/* GHasWaitNextEvent is set at startup, and tells whether the WaitNextEvent
trap is available. If it is false, we know that we must call GetNextEvent. */
//Boolean gHasWaitNextEvent; /* set up by Initialize */
/* GInBackground is maintained by our osEvent handling routines. Any part of
the program can check it to find out if it is currently in the background. */
Boolean gInBackground; /* maintained by Initialize and DoEvent */
/* Here are declarations for all of the C routines. In MPW 3.0 we can use
actual prototypes for parameter type checking. */
void EventLoop( void );
void DoEvent( EventRecord *event );
void DoMenuCommand( long menuResult );
void MemoryInit( void );
void MacintoshInit( void );
void Restart(void);
void Terminate( void );
void GetTERect(WindowPtr window, Rect *teRect);
Boolean TrapAvailable( short tNumber, TrapType tType );
void AlertUser( void );
/* Define HiWrd and LoWrd macros for efficiency. */
#define HiWrd(aLong) (((aLong) >> 16) & 0xFFFF)
#define LoWrd(aLong) ((aLong) & 0xFFFF)
/* This routine is part of the MPW runtime library. This external
reference to it is done so that we can unload its segment, %A5Init. */
extern void _DataInit();
int main(void)
{
OSErr error = 0;
FILE *fildes;
char buff[255];
UnloadSeg((Ptr) _DataInit);
MemoryInit();
MacintoshInit(); /* initialize the program */
test_init();
EventLoop(); /* call the main event loop */
return 0;
}
/* Get events forever, and handle them by calling DoEvent.
Get the events by calling WaitNextEvent, if it's available, otherwise
by calling GetNextEvent. Also call AdjustCursor each time through the loop. */
#pragma segment Main
void EventLoop()
{
Boolean gotEvent;
EventRecord event;
RgnHandle cursorRgn;
do {
/* use WNE if it is available */
//if ( gHasWaitNextEvent )
//{
// gotEvent = WaitNextEvent(everyEvent, &event, MAXLONG, cursorRgn);
//} else
//{
SystemTask();
gotEvent = GetNextEvent(everyEvent, &event);
//}
if ( gotEvent )
{
/* Handle the event */
DoEvent(&event);
}
test_poll();
} while ( true ); /* loop forever; we quit via ExitToShell */
} /*EventLoop*/
/* Do the right thing for an event. Determine what kind of event it is, and call
the appropriate routines. */
void DoEvent( EventRecord *event )
{
short part, err;
WindowPtr window;
Boolean hit;
char key;
switch ( event->what ) {
case mouseDown:
part = FindWindow(event->where, &window);
switch ( part ) {
case inMenuBar: /* process a mouse menu command (if any) */
DoMenuCommand(MenuSelect(event->where));
break;
case inSysWindow: /* let the system handle the mouseDown */
SystemClick(event, window);
break;
}
break;
case keyDown:
case autoKey: /* check for menukey equivalents */
key = event->message & charCodeMask;
if ( event->modifiers & cmdKey ) /* Command key down */
{
if ( event->what == keyDown ) {
DoMenuCommand(MenuKey(key));
}
}
break;
case kOSEvent:
/* 1.02 - must BitAND with 0x0FF to get only low byte */
switch ((event->message >> 24) & 0x0FF) { /* high byte of message */
case kSuspendResumeMessage: /* suspend/resume is also an activate/deactivate */
gInBackground = (event->message & kResumeMask) == 0;
//DoActivate(FrontWindow(), !gInBac
|