Adobe 65061456 Programming Guide - Page 19

Helper classes, Plug-in adapters, About Plug-ins menu

Page 19 highlights

CHAPTER 1: Overview Plug-in adapters 19 Helper classes The API provides helper classes that make it easier to write plug-in code. These classes encapsulate calling of suites; they remove the need to call suites directly in your code. For example, ai::UnicodeString provides support for Unicode strings and removes the need to call AIUnicodeStringSuite. Source files for these helpers are provided by the API. To use a helper, add the .cpp file that implements it to your project and build the code as part of your plug-in. For example, IAIUnicodeString.cpp file implements the ai::UnicodeString class. NOTE: Using helper classes is different than using suites. Suites are implemented by another binary component (the Illustrator application or its plug-ins) and called by your plug-in; an API header file defines the interface. Helper classes, on the other hand, are built as part of your plug-in; an API header file defines the interface, and an API source file (.cpp file) provides the implementation. To use a helper class, a plug-in typically must provide pointers to the suites used by the class, in global variables with well-known names. For example, ai::UnicodeString requires that the calling plug-in acquire a pointer to AIUnicodeStringSuite and SPBlocksSuite in the global variables below: extern "C" { AIUnicodeStringSuite* sAIUnicodeString = nil; SPBlocksSuite* 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 suites the class depends on, run-time errors will occur (see "Acquiring and releasing suites" on page 16). On Windows, if you add a helper class to your plug-in and your Visual Studio project is using pre-compiled headers, you will get a compilation error, because the source file for the helper class does not #include your pre-compiled header file. To fix this override the Create/Use Precompiled Header setting to be Not Using Precompiled Headers for the helper-class source file. For documentation on the classes provided, see Adobe Illustrator API Reference > Helper classes. Plug-in adapters Support for older plug-ins, as well as for Photoshop plug-ins, is provided through plug-in adapters, plug-ins that map API calls between Illustrator and the older or non-native APIs of the other plug-ins. Adapters are not discussed in detail in this document. About Plug-ins menu To display company contact information or copyright statements about your plug-in, follow these steps: X Create a new menu group under Illustrator's About group (see kAboutMenuGroup), to contain all the About plug-in menu items. X For each plug-in, create a menu item under this new group. X Handle the menu message related to use of your About plug-in menu by popping an About box containing plug-in specific information. An illustration of the resulting menus on Mac OS is given below:

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

C
HAPTER
1: Overview
Plug-in adapters
19
Helper classes
The API provides helper classes that make it easier to write plug-in code. These classes encapsulate calling
of suites; they remove the need to call suites directly in your code. For example,
ai::UnicodeString
provides support for Unicode strings and removes the need to call
AIUnicodeStringSuite
.
Source files for these helpers are provided by the API. To use a helper, add the
.cpp
file that implements it
to your project and build the code as part of your plug-in. For example,
IAIUnicodeString.cpp
file
implements the
ai::UnicodeString
class.
N
OTE
:
Using helper classes is different than using suites. Suites are implemented by another binary
component (the Illustrator application or its plug-ins) and called by your plug-in; an API header file defines
the interface. Helper classes, on the other hand, are built as part of your plug-in; an API header file defines
the interface, and an API source file (
.cpp
file) provides the implementation.
To use a helper class, a plug-in typically must provide pointers to the suites used by the class, in global
variables with well-known names. For example,
ai::UnicodeString
requires that the calling plug-in
acquire a pointer to
AIUnicodeStringSuite
and
SPBlocksSuite
in the global variables below:
extern "C" {
AIUnicodeStringSuite* sAIUnicodeString = nil;
SPBlocksSuite* 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 suites the class depends on,
run-time errors will occur (see
Acquiring and releasing suites
” on page 16
). On Windows, if you add a
helper class to your plug-in and your Visual Studio project is using pre-compiled headers, you will get a
compilation error, because the source file for the helper class does not
#include
your pre-compiled
header file. To fix this override the Create/Use Precompiled Header setting to be Not Using Precompiled
Headers for the helper-class source file.
For documentation on the classes provided, see
Adobe Illustrator API Reference > Helper classes
.
Plug-in adapters
Support for older plug-ins, as well as for Photoshop plug-ins, is provided through
plug-in adapters
, plug-ins
that map API calls between Illustrator and the older or non-native APIs of the other plug-ins. Adapters are
not discussed in detail in this document.
About Plug-ins menu
To display company contact information or copyright statements about your plug-in, follow these steps:
X
Create a new menu group under Illustrator’s About group (see
kAboutMenuGroup
), to contain all the
About plug-in menu items.
X
For each plug-in, create a menu item under this new group.
X
Handle the menu message related to use of your About plug-in menu by popping an About box
containing plug-in specific information.
An illustration of the resulting menus on Mac OS is given below: