1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Declaration of wxKeyboardState class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_KBDSTATE_H_
12 #define _WX_KBDSTATE_H_
16 // ----------------------------------------------------------------------------
17 // wxKeyboardState stores the state of the keyboard modifier keys
18 // ----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxKeyboardState
23 wxKeyboardState(bool controlDown
= false,
24 bool shiftDown
= false,
26 bool metaDown
= false)
27 : m_controlDown(controlDown
),
28 m_shiftDown(shiftDown
),
32 ,m_rawControlDown(false)
37 // default copy ctor, assignment operator and dtor are ok
40 // accessors for the various modifier keys
41 // ---------------------------------------
43 // should be used check if the key event has exactly the given modifiers:
44 // "GetModifiers() = wxMOD_CONTROL" is easier to write than "ControlDown()
45 // && !MetaDown() && !AltDown() && !ShiftDown()"
46 int GetModifiers() const
48 return (m_controlDown
? wxMOD_CONTROL
: 0) |
49 (m_shiftDown
? wxMOD_SHIFT
: 0) |
50 (m_metaDown
? wxMOD_META
: 0) |
52 (m_rawControlDown
? wxMOD_RAW_CONTROL
: 0) |
54 (m_altDown
? wxMOD_ALT
: 0);
57 // returns true if any modifiers at all are pressed
58 bool HasModifiers() const { return GetModifiers() != wxMOD_NONE
; }
60 // accessors for individual modifier keys
61 bool ControlDown() const { return m_controlDown
; }
62 bool RawControlDown() const
65 return m_rawControlDown
;
70 bool ShiftDown() const { return m_shiftDown
; }
71 bool MetaDown() const { return m_metaDown
; }
72 bool AltDown() const { return m_altDown
; }
74 // "Cmd" is a pseudo key which is Control for PC and Unix platforms but
75 // Apple ("Command") key under Macs: it makes often sense to use it instead
76 // of, say, ControlDown() because Cmd key is used for the same thing under
77 // Mac as Ctrl elsewhere (but Ctrl still exists, just not used for this
84 // these functions are mostly used by wxWidgets itself
85 // ---------------------------------------------------
87 void SetControlDown(bool down
) { m_controlDown
= down
; }
88 void SetRawControlDown(bool down
)
91 m_rawControlDown
= down
;
96 void SetShiftDown(bool down
) { m_shiftDown
= down
; }
97 void SetAltDown(bool down
) { m_altDown
= down
; }
98 void SetMetaDown(bool down
) { m_metaDown
= down
; }
101 // for backwards compatibility with the existing code accessing these
102 // members of wxKeyEvent directly, these variables are public, however you
103 // should not use them in any new code, please use the accessors instead
105 bool m_controlDown
: 1;
106 bool m_shiftDown
: 1;
110 bool m_rawControlDown
: 1;
114 #endif // _WX_KBDSTATE_H_