Listing 1: Header for resource classes

// MACRES.H by Jeff Heaton(jeffheaton@aol.com)
#include <stdio.h>

// MAC_RESOURCE is the class that a single variable
// length MAC resource is loaded into.
class MAC_RESOURCE 
{
public:
    MAC_RESOURCE();
    ~MAC_RESOURCE();
    unsigned char *GetBuffer(void){return buffer;};
    long GetLength(void){return length;};
    void Setup(FILE *fp,long len);
protected:
    unsigned char *buffer;
    long length;
};

class MAC_RESOURCE_FILE
{
public:
    MAC_RESOURCE_FILE();
    ~MAC_RESOURCE_FILE(){Close();};
    void Open(char *fn);
    void Close(void);
    void GetFirstType(char *name);
    void GetNextType(char *name);
    void GetFirstResource(short *res);
    void GetNextResource(short *res);
    short GetNumTypes(void){return numTypes;};
    short GetNumResources(void){return numThis;};
    MAC_RESOURCE *LoadResource(char *name,short id);

protected:
    FILE *fp;
    long nextTypeLoc;// Offset to next res type
    long nextResLoc;// Offset to next resource
    unsigned char buffer[256];// Misc. Buffer
    unsigned short numTypes,// How many res types?
        numThis,// How many resources of the current type?
        offsetReffList;// Offset to refference list
    unsigned long resourceLocation,// Offset to current res
        offsetResourceData,// MACBINARY:Offset to res data
        offsetResourceMap,lengthResourceData,
        lengthResourceMap,locationTypeList,
        resourceData;// Where the current resource is stored
};

// Motarola stores integers in the opposit order of an
// intel based platform.  The following macros make it
// so our integer reads work on either platform
#define MAC_LONG(a,b,c,d) ((a<<24)+(b<<16)+(c<<8)+d)
#define MAC_WORD(a,b) ((short)((a<<8)+b));
#define MAC_TRI(a,b,c) ((a<<16)+(b<<8)+c)

// Resource item types supported
#define ctrlItem 4
#define btnCtrl 0
#define chkCtrl 1
#define radCtrl 2
#define    editText 16

// Mac and windows resources are not measured in the same "units"
// The following converts Windows' metric measurement into Mac's
// pixel measure.
#define CHANGE_X(x) (short)(((double)x/2.0))
#define CHANGE_Y(x) (short)((((double)x*1.2)/2.4))

/* End of File */