]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/accel.h
Move code removing "-psn_xxx" command line arguments to common code.
[wxWidgets.git] / interface / wx / accel.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: accel.h
463b4bfa 3// Purpose: interface of wxAccelerator* classes
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
463b4bfa
FM
8
9/** wxAcceleratorEntry flags */
10enum wxAcceleratorEntryFlags
11{
12 /** no modifiers */
13 wxACCEL_NORMAL,
14
15 /** hold Alt key down */
16 wxACCEL_ALT,
17
cfc77ac0 18 /** hold Ctrl key down, corresponds to Command key on OS X */
463b4bfa
FM
19 wxACCEL_CTRL,
20
21 /** hold Shift key down */
22 wxACCEL_SHIFT,
23
cfc77ac0
SC
24 /** corresponds to real Ctrl key on OS X, identic to @c wxACCEL_CTRL on other platforms */
25 wxACCEL_RAW_CTRL,
26
27 /** deprecated, identic to @c wxACCEL_CTRL on all platforms. */
463b4bfa
FM
28 wxACCEL_CMD
29};
30
31
23324ae1
FM
32/**
33 @class wxAcceleratorEntry
7c913512 34
463b4bfa
FM
35 An object used by an application wishing to create an accelerator table
36 (see wxAcceleratorTable).
7c913512 37
23324ae1 38 @library{wxcore}
3c99e2fd 39 @category{data}
7c913512 40
3a65144e 41 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
23324ae1 42*/
7c913512 43class wxAcceleratorEntry
23324ae1
FM
44{
45public:
23324ae1
FM
46 /**
47 Constructor.
463b4bfa 48
7c913512 49 @param flags
d4624460 50 A combination of the ::wxAcceleratorEntryFlags values, which
463b4bfa 51 indicates which modifier keys are held down.
7c913512 52 @param keyCode
d4624460 53 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
7c913512 54 @param cmd
3d8662ab
FM
55 The menu or control command identifier (ID).
56 @param item
57 The menu item associated with this accelerator.
58 */
59 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
60 wxMenuItem *item = NULL);
61
62 /**
63 Copy ctor.
23324ae1 64 */
3d8662ab 65 wxAcceleratorEntry(const wxAcceleratorEntry& entry);
23324ae1
FM
66
67 /**
68 Returns the command identifier for the accelerator table entry.
69 */
328f5751 70 int GetCommand() const;
23324ae1
FM
71
72 /**
73 Returns the flags for the accelerator table entry.
74 */
328f5751 75 int GetFlags() const;
23324ae1
FM
76
77 /**
78 Returns the keycode for the accelerator table entry.
79 */
328f5751 80 int GetKeyCode() const;
23324ae1 81
3d8662ab
FM
82 /**
83 Returns the menu item associated with this accelerator entry.
84 */
85 wxMenuItem *GetMenuItem() const;
86
23324ae1
FM
87 /**
88 Sets the accelerator entry parameters.
3c4f71cc 89
7c913512 90 @param flags
d4624460 91 A combination of the ::wxAcceleratorEntryFlags values, which
463b4bfa 92 indicates which modifier keys are held down.
7c913512 93 @param keyCode
d4624460 94 The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
7c913512 95 @param cmd
3d8662ab
FM
96 The menu or control command identifier (ID).
97 @param item
98 The menu item associated with this accelerator.
99 */
100 void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL);
463b4bfa 101
3d8662ab
FM
102 /**
103 Returns @true if this object is correctly initialized.
23324ae1 104 */
3d8662ab
FM
105 bool IsOk() const;
106
107 /**
944f641c 108 Returns a textual representation of this accelerator.
d4624460 109
5ec18516 110 The returned string is of the form <code>[Alt+][Ctrl+][RawCtrl+][Shift+]Key</code>
944f641c
VZ
111 where the modifier keys are present only if the corresponding flag is
112 set.
3d8662ab
FM
113 */
114 wxString ToString() const;
115
86f5e64b
VZ
116 /**
117 Returns a textual representation of this accelerator which is
118 appropriate for saving in configuration files.
119
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.
123
124 The returned string can still be parsed by FromString().
125
126 @since 2.9.4
127 */
128 wxString ToRawString() const;
129
3d8662ab
FM
130 /**
131 Parses the given string and sets the accelerator accordingly.
132
133 @param str
944f641c
VZ
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
6fc7a1ad
VZ
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.
3d8662ab 142
d29a9a8a
BP
143 @return @true if the given string correctly initialized this object
144 (i.e. if IsOk() returns true after this call)
3d8662ab
FM
145 */
146 bool FromString(const wxString& str);
147
148
149 wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry);
150 bool operator==(const wxAcceleratorEntry& entry) const;
151 bool operator!=(const wxAcceleratorEntry& entry) const;
23324ae1
FM
152};
153
154
155/**
156 @class wxAcceleratorTable
7c913512 157
23324ae1 158 An accelerator table allows the application to specify a table of keyboard
b1bb04c5 159 shortcuts for menu or button commands.
463b4bfa 160
3a65144e 161 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
463b4bfa
FM
162 is the initial accelerator table for a window.
163
164 Example:
165
166 @code
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);
172
173 wxAcceleratorTable accel(4, entries);
174 frame->SetAcceleratorTable(accel);
175 @endcode
7c913512 176
463b4bfa
FM
177 @remarks
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
aa47271c 181 'OK'.
7c913512 182
23324ae1 183 @library{wxcore}
3c99e2fd 184 @category{data}
7c913512 185
23324ae1 186 @stdobjects
3a65144e 187 ::wxNullAcceleratorTable
7c913512 188
3a65144e 189 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
23324ae1
FM
190*/
191class wxAcceleratorTable : public wxObject
192{
193public:
23324ae1 194 /**
463b4bfa
FM
195 Default ctor.
196 */
197 wxAcceleratorTable();
198
463b4bfa
FM
199 /**
200 Initializes the accelerator table from an array of wxAcceleratorEntry.
3c4f71cc 201
7c913512 202 @param n
4cc4bfaf 203 Number of accelerator entries.
7c913512 204 @param entries
4cc4bfaf 205 The array of entries.
1058f652
MB
206
207 @beginWxPerlOnly
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.
212 @endWxPerlOnly
463b4bfa 213 */
3d8662ab 214 wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
463b4bfa
FM
215
216 /**
217 Loads the accelerator table from a Windows resource (Windows only).
3c4f71cc 218
d9faa1fe
FM
219 @onlyfor{wxmsw}
220
7c913512 221 @param resource
4cc4bfaf 222 Name of a Windows accelerator.
23324ae1 223 */
7c913512 224 wxAcceleratorTable(const wxString& resource);
23324ae1
FM
225
226 /**
227 Destroys the wxAcceleratorTable object.
463b4bfa 228 See @ref overview_refcount_destruct for more info.
23324ae1 229 */
8d483c9b 230 virtual ~wxAcceleratorTable();
23324ae1
FM
231
232 /**
233 Returns @true if the accelerator table is valid.
234 */
328f5751 235 bool IsOk() const;
23324ae1 236};
463b4bfa 237
39fb8056
FM
238
239// ============================================================================
240// Global functions/macros
241// ============================================================================
242
463b4bfa
FM
243/**
244 An empty accelerator table.
245*/
246wxAcceleratorTable wxNullAcceleratorTable;