Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
hdicorePlugin.h
Go to the documentation of this file.
1 
7 #ifndef __HDI_CORE_PLUGIN__
8 #define __HDI_CORE_PLUGIN__
9 
10 #include <vector>
11 
12 #include "hdicoreMain.h"
13 
17 #define HDI_CORE_PLUGIN hdi::core::Plugin::instance()
18 
19 namespace hdi
20 {
21  namespace core
22  {
23  #if defined(MAC_ENV)
24  typedef NSBundle* PlatformPluginPtr;
25  #elif defined(WIN_ENV)
26  typedef HINSTANCE PlatformPluginPtr;
27  #endif
28 
29  class Callback;
30  class Dispatcher;
31  class MenuItem;
32  class ModalDialog;
33  class Tool;
34 
40  class Plugin
41  {
42  public:
43  typedef std::vector<byte> ByteVector;
44 
48  enum Options
49  {
50  NoOptions = 0,
51  AutoSelectsResultsOption = 1 << 0,
52  RetainsPartialPathSelectionOption = 1 << 1
53  };
54 
59  {
60  UnknownUndoContext = 0,
61 
62  // A standard undo context results in the addition of a new transaction which can be undone/redone
63  // by the user
64  StandardUndoContext = 10,
65 
66  // A silent context does not cause redos to be discarded and is skipped over when undoing and
67  // redoing. An example is a selection change.
68  SilentUndoContext = 20,
69 
70  // An appended context is like a standard context, except that it is combined with the preceding
71  // transaction. It does not appear as a separate transaction. Used, for example, to collect
72  // sequential changes to the color of an object into a single undo/redo transaction.
73  AppendUndoContext = 30
74  };
75 
83  static Plugin* const instance();
84 
96  virtual SPPluginRef spPluginRef() const;
97 
105  PlatformPluginPtr platformPlugin() const;
106 
114  virtual std::string filePath() const;
115 
123  virtual std::string fileName() const;
124 
132  virtual std::string name() const;
133 
141  virtual void setName(const std::string& name_);
142 
150  virtual Options options() const;
151 
159  virtual void setOptions(const Options options_);
160 
168  virtual Dispatcher* const dispatcher() const;
169 
177  virtual Tool* const currentTool() const;
178 
184  virtual void undo() const;
185 
194  virtual bool setUndoKind(const UndoContext uc_);
195 
208  virtual bool resourceData(const int32_t type_, const int16_t id_, ByteVector& data__) const;
209 
222  virtual bool resourceData(
223  const int32_t type_,
224  const std::string& name_,
225  ByteVector& data__
226  ) const;
227 
238  virtual bool toolsSnapToArt() const;
239 
247  virtual void setToolsSnapToArt(const bool snap_);
248 
259  virtual bool toolsSnapToArtBounds() const;
260 
268  virtual void setToolsSnapToArtBounds(const bool snap_);
269 
280  virtual bool toolsSnapToArtboard() const;
281 
289  virtual void setToolsSnapToArtboard(const bool snap_);
290 
302  virtual bool toolsSnapToGrids() const;
303 
312  virtual void setToolsSnapToGrids(const bool snap_);
313 
321  virtual bool startingUp() const;
322 
330  virtual bool hasStartedUp() const;
331 
339  virtual bool postStartingUp() const;
340 
348  virtual bool hasPostStartedUp() const;
349 
357  virtual bool preShuttingDown() const;
358 
366  virtual bool hasPreShutdown() const;
367 
375  virtual bool shuttingDown() const;
376 
384  virtual bool hasShutdown() const;
385 
393  virtual Callback* const startupCallback() const;
394 
402  virtual void setStartupCallback(const Callback& cb_);
403 
411  virtual Callback* const postStartupCallback() const;
412 
420  virtual void setPostStartupCallback(const Callback& cb_);
421 
429  virtual Callback* const preShutdownCallback() const;
430 
438  virtual void setPreShutdownCallback(const Callback& cb_);
439 
447  virtual Callback* const shutdownCallback() const;
448 
456  virtual void setShutdownCallback(const Callback& cb_);
457 
465  virtual Callback* const menuItemSelectedCallback() const;
466 
474  virtual void setMenuItemSelectedCallback(const Callback& cb_);
475 
484  virtual Callback* const menuItemsUpdateCallback() const;
485 
494  virtual void setMenuItemsUpdateCallback(const Callback& cb_);
495 
504  virtual Callback* const brightnessAdjustedCallback() const;
505 
514  virtual void setBrightnessAdjustedCallback(const Callback& cb_);
515 
524  virtual Callback* const toolPreSelectedCallback() const;
525 
534  virtual void setToolPreSelectedCallback(const Callback& cb_);
535 
544  virtual Callback* const toolPostSelectedCallback() const;
545 
554  virtual void setToolPostSelectedCallback(const Callback& cb_);
555 
564  virtual Callback* const toolPreDeselectedCallback() const;
565 
574  virtual void setToolPreDeselectedCallback(const Callback& cb_);
575 
584  virtual Callback* const toolPostDeselectedCallback() const;
585 
594  virtual void setToolPostDeselectedCallback(const Callback& cb_);
595 
604  virtual Callback* const toolPreReselectedCallback() const;
605 
614  virtual void setToolPreReselectedCallback(const Callback& cb_);
615 
624  virtual Callback* const toolPostReselectedCallback() const;
625 
633  virtual void setToolPostReselectedCallback(const Callback& cb_);
634 
643  virtual Callback* const toolPreTrackedCallback() const;
644 
653  virtual void setToolPreTrackedCallback(const Callback& cb_);
654 
663  virtual Callback* const toolPostTrackedCallback() const;
664 
673  virtual void setToolPostTrackedCallback(const Callback& cb_);
674 
683  virtual Callback* const toolPreMouseDownCallback() const;
684 
693  virtual void setToolPreMouseDownCallback(const Callback& cb_);
694 
703  virtual Callback* const toolPostMouseDownCallback() const;
704 
713  virtual void setToolPostMouseDownCallback(const Callback& cb_);
714 
723  virtual Callback* const toolPreDraggedCallback() const;
724 
733  virtual void setToolPreDraggedCallback(const Callback& cb_);
734 
743  virtual Callback* const toolPostDraggedCallback() const;
744 
753  virtual void setToolPostDraggedCallback(const Callback& cb_);
754 
763  virtual Callback* const toolPreMouseUpCallback() const;
764 
773  virtual void setToolPreMouseUpCallback(const Callback& cb_);
774 
783  virtual Callback* const toolPostMouseUpCallback() const;
784 
793  virtual void setToolPostMouseUpCallback(const Callback& cb_);
794 
803  virtual Callback* const toolPreDiameterDecreasedCallback() const;
804 
813  virtual void setToolPreDiameterDecreasedCallback(const Callback& cb_);
814 
823  virtual Callback* const toolPostDiameterDecreasedCallback() const;
824 
833  virtual void setToolPostDiameterDecreasedCallback(const Callback& cb_);
834 
843  virtual Callback* const toolPreDiameterIncreasedCallback() const;
844 
853  virtual void setToolPreDiameterIncreasedCallback(const Callback& cb_);
854 
863  virtual Callback* const toolPostDiameterIncreasedCallback() const;
864 
873  virtual void setToolPostDiameterIncreasedCallback(const Callback& cb_);
874 
883  virtual Callback* const toolPreEditedCallback() const;
884 
893  virtual void setToolPreEditedCallback(const Callback& cb_);
894 
903  virtual Callback* const toolPostEditedCallback() const;
904 
913  virtual void setToolPostEditedCallback(const Callback& cb_);
914 
928  virtual ModalDialog* const aboutBox() const;
929 
943  virtual void setAboutBox(const ModalDialog& dialog_);
944 
958  virtual ModalDialog* const prefsDialog() const;
959 
973  virtual void setPrefsDialog(const ModalDialog& dialog_);
974 
988  virtual MenuItem* const aboutMenuItem() const;
989 
1004  virtual void setAboutMenuItem(const MenuItem& mi_);
1005 
1019  virtual MenuItem* const prefsMenuItem() const;
1020 
1035  virtual void setPrefsMenuItem(const MenuItem& mi_);
1036 
1037 
1038  private:
1039  friend __MainError (::PluginMain) (const char*, const char*, void*);
1040 
1044  enum __StartupError
1045  {
1046  __NoStartupError = 0,
1047  __CantLockPluginError = 1000,
1048  __CantSetPluginNameError = 1010,
1049  __BadIllustratorVersionError = 1020,
1050  __WrongPluginBinaryError = 1030,
1051  __WrongInstallLocationError = 1040,
1052  __CantLoadPrefsError = 1050,
1053  __CantSetupToolsError = 1060,
1054  __CantSetupNotifiersError = 1070,
1055  __CantSetupAnnotatorsError = 1080,
1056  __CantSetupTimersError = 1090,
1057  __CustomStartupErrorOffset = 1000000
1058  };
1059 
1063  enum __PostStartupError
1064  {
1065  __NoPostStartupError = 0,
1066  __CustomPostStartupErrorOffset = 2000000
1067  };
1068 
1072  enum __PreShutdownError
1073  {
1074  __NoPreShutdownError = 0,
1075  __CustomPreShutdownErrorOffset = 3000000
1076  };
1077 
1081  enum __ShutdownError
1082  {
1083  __NoShutdownError = 0,
1084  __CantUnlockPluginError = 4000,
1085  __CustomShutdownErrorOffset = 4000000
1086  };
1087 
1091  static Plugin* __instance;
1092 
1096  void* __data;
1097 
1103  Plugin();
1104 
1110  Plugin(const Plugin&);
1111 
1117  Plugin(const void*, const std::string&);
1118 
1124  virtual ~Plugin();
1125 
1131  Plugin& operator=(const Plugin& rhs_);
1132 
1138  __StartupError __startup();
1139 
1145  __PostStartupError __postStartup();
1146 
1152  __PreShutdownError __preShutdown();
1153 
1159  __ShutdownError __shutdown();
1160  };
1161  }
1162 }
1163 
1164 hdi::core::Plugin::Options operator|(
1165  const hdi::core::Plugin::Options lhs_,
1166  const hdi::core::Plugin::Options rhs_
1167 );
1168 
1169 hdi::core::Plugin::Options& operator|=(
1171  const hdi::core::Plugin::Options rhs_
1172 );
1173 
1174 #endif
1175 // __HDI_CORE_PLUGIN__
virtual bool hasShutdown() const
Gets whether the plugin has already completed shutting down.
virtual Callback *const brightnessAdjustedCallback() const
Gets the callback that's called when the brightness of the Illustrator UI is changed via the app pref...
virtual bool hasPreShutdown() const
Gets whether the plugin has already completed pre-shutting down.
virtual void setMenuItemsUpdateCallback(const Callback &cb_)
Sets the callback that's called when a user hovers over menu groups that will show this plugin's menu...
virtual void setToolsSnapToArt(const bool snap_)
Sets whether tools belonging to this plugin should snap the cursor to artwork.
virtual Callback *const toolPostDeselectedCallback() const
Gets the callback that's called just after a tool is deselected (i.e. the tool's deselection callback...
virtual std::string fileName() const
Gets the name of the plugin file at runtime.
virtual void setToolPostTrackedCallback(const Callback &cb_)
Sets the callback that's called just after the cursor moves (with the mouse button released; i...
virtual Callback *const toolPreMouseDownCallback() const
Gets the callback that's called just before the mouse button goes down (i.e. the tool's mouse down ca...
virtual Dispatcher *const dispatcher() const
Convenience method to return the Dispatcher instance.
virtual Callback *const toolPreEditedCallback() const
Gets the callback that's called just before a tool is double-clicked in the toolbar (i...
virtual Callback *const preShutdownCallback() const
Gets the callback that's called just before the plugin will shutdown.
virtual bool hasPostStartedUp() const
Gets whether the plugin has already completed post-starting up.
virtual void setToolPostMouseUpCallback(const Callback &cb_)
Sets the callback that's called just after the mouse button comes up (i.e. the tool's mouse up callba...
virtual bool preShuttingDown() const
Gets whether the plugin is in the process of pre-shutting down.
virtual void setToolPreDiameterDecreasedCallback(const Callback &cb_)
Sets the callback that's called just before the '[' key is hit while a tool is selected (i...
virtual Callback *const toolPostTrackedCallback() const
Gets the callback that's called just after the cursor moves (with the mouse button released; i...
virtual ModalDialog *const prefsDialog() const
Gets the global prefs modal dialog for the plugin.
virtual Callback *const toolPostMouseUpCallback() const
Gets the callback that's called just after the mouse button comes up (i.e. the tool's mouse up callba...
virtual Callback *const toolPreDraggedCallback() const
Gets the callback that's called just before the mouse button is down and the cursor moves (i...
virtual Callback *const toolPostEditedCallback() const
Gets the callback that's called just after a tool is double-clicked in the toolbar (i...
virtual void setAboutMenuItem(const MenuItem &mi_)
Sets the about box menu item for the plugin.
virtual void setPreShutdownCallback(const Callback &cb_)
Sets the callback that's called just before the plugin will shutdown.
virtual void setToolPostReselectedCallback(const Callback &cb_)
Sets the callback that's called just after a tool is reselected (i.e. the tool's reselection callback...
Base plugin class; the heart of any plugin project.
Definition: hdicorePlugin.h:40
virtual bool postStartingUp() const
Gets whether the plugin is in the process of post-starting up.
Used to create and display a modal dialog to the user, blocking input to other UI elements...
Definition: hdicoreModalDialog.h:30
UndoContext
Allows for setting of the undo context to other behaviors.
Definition: hdicorePlugin.h:58
virtual Callback *const menuItemsUpdateCallback() const
Gets the callback that's called when a user hovers over menu groups that will show this plugin's menu...
virtual Options options() const
Gets the plugin's options.
virtual SPPluginRef spPluginRef() const
Gets the plugin ref around which the target object is wrapped.
virtual bool resourceData(const int32_t type_, const int16_t id_, ByteVector &data__) const
Acquires a byte vector for a given resource.
virtual Callback *const toolPostReselectedCallback() const
Gets the callback that's called just after a tool is reselected (i.e. the tool's reselection callback...
virtual bool startingUp() const
Gets whether the plugin is in the process of starting up.
virtual Callback *const toolPostDiameterDecreasedCallback() const
Gets the callback that's called just after the '[' key is hit while a tool is selected (i...
virtual ModalDialog *const aboutBox() const
Gets the about box modal dialog for the plugin.
virtual MenuItem *const prefsMenuItem() const
Gets the global prefs menu item for the plugin.
virtual void setStartupCallback(const Callback &cb_)
Sets the callback that's called when the plugin is starting up.
virtual Callback *const toolPostSelectedCallback() const
Gets the callback that's called just after a tool is selected from the toolbar (i.e. the tool's selection callback has already been called)
virtual bool setUndoKind(const UndoContext uc_)
Changes the undo context to another type.
virtual void setOptions(const Options options_)
Sets the plugin's options.
virtual void setPostStartupCallback(const Callback &cb_)
Sets the callback that's called just after the plugin has started up.
virtual void setPrefsMenuItem(const MenuItem &mi_)
Sets the global prefs menu item for the plugin.
virtual void setToolPreDiameterIncreasedCallback(const Callback &cb_)
Sets the callback that's called just before the ']' key is hit while a tool is selected (i...
virtual Callback *const toolPreDeselectedCallback() const
Gets the callback that's called just before a tool is deselected (i.e. the tool's deselection callbac...
virtual void setToolPreReselectedCallback(const Callback &cb_)
Sets the callback that's called just before a tool is reselected (i.e. the tool's reselection callbac...
virtual void setToolPreMouseDownCallback(const Callback &cb_)
Sets the callback that's called just before the mouse button goes down (i.e. the tool's mouse down ca...
Base class for templated __Callback class.
Definition: hdicoreCallback.h:67
virtual Tool *const currentTool() const
Gets a pointer to the currently selected tool.
virtual std::string filePath() const
Gets the full path of the plugin file at runtime.
virtual Callback *const toolPostDraggedCallback() const
Gets the callback that's called just after the mouse button is down and the cursor moves (i...
static Plugin *const instance()
Allows access to the singleton Plugin instance object.
virtual Callback *const toolPreDiameterIncreasedCallback() const
Gets the callback that's called just before the ']' key is hit while a tool is selected (i...
virtual void setToolPreSelectedCallback(const Callback &cb_)
Sets the callback that's called just before a tool is selected from the toolbar (i.e. the tool's selection callback has not been called)
virtual Callback *const toolPreSelectedCallback() const
Gets the callback that's called just before a tool is selected from the toolbar (i.e. the tool's selection callback has not been called)
Wraps around an Illustrator menu item to allow for selection callbacks, en/disabling, setting text, grouping, etc.
Definition: hdicoreMenuItem.h:23
virtual void setToolsSnapToArtboard(const bool snap_)
Sets whether tools belonging to this plugin should snap the cursor to the artboard edges...
virtual bool shuttingDown() const
Gets whether the plugin is in the process of shutting down.
virtual Callback *const startupCallback() const
Gets the callback that's called when the plugin is starting up.
virtual void setToolPostDraggedCallback(const Callback &cb_)
Sets the callback that's called just after the mouse button is down and the cursor moves (i...
virtual void setToolPostEditedCallback(const Callback &cb_)
Sets the callback that's called just after a tool is double-clicked in the toolbar (i...
virtual std::string name() const
Gets the plugin name.
virtual Callback *const toolPostMouseDownCallback() const
Gets the callback that's called just after the mouse button goes down (i.e. the tool's mouse down cal...
virtual MenuItem *const aboutMenuItem() const
Gets the about box menu item for the plugin.
virtual void setToolsSnapToGrids(const bool snap_)
Sets whether tools belonging to this plugin should snap the cursor to the Illustrator gridlines...
virtual void setToolPostDiameterIncreasedCallback(const Callback &cb_)
Sets the callback that's called just after the ']' key is hit while a tool is selected (i...
virtual bool hasStartedUp() const
Gets whether the plugin has already completed starting up.
Definition: hdicoreaiArray.h:12
virtual void setToolPostDiameterDecreasedCallback(const Callback &cb_)
Sets the callback that's called just after the '[' key is hit while a tool is selected (i...
virtual Callback *const shutdownCallback() const
Gets the callback that's called when the plugin is shutting down.
Base class for all tools; stores hit data, cursor loc, dialogs, etc.; receives tool-related messages...
Definition: hdicoreTool.h:32
Options
Allows for configuration of various plug-in behaviors.
Definition: hdicorePlugin.h:48
virtual void setToolPostMouseDownCallback(const Callback &cb_)
Sets the callback that's called just after the mouse button goes down (i.e. the tool's mouse down cal...
virtual void setToolPreTrackedCallback(const Callback &cb_)
Sets the callback that's called just before the cursor moves (with the mouse button released; i...
virtual void undo() const
Undoes the last set of artwork changes by this specific plugin.
virtual void setShutdownCallback(const Callback &cb_)
Sets the callback that's called when the plugin is shutting down.
virtual void setName(const std::string &name_)
Sets the plugin name.
virtual bool toolsSnapToGrids() const
Gets whether tools belonging to this plugin should snap the cursor to the Illustrator gridlines...
virtual void setToolPreMouseUpCallback(const Callback &cb_)
Sets the callback that's called just before the mouse button comes up (i.e. the tool's mouse up callb...
virtual Callback *const postStartupCallback() const
Gets the callback that's called just after the plugin has started up.
virtual Callback *const menuItemSelectedCallback() const
Gets the callback that's called when a user selects one of the plugin's menu items.
virtual void setToolPreEditedCallback(const Callback &cb_)
Sets the callback that's called just before a tool is double-clicked in the toolbar (i...
virtual void setToolPostSelectedCallback(const Callback &cb_)
Sets the callback that's called just after a tool is selected from the toolbar (i.e. the tool's selection callback has already been called)
virtual Callback *const toolPreReselectedCallback() const
Gets the callback that's called just before a tool is reselected (i.e. the tool's reselection callbac...
Header file for various Illustrator plugin entry points.
friend __MainError() PluginMain(const char *, const char *, void *)
Main entry point for all plugins (required by Illustrator). This is called whenever a plugin should p...
virtual void setToolPreDeselectedCallback(const Callback &cb_)
Sets the callback that's called just before a tool is deselected (i.e. the tool's deselection callbac...
virtual bool toolsSnapToArt() const
Gets whether tools belonging to this plugin should snap the cursor to artwork.
virtual bool toolsSnapToArtBounds() const
Gets whether tools belonging to this plugin should snap the cursor to artwork bounds.
virtual void setToolPreDraggedCallback(const Callback &cb_)
Sets the callback that's called just before the mouse button is down and the cursor moves (i...
virtual bool toolsSnapToArtboard() const
Gets whether tools belonging to this plugin should snap the cursor to the artboard edges...
Class through which all messages ultimately pass; holds registered callbacks for messages, notifiers, timers, etc. and calls them at the proper time.
Definition: hdicoreDispatcher.h:29
virtual Callback *const toolPreTrackedCallback() const
Gets the callback that's called just before the cursor moves (with the mouse button released; i...
virtual void setToolPostDeselectedCallback(const Callback &cb_)
Sets the callback that's called just after a tool is deselected (i.e. the tool's deselection callback...
virtual void setBrightnessAdjustedCallback(const Callback &cb_)
Sets the callback that's called when the brightness of the Illustrator UI is changed via the app pref...
virtual Callback *const toolPreMouseUpCallback() const
Gets the callback that's called just before the mouse button comes up (i.e. the tool's mouse up callb...
virtual void setToolsSnapToArtBounds(const bool snap_)
Sets whether tools belonging to this plugin should snap the cursor to artwork bounds.
virtual Callback *const toolPreDiameterDecreasedCallback() const
Gets the callback that's called just before the '[' key is hit while a tool is selected (i...
PlatformPluginPtr platformPlugin() const
Gets a pointer to the platform object representing the current Plugin instance.
virtual void setPrefsDialog(const ModalDialog &dialog_)
Sets the global prefs modal dialog for the plugin.
virtual void setAboutBox(const ModalDialog &dialog_)
Sets the about box modal dialog for the plugin.
virtual void setMenuItemSelectedCallback(const Callback &cb_)
Sets the callback that's called when a user selects one of the plugin's menu items.
virtual Callback *const toolPostDiameterIncreasedCallback() const
Gets the callback that's called just after the ']' key is hit while a tool is selected (i...