2#include "control/SHotKeyCtrl.h"
12 m_evtSet.addEvent(EVENTID(EventSetHotKey));
21 __baseCls::OnLButtonDown(nFlags, pt);
33 pRT->
DrawText(str, str.GetLength(), &rcClient, uAlign);
47 int x = rcClient.left + szTxt.cx;
48 int y = rcClient.top + (rcClient.Height() - szTxt.cy) / 2;
49 if (uAlign & DT_CENTER)
50 x += (rcClient.Width() - szTxt.cx) / 2;
51 else if (uAlign & DT_RIGHT)
61 uAlign |= DT_VCENTER | DT_SINGLELINE;
81 __baseCls::OnSetFocus(wndOld);
88 __baseCls::OnKillFocus(wndFocus);
93 BOOL bAlt = GetKeyState(VK_MENU) & 0x8000;
94 BOOL bCtrl = GetKeyState(VK_CONTROL) & 0x8000;
95 BOOL bShift = GetKeyState(VK_SHIFT) & 0x8000;
98 WORD wCombMask = HKCOMB_NONE;
99 if (!bAlt && !bCtrl && !bShift)
101 else if (bAlt && !bCtrl && !bShift)
102 wCombKey = Mod_Alt, wCombMask = HKCOMB_A;
103 else if (!bAlt && bCtrl && !bShift)
104 wCombKey = Mod_Ctrl, wCombMask = HKCOMB_C;
105 else if (!bAlt && !bCtrl && bShift)
106 wCombKey = Mod_Shift, wCombMask = HKCOMB_S;
107 else if (bAlt && bCtrl && !bShift)
108 wCombKey = Mod_CA, wCombMask = HKCOMB_CA;
109 else if (bAlt && !bCtrl && bShift)
110 wCombKey = Mod_SA, wCombMask = HKCOMB_SA;
111 else if (!bAlt && bCtrl && bShift)
112 wCombKey = Mod_SC, wCombMask = HKCOMB_SC;
114 wCombKey = Mod_SCA, wCombMask = HKCOMB_SCA;
120 EventSetHotKey ev(
this);
135 if (!strKey.IsEmpty())
159 else if (
m_wVK == 0 && (GetKeyState(VK_SHIFT) & 0x8000) == 0 && (GetKeyState(VK_MENU) & 0x8000) == 0 && (GetKeyState(VK_CONTROL) & 0x8000) == 0)
166 else if (nChar == VK_SHIFT || nChar == VK_MENU || nChar == VK_CONTROL)
177 if (GetKeyState(VK_MENU) & 0x8000 || nChar == VK_F10)
185 if (nChar == VK_MENU || GetKeyState(VK_MENU) & 0x8000 || nChar == VK_F10)
186 OnKeyUp(nChar, nRepCnt, nFlags);
223 SStringWList arrComb;
224 SplitString(value, L
'|', arrComb);
225 for (UINT i = 0; i < arrComb.GetCount(); i++)
228 switch (HIWORD(dwKey))
253 return bLoading ? S_OK : S_FALSE;
258 SStringWList arrComb;
259 SplitString(value, L
'|', arrComb);
260 for (UINT i = 0; i < arrComb.GetCount(); i++)
263 switch (HIWORD(dwKey))
276 return bLoading ? S_OK : S_FALSE;
290 m_wVK = LOWORD(dwKey);
291 return bLoading ? S_OK : S_FALSE;
static DWORD TranslateAccelKey(LPCTSTR pszKeyName)
Translates a string to an accelerator key value.
static SStringT GetKeyName(WORD vk)
Converts a virtual key code to its string representation.
SStringT FormatHotkey()
Formats the accelerator key as a string.
void SetHotKey(WORD wKey, WORD wModifiers) OVERRIDE
Set the hotkey.
void UpdateCaret(IRenderTarget *pRT)
Update the caret position.
virtual ~SHotKeyCtrl(void)
Destructor.
SHotKeyCtrl(void)
Constructor.
void OnLButtonDown(UINT nFlags, CPoint pt)
Handle left mouse button down event.
void SetRule(WORD wInvalidComp, WORD wModifier) OVERRIDE
Set the rules for invalid combinations and modifiers.
HRESULT OnAttrInvalidComb(const SStringW &value, BOOL bLoading)
Handle custom attribute "invalidComb".
HRESULT OnAttrInvalidModifier(const SStringW &value, BOOL bLoading)
Handle custom attribute "invalidModifier".
HRESULT OnAttrInvalidSysKey(const SStringW &value, BOOL bLoading)
Handle custom attribute "invalidSysKey".
void OnPaint(IRenderTarget *pRT)
Paint the control.
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle key down event.
HRESULT OnAttrHotKey(const SStringW &value, BOOL bLoading)
Handle custom attribute "hotKey".
void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle system key down event.
UINT GetTextAlign()
Get the text alignment.
void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle system key up event.
void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle key up event.
virtual SStringT GetWindowText(BOOL bRawText=FALSE)
Get the window text.
void UpdateModifier()
Update the modifier keys.
void OnKillFocus(SWND wndFocus)
Handle kill focus event.
void OnSetFocus(SWND wndOld)
Handle set focus event.
void GetHotKey(WORD *wKey, WORD *wModifiers) SCONST OVERRIDE
Get the hotkey.
Helper class for painting.
A class representing an ASCII string.
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
void SetCaretPos(int x, int y) OVERRIDE
Sets the caret position.
void ReleaseRenderTarget(IRenderTarget *pRT)
Releases the RenderTarget obtained via GetRenderTarget.
UINT GetTextAlign() const
Retrieves the text alignment of the window.
ISwndContainer * GetContainer() OVERRIDE
Retrieves the container associated with this window.
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
virtual void GetTextRect(LPRECT pRect)
Calculate text display rectangle.
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
void ShowCaret(BOOL bShow) OVERRIDE
Shows or hides the caret.
void Invalidate() OVERRIDE
Invalidates the entire window.
BOOL CreateCaret(HBITMAP pBmp, int nWid, int nHeight) OVERRIDE
Creates a caret.
void SetMsgHandled(BOOL bHandled)
Sets the message handled flag.
SWND m_swnd
Member variables representing various properties of the window.
void BeforePaintEx(IRenderTarget *pRT)
Prepares the drawing environment for the current window's RenderTarget, starting from the top-level w...
IRenderTarget * GetRenderTarget(LPCRECT pRc=NULL, GrtFlag gdcFlags=GRT_NODRAW, BOOL bClientRT=TRUE)
Retrieves a memory DC compatible with the SWND window.
Interface for rendering target objects.
HRESULT DrawText(LPCTSTR pszText, int cchLen, LPRECT pRc, UINT uFormat) PURE
Draw text within a rectangle.
HRESULT MeasureText(LPCTSTR pszText, int cchLen, SIZE *psz) PURE
Measure the size of the text.
void OnSetSwndFocus(SWND swnd) PURE
Sets the focus to the specified Swnd object.
void EnableIME(BOOL bEnable) PURE
Enables or disables the input method editor (IME).