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) wxWidgets team
9 // Licence: wxWindows licence
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
)
53 wxAcceleratorEntry(const wxAcceleratorEntry
& entry
)
54 : m_flags(entry
.m_flags
)
55 , m_keyCode(entry
.m_keyCode
)
56 , m_command(entry
.m_command
)
57 , m_item(entry
.m_item
)
60 wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
)
62 Set(entry
.m_flags
, entry
.m_keyCode
, entry
.m_command
, entry
.m_item
);
66 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
)
74 void SetMenuItem(wxMenuItem
*item
) { m_item
= item
; }
76 int GetFlags() const { return m_flags
; }
77 int GetKeyCode() const { return m_keyCode
; }
78 int GetCommand() const { return m_command
; }
80 wxMenuItem
*GetMenuItem() const { return m_item
; }
82 bool operator==(const wxAcceleratorEntry
& entry
) const
84 return m_flags
== entry
.m_flags
&&
85 m_keyCode
== entry
.m_keyCode
&&
86 m_command
== entry
.m_command
&&
87 m_item
== entry
.m_item
;
90 bool operator!=(const wxAcceleratorEntry
& entry
) const
91 { return !(*this == entry
); }
93 #if defined(__WXMOTIF__)
94 // Implementation use only
95 bool MatchesEvent(const wxKeyEvent
& event
) const;
99 int m_flags
; // combination of wxACCEL_XXX constants
100 int m_keyCode
; // ASCII or virtual keycode
101 int m_command
; // Command id to generate
103 // the menu item this entry corresponds to, may be NULL
106 // for compatibility with old code, use accessors now!
107 friend class WXDLLEXPORT wxMenu
;
110 // ----------------------------------------------------------------------------
111 // include wxAcceleratorTable class declaration, it is only used by the library
112 // and so doesn't have any published user visible interface
113 // ----------------------------------------------------------------------------
115 #if defined(__WXUNIVERSAL__)
116 #include "wx/generic/accel.h"
117 #elif defined(__WXMSW__)
118 #include "wx/msw/accel.h"
119 #elif defined(__WXMOTIF__)
120 #include "wx/motif/accel.h"
121 #elif defined(__WXGTK20__)
122 #include "wx/gtk/accel.h"
123 #elif defined(__WXGTK__)
124 #include "wx/gtk1/accel.h"
125 #elif defined(__WXMAC__)
126 #include "wx/mac/accel.h"
127 #elif defined(__WXCOCOA__)
128 #include "wx/generic/accel.h"
129 #elif defined(__WXPM__)
130 #include "wx/os2/accel.h"
133 extern WXDLLEXPORT_DATA(wxAcceleratorTable
) wxNullAcceleratorTable
;
135 #endif // wxUSE_ACCEL