background image

C

HAPTER

 2: Tutorial

Plug-in type-specific messages

     27

else if ( strcmp( caller, kCallerAITool ) == 0  ) {

if ( strcmp( selector, kSelectorAIToolMouseDown ) == 0 )

error = ToolMouseDown( ( AIToolMessage* )message );

}

When the mouse is clicked, the Tutorial plug-in receives this selector and can process it. See the 

ToolMouseDown

 function in 

Tutorial.cpp

. This function draws path segments to each mouse-down 

location. The location of the mouse is passed in the tool-message structure; see 

AIToolMessage

 in 

Adobe 

Illustrator API Reference

. The tool message contains the basic plug-in data and a reference to the tool being 

used. The 

cursor

 field contains the point on the art board where the last tool event occurred, and the 

Tutorial plug-in’s mouse-down handler uses this to create a path. The 

ToolMouseDown

 function begins by 

acquiring the suites it needs to make a line. The function checks whether a selected path exists. If so, it 
adds path segments to it; otherwise, it creates the first point in a new path. The function ends by releasing 
the suites it acquired.

While the 

ToolMouseDown

 function adds a basic tool, other selectors can be processed to give the line tool 

more functionality, like setting the cursor or tracking a mouse drag. This is left as an exercise for the reader.

Action plug-ins

For your plug-in to be recordable by Illustrator’s Actions panel, you must add special code to your plug-in. 
Follow these steps:

1.

Register action events

 — During start-up, your plug-in must register one or more action events. An 

action event is a single operation your plug-in executes. An Action event is shown in Illustrator’s 
Actions panel, if the user chooses to record it.

2.

Record action events

 — During your plug-in’s execution, you must check whether the user is in 

record mode. If so, you must record your action event and pass all relevant parameters to the Action 
Manager.

3.

Respond to the DoAction selector

 — Once you register one or more Action Events, your plug-in 

must be ready to execute those Action Events when requested. Your plug-in must respond to the 

kActionCaller

 caller and 

kDoActionSelector

 selector. These are defined in the Action Manager 

suite header file.

Registering action events

First, determine how many action events your plug-in will register, by separating the functionality of your 
plug-in into discrete operations. Basically, try to think of which operations users will want to record in the 
Actions panel.

During start-up, your plug-in should first make sure the Action Manager suite (see 

AIActionManagerSuite

) is available, by trying to acquire a pointer to the suite. This check is necessary 

because the Action Plug-in may be disabled by removing it from the 

Plug-ins

 folder.

To register an action event, your plug-in must do the following:

X

Call 

AIActionManagerSuite::AINewActionParamType

 to create a type parameter block (TPB) that 

describes the parameters your action event requires.

X

Populate the TPB with key-value pairs that give the name and data type of each parameter by calling 

AIActionManagerSuite::

AIActionSetTypeKey

.

X

Call 

AIActionManagerSuite::

RegisterActionEvent

 to register the action event.

Summary of Contents for 65061456

Page 1: ...ADOBE ILLUSTRATOR CS5 ADOBE ILLUSTRATOR CS5 PROGRAMMER S GUIDE...

Page 2: ...h Flex and ActionScript are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and or other countries Microsoft and Windows are either registered trademarks...

Page 3: ...n types 10 Where plug ins live 10 What defines a plug in 11 PiPL resources 11 Plug in management 11 Plug in entry point and messages 12 Message actions callers and selectors 12 Core message actions 13...

Page 4: ...elector 24 Caller kSPAccessCaller selector kSPAccessUnloadSelector 25 Plug in type specific messages 25 Filter plug ins 25 Tool plug ins 26 Action plug ins 27 Menu plug ins 29 Next steps 29 3 Creating...

Page 5: ...ronment and the code samples included in the SDK Provides step by step guides on creating new projects either from scratch or from the templates provided with the SDK X Adobe Illustrator CS5 Porting G...

Page 6: ...e Illustrator 5 5 to include file formats The 5 x APIs displayed characteristics of many early API design efforts the interface was monolithic incorporating enough function to achieve its intended pur...

Page 7: ...for any strings displayed in the user interface In Mac OS the object file format for Illustrator plug ins changed to Mach O The old format was PEF a preferred executable format Moving forward Mach O...

Page 8: ...le and described more fully after the table Adobe Illustrator Plug in manager Required plug ins Additional plug ins Plug in Type What it does Action Playback or register actions Effects Add menu items...

Page 9: ...reads and writes non native files e g TIFF or JPEG files In Illustrator these are called file format plug ins Illustrator uses the term filter plug in in a way similar to Adobe Photoshop a filter plug...

Page 10: ...determine which artwork was selected and act on it For example a tool might create or distort objects Some things are handled automatically for plug in tools like scrolling the window For more informa...

Page 11: ...f the plug in given by a code descriptor property Illustrator considers only files with a valid PiPL to be potential plug ins PiPL properties are defined using native platform resources For more infor...

Page 12: ...lug in to perform an action The message action passed to your plug in consists of two identifiers X The caller identifies the sender of the message PICA the host application or a plug in and a general...

Page 13: ...r Startup define kSPInterfaceShutdownSelector Shutdown When Illustrator is launched it sends a startup message to each plug in it finds This allows your plug in to allocate global memory add user inte...

Page 14: ...and Unload if strcmp selector kSPAccessReloadSelector 0 error MyRestoreGlobals message else if strcmp selector kSPAccessUnloadSelector 0 error MySaveGlobals message else if strcmp caller kSPInterfaceC...

Page 15: ...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...

Page 16: ...or detailed descriptions of suites and their associated functions see Adobe Illustrator API Reference Acquiring and releasing suites Before you can use a function in a suite you must first acquire the...

Page 17: ...echanism of the Illustrator API Plug ins also can publish suites of their own for use by other plug ins This feature where plug ins may be both clients of suites and publishers of suites is extremely...

Page 18: ...he Illustrator specific code can be run with little modification often only a few lines of code within an ifdef For example the Tutorial sample in the SDK uses identical source code only the resources...

Page 19: ...sSPBlocks nil If you add a helper class to your plug in and you do not declare the global suite pointers it requires you will get linker errors when you build your project If you do not acquire the su...

Page 20: ...quest further information about a specific plug in As of Illustrator CS3 the About Plug ins dialog was removed Next steps In this chapter we introduced plug ins for Adobe Illustrator and defined sever...

Page 21: ...unload and reload Your plug in can expect certain services from the application Because your plug in may be unloaded Illustrator provides a means of storing important data when the plug in is unloade...

Page 22: ...be called through this pointer long count 0 sAIMenu CountMenuItems count After the function is used the suite is released sSPBasic ReleaseSuite kAIMenuSuite kAIMenuSuiteVersion Since they are used th...

Page 23: ...field Usually it is a pointer to a block of memory If you do not have any global data you can leave the globals field empty During the start up message you need to inform Illustrator of the filters to...

Page 24: ...kSPInterfaceShutdownSelector message Only one such message is received per Illustrator session Actions that should happen when the user is completely finished using the plug in like saving preference...

Page 25: ...ect menu To add a filter your plug in must do the following X Call AIFilterSuite AddFilter on start up to add the filter to Illustrator X Handle messages relating to filter events There are two caller...

Page 26: ...he user by the GetFilterParameters function in Tutorial cpp The return result from GetFilterParameters should be kNoErr if the user hit OK or if you do not have any parameters or kCanceledErr if the u...

Page 27: ...must register one or more action events An action event is a single operation your plug in executes An Action event is shown in Illustrator s Actions panel if the user chooses to record it 2 Record ac...

Page 28: ...nt X Call AIActionManagerSuite AIDeleteActionParamValue to dispose of your reference to the VPB For sample code see the GoFilter and RecordFilterAction functions in Tutorial cpp Responding to the DoAc...

Page 29: ...IGoMenuItem The Tutorial plug in adds an About plug in menu on start up see About Plug ins menu on page 19 For sample code see the AddMenu function in Tutorial cpp A helper class SDKAboutBoxHelper is...

Page 30: ...you are using an extension only to provide a UI for an Illustrator C plug in you typically put the program logic in the C plug in where you can use Illustrator s native C API rather than the scriptin...

Page 31: ...CSXS library SWC is an ActionScript component that provides the API that the extension uses to interact with C plug ins To dispatch events from an extension to a plug in call the ActionScript library...

Page 32: ...nto data items useful to the plug in X Before unloading the extension you must use SDKPlugPlug RemoveEventListener to remove any event listeners you have registered For example RemoveEventListener com...

Page 33: ...m adobe csxs events updatePanel updatePanel X To dispatch events from your extension to your C plug in use dispatchEvent You can pass related data as a string To encapsulate complex values in data you...

Page 34: ...s used by the extension and a signature that ensures the files have not changed The Adobe Creative Suite SDK allows you to debug your extension during development before you actually package and insta...

Page 35: ...L are documented in the Illustrator API Reference and listed in the following table Required PiPL properties Your plug in s PiPL resource must include the required properties listed in the following t...

Page 36: ...riptor containing entry point of Intel code for plug ins on Mac OS platforms PIPowerPCMachOCodeProperty mach PIMachCodeDesc code descriptor containing entry point of PowerPC code in Mach O format for...

Page 37: ...ore information Adobe Illustrator API Reference describes the property names and associated data structures such as PIPropertyList The sample plug ins on the SDK show how to define a PiPL using native...

Page 38: ...nu plug ins 29 message action defined 12 messages 12 core actions 13 passing data 14 persistent data 15 reload and unload 13 startup and shutdown 13 N notifiers 14 P PICA Plug in Component Architectur...

Reviews: