1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxAccelerator* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
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
34 An object used by an application wishing to create an accelerator table
35 (see wxAcceleratorTable).
40 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
42 class wxAcceleratorEntry
49 A combination of the wxAcceleratorEntryFlags values, which
50 indicates which modifier keys are held down.
52 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
54 The menu or control command identifier (ID).
56 The menu item associated with this accelerator.
58 wxAcceleratorEntry(int flags
= 0, int keyCode
= 0, int cmd
= 0,
59 wxMenuItem
*item
= NULL
);
64 wxAcceleratorEntry(const wxAcceleratorEntry
& entry
);
67 Returns the command identifier for the accelerator table entry.
69 int GetCommand() const;
72 Returns the flags for the accelerator table entry.
77 Returns the keycode for the accelerator table entry.
79 int GetKeyCode() const;
82 Returns the menu item associated with this accelerator entry.
84 wxMenuItem
*GetMenuItem() const;
87 Sets the accelerator entry parameters.
90 A combination of the wxAcceleratorEntryFlags values, which
91 indicates which modifier keys are held down.
93 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
95 The menu or control command identifier (ID).
97 The menu item associated with this accelerator.
99 void Set(int flags
, int keyCode
, int cmd
, wxMenuItem
*item
= NULL
);
102 Returns @true if this object is correctly initialized.
107 Returns a wxString for this accelerator.
108 This function formats it using the @c "flags-keycode" format
109 where @c flags maybe a hyphen-separed list of @c "shift|alt|ctrl".
111 wxString
ToString() const;
114 Parses the given string and sets the accelerator accordingly.
117 Should be a string in the form "flags-keycode"
119 @returns @true if the given string correctly initialized this object
120 (i.e. if IsOk() returns true after this call)
122 bool FromString(const wxString
& str
);
125 wxAcceleratorEntry
& operator=(const wxAcceleratorEntry
& entry
);
126 bool operator==(const wxAcceleratorEntry
& entry
) const;
127 bool operator!=(const wxAcceleratorEntry
& entry
) const;
132 @class wxAcceleratorTable
135 An accelerator table allows the application to specify a table of keyboard
136 shortcuts for menu or button commands.
138 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
139 is the initial accelerator table for a window.
144 wxAcceleratorEntry entries[4];
145 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
146 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
147 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
148 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
150 wxAcceleratorTable accel(4, entries);
151 frame->SetAcceleratorTable(accel);
155 An accelerator takes precedence over normal processing and can be a convenient
156 way to program some event handling. For example, you can use an accelerator table
157 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
164 ::wxNullAcceleratorTable
166 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
168 class wxAcceleratorTable
: public wxObject
174 wxAcceleratorTable();
177 Initializes the accelerator table from an array of wxAcceleratorEntry.
180 Number of accelerator entries.
182 The array of entries.
184 wxAcceleratorTable(int n
, const wxAcceleratorEntry entries
[]);
187 Loads the accelerator table from a Windows resource (Windows only).
192 Name of a Windows accelerator.
194 wxAcceleratorTable(const wxString
& resource
);
197 Destroys the wxAcceleratorTable object.
198 See @ref overview_refcount_destruct for more info.
200 virtual ~wxAcceleratorTable();
203 Returns @true if the accelerator table is valid.
209 // ============================================================================
210 // Global functions/macros
211 // ============================================================================
214 An empty accelerator table.
216 wxAcceleratorTable wxNullAcceleratorTable
;