]> git.saurik.com Git - wxWidgets.git/blob - include/wx/accel.h
added wxBitmap::CopyFromIcon to wxGTK
[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 class WXDLLEXPORT wxKeyEvent;
24
25 // ----------------------------------------------------------------------------
26 // constants
27 // ----------------------------------------------------------------------------
28
29 // wxAcceleratorEntry flags
30 enum
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
42 class WXDLLEXPORT wxAcceleratorEntry
43 {
44 public:
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
78 #ifdef __WXMOTIF__
79 // Implementation use only
80 bool MatchesEvent(const wxKeyEvent& event) const ;
81 #endif
82
83 private:
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"
104 #elif defined(__WXMOTIF__)
105 #include "wx/motif/accel.h"
106 #elif defined(__WXGTK__)
107 #include "wx/gtk/accel.h"
108 #elif defined(__WXMAC__)
109 #include "wx/mac/accel.h"
110 #elif defined(__WXPM__)
111 #include "wx/os2/accel.h"
112 #elif defined(__WXSTUBS__)
113 #include "wx/stubs/accel.h"
114 #endif
115
116 WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
117
118 #endif // wxUSE_ACCEL
119
120 #endif
121 // _WX_ACCEL_H_BASE_