rendered paste body// PICTViewer 2008 Landon Rodgers// Includes#include <Appearance.h>#include <ToolUtils.h>// defines#define mBar 128#define mApple 129#define mFile 128#define iOpen 1#define iQuit 3#define rWindowResource 128#define rAboutAlert 128// globalsBoolean gDone;// prototypesvoid main(void);void doInitManagers(void);void doGetMenus(void);void doEvents(EventRecord *);void doMouseDown(EventRecord *);void doMenuChoice(SInt32);void doFileMenu(SInt16);void doOpenFileDialog(void);void main(void){ EventRecord eventStructure; WindowPtr windowPtr; doInitManagers(); if(!(windowPtr = GetNewCWindow(rWindowResource,NULL,(WindowPtr) -1))) { SysBeep(10); ExitToShell(); } SetPort(windowPtr); doGetMenus(); ShowWindow(windowPtr); gDone = false; while(!gDone) { if(WaitNextEvent(everyEvent,&eventStructure,180,NULL)) doEvents(&eventStructure); }}void doEvents(EventRecord * eventStrucPtr){ switch(eventStrucPtr->what) { case mouseDown: doMouseDown(eventStrucPtr); break; case updateEvt: BeginUpdate((WindowPtr)eventStrucPtr->message); EndUpdate((WindowPtr)eventStrucPtr->message); break; case osEvt: HiliteMenu(0); break; }}void doMouseDown(EventRecord *eventStrucPtr){ WindowPtr windowPtr; SInt16 partCode; SInt32 menuChoice; partCode = FindWindow(eventStrucPtr->where,&windowPtr); switch(partCode) { case inMenuBar: menuChoice = MenuSelect(eventStrucPtr->where); doMenuChoice(menuChoice); break; case inContent: if(windowPtr != FrontWindow()) SelectWindow(windowPtr); break; case inDrag: DragWindow(windowPtr,eventStrucPtr->where,&qd.screenBits.bounds); break; case inGoAway: if(TrackGoAway(windowPtr,eventStrucPtr->where)) gDone = true; break; }}void doMenuChoice(SInt32 menuChoice){ SInt16 menuID, menuItem; menuID = HiWord(menuChoice); menuItem = LoWord(menuChoice); if(menuID == 0) return; switch(menuID) { case mApple: if(menuItem == 1) NoteAlert(rAboutAlert, NULL); break; case mFile: doFileMenu(menuItem); break; } HiliteMenu(0);}void doFileMenu(SInt16 menuItem){ switch(menuItem) { case iOpen: doOpenFileDialog(); break; case iQuit: gDone = true; break; }}void doOpenFileDialog(void){ StandardFileReply reply; StandardGetFile(NULL, -1, NULL, &reply); if(reply.sfGood == true) { }}void doGetMenus(void){ Handle menubarHdl; MenuHandle menuHdl; menubarHdl = GetNewMBar(mBar); if(menubarHdl == NULL) ExitToShell(); SetMenuBar(menubarHdl); DrawMenuBar(); menuHdl = GetMenuHandle(mApple); if(menuHdl != NULL) AppendResMenu(menuHdl,'DRVR'); else ExitToShell();}void doInitManagers(void){ MaxApplZone(); MoreMasters(); InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(NULL); InitCursor(); FlushEvents(everyEvent,0);}