]> git.saurik.com Git - wxWidgets.git/blob - interface/accel.h
263dc02be64db2bdc7de14883b518880857c0c1e
[wxWidgets.git] / interface / accel.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: accel.h
3 // Purpose: interface of wxAccelerator* classes
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /** wxAcceleratorEntry flags */
11 enum wxAcceleratorEntryFlags
12 {
13 /** no modifiers */
14 wxACCEL_NORMAL,
15
16 /** hold Alt key down */
17 wxACCEL_ALT,
18
19 /** hold Ctrl key down */
20 wxACCEL_CTRL,
21
22 /** hold Shift key down */
23 wxACCEL_SHIFT,
24
25 /** Command key on OS X; identic to wxACCEL_CTRL on other platforms. */
26 wxACCEL_CMD
27 };
28
29
30 /**
31 @class wxAcceleratorEntry
32 @wxheader{accel.h}
33
34 An object used by an application wishing to create an accelerator table
35 (see wxAcceleratorTable).
36
37 @library{wxcore}
38 @category{misc}
39
40 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
41 */
42 class wxAcceleratorEntry
43 {
44 public:
45 /**
46 Default ctor.
47 */
48 wxAcceleratorEntry();
49
50 /**
51 Constructor.
52
53 @param flags
54 A combination of the wxAcceleratorEntryFlags values, which
55 indicates which modifier keys are held down.
56 @param keyCode
57 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
58 @param cmd
59 The menu or control command identifier.
60 */
61 wxAcceleratorEntry(int flags, int keyCode, int cmd);
62
63 /**
64 Returns the command identifier for the accelerator table entry.
65 */
66 int GetCommand() const;
67
68 /**
69 Returns the flags for the accelerator table entry.
70 */
71 int GetFlags() const;
72
73 /**
74 Returns the keycode for the accelerator table entry.
75 */
76 int GetKeyCode() const;
77
78 /**
79 Sets the accelerator entry parameters.
80
81 @param flags
82 A combination of the wxAcceleratorEntryFlags values, which
83 indicates which modifier keys are held down.
84 @param keyCode
85 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
86 @param cmd
87 The menu or control command identifier.
88
89 */
90 void Set(int flags, int keyCode, int cmd);
91 };
92
93
94 /**
95 @class wxAcceleratorTable
96 @wxheader{accel.h}
97
98 An accelerator table allows the application to specify a table of keyboard
99 shortcuts for menu or button commands.
100
101 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
102 is the initial accelerator table for a window.
103
104 Example:
105
106 @code
107 wxAcceleratorEntry entries[4];
108 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
109 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
110 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
111 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
112
113 wxAcceleratorTable accel(4, entries);
114 frame->SetAcceleratorTable(accel);
115 @endcode
116
117 @remarks
118 An accelerator takes precedence over normal processing and can be a convenient
119 way to program some event handling. For example, you can use an accelerator table
120 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
121 'OK'.
122
123 @library{wxcore}
124 @category{misc}
125
126 @stdobjects
127 ::wxNullAcceleratorTable
128
129 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
130 */
131 class wxAcceleratorTable : public wxObject
132 {
133 public:
134 /**
135 Default ctor.
136 */
137 wxAcceleratorTable();
138
139 /**
140 Initializes the accelerator table from an array of wxAcceleratorEntry.
141
142 @param n
143 Number of accelerator entries.
144 @param entries
145 The array of entries.
146 */
147 wxAcceleratorTable(int n, wxAcceleratorEntry entries[]);
148
149 /**
150 Loads the accelerator table from a Windows resource (Windows only).
151
152 @param resource
153 Name of a Windows accelerator.
154 */
155 wxAcceleratorTable(const wxString& resource);
156
157 /**
158 Destroys the wxAcceleratorTable object.
159 See @ref overview_refcount_destruct for more info.
160 */
161 ~wxAcceleratorTable();
162
163 /**
164 Returns @true if the accelerator table is valid.
165 */
166 bool IsOk() const;
167
168 /**
169 Assignment operator, using @ref overview_refcount "reference counting".
170
171 @param accel
172 Accelerator table to assign.
173 */
174 wxAcceleratorTable operator =(const wxAcceleratorTable& accel);
175 };
176
177
178 // ============================================================================
179 // Global functions/macros
180 // ============================================================================
181
182 /**
183 An empty accelerator table.
184 */
185 wxAcceleratorTable wxNullAcceleratorTable;