home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MySGStuff.c
-
- Contains: Sequence grabber code.
-
- Written by: John Wang
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 04/04/94 JW Created.
-
- To Do:
-
- I added ReportMessage
-
-
- */
-
- #ifdef THINK_C
- #define applec
- #endif
- #include "MyHeaders.h"
- #include <Folders.h>
- #include <TextUtils.h>
-
- #include "MyCaptureAppShell.h"
- //#include "MySGStuff.h"
- #include "MyUtils.h"
-
-
- #define STR_PREFSNAME 128
-
-
- /* ------------------------------------------------------------------------- */
-
- // Show Alert. Then, return true is err != noErr.
- void ReportWarning(Str255 procStr, long err)
- {
- Str255 myStr;
-
- NumToString(err, myStr);
- ParamText("\pWarning!", procStr, err ? myStr : nil, nil);
- Alert(kALERT_ERROR, nil);
- }
-
- void ReportMessage(Str255 procStr)
- {
- ParamText(procStr, nil, nil, nil);
- Alert(kALERT_ERROR, nil);
- }
-
-
-
- void ReportFatal(Str255 procStr, long err)
- {
- Str255 myStr;
-
- NumToString(err, myStr);
- ParamText("\pFatal Error!", procStr, err ? myStr : nil, nil);
- Alert(kALERT_ERROR, nil);
- ExitToShell();
- }
-
- void GetGlobalWindow(WindowPtr theWindow, Rect *windowRect)
- {
- // Get the windowRect in global coordinates.
- *windowRect = theWindow->portRect;
- LocalToGlobal(&topLeft(*windowRect));
- LocalToGlobal(&botRight(*windowRect));
- }
-
- /* ------------------------------------------------------------------------- */
-
- // readPreferencesFile will return refnum = -1 if not found.
- short readPreferencesFile()
- {
- short myVRefNum;
- long myDirID;
- StringHandle prefsName;
- short myRefNum;
-
- if (FindFolder(kOnSystemDisk, kPreferencesFolderType, true, &myVRefNum, &myDirID))
- return(-1);
-
- prefsName = GetString(STR_PREFSNAME);
- myRefNum = HOpenResFile(myVRefNum, myDirID, (unsigned char *) *prefsName, fsRdPerm);
- ReleaseResource((Handle) prefsName);
-
- return(myRefNum);
- }
-
- // writePreferencesFile returns -1 if preferences file can't be opened.
- short writePreferencesFile()
- {
- short myVRefNum;
- long myDirID;
- StringHandle prefsName;
- short myRefNum;
-
- if (FindFolder(kOnSystemDisk, kPreferencesFolderType, true, &myVRefNum, &myDirID))
- return(-1);
-
- prefsName = GetString(STR_PREFSNAME);
- HDelete(myVRefNum, myDirID, (unsigned char *) *prefsName);
- HCreateResFile(myVRefNum, myDirID, (unsigned char *) *prefsName);
- myRefNum = HOpenResFile(myVRefNum, myDirID, (unsigned char *) *prefsName, fsRdWrPerm);
- ReleaseResource((Handle) prefsName);
-
- return(myRefNum);
- }
-
- void closePreferencesFile(short myRefNum)
- {
- UpdateResFile(myRefNum);
- CloseResFile(myRefNum);
- }
-
-