Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
hdicoreDispatcher.h
Go to the documentation of this file.
1
7#ifndef __HDI_CORE_DISPATCHER__
8#define __HDI_CORE_DISPATCHER__
9
10#include <vector>
11
12#include "hdicoreTypes.h"
13
14namespace hdi
15{
16 namespace core
17 {
18 class Callback;
19 class Message;
20 class PrefData;
21 class Timer;
22
23 #if defined(HDI_CORE_AIP_MODE)
24 class Annotator;
25 class Notifier;
26 class ToolMessage;
27 #endif
28
34 {
35 public:
36 #if defined(HDI_CORE_AIP_MODE)
37 typedef std::vector< std::shared_ptr<Notifier> > NotifierVector;
38 #endif
39
43 enum Error
44 {
45 NoDispatchError = 0,
46 UnhandledMessageError = 10, // Not a "real error", just that a received message was not handled
47 UnknownMessageTypeError = 20,
48 RedundantMessageReceivedError = 30
49 };
50
55 {
56 // ==== Locale independent keys ====
57 CommandKey = 10, // Only useful on Mac
58 OptionKey = 20,
59 AltKey = OptionKey,
60 ControlKey = 30,
61 ShiftKey = 40,
62 CapsLockKey = 50,
63
64 SpaceKey = 110,
65 TabKey = 100,
66 ReturnKey = 120, // Same as enter key; no way to differentiate on all platforms
67
68 EscapeKey = 200,
69 ClearKey = 210,
70 DeleteKey = 220,
71 ForwardDeleteKey= 230,
72
73 UpArrowKey = 300,
74 DownArrowKey = 310,
75 LeftArrowKey = 320,
76 RightArrowKey = 330,
77
78 HomeKey = 400,
79 EndKey = 410,
80 PageUpKey = 420,
81 PageDownKey = 430,
82 HelpKey = 440,
83
84 F1Key = 500,
85 F2Key = 510,
86 F3Key = 520,
87 F4Key = 530,
88 F5Key = 540,
89 F6Key = 550,
90 F7Key = 560,
91 F8Key = 570,
92 F9Key = 580,
93 F10Key = 590,
94 F11Key = 600,
95 F12Key = 610,
96 F13Key = 620,
97 F14Key = 630,
98 F15Key = 640,
99 F16Key = 650,
100 F17Key = 660,
101 F18Key = 670,
102 F19Key = 680,
103 F20Key = 690,
104
105 NumPad0Key = 800,
106 NumPad1Key = 810,
107 NumPad2Key = 820,
108 NumPad3Key = 830,
109 NumPad4Key = 840,
110 NumPad5Key = 850,
111 NumPad6Key = 860,
112 NumPad7Key = 870,
113 NumPad8Key = 880,
114 NumPad9Key = 890,
115
116 NumPadDecimalKey = 1000,
117 NumPadPlusKey = 1010,
118 NumPadMinusKey = 1020,
119 NumPadMultiplyKey = 1030,
120 NumPadDivideKey = 1040,
121 // ==== End locale independent keys ====
122
123 // ==== Locale dependent keys ====
124 LD_0Key = 2010,
125 LD_1Key = 2020,
126 LD_2Key = 2030,
127 LD_3Key = 2040,
128 LD_4Key = 2050,
129 LD_5Key = 2060,
130 LD_6Key = 2070,
131 LD_7Key = 2080,
132 LD_8Key = 2090,
133 LD_9Key = 2100,
134
135 LD_AKey = 2110,
136 LD_BKey = 2120,
137 LD_CKey = 2130,
138 LD_DKey = 2140,
139 LD_EKey = 2150,
140 LD_FKey = 2160,
141 LD_GKey = 2170,
142 LD_HKey = 2180,
143 LD_IKey = 2190,
144 LD_JKey = 2200,
145 LD_KKey = 2210,
146 LD_LKey = 2220,
147 LD_MKey = 2230,
148 LD_NKey = 2240,
149 LD_OKey = 2250,
150 LD_PKey = 2260,
151 LD_QKey = 2270,
152 LD_RKey = 2280,
153 LD_SKey = 2290,
154 LD_TKey = 2300,
155 LD_UKey = 2310,
156 LD_VKey = 2320,
157 LD_WKey = 2330,
158 LD_XKey = 2340,
159 LD_YKey = 2350,
160 LD_ZKey = 2360,
161
162 LD_SlashKey = 2370, // "/" on US keyboard
163 LD_BackslashKey = 2380, // "\" on US keyboard
164
165 LD_CommaKey = 2390, // "," on US keyboard
166 LD_PeriodKey = 2400, // "." on US keyboard
167 LD_SemicolonKey = 2410, // ";" on US keyboard
168
169 LD_MinusKey = 2420, // "-" on US keyboard
170 LD_EqualKey = 2430, // "=" on US keyboard
171
172 LD_LeftBracketKey = 2440, // "[" on US keyboard
173 LD_RightBracketKey = 2450, // "]" on US keyboard
174
175 LD_GraveKey = 2460, // "`" on US keyboard
176 LD_QuoteKey = 2470 // "'" on US keyboard
177 // ==== End locale dependent keys ====
178 };
179
194 bool registerMessageCallback(const MessageType type_, const Callback& callback_);
195
204
226 const std::string& caller_,
227 const std::string& selector_,
228 const Callback& callback_
229 );
230
242 void unregisterMessageCallback(const std::string& caller_, const std::string& selector_);
243
244 #if defined(HDI_CORE_PSP_MODE)
265 const CallerType caller_,
266 const int16_t selector_,
267 const Callback& callback_
268 );
269
282 void unregisterMessageCallback(const CallerType caller_, const int16_t selector_);
283
291 Callback* const coreEventPreCallback() const;
292
302 void registerCoreEventPreCallback(const Callback& callback_);
303
311 Callback* const coreEventPostCallback() const;
312
322 void registerCoreEventPostCallback(const Callback& callback_);
323
335 PrefData* const coreEventMessage() const;
336
348 void setCoreEventResponse(const PrefData& response_);
349 #endif
350 // HDI_CORE_PSP_MODE
351
367 Error message(const MessageType type_, void* const msg_);
368
389 Error message(const std::string& caller_, const std::string& selector_, void* const msg_);
390
391 #if defined(HDI_CORE_PSP_MODE)
409 Error message(const CallerType caller_, const int16_t selector_, void* const msg_);
410
422 int16_t* const resultCode();
423 #endif
424 // HDI_CORE_PSP_MODE
425
444
453 void scheduleCallback(const Callback& callback_, const double delay_ = 0.0);
454
463 void registerTimer(const Timer& timer_);
464
473 bool unregisterTimer(const Timer& timer_);
474
475 #if defined(HDI_CORE_AIP_MODE)
491
503 void registerNotifier(const Notifier& notifier_);
504
513 NotifierVector registeredNotifiersOfType(const NotifierType type_);
514
523 bool unregisterNotifier(const Notifier& notifier_);
524
533 void registerAnnotator(const Annotator& annotator_);
534
543 bool unregisterAnnotator(const Annotator& annotator_);
544 #endif
545 // HDI_CORE_AIP_MODE
546
565 uint32_t addKeyDownMonitor(const VirtualKey key_, const Callback& cb_);
566
581 uint32_t addKeyUpMonitor(const VirtualKey key_, const Callback& cb_);
582
594 const VirtualKey key_,
595 uint32_t& id__,
596 std::unique_ptr<Callback>& cb__
597 ) const;
598
610 const VirtualKey key_,
611 uint32_t& id__,
612 std::unique_ptr<Callback>& cb__
613 ) const;
614
622 void removeKeyDownMonitor(const uint32_t id_);
623
631 void removeKeyUpMonitor(const uint32_t id_);
632
649 bool isKeyDown(const VirtualKey key_, bool& down__);
650
651
652
653 private:
654 // Only Plugin can construct a Dispatcher object
655 friend class Plugin;
656
660 void* __data;
661
667 Dispatcher();
668
674 Dispatcher(const Dispatcher&);
675
681 ~Dispatcher();
682
688 Dispatcher& operator=(const Dispatcher&);
689 };
690 }
691}
692
693#endif
694// __HDI_CORE_DISPATCHER__
Deals with annotator registration and drawing callbacks.
Definition: hdicoreAnnotator.h:29
Base class for templated __Callback class.
Definition: hdicoreCallback.h:68
Class through which all messages ultimately pass; holds registered callbacks for messages,...
Definition: hdicoreDispatcher.h:34
Message *const lastMessage()
Gets a Message object that wraps around the last message data received.
bool unregisterAnnotator(const Annotator &annotator_)
Unregisters a given annotator.
void scheduleCallback(const Callback &callback_, const double delay_=0.0)
Executes a given callback after a delay.
void removeKeyUpMonitor(const uint32_t id_)
Removes a key-up monitor previously created with addKeyUpMonitor()
VirtualKey
Describes which keys can be monitored for presses at anytime.
Definition: hdicoreDispatcher.h:55
NotifierVector registeredNotifiersOfType(const NotifierType type_)
Gets registered notifiers by their type.
bool unregisterTimer(const Timer &timer_)
Unregisters a given timer.
bool getKeyUpMonitor(const VirtualKey key_, uint32_t &id__, std::unique_ptr< Callback > &cb__) const
Gets an existing key-up monitor, if any.
Error message(const MessageType type_, void *const msg_)
Notifies the dispatcher of an incoming message, causing it to call the appropriate callback or return...
uint32_t addKeyUpMonitor(const VirtualKey key_, const Callback &cb_)
Creates an app-wide key-up monitor that executes a callback when a specific key has been released.
void unregisterMessageCallback(const std::string &caller_, const std::string &selector_)
Unregisters a callback for a given caller/selector pair.
void unregisterMessageCallback(const MessageType type_)
Unregisters a callback for a given message type.
bool registerMessageCallback(const std::string &caller_, const std::string &selector_, const Callback &callback_)
Registers a new callback for a given caller/selector pair.
bool registerMessageCallback(const MessageType type_, const Callback &callback_)
Registers a new callback for a given message type.
Error message(const std::string &caller_, const std::string &selector_, void *const msg_)
Notifies the dispatcher of an incoming (custom) message, causing it to call the appropriate callback ...
void removeKeyDownMonitor(const uint32_t id_)
Removes a key-down monitor previously created with addKeyDownMonitor()
bool unregisterNotifier(const Notifier &notifier_)
Unregisters a given notifier.
uint32_t addKeyDownMonitor(const VirtualKey key_, const Callback &cb_)
Creates an app-wide key-down monitor that executes a callback when a specific key has been pressed.
void registerNotifier(const Notifier &notifier_)
Registers a Notifier object for a given Illustrator notifier subscription.
Error
Describes a variety of dispatch-related errors.
Definition: hdicoreDispatcher.h:44
bool isKeyDown(const VirtualKey key_, bool &down__)
Gets whether the given key is down.
bool getKeyDownMonitor(const VirtualKey key_, uint32_t &id__, std::unique_ptr< Callback > &cb__) const
Gets an existing key-down monitor, if any.
ToolMessage *const lastToolMessage()
Gets the last tool message received, regardless of whether subsequent non-tool messages have been rec...
void registerAnnotator(const Annotator &annotator_)
Registers an Annotator object.
void registerTimer(const Timer &timer_)
Registers a Timer object.
Base class for all *Message subclasses.
Definition: hdicoreMessage.h:48
Acts as a receiver for specific notifications, passing them along to caller-supplied callbacks.
Definition: hdicoreNotifier.h:24
Base plugin class; the heart of any plugin project.
Definition: hdicorePlugin.h:35
Base class for persistent data objects, stored via JSON.
Definition: hdicorePrefData.h:25
Deals with timer registration and callbacks.
Definition: hdicoreTimer.h:32
Received for ToolEditMessageType, ToolTrackMessageType, ToolMouseDownMessageType, ToolMouseDragMessag...
Definition: hdicoreMessage.h:2986
Header file for a wide variety of necessary typedefs, enums, and forwards declarations.
NotifierType
Describes the types of Illustrator notifiers for which subscriptions are available.
Definition: hdicoreTypes.h:1264
MessageType
Describes the types of plugin messages for which subscriptions are available.
Definition: hdicoreTypes.h:1080