mirror of
https://github.com/jeremysrand/Apple2GSBuildPipeline.git
synced 2025-02-08 08:30:25 +00:00
Update the ORCA/C desktop template to have more error checking.
This commit is contained in:
parent
222afbf9d6
commit
3c5a978718
@ -16,28 +16,39 @@
|
||||
#include <Window.h>
|
||||
#include <Desk.h>
|
||||
#include <Resources.h>
|
||||
#include <MiscTool.h>
|
||||
|
||||
#include "___FILEBASENAME___.h"
|
||||
|
||||
|
||||
// Defines and macros
|
||||
|
||||
#define TOOLFAIL(string) \
|
||||
if (toolerror()) SysFailMgr(toolerror(), "\p" string "\n\r Error Code -> $");
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
BOOLEAN done;
|
||||
EventRecord myEvent;
|
||||
unsigned int userid;
|
||||
|
||||
|
||||
void DoAbout(void)
|
||||
// Implementation
|
||||
|
||||
void doAbout(void)
|
||||
{
|
||||
AlertWindow(awCString + awResource, NULL, aboutAlertString);
|
||||
AlertWindow(awCString + awResource, NULL, ABOUT_ALERT_STRING);
|
||||
}
|
||||
|
||||
|
||||
GrafPortPtr NewDocument(void)
|
||||
GrafPortPtr newDocument(void)
|
||||
{
|
||||
return(NewWindow2("\pMyWindow", 0, NULL, NULL, 0x02, windowRes, rWindParam1));
|
||||
return(NewWindow2("\p MyWindow ", 0, NULL, NULL, 0x02, WINDOW_RESID, rWindParam1));
|
||||
}
|
||||
|
||||
|
||||
void CloseDocument(GrafPortPtr wPtr)
|
||||
void closeDocument(GrafPortPtr wPtr)
|
||||
{
|
||||
if (wPtr != NULL) {
|
||||
CloseWindow(wPtr);
|
||||
@ -45,7 +56,7 @@ void CloseDocument(GrafPortPtr wPtr)
|
||||
}
|
||||
|
||||
|
||||
void HandleMenu(void)
|
||||
void handleMenu(void)
|
||||
{
|
||||
int menuNum;
|
||||
int menuItemNum;
|
||||
@ -54,47 +65,58 @@ void HandleMenu(void)
|
||||
menuItemNum = myEvent.wmTaskData;
|
||||
|
||||
switch (menuItemNum) {
|
||||
case appleAbout:
|
||||
DoAbout();
|
||||
case APPLE_ABOUT:
|
||||
doAbout();
|
||||
break;
|
||||
case fileNew:
|
||||
NewDocument();
|
||||
case FILE_NEW:
|
||||
newDocument();
|
||||
break;
|
||||
case fileOpen:
|
||||
NewDocument();
|
||||
case FILE_OPEN:
|
||||
newDocument();
|
||||
break;
|
||||
case fileClose:
|
||||
CloseDocument(FrontWindow());
|
||||
case FILE_CLOSE:
|
||||
closeDocument(FrontWindow());
|
||||
break;
|
||||
case fileQuit:
|
||||
case FILE_QUIT:
|
||||
done = TRUE;
|
||||
break;
|
||||
case editUndo:
|
||||
case EDIT_UNDO:
|
||||
break;
|
||||
case editCut:
|
||||
case EDIT_CUT:
|
||||
break;
|
||||
case editCopy:
|
||||
case EDIT_COPY:
|
||||
break;
|
||||
case editPaste:
|
||||
case EDIT_PASTE:
|
||||
break;
|
||||
case editClear:
|
||||
case EDIT_CLEAR:
|
||||
break;
|
||||
}
|
||||
HiliteMenu(FALSE, menuNum);
|
||||
}
|
||||
|
||||
|
||||
void InitMenus(void)
|
||||
void initMenus(void)
|
||||
{
|
||||
int height;
|
||||
MenuBarRecHndl menuBarHand;
|
||||
|
||||
menuBarHand = NewMenuBar2(refIsResource, menuBar, NULL);
|
||||
menuBarHand = NewMenuBar2(refIsResource, MENU_BAR, NULL);
|
||||
TOOLFAIL("Unable to create menu bar");
|
||||
|
||||
SetSysBar(menuBarHand);
|
||||
TOOLFAIL("Unable to set system menu bar");
|
||||
|
||||
SetMenuBar(NULL);
|
||||
FixAppleMenu(appleMenu);
|
||||
TOOLFAIL("Unable to set menu bar");
|
||||
|
||||
FixAppleMenu(APPLE_MENU);
|
||||
TOOLFAIL("Unable to fix Apple menu");
|
||||
|
||||
height = FixMenuBar();
|
||||
TOOLFAIL("Unable to fix menu bar");
|
||||
|
||||
DrawMenuBar();
|
||||
TOOLFAIL("Unable to draw menu bar");
|
||||
}
|
||||
|
||||
|
||||
@ -104,29 +126,40 @@ int main(void)
|
||||
Ref toolStartupRef;
|
||||
|
||||
userid = MMStartUp();
|
||||
TLStartUp();
|
||||
toolStartupRef = StartUpTools(userid, refIsResource, toolStartup);
|
||||
TOOLFAIL("Unable to start memory manager");
|
||||
|
||||
InitMenus();
|
||||
TLStartUp();
|
||||
TOOLFAIL("Unable to start tool locator");
|
||||
|
||||
toolStartupRef = StartUpTools(userid, refIsResource, TOOL_STARTUP);
|
||||
TOOLFAIL("Unable to start tools");
|
||||
|
||||
initMenus();
|
||||
InitCursor();
|
||||
|
||||
done = FALSE;
|
||||
myEvent.wmTaskMask = 0x001F7FFF;
|
||||
while (!done) {
|
||||
event = TaskMaster(everyEvent, &myEvent);
|
||||
TOOLFAIL("Unable to handle next event");
|
||||
|
||||
switch (event) {
|
||||
case wInSpecial:
|
||||
case wInMenuBar:
|
||||
HandleMenu();
|
||||
handleMenu();
|
||||
break;
|
||||
case wInGoAway:
|
||||
CloseDocument((GrafPortPtr)myEvent.wmTaskData);
|
||||
closeDocument((GrafPortPtr)myEvent.wmTaskData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ShutDownTools(refIsHandle, toolStartupRef);
|
||||
TOOLFAIL("Unable to shutdown tools");
|
||||
|
||||
TLShutDown();
|
||||
TOOLFAIL("Unable to shutdown tool locator");
|
||||
|
||||
MMShutDown(userid);
|
||||
TOOLFAIL("Unable to shutdown memory manager");
|
||||
}
|
||||
|
||||
|
@ -11,30 +11,30 @@
|
||||
#define _GUARD_PROJECT___PROJECTNAMEASIDENTIFIER____FILE___FILEBASENAMEASIDENTIFIER____
|
||||
|
||||
|
||||
#define menuBar 1
|
||||
#define MENU_BAR 1
|
||||
|
||||
#define appleMenu 3
|
||||
#define fileMenu 4
|
||||
#define editMenu 5
|
||||
#define APPLE_MENU 3
|
||||
#define FILE_MENU 4
|
||||
#define EDIT_MENU 5
|
||||
|
||||
#define editUndo 250
|
||||
#define editCut 251
|
||||
#define editCopy 252
|
||||
#define editPaste 253
|
||||
#define editClear 254
|
||||
#define EDIT_UNDO 250
|
||||
#define EDIT_CUT 251
|
||||
#define EDIT_COPY 252
|
||||
#define EDIT_PASTE 253
|
||||
#define EDIT_CLEAR 254
|
||||
|
||||
#define fileNew 401
|
||||
#define fileOpen 402
|
||||
#define fileClose 255
|
||||
#define fileQuit 256
|
||||
#define FILE_NEW 401
|
||||
#define FILE_OPEN 402
|
||||
#define FILE_CLOSE 255
|
||||
#define FILE_QUIT 256
|
||||
|
||||
#define appleAbout 301
|
||||
#define APPLE_ABOUT 301
|
||||
|
||||
#define aboutAlertString 1
|
||||
#define ABOUT_ALERT_STRING 1
|
||||
|
||||
#define windowRes 1001
|
||||
#define WINDOW_RESID 1001
|
||||
|
||||
#define toolStartup 1
|
||||
#define TOOL_STARTUP 1
|
||||
|
||||
|
||||
#endif /* defined(_GUARD_PROJECT___PROJECTNAMEASIDENTIFIER____FILE___FILEBASENAMEASIDENTIFIER____) */
|
||||
|
@ -25,171 +25,171 @@ resource rVersion (1) {
|
||||
};
|
||||
|
||||
|
||||
resource rMenuBar (menuBar) {
|
||||
resource rMenuBar (MENU_BAR) {
|
||||
{
|
||||
appleMenu,
|
||||
fileMenu,
|
||||
editMenu
|
||||
APPLE_MENU,
|
||||
FILE_MENU,
|
||||
EDIT_MENU
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
resource rMenu (appleMenu) {
|
||||
appleMenu,
|
||||
resource rMenu (APPLE_MENU) {
|
||||
APPLE_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
appleMenu,
|
||||
APPLE_MENU,
|
||||
{
|
||||
appleAbout
|
||||
APPLE_ABOUT
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
resource rMenu (fileMenu) {
|
||||
fileMenu,
|
||||
resource rMenu (FILE_MENU) {
|
||||
FILE_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
fileMenu,
|
||||
FILE_MENU,
|
||||
{
|
||||
fileNew,
|
||||
fileOpen,
|
||||
fileClose,
|
||||
fileQuit
|
||||
FILE_NEW,
|
||||
FILE_OPEN,
|
||||
FILE_CLOSE,
|
||||
FILE_QUIT
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
resource rMenu (editMenu) {
|
||||
editMenu,
|
||||
resource rMenu (EDIT_MENU) {
|
||||
EDIT_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
editMenu,
|
||||
EDIT_MENU,
|
||||
{
|
||||
editUndo,
|
||||
editCut,
|
||||
editCopy,
|
||||
editPaste,
|
||||
editClear
|
||||
EDIT_UNDO,
|
||||
EDIT_CUT,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_CLEAR
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (editUndo) {
|
||||
editUndo,
|
||||
resource rMenuItem (EDIT_UNDO) {
|
||||
EDIT_UNDO,
|
||||
"Z", "z",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
editUndo
|
||||
EDIT_UNDO
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (editCut) {
|
||||
editCut,
|
||||
resource rMenuItem (EDIT_CUT) {
|
||||
EDIT_CUT,
|
||||
"X", "x",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
editCut
|
||||
EDIT_CUT
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (editCopy) {
|
||||
editCopy,
|
||||
resource rMenuItem (EDIT_COPY) {
|
||||
EDIT_COPY,
|
||||
"C", "c",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
editCopy
|
||||
EDIT_COPY
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (editPaste) {
|
||||
editPaste,
|
||||
resource rMenuItem (EDIT_PASTE) {
|
||||
EDIT_PASTE,
|
||||
"V", "v",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
editPaste
|
||||
EDIT_PASTE
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (editClear) {
|
||||
editClear,
|
||||
resource rMenuItem (EDIT_CLEAR) {
|
||||
EDIT_CLEAR,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
editClear
|
||||
EDIT_CLEAR
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (fileNew) {
|
||||
fileNew,
|
||||
resource rMenuItem (FILE_NEW) {
|
||||
FILE_NEW,
|
||||
"N", "n",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
fileNew
|
||||
FILE_NEW
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (fileOpen) {
|
||||
fileOpen,
|
||||
resource rMenuItem (FILE_OPEN) {
|
||||
FILE_OPEN,
|
||||
"O", "o",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
fileOpen
|
||||
FILE_OPEN
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (fileClose) {
|
||||
fileClose,
|
||||
resource rMenuItem (FILE_CLOSE) {
|
||||
FILE_CLOSE,
|
||||
"W", "w",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
fileClose
|
||||
FILE_CLOSE
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (fileQuit) {
|
||||
fileQuit,
|
||||
resource rMenuItem (FILE_QUIT) {
|
||||
FILE_QUIT,
|
||||
"Q", "q",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
fileQuit
|
||||
FILE_QUIT
|
||||
};
|
||||
|
||||
|
||||
resource rMenuItem (appleAbout) {
|
||||
appleAbout,
|
||||
resource rMenuItem (APPLE_ABOUT) {
|
||||
APPLE_ABOUT,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
appleAbout
|
||||
APPLE_ABOUT
|
||||
};
|
||||
|
||||
|
||||
resource rPString (appleMenu, noCrossBank) {"@"};
|
||||
resource rPString (fileMenu, noCrossBank) {" File "};
|
||||
resource rPString (editMenu, noCrossBank) {" Edit "};
|
||||
resource rPString (APPLE_MENU, noCrossBank) {"@"};
|
||||
resource rPString (FILE_MENU, noCrossBank) {" File "};
|
||||
resource rPString (EDIT_MENU, noCrossBank) {" Edit "};
|
||||
|
||||
resource rPString (editUndo, noCrossBank) {"Undo"};
|
||||
resource rPString (editCut, noCrossBank) {"Cut"};
|
||||
resource rPString (editCopy, noCrossBank) {"Copy"};
|
||||
resource rPString (editPaste, noCrossBank) {"Paste"};
|
||||
resource rPString (editClear, noCrossBank) {"Clear"};
|
||||
resource rPString (EDIT_UNDO, noCrossBank) {"Undo"};
|
||||
resource rPString (EDIT_CUT, noCrossBank) {"Cut"};
|
||||
resource rPString (EDIT_COPY, noCrossBank) {"Copy"};
|
||||
resource rPString (EDIT_PASTE, noCrossBank) {"Paste"};
|
||||
resource rPString (EDIT_CLEAR, noCrossBank) {"Clear"};
|
||||
|
||||
resource rPString (fileNew, noCrossBank) {"New"};
|
||||
resource rPString (fileOpen, noCrossBank) {"Open"};
|
||||
resource rPString (fileClose, noCrossBank) {"Close"};
|
||||
resource rPString (fileQuit, noCrossBank) {"Quit"};
|
||||
resource rPString (FILE_NEW, noCrossBank) {"New"};
|
||||
resource rPString (FILE_OPEN, noCrossBank) {"Open"};
|
||||
resource rPString (FILE_CLOSE, noCrossBank) {"Close"};
|
||||
resource rPString (FILE_QUIT, noCrossBank) {"Quit"};
|
||||
|
||||
resource rPString (appleAbout, noCrossBank) {"About ___PROJECTNAME___..."};
|
||||
resource rPString (APPLE_ABOUT, noCrossBank) {"About ___PROJECTNAME___..."};
|
||||
|
||||
|
||||
resource rAlertString (aboutAlertString) {
|
||||
resource rAlertString (ABOUT_ALERT_STRING) {
|
||||
"0" /* Custom size */
|
||||
"\$38\$00" /* Upper Y coordinate at 56 */
|
||||
"\$90\$00" /* Left X coordinate at 144 */
|
||||
@ -207,7 +207,7 @@ resource rAlertString (aboutAlertString) {
|
||||
};
|
||||
|
||||
|
||||
resource rWindParam1 (windowRes) {
|
||||
resource rWindParam1 (WINDOW_RESID) {
|
||||
$DDA5, /* wFrameBits */
|
||||
nil, /* wTitle */
|
||||
0, /* wRefCon */
|
||||
@ -227,7 +227,7 @@ resource rWindParam1 (windowRes) {
|
||||
};
|
||||
|
||||
|
||||
resource rToolStartup (toolStartup) {
|
||||
resource rToolStartup (TOOL_STARTUP) {
|
||||
mode640,
|
||||
{
|
||||
3,$0100, /* Misc Tool */
|
||||
|
Loading…
x
Reference in New Issue
Block a user