Headers/App.h

/*************************************************************************************
#
#       App.h
#
#       This file contains the constants and structure definitions.
#
#       Author(s):  Michael Marinkovich & Guillermo Ortiz
#                   marink@apple.com
#
#       Modification History: 
#
#           4/3/96      MWM     Initial coding                   
#
#       Copyright © 1992-96 Apple Computer, Inc., All Rights Reserved
#
#
#       You may incorporate this sample code into your applications without
#       restriction, though the sample code has been provided "AS IS" and the
#       responsibility for its operation is 100% yours.  However, what you are
#       not permitted to do is to redistribute the source as "DSC Sample 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 Code, but that you've made changes.
#
*************************************************************************************/
 
#include <Printing.h>
#include <QDOffscreen.h>
 
 
//---------------------------------------------------------------------
//
//  JFIF (JPEG) markers
//
//---------------------------------------------------------------------
 
enum {
    kSOFMarker                          = 0xC0, // Start Of Frame N
    kSOFMarker2                         = 0xC2,
    kDHTMarker                          = 0xC4, // DHT Marker
    kDACMarker                          = 0xCC, // DAC
 
    kRSTOMarker                         = 0xD0, // RSTO marker
    kSOIMarker                          = 0xD8, // Image start marker
    kEOIMarker                          = 0xD9, // Image end marker
    kSOSMarker                          = 0xDA, // SOS marker
    kDQTMarker                          = 0xDB, // DQT marker
 
    kAPPOMarker                         = 0xE0, // APPO marker
    kCommentMarker                      = 0xFE, // comment marker
 
    kStartMarker                        = 0xFF  // marker loacted after this byte
};
 
 
//---------------------------------------------------------------------
//
//  Macros
//
//---------------------------------------------------------------------
 
#define MIN(x,y)            ( ((x)<(y)) ? (x) : (y) )
#define MAX(x,y)            ( ((x)>(y)) ? (x) : (y) )
#define TopLeft( r )        ( *(Point *) &(r).top )
#define BotRight( r )       ( *(Point *) &(r).bottom )
 
 
//---------------------------------------------------------------------
//
//  General
//
//---------------------------------------------------------------------
 
#define kMinHeap            300 * 1024
#define kMinSpace           300 * 1024
 
 
//---------------------------------------------------------------------
//
//  Menus
//
//---------------------------------------------------------------------
 
#define rMBarID             128
 
enum {
    mApple                  = 128,
    iAbout                  = 1,
 
    mFile                   = 129,
    iNew                    = 1,
    iOpen                   = 2,
    iSave                   = 3,
    iClose                  = 4,
    iQuit                   = 6
};
 
 
//---------------------------------------------------------------------
//
//  Window stuff
//
//---------------------------------------------------------------------
 
// doc types
enum {
    kDocKind                = 94,
    kDialogKind             = 95,
    kFloatKind              = 96,
    kAboutKind              = 97
};  
 
#define kFudgeFactor        4       // fudge factor for boundary around window
#define kTitleBarHeight     18      // title bar height
 
// scroll values
#define kScrollWidth        15
#define kScrollDelta        16
 
 
//---------------------------------------------------------------------
//
//  General resource ID's
//
//---------------------------------------------------------------------
 
#define rAboutPictID        3000 // about picture
#define rErrorDlg           128  // main error dialog
 
 
//---------------------------------------------------------------------
//
//  Alert Error ID's
//
//---------------------------------------------------------------------
 
#define kNeedsDisplayManager        128 // ID of no Display Manager
#define kNeedsQuickTime             129 // ID of no QuickTime
 
//---------------------------------------------------------------------
//
//  Custom Event Proc stuff
//
//---------------------------------------------------------------------
 
enum {
    kIdleProc           = 1,
    kMenuProc,
    kInContentProc,
    kInGoAwayProc,
    kInZoomProc,
    kInGrowProc,
    kMUpProc,
    kKeyProc,
    kActivateProc,
    kUpdateProc
};
    
 
//---------------------------------------------------------------------
//
//  Typedefs
//
//---------------------------------------------------------------------
 
// event handling proc
typedef void (*CustomProc)(WindowRef window, void *refCon);
 
 
// we just use the basic events for the callback procs
 
struct DocRec
{   
    CustomProc                  idleProc;           // custom idle proc
    CustomProc                  mMenuProc;          // custom menu proc
    CustomProc                  inContentProc;      // custom content click Proc
    CustomProc                  inGoAwayProc;       // custom inGoAway proc
    CustomProc                  inZoomProc;         // custom inZoom proc
    CustomProc                  inGrowProc;         // custom inGrow proc
    CustomProc                  mUpProc;            // custom mouseUp proc
    CustomProc                  keyProc;            // custom autoKey-keyDown proc
    CustomProc                  activateProc;       // custom activate window proc
    CustomProc                  updateProc;         // custom window update proc
    ControlRef                  hScroll;            // horz scroll bar
    ControlRef                  vScroll;            // vert scroll bar
    GWorldPtr                   world;              // offscreen for pict imaging
    PicHandle                   pict;               // windows picture
    THPrint                     printer;            // apps print record - inited at window int
    Boolean                     dirty;              // document needs saving
};
 
typedef struct DocRec DocRec;
typedef DocRec *DocPtr, **DocHnd;
 
 
struct DLDataRec
{   
    long                        refNum;             // ref number of cuurent file
    long                        fileLength;         
    Ptr                         origPtr;            // address of start of buffer;
    Ptr                         endPtr;             // ending address of the buffer
};
 
typedef struct DLDataRec DLDataRec;
typedef DLDataRec *DLDataPtr, **DLDataHnd;