1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxAcceleratorEntry and wxAcceleratorTable classes
4 // Author: Julian Smart, Robert Roebling, Vadim Zeitlin
6 // Created: 31.05.01 (extracted from other files)
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_ACCEL_H_BASE_
13 #define _WX_ACCEL_H_BASE_
19 #include "wx/object.h"
21 class WXDLLEXPORT wxAcceleratorTable
;
22 class WXDLLEXPORT wxMenuItem
;
23 class WXDLLEXPORT wxKeyEvent
;
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 // wxAcceleratorEntry flags
32 wxACCEL_NORMAL
= 0x0000, // no modifiers
33 wxACCEL_ALT
= 0x0001, // hold Alt key down
34 wxACCEL_CTRL
= 0x0002, // hold Ctrl key down
35 wxACCEL_SHIFT
= 0x0004 // hold Shift key down
38 // ----------------------------------------------------------------------------
39 // an entry in wxAcceleratorTable corresponds to one accelerator
40 // ----------------------------------------------------------------------------
42 class WXDLLEXPORT wxAcceleratorEntry
45 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0,
46 wxMenuItem
*item
= NULL
)
48 Set(flags
, keyCode
, cmd
, item
);
51 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
)
59 void SetMenuItem(wxMenuItem
*item
) { m_item
= item
; }
61 int GetFlags() const { return m_flags
; }
62 int GetKeyCode() const { return m_keyCode
; }
63 int GetCommand() const { return m_command
; }
65 wxMenuItem
*GetMenuItem() const { return m_item
; }
67 bool operator==(const wxAcceleratorEntry
& entry
) const
69 return m_flags
== entry
.m_flags
&&
70 m_keyCode
== entry
.m_keyCode
&&
71 m_command
== entry
.m_command
&&
72 m_item
== entry
.m_item
;
75 bool operator!=(const wxAcceleratorEntry
& entry
) const
76 { return !(*this == entry
); }
79 // Implementation use only
80 bool MatchesEvent(const wxKeyEvent
& event
) const ;
84 int m_flags
; // combination of wxACCEL_XXX constants
85 int m_keyCode
; // ASCII or virtual keycode
86 int m_command
; // Command id to generate
88 // the menu item this entry corresponds to, may be NULL
91 // for compatibility with old code, use accessors now!
92 friend class WXDLLEXPORT wxMenu
;
95 // ----------------------------------------------------------------------------
96 // include wxAcceleratorTable class declaration, it is only used by the library
97 // and so doesn't have any published user visible interface
98 // ----------------------------------------------------------------------------
100 #if defined(__WXUNIVERSAL__)
101 #include "wx/generic/accel.h"
102 #elif defined(__WXMSW__)
103 #include "wx/msw/accel.h"
104 #elif defined(__WXMOTIF__)
105 #include "wx/motif/accel.h"
106 #elif defined(__WXGTK__)
107 #include "wx/gtk/accel.h"
108 #elif defined(__WXQT__)
109 #include "wx/qt/accel.h"
110 #elif defined(__WXMAC__)
111 #include "wx/mac/accel.h"
112 #elif defined(__WXPM__)
113 #include "wx/os2/accel.h"
114 #elif defined(__WXSTUBS__)
115 #include "wx/stubs/accel.h"
118 WXDLLEXPORT_DATA(extern wxAcceleratorTable
) wxNullAcceleratorTable
;
120 #endif // wxUSE_ACCEL