
C
HAPTER
1: Overview
Illustrator API
15
struct SPBasicSuite *basic;
} SPMessageData;
If this is a valid message, the
SPCheck
field contains
kSPValidSPMessageData
.
The
self
field is a reference to the plug-in being called. The reference to the running plug-in’s
self
is used
to add plug-in suites, adapters, and other plug-in data to Illustrator. Illustrator stores this value with the
added data. It is used to recall your plug-in as needed.
The
globals
pointer is for use by your plug-in, to preserve any information between calls that it needs.
Usually, it is a pointer to a block of memory allocated by your plug-in at start-up. This value is preserved by
Illustrator when your plug-in is unloaded and passed back to the plug-in each time it is called. Plug-ins use
this block to store any state information they need to maintain between unload and reload.
N
OTE
:
It is important that the memory for globals be allocated using Illustrator's memory-allocation APIs;
otherwise, the memory may be destroyed by the operating system when a plug-in is unloaded.
The
basic
field is a pointer to the Basic suite (see
SPBasicSuite
), which allows your plug-in to acquire
other suites and provides basic memory management. See
“Suites” on page 15
.
When Illustrator or a plug-in wants to send a message to your plug-in, it passes in a relevant message data
structure. Some examples are given below.
Once a plug-in identifies the message action via the caller and selector parameters, it casts the message
parameter to access further message data. For example:
if (strcmp(caller, kSPAccessCaller) == 0) {
SPAccessMessage* accessMsg = static_cast<SPAccessMessage*>(message);
// access accessMsg
}
else if (strcmp(caller, kSPInterfaceCaller) == 0) {
SPInterfaceMessage* interfaceMsg = static_cast<SPInterfaceMessage*>(message);
// access interfaceMsg
}
else if (strcmp(caller, kCallerAIMenu) == 0) {
AIMenuMessage* menuMsg = static_cast<AIMenuMessage*>(message);
// access menuMsg
}
Illustrator API
Suites
The Illustrator plug-in manager calls a plug-in through the plug-in’s entry point, sending various messages
as described in the previous section. When a plug-in is active, it needs a way to perform actions within
Caller
Message type
Description
kSPAccessCaller
SPAccessMessage
Contains
SPMessageData
.
kSPInterfaceCaller
SPInterfaceMessage
Contains
SPMessageData
.
kCallerAIMenu
AIMenuMessage
Contains
SPMessageData
and a reference to a menu
item that was chosen.