soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SAccelerator-i.h
1#ifndef __SACCELERATOR_I__H__
2#define __SACCELERATOR_I__H__
3#include <utilities-def.h>
4
5SNSBEGIN
6
7/**
8 * @brief Modifier keys for accelerators.
9 */
10enum
11{
12 Mod_None = 0, /**< No modifier key. */
13 Mod_Alt = 1, /**< Alt modifier key. */
14 Mod_Ctrl = 2, /**< Ctrl modifier key. */
15 Mod_Shift = 4, /**< Shift modifier key. */
16};
17
18/**
19 * @interface IAccelerator
20 * @brief Interface for an accelerator key.
21 */
22#undef INTERFACE
23#define INTERFACE IAccelerator
24DECLARE_INTERFACE(IAccelerator)
25{
26 /**
27 * @brief Get the modifier keys of the accelerator.
28 * @return WORD representing the modifier keys.
29 */
30 STDMETHOD_(WORD, GetModifier)(CTHIS) SCONST PURE;
31
32 /**
33 * @brief Get the main key of the accelerator.
34 * @return WORD representing the main key.
35 */
36 STDMETHOD_(WORD, GetKey)(CTHIS) SCONST PURE;
37
38 /**
39 * @brief Get the accelerator key combination.
40 * @return DWORD representing the accelerator key combination.
41 */
42 STDMETHOD_(DWORD, GetAcc)(CTHIS) SCONST PURE;
43};
44
45/**
46 * @interface IAcceleratorTarget
47 * @brief Interface for handling accelerator key presses.
48 *
49 * Classes that want to register keyboard accelerators need to implement this interface.
50 */
51#undef INTERFACE
52#define INTERFACE IAcceleratorTarget
53DECLARE_INTERFACE(IAcceleratorTarget)
54{
55 /**
56 * @brief Handle an accelerator key press.
57 * @param acc Pointer to the accelerator key that was pressed.
58 * @return TRUE if the accelerator key was handled, FALSE otherwise.
59 */
60 STDMETHOD_(BOOL, OnAcceleratorPressed)(THIS_ const IAccelerator *acc) PURE;
61};
62
63/**
64 * @interface IAcceleratorMgr
65 * @brief Interface for managing accelerator keys.
66 */
67#undef INTERFACE
68#define INTERFACE IAcceleratorMgr
69DECLARE_INTERFACE(IAcceleratorMgr)
70{
71 /**
72 * @brief Register a keyboard accelerator for the specified target.
73 *
74 * If multiple targets are registered for an accelerator, a target registered later has higher priority.
75 * Note that we are currently limited to accelerators that are either:
76 * - a key combination including Ctrl or Alt
77 * - the escape key
78 * - the enter key
79 * - any F key (F1, F2, F3 ...)
80 * - any browser-specific keys (as available on special keyboards)
81 *
82 * @param pAcc Pointer to the accelerator key to register.
83 * @param target Pointer to the target that will handle the accelerator key press.
84 */
85 STDMETHOD_(void, RegisterAccelerator)(THIS_ const IAccelerator *pAcc, IAcceleratorTarget *target) PURE;
86
87 /**
88 * @brief Unregister a keyboard accelerator for the specified target.
89 * @param pAcc Pointer to the accelerator key to unregister.
90 * @param target Pointer to the target that was handling the accelerator key press.
91 */
92 STDMETHOD_(void, UnregisterAccelerator)(THIS_ const IAccelerator *pAcc, IAcceleratorTarget *target) PURE;
93
94 /**
95 * @brief Unregister all keyboard accelerators for the specified target.
96 * @param target Pointer to the target whose accelerators should be unregistered.
97 */
98 STDMETHOD_(void, UnregisterAccelerators)(THIS_ IAcceleratorTarget * target) PURE;
99};
100
101SNSEND
102#endif // __SACCELERATOR_I__H__
Interface for an accelerator key.
WORD GetKey() SCONST PURE
Get the main key of the accelerator.
DWORD GetAcc() SCONST PURE
Get the accelerator key combination.
WORD GetModifier() SCONST PURE
Get the modifier keys of the accelerator.
Interface for managing accelerator keys.
void UnregisterAccelerators(IAcceleratorTarget *target) PURE
Unregister all keyboard accelerators for the specified target.
void UnregisterAccelerator(const IAccelerator *pAcc, IAcceleratorTarget *target) PURE
Unregister a keyboard accelerator for the specified target.
void RegisterAccelerator(const IAccelerator *pAcc, IAcceleratorTarget *target) PURE
Register a keyboard accelerator for the specified target.
Interface for handling accelerator key presses.
BOOL OnAcceleratorPressed(const IAccelerator *acc) PURE
Handle an accelerator key press.