#ifndef ASTDefines #define ASTDefines /******************************** speak english *********/ #ifndef NULL #define NULL (void *) 0L #endif //#define nil 0L #define NIL 0L #define TRUE 1 #define FALSE 0 #define true 1 #define false 0 #define ZERO 0 #define AND && #define OR || #define NOT ! #define T TRUE #define F FALSE #define SELF ObjectH #define STOP -1 /******************************** Standard Typedefs *********/ typedef unsigned long Long; typedef unsigned char Char; typedef unsigned char Str3[4]; typedef unsigned char Str5[6]; //typedef unsigned char Str15[16]; //typedef unsigned char Str31[32]; //typedef unsigned char Str63[64]; typedef long *LPtr; //typedef short *IPtr; typedef char *CPtr; typedef Rect *RPtr; /********************** resource string categories (and resIDs ) *********/ enum { BUGS = 1500, PRshortERR,DEBUGINFO,WARNINGS,PROMPTS,TITLES,FATALS,BUTTONS}; /********************** standard buttons in dialogs *********/ enum { OKBTN = 1, CANCELBTN, SAVEBTN, REVERTBTN, DISCARDBTN }; /******************************** Toolbox defines *********/ #define MAXTELENGTH 32000 #define InFront -1L #define Enabled 0 #define ENABLED 0 #define Disabled 255 #define DISABLED 255 #define _UNDO 1 #define _CUT 3 #define _COPY 4 #define _PASTE 5 #define _CLEAR 6 enum { BUTTON = 4, CHECK, RADIO }; #define ScrollBarWidth 16 #define plain 0 #define Fatal FALSE #define Warning TRUE #define RecoverableError TRUE #define FatalError FALSE /******************************** Ada is my friend ******** NOT ANYMORE **/ //#define private static //#define public //#define foreign /******************************** Shortcut Function Calls *********/ #define BEEP SysBeep(6) #define ABSVAL(x) (((x) < 0) ? ((x) * -1) : (x)) #define SIGN(x) (((x) < 0) ? -1 : 1) #define MAX(a,b) ((a > b) ? (a) : (b)) #define MIN(a,b) ((a < b) ? (a) : (b)) #define ODD(a) (((a) % 2) == 1) #define EVEN(a) (((a) % 2) == 0) #define SQUARE(x) ((x) * (x)) void AssertionFailed(char *x); extern Boolean DEBUG; //#define ASSERT(x) if (!(x)) { if (DEBUG) Debugger(); else AssertionFailed( # x ); } #define _RoundTo(num,nearest) ((nearest) ? (((long)(((num) + (((num) > 0) ? (nearest) : -(nearest)) / 2) / (nearest)))* (nearest)) : (num)) #define _PinValue(Val,Min,Max) (MIN(MAX((Val),(Min)),(Max))) #define _InRange(Val,Min,Max) ((Val >= Min) AND (Val <= Max)) #define _TruncToMult(num,factor) ( (num / factor) * factor) #define _Width(r) (r.right - r.left) #define _Height(r) (r.bottom - r.top) #define _SetWidth(r,wid) r.right = r.left + wid #define _SetHeight(r,hgt) r.bottom = r.top + hgt #define _SetRectSize(r,wid,hgt) _SetWidth(r,wid); _SetHeight(r,hgt) #define _IncRectSize(r,wid,hgt) r.right += wid; r.bottom += hgt #define _DecRectSize(r,wid,hgt) r.right -= wid; r.bottom -= hgt //#define _StaticGrow(obj) {short height = WindowHeight((*obj)->port), \ wid= WindowWidth((*obj)->port); Dispatch(obj,GROW,&height,&wid); } //#define report(s) EAlert(s,0,Warning) //#define HVERIFY(h) if (!(h)) Oops(FATALS,1,0,Fatal) //#define RES_CHECK if (ResError()) Oops(FATALS,2,ResError(),Fatal); //#define FILE_CHECK(x) {OsErr os; if (os = x) Oops(FATALS,3,os,Fatal); } //#define MEM_CHECK if (MemError()) Oops(FATALS,4,MemError(),Fatal); #define _StrLSetCell(a,c,list) LSetCell(&((a)[1]), (short)(a)[0], c, list); #define _StrLGetCell(a,cell,list); {short len; len = 255;LGetCell(&a[1],&len,cell1,list); *a = len;} #define _GetHandleToRecord(recType) ((recType **) GetNewHandle((long) sizeof(recType))); MEM_CHECK #define _PtSet(src,destP) (destP)->h = (src).h; (destP)->v = (src).v; #define _lsizeof(x) ((long) sizeof(x)) #define _TrapExists(x) (NGetTrapAddress ((x),ToolTrap) != NGetTrapAddress(UnImplTrapNum, ToolTrap)) #define _ShiftKeyDown(ev) (((ev).modifiers & shiftKey)) #define _OptionKeyDown(ev) (((ev).modifiers & optionKey)) #define _CmdKeyDown(ev) (((ev).modifiers & cmdKey)) #define _Percent2Float(perc) (((float) perc) / 100000.0) #define _UpdateList(lst) LUpdate(((**lst).port)->visRgn,lst); #define _Upper(c) ( (c > 'Z') ? (c) + 'A' - 'a' : (c)) #define _EraseWindow(wP) EraseRect(&wP->portRect) #define _PtInObject(pt,obj) PtInRect(pt,&((*obj)->bounds)) #define _IncCtlValue(ctrl,amt) SetCtlValue(ctrl,GetCtlValue(ctrl) + amt) #define _DecCtlValue(ctrl,amt) SetCtlValue(ctrl,GetCtlValue(ctrl) - amt) #define POshort(h,v) ((v) * 65536 + (h)) #define _Adr2Long(adr) (StripAddress(adr)) /* 32 Bit Clean version!!!! */ #define _HiByte(word) ((word) >> 8) #define _LoByte(word) ((word) % 256) /******************************** Multifinder & SysEnvirons junk *********/ #define WaitNextTrapAddress 0x60 #define UnimplementedTrapAddress 0x9F #define System4_1 0x0410 /******************************** Pixel to inch conversion *********/ /*------------------------------------------------------------------*/ #define EIGHTHINCH 9 #define SIXTHINCH 12 #define QTRINCH 18 #define HALFINCH 36 #define INCH_75 64 #define INCH 72 #define INCHnQTR 90 #define INCHnHALF 108 #define INCHn3QTR 126 #define INCH2 144 #define INCH2_5 180 #define INCH3 216 #define INCH3_5 272 #define INCH4 288 #define INCH4_5 344 #define INCH5 360 #define INCH5_5 416 #define INCH6 432 #define INCH6_5 488 #define INCH7 504 /*----------------------------- common fonts in TextSpec --------------*/ #define TIMES14B (((long) times << 16) + (14 << 8) + bold) #define TIMES14 (((long) times << 16) + (14 << 8) + plain) #define TIMES12 (((long) times << 16) + (12 << 8) + plain) #define GENEVA10 (((long) geneva << 16) + (10 << 8) + plain) #define GENEVA12 (((long) geneva << 16) + (12 << 8) + plain) #define MONACO9 (((long) monaco << 16) + (09 << 8) + plain) /*------------------------------------------------------------------*/ #define STRTYPE 'STR ' #define STRINGTYPE 'STR ' #define PICTTYPE 'PICT' #define PARMTYPE 'PARM' #define PREFTYPE 'PREF' #define TEXTTYPE 'TEXT' #define DRVRTYPE 'DRVR' #define DLOGTYPE 'DLOG' #define FONTTYPE 'FONT' #define PNTGTYPE 'PNTG' #define ScPnTYPE 'ScPn' #define acurTYPE 'acur' /*animated cursor */ #endif