]> git.saurik.com Git - wxWidgets.git/blob - include/wx/accel.h
corrected conditional compilation
[wxWidgets.git] / include / wx / accel.h
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
12 #ifndef _WX_ACCEL_H_BASE_
13 #define _WX_ACCEL_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_ACCEL
18
19 #include "wx/object.h"
20
21 class WXDLLEXPORT wxAcceleratorTable;
22 class WXDLLEXPORT wxMenuItem;
23
24 // ----------------------------------------------------------------------------
25 // constants
26 // ----------------------------------------------------------------------------
27
28 // wxAcceleratorEntry flags
29 enum
30 {
31 wxACCEL_NORMAL = 0x0000, // no modifiers
32 wxACCEL_ALT = 0x0001, // hold Alt key down
33 wxACCEL_CTRL = 0x0002, // hold Ctrl key down
34 wxACCEL_SHIFT = 0x0004 // hold Shift key down
35 };
36
37 // ----------------------------------------------------------------------------
38 // an entry in wxAcceleratorTable corresponds to one accelerator
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxAcceleratorEntry
42 {
43 public:
44 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
45 wxMenuItem *item = NULL)
46 {
47 Set(flags, keyCode, cmd, item);
48 }
49
50 void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL)
51 {
52 m_flags = flags;
53 m_keyCode = keyCode;
54 m_command = cmd;
55 m_item = item;
56 }
57
58 void SetMenuItem(wxMenuItem *item) { m_item = item; }
59
60 int GetFlags() const { return m_flags; }
61 int GetKeyCode() const { return m_keyCode; }
62 int GetCommand() const { return m_command; }
63
64 wxMenuItem *GetMenuItem() const { return m_item; }
65
66 bool operator==(const wxAcceleratorEntry& entry) const
67 {
68 return m_flags == entry.m_flags &&
69 m_keyCode == entry.m_keyCode &&
70 m_command == entry.m_command &&
71 m_item == entry.m_item;
72 }
73
74 bool operator!=(const wxAcceleratorEntry& entry) const
75 { return !(*this == entry); }
76
77 private:
78 int m_flags; // combination of wxACCEL_XXX constants
79 int m_keyCode; // ASCII or virtual keycode
80 int m_command; // Command id to generate
81
82 // the menu item this entry corresponds to, may be NULL
83 wxMenuItem *m_item;
84
85 // for compatibility with old code, use accessors now!
86 friend class WXDLLEXPORT wxMenu;
87 };
88
89 // ----------------------------------------------------------------------------
90 // include wxAcceleratorTable class declaration, it is only used by the library
91 // and so doesn't have any published user visible interface
92 // ----------------------------------------------------------------------------
93
94 #if defined(__WXUNIVERSAL__)
95 #include "wx/generic/accel.h"
96 #elif defined(__WXMSW__)
97 #include "wx/msw/accel.h"
98 #elif defined(__WXMOTIF__)
99 #include "wx/motif/accel.h"
100 #elif defined(__WXGTK__)
101 #include "wx/gtk/accel.h"
102 #elif defined(__WXQT__)
103 #include "wx/qt/accel.h"
104 #elif defined(__WXMAC__)
105 #include "wx/mac/accel.h"
106 #elif defined(__WXPM__)
107 #include "wx/os2/accel.h"
108 #elif defined(__WXSTUBS__)
109 #include "wx/stubs/accel.h"
110 #endif
111
112 WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
113
114 #endif // wxUSE_ACCEL
115
116 #endif
117 // _WX_ACCEL_H_BASE_