]> git.saurik.com Git - wxWidgets.git/blame - interface/accel.h
removed wxAcceleratorTable copy ctor docs, no port implements it
[wxWidgets.git] / interface / accel.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: accel.h
463b4bfa 3// Purpose: interface of wxAccelerator* classes
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
463b4bfa
FM
9
10/** wxAcceleratorEntry flags */
11enum wxAcceleratorEntryFlags
12{
13 /** no modifiers */
14 wxACCEL_NORMAL,
15
16 /** hold Alt key down */
17 wxACCEL_ALT,
18
19 /** hold Ctrl key down */
20 wxACCEL_CTRL,
21
22 /** hold Shift key down */
23 wxACCEL_SHIFT,
24
25 /** Command key on OS X; identic to wxACCEL_CTRL on other platforms. */
26 wxACCEL_CMD
27};
28
29
23324ae1
FM
30/**
31 @class wxAcceleratorEntry
32 @wxheader{accel.h}
7c913512 33
463b4bfa
FM
34 An object used by an application wishing to create an accelerator table
35 (see wxAcceleratorTable).
7c913512 36
23324ae1 37 @library{wxcore}
3a65144e 38 @category{misc}
7c913512 39
3a65144e 40 @see wxAcceleratorTable, wxWindow::SetAcceleratorTable
23324ae1 41*/
7c913512 42class wxAcceleratorEntry
23324ae1
FM
43{
44public:
463b4bfa
FM
45 /**
46 Default ctor.
47 */
48 wxAcceleratorEntry();
49
23324ae1
FM
50 /**
51 Constructor.
463b4bfa 52
7c913512 53 @param flags
463b4bfa
FM
54 A combination of the wxAcceleratorEntryFlags values, which
55 indicates which modifier keys are held down.
7c913512 56 @param keyCode
463b4bfa 57 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
7c913512 58 @param cmd
4cc4bfaf 59 The menu or control command identifier.
23324ae1 60 */
7c913512 61 wxAcceleratorEntry(int flags, int keyCode, int cmd);
23324ae1
FM
62
63 /**
64 Returns the command identifier for the accelerator table entry.
65 */
328f5751 66 int GetCommand() const;
23324ae1
FM
67
68 /**
69 Returns the flags for the accelerator table entry.
70 */
328f5751 71 int GetFlags() const;
23324ae1
FM
72
73 /**
74 Returns the keycode for the accelerator table entry.
75 */
328f5751 76 int GetKeyCode() const;
23324ae1
FM
77
78 /**
79 Sets the accelerator entry parameters.
80
7c913512 81 @param flags
463b4bfa
FM
82 A combination of the wxAcceleratorEntryFlags values, which
83 indicates which modifier keys are held down.
7c913512 84 @param keyCode
463b4bfa 85 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
7c913512 86 @param cmd
4cc4bfaf 87 The menu or control command identifier.
463b4bfa 88
23324ae1 89 */
4cc4bfaf 90 void Set(int flags, int keyCode, int cmd);
23324ae1
FM
91};
92
93
94/**
95 @class wxAcceleratorTable
96 @wxheader{accel.h}
7c913512 97
23324ae1 98 An accelerator table allows the application to specify a table of keyboard
b1bb04c5 99 shortcuts for menu or button commands.
463b4bfa 100
3a65144e 101 The object ::wxNullAcceleratorTable is defined to be a table with no data, and
463b4bfa
FM
102 is the initial accelerator table for a window.
103
104 Example:
105
106 @code
107 wxAcceleratorEntry entries[4];
108 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
109 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
110 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
111 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
112
113 wxAcceleratorTable accel(4, entries);
114 frame->SetAcceleratorTable(accel);
115 @endcode
7c913512 116
463b4bfa
FM
117 @remarks
118 An accelerator takes precedence over normal processing and can be a convenient
119 way to program some event handling. For example, you can use an accelerator table
120 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
aa47271c 121 'OK'.
7c913512 122
23324ae1
FM
123 @library{wxcore}
124 @category{misc}
7c913512 125
23324ae1 126 @stdobjects
3a65144e 127 ::wxNullAcceleratorTable
7c913512 128
3a65144e 129 @see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
23324ae1
FM
130*/
131class wxAcceleratorTable : public wxObject
132{
133public:
23324ae1 134 /**
463b4bfa
FM
135 Default ctor.
136 */
137 wxAcceleratorTable();
138
463b4bfa
FM
139 /**
140 Initializes the accelerator table from an array of wxAcceleratorEntry.
23324ae1 141
7c913512 142 @param n
4cc4bfaf 143 Number of accelerator entries.
7c913512 144 @param entries
4cc4bfaf 145 The array of entries.
463b4bfa
FM
146 */
147 wxAcceleratorTable(int n, wxAcceleratorEntry entries[]);
148
149 /**
150 Loads the accelerator table from a Windows resource (Windows only).
151
7c913512 152 @param resource
4cc4bfaf 153 Name of a Windows accelerator.
23324ae1 154 */
7c913512 155 wxAcceleratorTable(const wxString& resource);
23324ae1
FM
156
157 /**
158 Destroys the wxAcceleratorTable object.
463b4bfa 159 See @ref overview_refcount_destruct for more info.
23324ae1
FM
160 */
161 ~wxAcceleratorTable();
162
163 /**
164 Returns @true if the accelerator table is valid.
165 */
328f5751 166 bool IsOk() const;
23324ae1
FM
167
168 /**
463b4bfa 169 Assignment operator, using @ref overview_refcount "reference counting".
23324ae1 170
7c913512 171 @param accel
4cc4bfaf 172 Accelerator table to assign.
23324ae1
FM
173 */
174 wxAcceleratorTable operator =(const wxAcceleratorTable& accel);
175};
463b4bfa 176
39fb8056
FM
177
178// ============================================================================
179// Global functions/macros
180// ============================================================================
181
463b4bfa
FM
182/**
183 An empty accelerator table.
184*/
185wxAcceleratorTable wxNullAcceleratorTable;