Tool Plug-Ins - Adobe 65061456 Programmer's Manual

Programming guide
Table of Contents

Advertisement

C
2: Tutorial
HAPTER
else if ( strcmp( selector, kSelectorAIGoFilter ) == 0 )
}
When the user chooses your filter in the Object menu, your plug-in is first called with
kSelectorAIGetFilterParameters
place them in a handle, storing the handle in the
how the
given back to you on subsequent calls; therefore, it is necessary to create this handle only once. Each time
you receive the get-filter-parameters selector, you can use the previous parameters to set the default
dialog values. If your plug-in places more than one filter in the Object menu, a separate
handle is kept for each one. Illustrator does not care about the specific contents of the
but the handle must be self contained; that is, you cannot include pointers or handles to more data inside
the
parameters
how to copy blocks of memory referenced by the structure. If you do not have any parameters, leave this
field zero.
The parameters used by the Tutorial plug-in's filter are shown below:
typedef struct {
ASInt32 corners;
ASInt32 size;
} MyFilterParameters;
These parameters are obtained from the user by the
The return result from
any parameters) or
Immediately after the plug-in returns from
(
kCallerAIFilter
filter does, using the globals and parameters the plug-in set up previously. The Tutorial plug-in's
function in
object and adding path segments to it.

Tool plug-ins

Illustrator allows plug-ins to add new tools to the Tools panel. To add a tool, your plug-in must do the
following:
Provide an icon to represent the tool in the Tools panel.
Call
AIToolSuite::AddTool
Handle tool-related messages relating to mouse events. For example, when the plug-in's tool is
selected in the Tools panel and the mouse button goes down and is released, the plug-in is notified by
a selector message (
communicate mouse drag events, and so on.
The Tutorial plug-in adds a line-drawing tool by calling
code, see the
The added tool appears in the Tools panel. When it is selected and used, Illustrator calls the plug-in with
the tool selectors listed above. To create a minimal straight-line tool, the plug-in needs to handle only the
mouse-down selector. The Tutorial plug-in's
error = GoFilter( ( AIFilterMessage* )message );
field is used, only
globals
handle. This is because Illustrator may make copies of the parameters and does not know
// number of corners on the polygon
// the maximum size, in points
GetFilterParameters
kCanceledErr
/
kSelectorAIGoFilter
creates a random polygon each time it is called, by creating a new path art
Tutorial.cpp
kCallerAITool
function in
AddTool
. You should get whatever parameters you need from the user and
parameters
must be a handle if it is not nil. The
parameters
GetFilterParameters
should be
if the user cancels the filter.
GetFilterParameters
). When the plug-in receives this, it performs whatever the
on start-up, to add the tool to Illustrator.
/
kSelectorAIToolMouseDown
AIToolSuite::AddTool
.
Tutorial.cpp
PluginMain
Plug-in type-specific messages 26
field of
AIFilterMessage
function in
if the user hit OK (or if you do not have
kNoErr
, it is sent the go-filter selector pair
). A similar approach is used to
function handles this as follows:
. This is similar to
handle is
parameters
parameters
handle,
parameters
.
Tutorial.cpp
GoFilter
on start-up. For sample

Advertisement

Table of Contents
loading

This manual is also suitable for:

Illustrator cs5

Table of Contents