soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SHotKeyCtrl.h
1#ifndef __SHOTKEYCTRL__H__
2#define __SHOTKEYCTRL__H__
3
4#include <core/SWnd.h>
5#include <core/SAccelerator.h>
6#include <proxy/SWindowProxy.h>
7#include <interface/SCtrl-i.h>
8
9SNSBEGIN
10
11/**
12 * @class SHotKeyCtrl
13 * @brief HotKey Control
14 * @details A control for setting and displaying hotkeys.
15 */
16class SOUI_EXP SHotKeyCtrl
17 : public TWindowProxy<IHotKeyCtrl>
18 , public SAccelerator {
19 DEF_SOBJECT(SWindow, L"hotkey")
20
21 enum
22 {
23 Mod_SC = Mod_Shift | Mod_Ctrl,
24 Mod_SA = Mod_Shift | Mod_Alt,
25 Mod_CA = Mod_Ctrl | Mod_Alt,
26 Mod_SCA = Mod_Shift | Mod_Ctrl | Mod_Alt,
27 };
28
29 public:
30 /**
31 * @brief Constructor
32 */
33 SHotKeyCtrl(void);
34
35 /**
36 * @brief Destructor
37 */
38 virtual ~SHotKeyCtrl(void);
39
40 public:
41 /**
42 * @brief Set the rules for invalid combinations and modifiers
43 * @param wInvalidComp Invalid combination flags
44 * @param wModifier Modifier flags
45 */
46 STDMETHOD_(void, SetRule)(THIS_ WORD wInvalidComp, WORD wModifier) OVERRIDE;
47
48 /**
49 * @brief Set the hotkey
50 * @param wKey Key code
51 * @param wModifiers Modifier flags
52 */
53 STDMETHOD_(void, SetHotKey)(THIS_ WORD wKey, WORD wModifiers) OVERRIDE;
54
55 /**
56 * @brief Get the hotkey
57 * @param wKey Output key code
58 * @param wModifiers Output modifier flags
59 */
60 STDMETHOD_(void, GetHotKey)(THIS_ WORD *wKey, WORD *wModifiers) SCONST OVERRIDE;
61
62 public:
63 /**
64 * @brief Get the window text
65 * @param bRawText Whether to get raw text
66 * @return Window text
67 */
68 virtual SStringT GetWindowText(BOOL bRawText = FALSE);
69
70 protected:
71 /**
72 * @brief Get the dialog code
73 * @return Dialog code
74 * @details This function is a message handler.
75 */
76 virtual UINT WINAPI OnGetDlgCode() const
77 {
78 return (SC_WANTALLKEYS | SC_WANTSYSKEY) & (~SC_WANTTAB);
79 }
80
81 /**
82 * @brief Handle left mouse button down event
83 * @param nFlags Flags
84 * @param pt Mouse coordinates
85 * @details This function is a message handler.
86 */
87 void OnLButtonDown(UINT nFlags, CPoint pt);
88
89 /**
90 * @brief Paint the control
91 * @param pRT Rendering target handle
92 * @details This function is a message handler.
93 */
94 void OnPaint(IRenderTarget *pRT);
95
96 /**
97 * @brief Handle set focus event
98 * @param wndOld Previous focus window handle
99 * @details This function is a message handler.
100 */
101 void OnSetFocus(SWND wndOld);
102
103 /**
104 * @brief Handle kill focus event
105 * @param wndFocus New focus window handle
106 * @details This function is a message handler.
107 */
108 void OnKillFocus(SWND wndFocus);
109
110 /**
111 * @brief Handle key down event
112 * @param nChar Key code
113 * @param nRepCnt Repeat count
114 * @param nFlags Flags
115 * @details This function is a message handler.
116 */
117 void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
118
119 /**
120 * @brief Handle key up event
121 * @param nChar Key code
122 * @param nRepCnt Repeat count
123 * @param nFlags Flags
124 * @details This function is a message handler.
125 */
126 void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
127
128 /**
129 * @brief Handle system key down event
130 * @param nChar Key code
131 * @param nRepCnt Repeat count
132 * @param nFlags Flags
133 * @details This function is a message handler.
134 */
135 void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
136
137 /**
138 * @brief Handle system key up event
139 * @param nChar Key code
140 * @param nRepCnt Repeat count
141 * @param nFlags Flags
142 * @details This function is a message handler.
143 */
144 void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
145
146 /**
147 * @brief Update the modifier keys
148 */
149 void UpdateModifier();
150
151 /**
152 * @brief Update the caret position
153 * @param pRT Rendering target handle
154 */
155 void UpdateCaret(IRenderTarget *pRT);
156
157 /**
158 * @brief Get the text alignment
159 * @return Text alignment
160 */
161 UINT GetTextAlign();
162
163 protected:
164 /**
165 * @brief Handle custom attribute "invalidComb"
166 * @param value Attribute value
167 * @param bLoading Loading flag
168 * @return HRESULT
169 */
170 HRESULT OnAttrInvalidComb(const SStringW &value, BOOL bLoading);
171
172 /**
173 * @brief Handle custom attribute "invalidSysKey"
174 * @param value Attribute value
175 * @param bLoading Loading flag
176 * @return HRESULT
177 */
178 HRESULT OnAttrInvalidSysKey(const SStringW &value, BOOL bLoading);
179
180 /**
181 * @brief Handle custom attribute "invalidModifier"
182 * @param value Attribute value
183 * @param bLoading Loading flag
184 * @return HRESULT
185 */
186 HRESULT OnAttrInvalidModifier(const SStringW &value, BOOL bLoading);
187
188 /**
189 * @brief Handle custom attribute "hotKey"
190 * @param value Attribute value
191 * @param bLoading Loading flag
192 * @return HRESULT
193 */
194 HRESULT OnAttrHotKey(const SStringW &value, BOOL bLoading);
195
196 SOUI_ATTRS_BEGIN()
197 ATTR_CUSTOM(L"invalidComb", OnAttrInvalidComb)
198 ATTR_CUSTOM(L"invalidSysKey", OnAttrInvalidSysKey)
199 ATTR_CUSTOM(L"invalidModifier", OnAttrInvalidModifier)
200 ATTR_CUSTOM(L"hotKey", OnAttrHotKey)
201 SOUI_ATTRS_END()
202
203 SOUI_MSG_MAP_BEGIN()
204 MSG_WM_PAINT_EX(OnPaint)
205 MSG_WM_LBUTTONDOWN(OnLButtonDown)
206 MSG_WM_SETFOCUS_EX(OnSetFocus)
207 MSG_WM_KILLFOCUS_EX(OnKillFocus)
208 MSG_WM_KEYDOWN(OnKeyDown)
209 MSG_WM_KEYUP(OnKeyUp)
210 MSG_WM_SYSKEYDOWN(OnSysKeyDown)
211 MSG_WM_SYSKEYUP(OnSysKeyUp)
212 SOUI_MSG_MAP_END()
213
214 protected:
215 WORD m_wInvalidComb; /**< Flags for invalid key combinations */
216 WORD m_wInvalidModifier; /**< Replacement modifiers for invalid combinations */
217 BOOL m_bInSetting; /**< Flag indicating if the control is being set */
218};
219
220SNSEND
221
222#endif // __SHOTKEYCTRL__H__
Accelerator management module.
SOUI基础DUI窗口模块
SAccelerator(DWORD dwAccel)
Constructor.
void SetHotKey(WORD wKey, WORD wModifiers) OVERRIDE
Set the hotkey.
SHotKeyCtrl(void)
Constructor.
WORD m_wInvalidComb
void SetRule(WORD wInvalidComp, WORD wModifier) OVERRIDE
Set the rules for invalid combinations and modifiers.
virtual UINT WINAPI OnGetDlgCode() const
Get the dialog code.
Definition SHotKeyCtrl.h:76
BOOL m_bInSetting
WORD m_wInvalidModifier
void GetHotKey(WORD *wKey, WORD *wModifiers) SCONST OVERRIDE
Get the hotkey.
A class representing an ASCII string.
Definition sstringw.h:96
int GetWindowText(TCHAR *pBuf, int nBufLen, BOOL bRawText) OVERRIDE
Retrieves the window text.
Definition Swnd.cpp:263
UINT GetTextAlign() const
Retrieves the text alignment of the window.
Definition Swnd.cpp:218
void OnKillFocus(SWND wndFocus)
Handles losing focus.
Definition Swnd.cpp:2274
void OnPaint(IRenderTarget *pRT)
Handles the painting of the window.
Definition Swnd.cpp:1785
SWindow()
Constructor.
Definition Swnd.cpp:104
void OnLButtonDown(UINT nFlags, CPoint pt)
Handles the left mouse button down event.
Definition Swnd.cpp:2092
void OnSetFocus(SWND wndOld)
Handles gaining focus.
Definition Swnd.cpp:2265
Interface for rendering target objects.
Definition SRender-i.h:1440