InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WEvent.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: ?
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Windows-specific implementation of IEvents
24 //
25 // This is the Windows edge implementation of the core IEvents interface.
26 //
27 //========================================================================================
28 
29 #ifndef __WEvent__
30 #define __WEvent__
31 
32 #ifndef __IEVENT__
33 #include "IEvent.h"
34 #endif
35 
36 #include "K2Assert.h"
37 
38 #if(WINVER < 0x0601)
39 
43 #define WM_GESTURE 0x0119
44 #define WM_GESTURENOTIFY 0x011A
45 
46 /*
47  * Gesture defines and functions
48  */
49 
50 /*
51  * Gesture information handle
52  */
53 DECLARE_HANDLE(HGESTUREINFO);
54 
55 
56 /*
57  * Gesture flags - GESTUREINFO.dwFlags
58  */
59 #define GF_BEGIN 0x00000001
60 #define GF_INERTIA 0x00000002
61 #define GF_END 0x00000004
62 
63 /*
64  * Gesture IDs
65  */
66 #define GID_BEGIN 1
67 #define GID_END 2
68 #define GID_ZOOM 3
69 #define GID_PAN 4
70 #define GID_ROTATE 5
71 #define GID_TWOFINGERTAP 6
72 #define GID_PRESSANDTAP 7
73 #define GID_ROLLOVER GID_PRESSANDTAP
74 
75 /*
76  * Gesture information structure
77  * - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the
78  * GetGestureInfo function to retrieve this information.
79  * - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE
80  * message lParam into the GetGestureExtraArgs function to retrieve extended
81  * argument information.
82  */
83 typedef struct tagGESTUREINFO {
84  UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
85  DWORD dwFlags; // see GF_* flags
86  DWORD dwID; // gesture ID, see GID_* defines
87  HWND hwndTarget; // handle to window targeted by this gesture
88  POINTS ptsLocation; // current location of this gesture
89  DWORD dwInstanceID; // internally used
90  DWORD dwSequenceID; // internally used
91  ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
92  UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
94 typedef GESTUREINFO const * PCGESTUREINFO;
95 
96 
97 /*
98  * Gesture notification structure
99  * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
100  * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
101  * in progress and a gesture will be generated if one is recognized under the
102  * current gesture settings.
103  */
104 typedef struct tagGESTURENOTIFYSTRUCT {
105  UINT cbSize; // size, in bytes, of this structure
106  DWORD dwFlags; // unused
107  HWND hwndTarget; // handle to window targeted by the gesture
108  POINTS ptsLocation; // starting location
109  DWORD dwInstanceID; // internally used
111 
112 /*
113  * Gesture argument helpers
114  * - Angle should be a double in the range of -2pi to +2pi
115  * - Argument should be an unsigned 16-bit value
116  */
117 #define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
118 #define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
119 
120 /*
121  * Gesture information retrieval
122  * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
123  */
124 WINUSERAPI
125 BOOL
126 WINAPI
127 GetGestureInfo(
128  __in HGESTUREINFO hGestureInfo,
129  __out PGESTUREINFO pGestureInfo);
130 
131 /*
132  * Gesture extra arguments retrieval
133  * - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
134  * - Size, in bytes, of the extra argument data is available in the cbExtraArgs
135  * field of the GESTUREINFO structure retrieved using the GetGestureInfo function.
136  */
137 WINUSERAPI
138 BOOL
139 WINAPI
140 GetGestureExtraArgs(
141  __in HGESTUREINFO hGestureInfo,
142  __in UINT cbExtraArgs,
143  __out_bcount(cbExtraArgs) PBYTE pExtraArgs);
144 
145 /*
146  * Gesture information handle management
147  * - If an application processes the WM_GESTURE message, then once it is done
148  * with the associated HGESTUREINFO, the application is responsible for
149  * closing the handle using this function. Failure to do so may result in
150  * process memory leaks.
151  * - If the message is instead passed to DefWindowProc, or is forwarded using
152  * one of the PostMessage or SendMessage class of API functions, the handle
153  * is transfered with the message and need not be closed by the application.
154  */
155 WINUSERAPI
156 BOOL
157 WINAPI
158 CloseGestureInfoHandle(
159  __in HGESTUREINFO hGestureInfo);
160 
161 
162 /*
163  * Gesture configuration structure
164  * - Used in SetGestureConfig and GetGestureConfig
165  * - Note that any setting not included in either GESTURECONFIG.dwWant or
166  * GESTURECONFIG.dwBlock will use the parent window's preferences or
167  * system defaults.
168  */
169 typedef struct tagGESTURECONFIG {
170  DWORD dwID; // gesture ID
171  DWORD dwWant; // settings related to gesture ID that are to be turned on
172  DWORD dwBlock; // settings related to gesture ID that are to be turned off
174 
175 /*
176  * Gesture configuration flags - GESTURECONFIG.dwWant or GESTURECONFIG.dwBlock
177  */
178 
179 /*
180  * Common gesture configuration flags - set GESTURECONFIG.dwID to zero
181  */
182 #define GC_ALLGESTURES 0x00000001
183 
184 /*
185  * Zoom gesture configuration flags - set GESTURECONFIG.dwID to GID_ZOOM
186  */
187 #define GC_ZOOM 0x00000001
188 
189 /*
190  * Pan gesture configuration flags - set GESTURECONFIG.dwID to GID_PAN
191  */
192 #define GC_PAN 0x00000001
193 #define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
194 #define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
195 #define GC_PAN_WITH_GUTTER 0x00000008
196 #define GC_PAN_WITH_INERTIA 0x00000010
197 
198 /*
199  * Rotate gesture configuration flags - set GESTURECONFIG.dwID to GID_ROTATE
200  */
201 #define GC_ROTATE 0x00000001
202 
203 /*
204  * Two finger tap gesture configuration flags - set GESTURECONFIG.dwID to GID_TWOFINGERTAP
205  */
206 #define GC_TWOFINGERTAP 0x00000001
207 
208 /*
209  * PressAndTap gesture configuration flags - set GESTURECONFIG.dwID to GID_PRESSANDTAP
210  */
211 #define GC_PRESSANDTAP 0x00000001
212 #define GC_ROLLOVER GC_PRESSANDTAP
213 
214 #define GESTURECONFIGMAXCOUNT 256 // Maximum number of gestures that can be included
215  // in a single call to SetGestureConfig / GetGestureConfig
216 
217 WINUSERAPI
218 BOOL
219 WINAPI
220 SetGestureConfig(
221  __in HWND hwnd, // window for which configuration is specified
222  __in DWORD dwReserved, // reserved, must be 0
223  __in UINT cIDs, // count of GESTURECONFIG structures
224  __in_ecount(cIDs) PGESTURECONFIG pGestureConfig, // array of GESTURECONFIG structures, dwIDs will be processed in the
225  // order specified and repeated occurances will overwrite previous ones
226  __in UINT cbSize); // sizeof(GESTURECONFIG)
227 
228 
229 #define GCF_INCLUDE_ANCESTORS 0x00000001 // If specified, GetGestureConfig returns consolidated configuration
230  // for the specified window and it's parent window chain
231 
232 WINUSERAPI
233 BOOL
234 WINAPI
235 GetGestureConfig(
236  __in HWND hwnd, // window for which configuration is required
237  __in DWORD dwReserved, // reserved, must be 0
238  __in DWORD dwFlags, // see GCF_* flags
239  __in PUINT pcIDs, // *pcIDs contains the size, in number of GESTURECONFIG structures,
240  // of the buffer pointed to by pGestureConfig
241  __inout_ecount(*pcIDs) PGESTURECONFIG pGestureConfig,
242  // pointer to buffer to receive the returned array of GESTURECONFIG structures
243  __in UINT cbSize); // sizeof(GESTURECONFIG)
244 
245 #endif /* WINVER < 0x0601 */
246 
247 
249  HWND hwnd;
250  UINT msg;
251  WPARAM wParam;
252  LPARAM lParam;
253 };
254 
274 class WEvent : public IEvent
275 {
276  public:
277  WEvent();
278 
279  WEvent(WinProcParam *);
280 
281  WEvent( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
282 
283  virtual bool16 LButtonDn() const;
284 
285  virtual bool16 OptionAltKeyDown() const;
286 
287  virtual bool16 CmdKeyDown() const;
288 
289  virtual bool16 ShiftKeyDown() const;
290 
291  virtual bool16 ShiftLockKeyDown() const;
292 
293  virtual bool16 MacCtrlDown() const;
294 
295  virtual bool16 LeftAltDown() const;
296 
297  virtual bool16 RightAltDown() const;
298 
299  virtual bool16 LeftControlDown() const;
300 
301  virtual bool16 RightControlDown() const;
302 
303  virtual SysChar GetChar() const;
304 
305  virtual void SetChar( SysChar theChar );
306 
307 
308  virtual VirtualKey GetVirtualKey() const;
309 
310  virtual SysEvent GetSysEvent();
311 
312  virtual void SetSysEvent(SysEvent theEvent);
313 
314  virtual bool16 IsRepeatKey() const;
315 
316  virtual bool16 IsAltGrChar() const;
317 
318  virtual GSysPoint GlobalWhere() const;
319 
320  virtual PMPoint GetMouseScrollDelta(ScrollUnits units = kLines) const;
321 
322  virtual PMReal GetTime() const;
323 
324  virtual SysWindow GetSysWindow() const;
325 
326  virtual void SetSysWindow(const SysWindow targetWindow);
327 
328 
329  virtual IEventHandler *GetTarget() const;
330  virtual void SetTarget(const IEventHandler *target);
331 
332  virtual void SetReturnValue(uintptr_t value);
333  virtual uintptr_t GetReturnValue() const;
334 
335  virtual void SetSystemHandledState(SystemHandledState state);
336  virtual SystemHandledState GetSystemHandledState() const;
337 
338  virtual EventType GetType() const;
339  virtual void SetType(const EventType theType);
340 
341  virtual IPMUnknown* QueryTargetWindowInterface(const PMIID&) const;
342 
343  virtual int16 GetPartCode() const{ return fPartCode; }
344  virtual void SetPartCode(const int16 pCode) { fPartCode = pCode; }
345 
346 
347  const WEvent& operator=(const WEvent& e)
348  {
349  fEvent = *((WEvent&)e).GetSysEvent();
350  fTheWindow = e.GetSysWindow();
351  fType = e.GetType();
352  return *this;
353  }
354 
355 
356  private:
357  MSG fEvent;
358  SysWindow fTheWindow;
359  IEventHandler* fTarget;
360  uintptr_t fReturnValue;
361  SystemHandledState fSystemHandledState;
362  IEvent::EventType fType;
363  int16 fPartCode;
364 };
365 
366 // private message used in handling app resume
367 #define kDelayResumeEvent (WM_USER+321)
368 
369 // Private app message to handle main thread tasks
370 #define kMainThreadTaskQueuedEvent (WM_APP + 1)
371 
372 #endif // __WEvent__