1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxAccelerator* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 /** wxAcceleratorEntry flags */
11 enum wxAcceleratorEntryFlags
16 /** hold Alt key down */
19 /** hold Ctrl key down, corresponds to Command key on OS X */
22 /** hold Shift key down */
25 /** corresponds to real Ctrl key on OS X, identic to @c wxACCEL_CTRL on other platforms */
28 /** deprecated, identic to @c wxACCEL_CTRL on all platforms. */
34 @class wxAcceleratorEntry
36 An object used by an application wishing to create an accelerator table
37 (see wxAcceleratorTable).
42 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
44 class wxAcceleratorEntry
51 A combination of the ::wxAcceleratorEntryFlags values, which
52 indicates which modifier keys are held down.
54 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
56 The menu or control command identifier (ID).
58 The menu item associated with this accelerator.
60 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0,
61 wxMenuItem
*item
= NULL
);
66 wxAcceleratorEntry(const wxAcceleratorEntry
& entry
);
69 Returns the command identifier for the accelerator table entry.
71 int GetCommand() const;
74 Returns the flags for the accelerator table entry.
79 Returns the keycode for the accelerator table entry.
81 int GetKeyCode() const;
84 Returns the menu item associated with this accelerator entry.
86 wxMenuItem
*GetMenuItem() const;
89 Sets the accelerator entry parameters.
92 A combination of the ::wxAcceleratorEntryFlags values, which
93 indicates which modifier keys are held down.
95 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
97 The menu or control command identifier (ID).
99 The menu item associated with this accelerator.
101 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
);
104 Returns @true if this object is correctly initialized.
109 Returns a textual representation of this accelerator.
111 The returned string is of the form <code>[Alt+][Ctrl+][RawCtrl+][Shift+]Key</code>
112 where the modifier keys are present only if the corresponding flag is
115 wxString
ToString() const;
118 Returns a textual representation of this accelerator which is
119 appropriate for saving in configuration files.
121 Unlike the string returned by ToString(), this one is never translated
122 so, while it's not suitable for showing to the user, it can be used to
123 uniquely identify the accelerator independently of the user language.
125 The returned string can still be parsed by FromString().
129 wxString
ToRawString() const;
132 Parses the given string and sets the accelerator accordingly.
135 This string may be either in the same format as returned by
136 ToString(), i.e. contain the accelerator itself only, or have the
137 format of a full menu item text with i.e. <code>Label TAB
138 Accelerator</code>. In the latter case, the part of the string
139 before the TAB is ignored. Notice that the latter format is only
140 supported for the compatibility with the previous wxWidgets
141 versions and the new code should pass only the accelerator string
142 itself to this function.
144 @return @true if the given string correctly initialized this object
145 (i.e. if IsOk() returns true after this call)
147 bool FromString(const wxString
& str
);
150 wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
);
151 bool operator==(const wxAcceleratorEntry
& entry
) const;
152 bool operator!=(const wxAcceleratorEntry
& entry
) const;
157 @class wxAcceleratorTable
159 An accelerator table allows the application to specify a table of keyboard
160 shortcuts for menu or button commands.
162 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
163 is the initial accelerator table for a window.
168 wxAcceleratorEntry entries[4];
169 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
170 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
171 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
172 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
174 wxAcceleratorTable accel(4, entries);
175 frame->SetAcceleratorTable(accel);
179 An accelerator takes precedence over normal processing and can be a convenient
180 way to program some event handling. For example, you can use an accelerator table
181 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
188 ::wxNullAcceleratorTable
190 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
192 class wxAcceleratorTable
: public wxObject
198 wxAcceleratorTable();
201 Initializes the accelerator table from an array of wxAcceleratorEntry.
204 Number of accelerator entries.
206 The array of entries.
209 The wxPerl constructor accepts a list of either
210 Wx::AcceleratorEntry objects or references to 3-element arrays
211 [flags, keyCode, cmd] , like the parameters of
212 Wx::AcceleratorEntry::new.
215 wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]);
218 Loads the accelerator table from a Windows resource (Windows only).
223 Name of a Windows accelerator.
225 wxAcceleratorTable(const wxString
& resource
);
228 Destroys the wxAcceleratorTable object.
229 See @ref overview_refcount_destruct for more info.
231 virtual ~wxAcceleratorTable();
234 Returns @true if the accelerator table is valid.
240 // ============================================================================
241 // Global functions/macros
242 // ============================================================================
245 An empty accelerator table.
247 wxAcceleratorTable wxNullAcceleratorTable
;