]> git.saurik.com Git - wxWidgets.git/blame - include/wx/accel.h
reverted Julian's unintentional breakage of wxChoice
[wxWidgets.git] / include / wx / accel.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/accel.h
3// Purpose: wxAcceleratorEntry and wxAcceleratorTable classes
4// Author: Julian Smart, Robert Roebling, Vadim Zeitlin
5// Modified by:
6// Created: 31.05.01 (extracted from other files)
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_ACCEL_H_BASE_
13#define _WX_ACCEL_H_BASE_
14
1e6feb95
VZ
15#include "wx/defs.h"
16
17#if wxUSE_ACCEL
18
19#include "wx/object.h"
20
21class WXDLLEXPORT wxAcceleratorTable;
22class WXDLLEXPORT wxMenuItem;
45f22d48 23class WXDLLEXPORT wxKeyEvent;
1e6feb95
VZ
24
25// ----------------------------------------------------------------------------
26// constants
27// ----------------------------------------------------------------------------
28
29// wxAcceleratorEntry flags
30enum
31{
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
36};
37
38// ----------------------------------------------------------------------------
39// an entry in wxAcceleratorTable corresponds to one accelerator
40// ----------------------------------------------------------------------------
41
42class WXDLLEXPORT wxAcceleratorEntry
43{
44public:
45 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
46 wxMenuItem *item = NULL)
47 {
48 Set(flags, keyCode, cmd, item);
49 }
50
51 void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL)
52 {
53 m_flags = flags;
54 m_keyCode = keyCode;
55 m_command = cmd;
56 m_item = item;
57 }
58
59 void SetMenuItem(wxMenuItem *item) { m_item = item; }
60
61 int GetFlags() const { return m_flags; }
62 int GetKeyCode() const { return m_keyCode; }
63 int GetCommand() const { return m_command; }
64
65 wxMenuItem *GetMenuItem() const { return m_item; }
66
67 bool operator==(const wxAcceleratorEntry& entry) const
68 {
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;
73 }
74
75 bool operator!=(const wxAcceleratorEntry& entry) const
76 { return !(*this == entry); }
77
b82d2a00 78#if defined(__WXMOTIF__)
45f22d48 79 // Implementation use only
b82d2a00 80 bool MatchesEvent(const wxKeyEvent& event) const;
45f22d48
JS
81#endif
82
1e6feb95
VZ
83private:
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
87
88 // the menu item this entry corresponds to, may be NULL
89 wxMenuItem *m_item;
90
91 // for compatibility with old code, use accessors now!
92 friend class WXDLLEXPORT wxMenu;
93};
94
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// ----------------------------------------------------------------------------
99
100#if defined(__WXUNIVERSAL__)
101 #include "wx/generic/accel.h"
102#elif defined(__WXMSW__)
103 #include "wx/msw/accel.h"
34138703 104#elif defined(__WXMOTIF__)
1e6feb95 105 #include "wx/motif/accel.h"
34138703 106#elif defined(__WXGTK__)
1e6feb95 107 #include "wx/gtk/accel.h"
34138703 108#elif defined(__WXMAC__)
1e6feb95 109 #include "wx/mac/accel.h"
1777b9bb 110#elif defined(__WXPM__)
1e6feb95 111 #include "wx/os2/accel.h"
34138703 112#elif defined(__WXSTUBS__)
1e6feb95 113 #include "wx/stubs/accel.h"
34138703
JS
114#endif
115
1e6feb95
VZ
116WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
117
118#endif // wxUSE_ACCEL
119
34138703
JS
120#endif
121 // _WX_ACCEL_H_BASE_