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 */
22 /** hold Shift key down */
25 /** Command key on OS X; identic to wxACCEL_CTRL on other platforms. */
31 @class wxAcceleratorEntry
33 An object used by an application wishing to create an accelerator table
34 (see wxAcceleratorTable).
39 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
41 class wxAcceleratorEntry
48 A combination of the ::wxAcceleratorEntryFlags values, which
49 indicates which modifier keys are held down.
51 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
53 The menu or control command identifier (ID).
55 The menu item associated with this accelerator.
57 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0,
58 wxMenuItem
*item
= NULL
);
63 wxAcceleratorEntry(const wxAcceleratorEntry
& entry
);
66 Returns the command identifier for the accelerator table entry.
68 int GetCommand() const;
71 Returns the flags for the accelerator table entry.
76 Returns the keycode for the accelerator table entry.
78 int GetKeyCode() const;
81 Returns the menu item associated with this accelerator entry.
83 wxMenuItem
*GetMenuItem() const;
86 Sets the accelerator entry parameters.
89 A combination of the ::wxAcceleratorEntryFlags values, which
90 indicates which modifier keys are held down.
92 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
94 The menu or control command identifier (ID).
96 The menu item associated with this accelerator.
98 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
);
101 Returns @true if this object is correctly initialized.
106 Returns a textual representation of this accelerator.
108 The returned string is of the form <code>[Alt+][Ctrl+][Shift+]Key</code>
109 where the modifier keys are present only if the corresponding flag is
112 wxString
ToString() const;
115 Parses the given string and sets the accelerator accordingly.
118 This string may be either in the same format as returned by
119 ToString(), i.e. contain the accelerator itself only, or have the
120 format of a full menu item text with i.e. <code>Label TAB
121 Accelerator</code>. In the latter case, the part of the string
122 before the TAB is ignored. Notice that the latter format is only
123 supported for the compatibility with the previous wxWidgets
124 versions and the new code should pass only the accelerator string
125 itself to this function.
127 @return @true if the given string correctly initialized this object
128 (i.e. if IsOk() returns true after this call)
130 bool FromString(const wxString
& str
);
133 wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
);
134 bool operator==(const wxAcceleratorEntry
& entry
) const;
135 bool operator!=(const wxAcceleratorEntry
& entry
) const;
140 @class wxAcceleratorTable
142 An accelerator table allows the application to specify a table of keyboard
143 shortcuts for menu or button commands.
145 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
146 is the initial accelerator table for a window.
151 wxAcceleratorEntry entries[4];
152 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
153 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
154 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
155 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
157 wxAcceleratorTable accel(4, entries);
158 frame->SetAcceleratorTable(accel);
162 An accelerator takes precedence over normal processing and can be a convenient
163 way to program some event handling. For example, you can use an accelerator table
164 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
171 ::wxNullAcceleratorTable
173 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
175 class wxAcceleratorTable
: public wxObject
181 wxAcceleratorTable();
184 Initializes the accelerator table from an array of wxAcceleratorEntry.
187 Number of accelerator entries.
189 The array of entries.
192 The wxPerl constructor accepts a list of either
193 Wx::AcceleratorEntry objects or references to 3-element arrays
194 [flags, keyCode, cmd] , like the parameters of
195 Wx::AcceleratorEntry::new.
198 wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]);
201 Loads the accelerator table from a Windows resource (Windows only).
206 Name of a Windows accelerator.
208 wxAcceleratorTable(const wxString
& resource
);
211 Destroys the wxAcceleratorTable object.
212 See @ref overview_refcount_destruct for more info.
214 virtual ~wxAcceleratorTable();
217 Returns @true if the accelerator table is valid.
223 // ============================================================================
224 // Global functions/macros
225 // ============================================================================
228 An empty accelerator table.
230 wxAcceleratorTable wxNullAcceleratorTable
;