Structs.h

/*------------------------------------------------------------------------------
 *
 *  Apple Developer Technical Support
 *
 *  Text section handling routines
 *
 *  Program:    AEObject-Edition Sample
 *  File:       AESampStructs.h -    C Source
 *
 *  by:         C.K. Haun <TR>
 *
 *  Copyright © 1990-1992 Apple Computer, Inc.
 *  All rights reserved.
 *
 *------------------------------------------------------------------------------
 * This file contains all the structure definitions for the structs I use
 * in this sample
*----------------------------------------------------------------------------*/
 
 
#ifndef __STRUCTS__
#define __STRUCTS__
/* Structures */
struct myLine {                /* my own structure for defining a line */
    Point start;
    Point end;
};
typedef struct myLine myLine, *myLinePtr, **myLineHandle;
/* my text section (pub or sub) structure.  I will probably make this  */
/* a struct for all my editions soon. */
struct textSection {
    struct textSection **nextSection;
    Boolean publishing;  /* I don't really need to include this flag, but I would */
                        /* rather do it here than dereferencing the section handle */
                        /* all the time, makes the code a little more readable */
    Boolean bordered;  /* this section should currently be bordered */
    short startChar;
    short endChar;
    Handle  theText;
    SectionHandle theSection;
    unsigned long theID;
};
typedef struct textSection textSection, *textSectionPtr, **textSectionHandle;
 
/* Instead of using the handles I've used in the window structure, a */
/* section list like this may be more helpful, particularly if you */
/* will be working with a great many sections */
struct mySectionData {
    struct mySectionData **nextSection;
    Boolean publishing;
    Boolean bordered;
    SectionHandle theSection;
    Rect theRect;
    short startChar;
    short endChar;
    Handle additionalData;
    unsigned long theID;
};
typedef struct mySectionData mySectionData, *mySectionDataPtr,**mySectionDataHandle;
 
 
 
/* structure for the graphic elements in a document window */
struct Shapes{
short type; /* what kind is this? */
DescType aeType;
Rect theRect;   /* what's it's rectangle? */
 struct Shapes **nextShape;
long shapeIndex;
RGBColor theColor;  
};
typedef struct Shapes Shapes;
typedef Shapes *ShapesPtr,**ShapesHandle;
 
 
/* windowControl is the structure attached to every window I create (in the refCon */
/* field) that contains all the information I need to know about the window. */
/* data, procedure pointers for controlling, and anything else gets put in this */
/* struct.  That makes my windows autonomous, almost object-like */
struct windowControl {
    unsigned long windowID;                                 /* master ID number for section recording */
    ProcPtr drawMe;                                         /* content drawing procedure pointer */
    ProcPtr clickMe;                                        /* content click routine */
    ProcPtr saveMe;                                         /* document save procedure pointer */
    ProcPtr closeMe;                                        /* document close procedure pointer */
    ProcPtr sizeMe;
    AliasHandle fileAliasHandle;                            /* alias for this document */
    ShapesHandle theShapes;                                 /* list of shapes for this document */
    unsigned short numShapes;                               /* so I can save a number in the file */
    Rect selectionRect;                                     /* currently selected area in document */
    Boolean hasSelection;                                   /* is there a selection? */
    short currentAction;                                    /* what mode is document in */
    short undoAction;                                       /* last completed action */
    Boolean windowDirty;
    mySectionDataHandle graphicSections;    
    short numPubs;                                          /* count of active publishers */
    Handle pubs;                                            /* handle containing section handles for publishers */
    Handle pubRects;                                        /* where in the document the publisher is */
    short numSubs;                                          /* count of active subscribers */
    Handle subs;                                            /* handle containing section handles for subscribers */
    Handle subRects;                                        /* where in the document the subscriber is */
    Handle subDataHandle;                                   /* PICT data handles for each subscriber */
    short numPicts;                                         /* number of non-sub PICTS */
    Handle pictHandle;                                      /* handle to pic handles. This is needed when a user */
    /* cancels a subscription, move the PICT to here */
    Handle pictRects;                                       /* where in the document the subscriber is */
    mySectionDataHandle textSections;
    Rect textBox;
    TEHandle boxHandle;
    long windowIndex;                                       /* for AppleEvent information */
 
};
typedef struct windowControl windowControl, *windowCPtr, **windowCHandle;
 
 
/* A handy structure used to install AppleEvent handlers */
struct AEinstalls{
    AEEventClass theClass;
    AEEventID   theEvent;
    AEEventHandlerUPP   theProc;
};
typedef struct AEinstalls AEinstalls;
 
/* Ditto for coercion handlers */
struct CoercionInstalls{
    DescType fromType;
    DescType toType;
    AECoercionHandlerUPP    theProc;
    Boolean isDesc;  /* will usually be FALSE, System coercion */
};
typedef struct CoercionInstalls CoercionInstalls;
 
/* Here are the structures I am using to define the type of  */
/* object you want acted upon by an event.  Probably not very useful */
/* outside of this sample */
struct WindowObjectDef {
DescType form;
union {
Str63 name;
long index;
} u;
};
typedef struct WindowObjectDef WindowObjectDef, *WindowObjectDefPtr, **WindowObjectDefHandle;
struct TextObjectDef {
DescType form;
union {
Str63 name;
long index;
} u;
Boolean andWord;
long wordNumber;
};
typedef struct TextObjectDef TextObjectDef, *TextObjectDefPtr, **TextObjectDefHandle;
 
struct ShapeObjectDef {
short type;
DescType form;
union {
Str63 name;
long index;
} u;
 
};
typedef struct ShapeObjectDef ShapeObjectDef, *ShapeObjectDefPtr, **ShapeObjectDefHandle;
 
 
/* Here are the structures that define my Tokens, that I pass */
/* back and hand around during AEResolve */
/* All these things are designed to give me all the info I */
/* need to take an event action on an object */
/* I didn't create a structure for my window token, since it's so simple */
/* (just the window pointer) */
 
/* structure of my cText token */
struct CTextObject {
TEHandle theText;
WindowPtr theOwningWindow;
};
typedef struct CTextObject CTextObject, *CTextObjPtr,**CTextObjHandle;
 
/* my word token */
struct CWordObject {
TEHandle theText;   /* need this for setting data */
WindowPtr theOwningWindow;
long startPos;
long endPos;
};
typedef struct CWordObject CWordObject, *CWordObjPtr,**CWordObjHandle;
/* structure of my cGraphicShape token */
struct CShapeObject {
WindowPtr theOwningWindow;
ShapesHandle theShape;
long shapeNumber;
DescType type;
};
typedef struct CShapeObject CShapeObject, *CShapeObjPtr,**CShapeObjHandle;
 
/* structure of my Property token */
struct PropertyToken {
DescType owningTokenType;
WindowPtr inWindow;
union {
ShapesHandle shapeHandle;
TEHandle textHandle;
WindowPtr window;
} token;
DescType theProperty;
DescType theDataType;
Handle theData;
};
typedef struct PropertyToken PropertyToken, *PropertyTPtr,**PropertyTHdl;
 
 
/* My preferences structure */
struct prefStruct {
long version;
Boolean prefsChanged;
Boolean bringAEUp;
Boolean verboseAE;
Boolean saveWindDef;
WindowObjectDef savedWOD;
Boolean saveTextDef;
TextObjectDef savedTOD;
Boolean saveShapeDef;
ShapeObjectDef savedSOD;
Boolean saveInteract;
short localInteraction;
short sendInteraction;
Boolean layerSwitch;
Boolean saveTarget;
short targetMode;
Boolean saveReply;
short replyMode;
};
typedef struct prefStruct prefStruct, *prefStructPtr, **prefStructHandle;
 
/* I thought about making this a union, but I use it so infrequently I didn't want it to get confusing */
struct NewElementData{
Rect theRect;
long long1;
long long2;
Str63 name;
};
typedef struct NewElementData NewElementData,*NewElementDataPtr,**NewElementDataHdl;
 
 
/* for passing back intl text information */
typedef WritingCode *WritingCodePtr, **WritingCodeHdl;
 
 
#endif