1 /*
2 * Alerts.cpp
3 * Copyright (C) 2007 by Bryan Duff <duff0097@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20
21 #include "Alerts.h"
22
23 /********************> SelectResolution() <*****/
SelectResolution(void)24 int SelectResolution(void)
25 {
26 DialogPtr dialog;
27 Boolean dialogDone = false;
28 short itemHit, itemType;
29 Handle okItem;
30 Handle resolutionItem;
31 Rect itemRect;
32 int selectionNum;
33
34 // Load the dialog
35 dialog = GetNewDialog(kResID_DLOG_SelectResolution, nil, kMoveToFront);
36
37 // Display the dialog
38 ShowWindow(dialog);
39 SetPort(dialog);
40
41 // Load dialog items
42 SetDialogDefaultItem(dialog, iOK);
43 SetDialogTracksCursor(dialog, true);
44 GetDialogItem(dialog, iOK, &itemType, &okItem, &itemRect);
45 GetDialogItem(dialog, iResolutionPopUp, &itemType, &resolutionItem,
46 &itemRect);
47
48 // Set item values
49 SetControlValue((ControlHandle) resolutionItem, i640x480);
50
51 while(!dialogDone) {
52
53 ModalDialog(nil, &itemHit);
54
55 switch (itemHit) {
56 case iOK:
57 dialogDone = true;
58 // Get the item number selected int the popup
59 selectionNum = GetControlValue((ControlHandle) resolutionItem);
60 break;
61 case iResolutionPopUp:
62 // We don't actually need to do anything here
63 break;
64 }
65
66 }
67
68 DisposeDialog(dialog);
69
70 // Return the item selected in the popup menu
71 return selectionNum;
72 }
73
74 /********************> MessageAlert() <*****/
MessageAlert(unsigned char * theMessage)75 void MessageAlert(unsigned char *theMessage)
76 {
77 // Set parameter ^0 to our message (I could set up to three, but for simplicity's sake I won't)
78 ParamText((unsigned char *)theMessage, NULL, NULL, NULL);
79
80 // Do the Alert
81 NoteAlert(kResID_ALRT_MessageAlert, nil);
82 }
83
84 /********************> FatalErrorAlert() <*****/
FatalErrorAlert(UInt16 errorNum,OSErr osError)85 void FatalErrorAlert(UInt16 errorNum, OSErr osError)
86 {
87 Str15 errNumStr;
88 Str255 mainMessage;
89
90 // Convert the OSErr to a string
91 NumToString(osError, errNumStr);
92
93 // Get the error description (inErrorDesc) from the STR# resource
94 GetIndString(mainMessage, kResID_STRn_ErrorStrings, errorNum);
95
96 // Set the parameters (^0 and ^1) in the ALRT to our error messages
97 ParamText(mainMessage, errNumStr, NULL, NULL);
98
99 // Do the alert (which now has our messages in it)
100 StopAlert(kResID_ALRT_ErrorAlert, NULL);
101
102 // Quit
103 exit(EXIT_SUCCESS);
104 }
105