]> git.saurik.com Git - wxWidgets.git/blame - include/wx/accel.h
experimental --inplace flag implementation
[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)
54380f29
GD
47 : m_flags(flags)
48 , m_keyCode(keyCode)
49 , m_command(cmd)
50 , m_item(item)
51 { }
52
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)
58 { }
59
60 wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry)
1e6feb95 61 {
54380f29
GD
62 Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item);
63 return *this;
1e6feb95 64 }
54380f29 65
1e6feb95
VZ
66 void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL)
67 {
68 m_flags = flags;
69 m_keyCode = keyCode;
70 m_command = cmd;
71 m_item = item;
72 }
73
74 void SetMenuItem(wxMenuItem *item) { m_item = item; }
75
76 int GetFlags() const { return m_flags; }
77 int GetKeyCode() const { return m_keyCode; }
78 int GetCommand() const { return m_command; }
79
80 wxMenuItem *GetMenuItem() const { return m_item; }
81
82 bool operator==(const wxAcceleratorEntry& entry) const
83 {
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;
88 }
89
90 bool operator!=(const wxAcceleratorEntry& entry) const
91 { return !(*this == entry); }
92
b82d2a00 93#if defined(__WXMOTIF__)
45f22d48 94 // Implementation use only
b82d2a00 95 bool MatchesEvent(const wxKeyEvent& event) const;
45f22d48
JS
96#endif
97
1e6feb95
VZ
98private:
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
102
103 // the menu item this entry corresponds to, may be NULL
104 wxMenuItem *m_item;
105
106 // for compatibility with old code, use accessors now!
107 friend class WXDLLEXPORT wxMenu;
108};
109
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// ----------------------------------------------------------------------------
114
115#if defined(__WXUNIVERSAL__)
116 #include "wx/generic/accel.h"
117#elif defined(__WXMSW__)
118 #include "wx/msw/accel.h"
34138703 119#elif defined(__WXMOTIF__)
1e6feb95 120 #include "wx/motif/accel.h"
34138703 121#elif defined(__WXGTK__)
1e6feb95 122 #include "wx/gtk/accel.h"
34138703 123#elif defined(__WXMAC__)
1e6feb95 124 #include "wx/mac/accel.h"
1777b9bb 125#elif defined(__WXPM__)
1e6feb95 126 #include "wx/os2/accel.h"
34138703
JS
127#endif
128
1e6feb95
VZ
129WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
130
131#endif // wxUSE_ACCEL
132
34138703
JS
133#endif
134 // _WX_ACCEL_H_BASE_