Source/WRay_Error.c

/* 
 *  WRay_Error.c
 *
 *  QuickDraw 3D 1.6 Sample
 *  Robert Dierkes
 *
 *   07/28/98   RDD     Created.
 */
 
/*------------------*/
/*  Include Files   */
/*------------------*/
#include "QD3D.h"
 
#if defined(OS_MACINTOSH) && OS_MACINTOSH
#include <Dialogs.h>
#include <Strings.h>
#include <TextUtils.h>
#endif
 
#include "WRay_Main.h"  /* kStringRsrcID */
#include "WRay_Error.h"
 
 
/*------------------*/
/*    Constants     */
/*------------------*/
#define kErrorAlertRsrcID   129
 
 
/*----------------------*/
/*  Local Prototypes    */
/*----------------------*/
 
 
/*
 *  QuickDraw3D_Exit
 *
 *  Displays C string in an alert box.
 */
void Error_Alert(
    short       iconType,
    char        *pMessage)
{
    GrafPtr     oldPort;
    short       itemHit;
 
    if (pMessage == NULL)
        return;
 
    /* Convert C string to Pascal */
    c2pstr (pMessage);
    ParamText ((ConstStr255Param) pMessage, NULL, NULL, NULL);
 
    GetPort (&oldPort);
 
    if (iconType == kStopIcon)
        itemHit = StopAlert (kErrorAlertRsrcID, NULL);
    else
        itemHit = NoteAlert (kErrorAlertRsrcID, NULL);
 
    SetPort (oldPort);
 
    /* Restore C string */
    p2cstr ((StringPtr) pMessage);
}
 
 
/*
 *  QuickDraw3D_Exit
 */
Boolean Error_ShowMessage(
    short       resStringIndex)
{
    Str255  notice;
 
    GetIndString (notice, kStringRsrcID, resStringIndex);
    if (notice[0] > 0)
    {
        p2cstr (notice);
        Error_Alert(kNoteIcon, (char *) notice);
        return true;
    }
 
    return false;
}