]> git.saurik.com Git - wxWidgets.git/blame - interface/accel.h
revised the first two interface headers
[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
FM
37 @library{wxcore}
38 @category{FIXME}
7c913512 39
23324ae1
FM
40 @seealso
41 wxAcceleratorTable, wxWindow::SetAcceleratorTable
42*/
7c913512 43class wxAcceleratorEntry
23324ae1
FM
44{
45public:
463b4bfa
FM
46 /**
47 Default ctor.
48 */
49 wxAcceleratorEntry();
50
23324ae1
FM
51 /**
52 Constructor.
463b4bfa 53
7c913512 54 @param flags
463b4bfa
FM
55 A combination of the wxAcceleratorEntryFlags values, which
56 indicates which modifier keys are held down.
7c913512 57 @param keyCode
463b4bfa 58 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
7c913512 59 @param cmd
4cc4bfaf 60 The menu or control command identifier.
23324ae1 61 */
7c913512 62 wxAcceleratorEntry(int flags, int keyCode, int cmd);
23324ae1
FM
63
64 /**
65 Returns the command identifier for the accelerator table entry.
66 */
328f5751 67 int GetCommand() const;
23324ae1
FM
68
69 /**
70 Returns the flags for the accelerator table entry.
71 */
328f5751 72 int GetFlags() const;
23324ae1
FM
73
74 /**
75 Returns the keycode for the accelerator table entry.
76 */
328f5751 77 int GetKeyCode() const;
23324ae1
FM
78
79 /**
80 Sets the accelerator entry parameters.
81
7c913512 82 @param flags
463b4bfa
FM
83 A combination of the wxAcceleratorEntryFlags values, which
84 indicates which modifier keys are held down.
7c913512 85 @param keyCode
463b4bfa 86 The keycode to be detected. See @ref page_keycodes for a full list of keycodes.
7c913512 87 @param cmd
4cc4bfaf 88 The menu or control command identifier.
463b4bfa 89
23324ae1 90 */
4cc4bfaf 91 void Set(int flags, int keyCode, int cmd);
23324ae1
FM
92};
93
94
95/**
96 @class wxAcceleratorTable
97 @wxheader{accel.h}
7c913512 98
23324ae1 99 An accelerator table allows the application to specify a table of keyboard
463b4bfa
FM
100 shortcuts for menus or other commands. On Windows and Mac OS X, menu or button
101 commands are supported; on GTK, only menu commands are supported.
102
103 The object #wxNullAcceleratorTable is defined to be a table with no data, and
104 is the initial accelerator table for a window.
105
106 Example:
107
108 @code
109 wxAcceleratorEntry entries[4];
110 entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
111 entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
112 entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
113 entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
114
115 wxAcceleratorTable accel(4, entries);
116 frame->SetAcceleratorTable(accel);
117 @endcode
7c913512 118
463b4bfa
FM
119 @remarks
120 An accelerator takes precedence over normal processing and can be a convenient
121 way to program some event handling. For example, you can use an accelerator table
122 to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
123 'OK' (but not in GTK+ at present).
7c913512 124
23324ae1
FM
125 @library{wxcore}
126 @category{misc}
7c913512 127
23324ae1 128 @stdobjects
23324ae1 129 wxNullAcceleratorTable
7c913512 130
23324ae1
FM
131 @seealso
132 wxAcceleratorEntry, wxWindow::SetAcceleratorTable
133*/
134class wxAcceleratorTable : public wxObject
135{
136public:
23324ae1 137 /**
463b4bfa
FM
138 Default ctor.
139 */
140 wxAcceleratorTable();
141
142 /**
143 Copy ctor.
144 */
145 wxAcceleratorTable(const wxAcceleratorTable& bitmap);
146
147 /**
148 Initializes the accelerator table from an array of wxAcceleratorEntry.
23324ae1 149
7c913512 150 @param n
4cc4bfaf 151 Number of accelerator entries.
7c913512 152 @param entries
4cc4bfaf 153 The array of entries.
463b4bfa
FM
154 */
155 wxAcceleratorTable(int n, wxAcceleratorEntry entries[]);
156
157 /**
158 Loads the accelerator table from a Windows resource (Windows only).
159
7c913512 160 @param resource
4cc4bfaf 161 Name of a Windows accelerator.
23324ae1 162 */
7c913512 163 wxAcceleratorTable(const wxString& resource);
23324ae1
FM
164 //@}
165
166 /**
167 Destroys the wxAcceleratorTable object.
463b4bfa 168 See @ref overview_refcount_destruct for more info.
23324ae1
FM
169 */
170 ~wxAcceleratorTable();
171
172 /**
173 Returns @true if the accelerator table is valid.
174 */
328f5751 175 bool IsOk() const;
23324ae1
FM
176
177 /**
463b4bfa 178 Assignment operator, using @ref overview_refcount "reference counting".
23324ae1 179
7c913512 180 @param accel
4cc4bfaf 181 Accelerator table to assign.
23324ae1
FM
182 */
183 wxAcceleratorTable operator =(const wxAcceleratorTable& accel);
184};
463b4bfa
FM
185
186/**
187 An empty accelerator table.
188*/
189wxAcceleratorTable wxNullAcceleratorTable;