Utilities.r

/*
    File:       Utilities.r
 
    Contains:   Collection of Utilities for DTS Sample code
 
    Written by:     
 
    Copyright:  Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
#include "UtilitiesCommon.h"
#include "Types.r"
 
/* These #defines are used to set enable/disable flags of a menu */
 
#define AllItems    0b1111111111111111111111111111111   /* 31 flags */
#define NoItems     0b0000000000000000000000000000000
#define MenuItem1   0b0000000000000000000000000000001
#define MenuItem2   0b0000000000000000000000000000010
#define MenuItem3   0b0000000000000000000000000000100
#define MenuItem4   0b0000000000000000000000000001000
#define MenuItem5   0b0000000000000000000000000010000
#define MenuItem6   0b0000000000000000000000000100000
#define MenuItem7   0b0000000000000000000000001000000
#define MenuItem8   0b0000000000000000000000010000000
#define MenuItem9   0b0000000000000000000000100000000
#define MenuItem10  0b0000000000000000000001000000000
#define MenuItem11  0b0000000000000000000010000000000
#define MenuItem12  0b0000000000000000000100000000000
#define MenuItem13  0b0000000000000000001000000000000
#define MenuItem14  0b0000000000000000010000000000000
#define MenuItem15  0b0000000000000000100000000000000
#define MenuItem16  0b0000000000000001000000000000000
#define MenuItem17  0b0000000000000010000000000000000
#define MenuItem18  0b0000000000000100000000000000000
#define MenuItem19  0b0000000000001000000000000000000
#define MenuItem20  0b0000000000010000000000000000000
#define MenuItem21  0b0000000000100000000000000000000
#define MenuItem22  0b0000000001000000000000000000000
#define MenuItem23  0b0000000010000000000000000000000
#define MenuItem24  0b0000000100000000000000000000000
#define MenuItem25  0b0000001000000000000000000000000
#define MenuItem26  0b0000010000000000000000000000000
#define MenuItem27  0b0000100000000000000000000000000
#define MenuItem28  0b0001000000000000000000000000000
#define MenuItem29  0b0010000000000000000000000000000
#define MenuItem30  0b0100000000000000000000000000000
#define MenuItem31  0b1000000000000000000000000000000
 
 
// The following values are used to place the locations of items in
// an alert according to the Human Interface Guidelines (HIN #10)
 
// These values are very customizable, and you'll probably want to change them.
#define NumTextLines        5   // number of lines of text to allow in the alert
#define AlertWidth          341 // Just 'cause
#define LongestButtonName   41  // width of "Cancel" in Chicago 12
 
// These 3 values are customizable, but you probably wouldn't change them
#define LineHeight          16  // height of a single line of Chicago 12
#define ButtonHeight        20  // standard button height
#define ButtonWidth         (LongestButtonName + 18)
 
// The next 6 values are very fixed, and don't depend on anything
#define MarginA             10  // white space between most elements
#define MarginB             20  // white space to left and right of icon
 
#define IconTop             (MarginA)
#define IconLeft            (MarginB)
#define IconBottom          (IconTop + 32)
#define IconRight           (IconLeft + 32)
 
// The remaining values here are very flexible, mostly relying on the
// settings of NumTextLines, LineHeight, AlertWidth, and LongestButtonName
#define TextTop             (MarginA)
#define TextLeft            (IconRight + MarginB)
#define TextBottom          (TextTop + (NumTextLines * LineHeight))
#define TextRight           (AlertWidth - MarginA)
 
#define ButtonTop           (TextBottom + MarginA)
#define ButtonBottom        (ButtonTop + ButtonHeight)
#define ActionButtonRight   (AlertWidth - MarginA)
#define ActionButtonLeft    (ActionButtonRight - ButtonWidth)
#define CancelButtonRight   (ActionButtonLeft - MarginA)
#define CancelButtonLeft    (CancelButtonRight - ButtonWidth)
 
#define AlertHeight         (ButtonBottom + MarginA)
 
 
resource 'STR#' (rUtilStrings, purgeable) {
    {
    /* [1] */   "An error occurred";
    /* [2] */   "I couldn't create the menubar because I couldn't find the specified MBAR resource";
    };
};
 
 
 
/* this ALRT and DITL are used in our error alerts */
 
resource 'ALRT' (rUtilErrorAlert, purgeable) {
    {0, 0, AlertHeight, AlertWidth},
    rUtilErrorAlert,
    {
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent
    },
    alertPositionMainScreen
};
 
resource 'DITL' (rUtilErrorAlert, purgeable) {
    {
        { ButtonTop, ActionButtonLeft, ButtonBottom, ActionButtonRight },
        Button { enabled, "OK" },
 
        { TextTop, TextLeft, TextBottom, TextRight },
        StaticText { disabled, "^0." },
        
        { IconTop, IconLeft, IconBottom, IconRight },
        Icon { enabled, 0 };            // Stop Icon
    };
};
 
 
/* this ALRT and DITL are used in our message error alerts */
 
resource 'ALRT' (rUtilErrorMessageAlert, purgeable) {
    {0, 0, AlertHeight, AlertWidth},
    rUtilErrorMessageAlert,
    {
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent
    },
    alertPositionMainScreen
};
 
resource 'DITL' (rUtilErrorMessageAlert, purgeable) {
    {
        { ButtonTop, ActionButtonLeft, ButtonBottom, ActionButtonRight },
        Button { enabled, "OK" },
 
        { TextTop, TextLeft, TextBottom, TextRight },
        StaticText { disabled, "^0.   The error number reported was: ^1." },
        
        { IconTop, IconLeft, IconBottom, IconRight },
        Icon { enabled, 0 };            // Stop Icon
    };
};
 
 
/* this ALRT and DITL are used as an About screen */
 
resource 'ALRT' (rStdAboutAlert, purgeable) {
    {0, 0, 136, 290},
    rStdAboutAlert,
    {
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent,
        OK, visible, silent
    },
    alertPositionMainScreen
};
 
resource 'DITL' (rStdAboutAlert, purgeable) {
    {
        { 104, 180, 124, 260 },
        Button { enabled, "OK" },
 
        { 8, 8, 24, 262 },
        StaticText { disabled, "^0" },
 
        { 32, 8, 48, 65 },
        StaticText { disabled, "Version:" },
 
        { 32, 65, 64, 270 },
        StaticText { disabled, "^1" },
 
        { 72, 8, 88, 136 },
        StaticText { disabled, "Brought to you by:" },
 
        { 96, 24, 128, 167 },
        StaticText { disabled, "Apple Developer ÊTechnical Support" },
    }
};