Resource Suite Callbacks

This suite of callback routines provides support for storing and retrieving data from a document. More...

Data Structures

struct  ResourceProcs
 The set of routines available in the Resource suite. More...

Defines

#define kCurrentResourceProcsVersion   3
 The current version of the resource suite.
#define kCurrentResourceProcsCount   ((sizeof(ResourceProcs) - offsetof(ResourceProcs, countProc)) / sizeof(void *))
 Current number of routines in the Resource Suite.

Typedefs

typedef struct ResourceProcs ResourceProcs
 The set of routines available in the Resource suite.

Pseudo-Resource Suite Callbacks

typedef MACPASCAL int16(* CountPIResourcesProc )(ResType type)
 Counts the number of resources of a given type.
typedef MACPASCAL Handle(* GetPIResourceProc )(ResType type, int16 index)
 Gets the indicated resource for the current document.
typedef MACPASCAL void(* DeletePIResourceProc )(ResType type, int16 index)
 Deletes the indicated resource in the current document.
typedef MACPASCAL OSErr(* AddPIResourceProc )(ResType type, Handle data)
 Adds a resource of the given type at the end of the list for that type.

Detailed Description

This suite of callback routines provides support for storing and retrieving data from a document.

These routines provide pseudo-resources which plug-in modules can attach to documents and use to communicate with each other.

Each resource is a Handle of data and is identified by a 4 character code ResType and a one-based index. The maximum number of pseudo-resources in a document for Photoshop is 1000. Use the Handle Suite Callbacks to manage the Handle data structure.

The standard Resource Suite is found as a pointer in the parameter blocks of the plug-in modules. You can access the routines within the Resource Suite in the following manner:

    // FormatRecord global pointer.
    FormatRecord * gFormatRecord = NULL;

    DLLExport MACPASCAL void PluginMain (const int16 selector,
                                         FormatRecordPtr formatParamBlock,
                                         intptr_t* data,
                                         int16* result)
    {
        // The Resource Suite is contained in the parameter block passed
        // in formatParamBlock.
        gFormatRecord = formatParamBlock;
        ...

        // Get the Resource Suite from the parameter block, and call
        // countProc to count the number of "histResource" resources.
        int16 resourceCount = gFormatRecord->resourceProcs->countProc(histResource);
        
        ...
    }

Define Documentation

The current version of the resource suite.

#define kCurrentResourceProcsCount   ((sizeof(ResourceProcs) - offsetof(ResourceProcs, countProc)) / sizeof(void *))

Current number of routines in the Resource Suite.


Typedef Documentation

typedef MACPASCAL int16(* CountPIResourcesProc)(ResType type)

Counts the number of resources of a given type.

Parameters:
typeThe type of resource to count.
Returns:
The number of resources of the given type.
typedef struct ResourceProcs ResourceProcs

The set of routines available in the Resource suite.

typedef MACPASCAL Handle(* GetPIResourceProc)(ResType type, int16 index)

Gets the indicated resource for the current document.

The plug-in host owns the returned handle. The handle should be treated as read-only.

Parameters:
typeThe type of resource to get.
indexThe index of the resource to get.
Returns:
A handle to the resource for the current document; NULL if no resource exists with the given type and index.
typedef MACPASCAL void(* DeletePIResourceProc)(ResType type, int16 index)

Deletes the indicated resource in the current document.

Note that since resources are identified by index rather than ID, this causes subsequent resources to be renumbered.

Parameters:
typeThe type of resource to delete.
indexThe index of the resource to delete.
typedef MACPASCAL OSErr(* AddPIResourceProc)(ResType type, Handle data)

Adds a resource of the given type at the end of the list for that type.

The contents of data are duplicated so that the plug-in retains control over the original handle. The maximum number of resources in a Photoshop document is 1000.

Parameters:
typeThe type of resource to add.
dataThe resource data to add.
Returns:
memFullErr if there is not enough memory or the document already has too many plug-in resources.