1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxAccelerator* classes
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 /** wxAcceleratorEntry flags */
10 enum wxAcceleratorEntryFlags
15 /** hold Alt key down */
18 /** hold Ctrl key down, corresponds to Command key on OS X */
21 /** hold Shift key down */
24 /** corresponds to real Ctrl key on OS X, identic to @c wxACCEL_CTRL on other platforms */
27 /** deprecated, identic to @c wxACCEL_CTRL on all platforms. */
33 @class wxAcceleratorEntry
35 An object used by an application wishing to create an accelerator table
36 (see wxAcceleratorTable).
41 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
43 class wxAcceleratorEntry
50 A combination of the ::wxAcceleratorEntryFlags values, which
51 indicates which modifier keys are held down.
53 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
55 The menu or control command identifier (ID).
57 The menu item associated with this accelerator.
59 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0,
60 wxMenuItem
*item
= NULL
);
65 wxAcceleratorEntry(const wxAcceleratorEntry
& entry
);
68 Returns the command identifier for the accelerator table entry.
70 int GetCommand() const;
73 Returns the flags for the accelerator table entry.
78 Returns the keycode for the accelerator table entry.
80 int GetKeyCode() const;
83 Returns the menu item associated with this accelerator entry.
85 wxMenuItem
*GetMenuItem() const;
88 Sets the accelerator entry parameters.
91 A combination of the ::wxAcceleratorEntryFlags values, which
92 indicates which modifier keys are held down.
94 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
96 The menu or control command identifier (ID).
98 The menu item associated with this accelerator.
100 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
);
103 Returns @true if this object is correctly initialized.
108 Returns a textual representation of this accelerator.
110 The returned string is of the form <code>[Alt+][Ctrl+][RawCtrl+][Shift+]Key</code>
111 where the modifier keys are present only if the corresponding flag is
114 wxString
ToString() const;
117 Returns a textual representation of this accelerator which is
118 appropriate for saving in configuration files.
120 Unlike the string returned by ToString(), this one is never translated
121 so, while it's not suitable for showing to the user, it can be used to
122 uniquely identify the accelerator independently of the user language.
124 The returned string can still be parsed by FromString().
128 wxString
ToRawString() const;
131 Parses the given string and sets the accelerator accordingly.
134 This string may be either in the same format as returned by
135 ToString(), i.e. contain the accelerator itself only, or have the
136 format of a full menu item text with i.e. <code>Label TAB
137 Accelerator</code>. In the latter case, the part of the string
138 before the TAB is ignored. Notice that the latter format is only
139 supported for the compatibility with the previous wxWidgets
140 versions and the new code should pass only the accelerator string
141 itself to this function.
143 @return @true if the given string correctly initialized this object
144 (i.e. if IsOk() returns true after this call)
146 bool FromString(const wxString
& str
);
149 wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
);
150 bool operator==(const wxAcceleratorEntry
& entry
) const;
151 bool operator!=(const wxAcceleratorEntry
& entry
) const;
156 @class wxAcceleratorTable
158 An accelerator table allows the application to specify a table of keyboard
159 shortcuts for menu or button commands.
161 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
162 is the initial accelerator table for a window.
167 wxAcceleratorEntry entries[4];
168 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
169 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
170 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
171 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
173 wxAcceleratorTable accel(4, entries);
174 frame->SetAcceleratorTable(accel);
178 An accelerator takes precedence over normal processing and can be a convenient
179 way to program some event handling. For example, you can use an accelerator table
180 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
187 ::wxNullAcceleratorTable
189 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
191 class wxAcceleratorTable
: public wxObject
197 wxAcceleratorTable();
200 Initializes the accelerator table from an array of wxAcceleratorEntry.
203 Number of accelerator entries.
205 The array of entries.
208 The wxPerl constructor accepts a list of either
209 Wx::AcceleratorEntry objects or references to 3-element arrays
210 [flags, keyCode, cmd] , like the parameters of
211 Wx::AcceleratorEntry::new.
214 wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]);
217 Loads the accelerator table from a Windows resource (Windows only).
222 Name of a Windows accelerator.
224 wxAcceleratorTable(const wxString
& resource
);
227 Destroys the wxAcceleratorTable object.
228 See @ref overview_refcount_destruct for more info.
230 virtual ~wxAcceleratorTable();
233 Returns @true if the accelerator table is valid.
239 // ============================================================================
240 // Global functions/macros
241 // ============================================================================
244 An empty accelerator table.
246 wxAcceleratorTable wxNullAcceleratorTable
;