summary refs log tree commit diff
path: root/src/Alerts.cpp
blob: 2e01ca95c947a7f0ee1f366657018de7db79ca2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**> HEADER FILES <**/
#include "Alerts.h"

/********************> SelectResolution() <*****/
int		SelectResolution( void )
{
	DialogPtr	dialog;
	Boolean		dialogDone = false;
	short		itemHit, itemType;
	Handle		okItem;
	Handle		resolutionItem;
	Rect		itemRect;
	int			selectionNum;

	// Load the dialog
	dialog = GetNewDialog( kResID_DLOG_SelectResolution, nil, kMoveToFront );

	// Display the dialog
	ShowWindow( dialog );
	SetPort( dialog );

	// Load dialog items
	SetDialogDefaultItem( dialog, iOK );
	SetDialogTracksCursor( dialog, true );
	GetDialogItem( dialog, iOK, &itemType, &okItem, &itemRect );
	GetDialogItem( dialog, iResolutionPopUp, &itemType, &resolutionItem, &itemRect );

	// Set item values
	SetControlValue( ( ControlHandle )resolutionItem, i640x480 );

	while ( !dialogDone )
	{

		ModalDialog( nil, &itemHit );

		switch( itemHit )
		{
			case iOK:
				dialogDone = true;
				// Get the item number selected int the popup
				selectionNum = GetControlValue( ( ControlHandle )resolutionItem );
				break;
			case iResolutionPopUp:
				// We don't actually need to do anything here
				break;
		}

	}

	DisposeDialog( dialog );

	// Return the item selected in the popup menu
	return selectionNum;
}

/********************> MessageAlert() <*****/
void	MessageAlert( unsigned char *theMessage )
{

	// Set parameter ^0 to our message (I could set up to three, but for simplicity's sake I won't)
	ParamText( ( unsigned char * )theMessage, NULL, NULL, NULL );

	// Do the Alert
	NoteAlert( kResID_ALRT_MessageAlert, nil );

}

/********************> FatalErrorAlert() <*****/
void	FatalErrorAlert( UInt16 errorNum, OSErr osError )
{

	Str15				errNumStr;
	Str255				mainMessage;

	// Convert the OSErr to a string
	NumToString( osError, errNumStr );

	// Get the error description (inErrorDesc) from the STR# resource
	GetIndString( mainMessage, kResID_STRn_ErrorStrings, errorNum );

	// Set the parameters (^0 and ^1) in the ALRT to our error messages
	ParamText( mainMessage, errNumStr, NULL, NULL );

	// Do the alert (which now has our messages in it)
	StopAlert( kResID_ALRT_ErrorAlert, NULL );

	// Quit
	exit( EXIT_SUCCESS );
}