]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: event.h | |
42013f4c FM |
3 | // Purpose: interface of wxEventHandler, wxEventBlocker and many |
4 | // wxEvent-derived classes | |
23324ae1 FM |
5 | // Author: wxWidgets team |
6 | // RCS-ID: $Id$ | |
7 | // Licence: wxWindows license | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
7c913512 | 10 | |
7c913512 | 11 | |
42013f4c FM |
12 | /** |
13 | @class wxEvent | |
14 | @wxheader{event.h} | |
7c913512 | 15 | |
42013f4c FM |
16 | An event is a structure holding information about an event passed to a |
17 | callback or member function. | |
1f1d2182 | 18 | |
42013f4c FM |
19 | wxEvent used to be a multipurpose event object, and is an abstract base class |
20 | for other event classes (see below). | |
1f1d2182 | 21 | |
42013f4c | 22 | For more information about events, see the @ref overview_eventhandling overview. |
1f1d2182 | 23 | |
42013f4c FM |
24 | @beginWxPerlOnly |
25 | In wxPerl custom event classes should be derived from | |
26 | @c Wx::PlEvent and @c Wx::PlCommandEvent. | |
27 | @endWxPerlOnly | |
1f1d2182 | 28 | |
42013f4c | 29 | @library{wxbase} |
23324ae1 | 30 | @category{events} |
42013f4c FM |
31 | |
32 | @see wxCommandEvent, wxMouseEvent | |
23324ae1 | 33 | */ |
42013f4c | 34 | class wxEvent : public wxObject |
23324ae1 FM |
35 | { |
36 | public: | |
37 | /** | |
42013f4c | 38 | Constructor. Should not need to be used directly by an application. |
23324ae1 | 39 | */ |
42013f4c | 40 | wxEvent(int id = 0, wxEventType eventType = wxEVT_NULL); |
23324ae1 FM |
41 | |
42 | /** | |
42013f4c | 43 | Returns a copy of the event. |
1f1d2182 | 44 | |
c3f94162 VZ |
45 | Any event that is posted to the wxWidgets event system for later action |
46 | (via wxEvtHandler::AddPendingEvent or wxPostEvent()) must implement | |
47 | this method. | |
42013f4c FM |
48 | |
49 | All wxWidgets events fully implement this method, but any derived events | |
50 | implemented by the user should also implement this method just in case they | |
51 | (or some event derived from them) are ever posted. | |
52 | ||
53 | All wxWidgets events implement a copy constructor, so the easiest way of | |
54 | implementing the Clone function is to implement a copy constructor for | |
55 | a new event (call it MyEvent) and then define the Clone function like this: | |
56 | ||
57 | @code | |
58 | wxEvent *Clone() const { return new MyEvent(*this); } | |
59 | @endcode | |
23324ae1 | 60 | */ |
42013f4c | 61 | virtual wxEvent* Clone() const = 0; |
23324ae1 FM |
62 | |
63 | /** | |
42013f4c | 64 | Returns the object (usually a window) associated with the event, if any. |
23324ae1 | 65 | */ |
42013f4c | 66 | wxObject* GetEventObject() const; |
23324ae1 FM |
67 | |
68 | /** | |
42013f4c | 69 | Returns the identifier of the given event type, such as @c wxEVT_COMMAND_BUTTON_CLICKED. |
23324ae1 | 70 | */ |
42013f4c | 71 | wxEventType GetEventType() const; |
23324ae1 FM |
72 | |
73 | /** | |
42013f4c | 74 | Returns the identifier associated with this event, such as a button command id. |
23324ae1 | 75 | */ |
42013f4c | 76 | int GetId() const; |
23324ae1 FM |
77 | |
78 | /** | |
42013f4c | 79 | Returns @true if the event handler should be skipped, @false otherwise. |
23324ae1 | 80 | */ |
42013f4c | 81 | bool GetSkipped() const; |
23324ae1 | 82 | |
23324ae1 | 83 | /** |
42013f4c FM |
84 | Gets the timestamp for the event. The timestamp is the time in milliseconds |
85 | since some fixed moment (not necessarily the standard Unix Epoch, so only | |
86 | differences between the timestamps and not their absolute values usually make sense). | |
23324ae1 | 87 | */ |
42013f4c | 88 | long GetTimestamp() const; |
23324ae1 FM |
89 | |
90 | /** | |
42013f4c | 91 | Returns @true if the event is or is derived from wxCommandEvent else it returns @false. |
1f1d2182 | 92 | |
42013f4c | 93 | @note exists only for optimization purposes. |
23324ae1 | 94 | */ |
42013f4c | 95 | bool IsCommandEvent() const; |
23324ae1 FM |
96 | |
97 | /** | |
42013f4c FM |
98 | Sets the propagation level to the given value (for example returned from an |
99 | earlier call to wxEvent::StopPropagation). | |
100 | */ | |
101 | void ResumePropagation(int propagationLevel); | |
1f1d2182 | 102 | |
42013f4c FM |
103 | /** |
104 | Sets the originating object. | |
23324ae1 | 105 | */ |
42013f4c | 106 | void SetEventObject(wxObject* object); |
23324ae1 FM |
107 | |
108 | /** | |
42013f4c FM |
109 | Sets the event type. |
110 | */ | |
111 | void SetEventType(wxEventType type); | |
1f1d2182 | 112 | |
42013f4c FM |
113 | /** |
114 | Sets the identifier associated with this event, such as a button command id. | |
23324ae1 | 115 | */ |
42013f4c | 116 | void SetId(int id); |
23324ae1 FM |
117 | |
118 | /** | |
42013f4c | 119 | Sets the timestamp for the event. |
23324ae1 | 120 | */ |
42013f4c | 121 | void SetTimestamp(long = 0); |
23324ae1 FM |
122 | |
123 | /** | |
42013f4c FM |
124 | Test if this event should be propagated or not, i.e. if the propagation level |
125 | is currently greater than 0. | |
23324ae1 | 126 | */ |
42013f4c | 127 | bool ShouldPropagate() const; |
23324ae1 FM |
128 | |
129 | /** | |
42013f4c FM |
130 | This method can be used inside an event handler to control whether further |
131 | event handlers bound to this event will be called after the current one returns. | |
1f1d2182 | 132 | |
42013f4c FM |
133 | Without Skip() (or equivalently if Skip(@false) is used), the event will not |
134 | be processed any more. If Skip(@true) is called, the event processing system | |
135 | continues searching for a further handler function for this event, even though | |
136 | it has been processed already in the current handler. | |
137 | ||
138 | In general, it is recommended to skip all non-command events to allow the | |
139 | default handling to take place. The command events are, however, normally not | |
140 | skipped as usually a single command such as a button click or menu item | |
141 | selection must only be processed by one handler. | |
23324ae1 | 142 | */ |
42013f4c | 143 | void Skip(bool skip = true); |
23324ae1 FM |
144 | |
145 | /** | |
42013f4c | 146 | Stop the event from propagating to its parent window. |
1f1d2182 | 147 | |
42013f4c FM |
148 | Returns the old propagation level value which may be later passed to |
149 | ResumePropagation() to allow propagating the event again. | |
23324ae1 | 150 | */ |
42013f4c | 151 | int StopPropagation(); |
23324ae1 | 152 | |
42013f4c | 153 | protected: |
23324ae1 | 154 | /** |
42013f4c | 155 | Indicates how many levels the event can propagate. |
23324ae1 | 156 | |
42013f4c FM |
157 | This member is protected and should typically only be set in the constructors |
158 | of the derived classes. It may be temporarily changed by StopPropagation() | |
159 | and ResumePropagation() and tested with ShouldPropagate(). | |
23324ae1 | 160 | |
42013f4c FM |
161 | The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default) |
162 | meaning that the event shouldn't be propagated at all or to | |
163 | @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be | |
164 | propagated as much as necessary. | |
23324ae1 | 165 | |
42013f4c FM |
166 | Any positive number means that the event should be propagated but no more than |
167 | the given number of times. E.g. the propagation level may be set to 1 to | |
168 | propagate the event to its parent only, but not to its grandparent. | |
169 | */ | |
170 | int m_propagationLevel; | |
171 | }; | |
e54c96f1 | 172 | |
23324ae1 | 173 | /** |
42013f4c | 174 | @class wxEventBlocker |
23324ae1 | 175 | @wxheader{event.h} |
7c913512 | 176 | |
42013f4c FM |
177 | This class is a special event handler which allows to discard |
178 | any event (or a set of event types) directed to a specific window. | |
7c913512 | 179 | |
42013f4c FM |
180 | Example: |
181 | ||
182 | @code | |
183 | void MyWindow::DoSomething() | |
184 | { | |
185 | { | |
186 | // block all events directed to this window while | |
187 | // we do the 1000 FunctionWhichSendsEvents() calls | |
188 | wxEventBlocker blocker(this); | |
189 | ||
190 | for ( int i = 0; i 1000; i++ ) | |
191 | FunctionWhichSendsEvents(i); | |
192 | ||
193 | } // ~wxEventBlocker called, old event handler is restored | |
194 | ||
195 | // the event generated by this call will be processed: | |
196 | FunctionWhichSendsEvents(0) | |
197 | } | |
198 | @endcode | |
1f1d2182 | 199 | |
23324ae1 FM |
200 | @library{wxcore} |
201 | @category{events} | |
7c913512 | 202 | |
42013f4c | 203 | @see @ref overview_eventhandling, wxEvtHandler |
23324ae1 | 204 | */ |
42013f4c | 205 | class wxEventBlocker : public wxEvtHandler |
23324ae1 FM |
206 | { |
207 | public: | |
208 | /** | |
42013f4c | 209 | Constructs the blocker for the given window and for the given event type. |
23324ae1 | 210 | |
42013f4c FM |
211 | If @a type is @c wxEVT_ANY, then all events for that window are blocked. |
212 | You can call Block() after creation to add other event types to the list | |
213 | of events to block. | |
3c4f71cc | 214 | |
42013f4c FM |
215 | Note that the @a win window @b must remain alive until the |
216 | wxEventBlocker object destruction. | |
23324ae1 | 217 | */ |
42013f4c | 218 | wxEventBlocker(wxWindow* win, wxEventType = wxEVT_ANY); |
23324ae1 FM |
219 | |
220 | /** | |
42013f4c FM |
221 | Destructor. The blocker will remove itself from the chain of event handlers for |
222 | the window provided in the constructor, thus restoring normal processing of events. | |
23324ae1 | 223 | */ |
42013f4c | 224 | virtual ~wxEventBlocker(); |
23324ae1 FM |
225 | |
226 | /** | |
42013f4c | 227 | Adds to the list of event types which should be blocked the given @a eventType. |
23324ae1 | 228 | */ |
42013f4c FM |
229 | void Block(wxEventType eventType); |
230 | }; | |
23324ae1 | 231 | |
1f1d2182 | 232 | |
42013f4c FM |
233 | |
234 | /** | |
235 | @class wxEvtHandler | |
236 | @wxheader{event.h} | |
237 | ||
238 | A class that can handle events from the windowing system. | |
239 | wxWindow (and therefore all window classes) are derived from this class. | |
240 | ||
241 | When events are received, wxEvtHandler invokes the method listed in the | |
242 | event table using itself as the object. When using multiple inheritance | |
243 | it is imperative that the wxEvtHandler(-derived) class be the first | |
244 | class inherited such that the "this" pointer for the overall object | |
245 | will be identical to the "this" pointer for the wxEvtHandler portion. | |
246 | ||
247 | @library{wxbase} | |
248 | @category{events} | |
249 | ||
250 | @see @ref overview_eventhandling | |
251 | */ | |
252 | class wxEvtHandler : public wxObject | |
253 | { | |
254 | public: | |
255 | /** | |
256 | Constructor. | |
23324ae1 | 257 | */ |
42013f4c | 258 | wxEvtHandler(); |
23324ae1 FM |
259 | |
260 | /** | |
42013f4c | 261 | Destructor. |
1f1d2182 | 262 | |
42013f4c FM |
263 | If the handler is part of a chain, the destructor will unlink itself and |
264 | restore the previous and next handlers so that they point to each other. | |
23324ae1 | 265 | */ |
42013f4c | 266 | virtual ~wxEvtHandler(); |
23324ae1 FM |
267 | |
268 | /** | |
c3f94162 VZ |
269 | Queue event for a later processing. |
270 | ||
271 | This method is similar to ProcessEvent() but while the latter is | |
272 | synchronous, i.e. the event is processed immediately, before the | |
273 | function returns, this one is asynchronous and returns immediately | |
274 | while the event will be processed at some later time (usually during | |
275 | the next event loop iteration). | |
276 | ||
277 | Another important difference is that this method takes ownership of the | |
278 | @a event parameter, i.e. it will delete it itself. This implies that | |
279 | the event should be allocated on the heap and that the pointer can't be | |
280 | used any more after the function returns (as it can be deleted at any | |
281 | moment). | |
282 | ||
283 | QueueEvent() can be used for inter-thread communication from the worker | |
284 | threads to the main thread, it is safe in the sense that it uses | |
285 | locking internally and avoids the problem mentioned in AddPendingEvent() | |
286 | documentation by ensuring that the @a event object is not used by the | |
287 | calling thread any more. Care should still be taken to avoid that some | |
288 | fields of this object are used by it, notably any wxString members of | |
289 | the event object must not be shallow copies of another wxString object | |
290 | as this would result in them still using the same string buffer behind | |
291 | the scenes. For example | |
292 | @code | |
293 | void FunctionInAWorkerThread(const wxString& str) | |
294 | { | |
36a2d2c4 | 295 | wxCommandEvent* evt = new wxCommandEvent; |
42013f4c | 296 | |
36a2d2c4 RR |
297 | // NOT evt->SetString(str) as this would be a shallow copy |
298 | evt->SetString(str.c_str()); // make a deep copy | |
42013f4c | 299 | |
36a2d2c4 | 300 | wxTheApp->QueueEvent( evt ); |
c3f94162 VZ |
301 | } |
302 | @endcode | |
42013f4c | 303 | |
c3f94162 VZ |
304 | Finally notice that this method automatically wakes up the event loop |
305 | if it is currently idle by calling ::wxWakeUpIdle() so there is no need | |
306 | to do it manually when using it. | |
42013f4c | 307 | |
c3f94162 | 308 | @since 2.9.0 |
42013f4c FM |
309 | |
310 | @param event | |
c3f94162 VZ |
311 | A heap-allocated event to be queued, QueueEvent() takes ownership |
312 | of it. This parameter shouldn't be @c NULL. | |
313 | */ | |
314 | virtual void QueueEvent(wxEvent *event); | |
315 | ||
316 | /** | |
317 | Post an event to be processed later. | |
318 | ||
319 | This function is similar to QueueEvent() but can't be used to post | |
320 | events from worker threads for the event objects with wxString fields | |
321 | (i.e. in practice most of them) because of an unsafe use of the same | |
322 | wxString object which happens because the wxString field in the | |
323 | original @a event object and its copy made internally by this function | |
324 | share the same string buffer internally. Use QueueEvent() to avoid | |
325 | this. | |
326 | ||
327 | A copy of event is made by the function, so the original can be deleted | |
328 | as soon as function returns (it is common that the original is created | |
329 | on the stack). This requires that the wxEvent::Clone() method be | |
330 | implemented by event so that it can be duplicated and stored until it | |
331 | gets processed. | |
332 | ||
333 | @param event | |
334 | Event to add to the pending events queue. | |
23324ae1 | 335 | */ |
42013f4c | 336 | virtual void AddPendingEvent(const wxEvent& event); |
23324ae1 FM |
337 | |
338 | /** | |
42013f4c FM |
339 | Connects the given function dynamically with the event handler, id and event type. |
340 | This is an alternative to the use of static event tables. | |
341 | ||
342 | See the @ref page_samples_event sample for usage. | |
343 | ||
344 | This specific overload allows you to connect an event handler to a @e range | |
345 | of @e source IDs. | |
346 | Do not confuse @e source IDs with event @e types: source IDs identify the | |
347 | event generator objects (typically wxMenuItem or wxWindow objects) while the | |
348 | event @e type identify which type of events should be handled by the | |
349 | given @e function (an event generator object may generate many different | |
350 | types of events!). | |
351 | ||
352 | @param id | |
353 | The first ID of the identifier range to be associated with the event | |
354 | handler function. | |
355 | @param lastId | |
356 | The last ID of the identifier range to be associated with the event | |
357 | handler function. | |
358 | @param eventType | |
359 | The event type to be associated with this event handler. | |
360 | @param function | |
361 | The event handler function. Note that this function should | |
362 | be explicitly converted to the correct type which can be done using a macro | |
363 | called @c wxFooEventHandler for the handler for any @c wxFooEvent. | |
364 | @param userData | |
365 | Data to be associated with the event table entry. | |
366 | @param eventSink | |
367 | Object whose member function should be called. | |
368 | If this is @NULL, @c *this will be used. | |
23324ae1 | 369 | */ |
42013f4c FM |
370 | void Connect(int id, int lastId, wxEventType eventType, |
371 | wxObjectEventFunction function, | |
372 | wxObject* userData = NULL, | |
373 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
374 | |
375 | /** | |
42013f4c FM |
376 | See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) |
377 | overload for more info. | |
378 | ||
379 | This overload can be used to attach an event handler to a single source ID: | |
380 | ||
381 | Example: | |
382 | @code | |
383 | frame->Connect( wxID_EXIT, | |
384 | wxEVT_COMMAND_MENU_SELECTED, | |
385 | wxCommandEventHandler(MyFrame::OnQuit) ); | |
386 | @endcode | |
23324ae1 | 387 | */ |
42013f4c FM |
388 | void Connect(int id, wxEventType eventType, |
389 | wxObjectEventFunction function, | |
390 | wxObject* userData = NULL, | |
391 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
392 | |
393 | /** | |
42013f4c FM |
394 | See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) |
395 | overload for more info. | |
396 | ||
397 | This overload will connect the given event handler so that regardless of the | |
398 | ID of the event source, the handler will be called. | |
23324ae1 | 399 | */ |
42013f4c FM |
400 | void Connect(wxEventType eventType, |
401 | wxObjectEventFunction function, | |
402 | wxObject* userData = NULL, | |
403 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
404 | |
405 | /** | |
42013f4c FM |
406 | Disconnects the given function dynamically from the event handler, using the |
407 | specified parameters as search criteria and returning @true if a matching | |
408 | function has been found and removed. | |
409 | ||
410 | This method can only disconnect functions which have been added using the | |
411 | Connect() method. There is no way to disconnect functions connected using | |
412 | the (static) event tables. | |
413 | ||
414 | @param eventType | |
415 | The event type associated with this event handler. | |
416 | @param function | |
417 | The event handler function. | |
418 | @param userData | |
419 | Data associated with the event table entry. | |
420 | @param eventSink | |
421 | Object whose member function should be called. | |
23324ae1 | 422 | */ |
42013f4c FM |
423 | bool Disconnect(wxEventType eventType = wxEVT_NULL, |
424 | wxObjectEventFunction function = NULL, | |
425 | wxObject* userData = NULL, | |
426 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
427 | |
428 | /** | |
42013f4c FM |
429 | See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) |
430 | overload for more info. | |
23324ae1 | 431 | |
42013f4c FM |
432 | This overload takes the additional @a id parameter. |
433 | */ | |
434 | bool Disconnect(int id = wxID_ANY, | |
435 | wxEventType eventType = wxEVT_NULL, | |
436 | wxObjectEventFunction function = NULL, | |
437 | wxObject* userData = NULL, | |
438 | wxEvtHandler* eventSink = NULL); | |
23324ae1 | 439 | |
42013f4c FM |
440 | /** |
441 | See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) | |
442 | overload for more info. | |
e54c96f1 | 443 | |
42013f4c FM |
444 | This overload takes an additional range of source IDs. |
445 | */ | |
446 | bool Disconnect(int id, int lastId = wxID_ANY, | |
447 | wxEventType eventType = wxEVT_NULL, | |
448 | wxObjectEventFunction function = NULL, | |
449 | wxObject* userData = NULL, | |
450 | wxEvtHandler* eventSink = NULL); | |
7c913512 | 451 | |
42013f4c FM |
452 | /** |
453 | Returns user-supplied client data. | |
7c913512 | 454 | |
42013f4c FM |
455 | @remarks Normally, any extra data the programmer wishes to associate with |
456 | the object should be made available by deriving a new class with | |
457 | new data members. | |
1f1d2182 | 458 | |
42013f4c FM |
459 | @see SetClientData() |
460 | */ | |
461 | void* GetClientData() const; | |
1f1d2182 | 462 | |
42013f4c FM |
463 | /** |
464 | Returns a pointer to the user-supplied client data object. | |
1f1d2182 | 465 | |
42013f4c FM |
466 | @see SetClientObject(), wxClientData |
467 | */ | |
468 | wxClientData* GetClientObject() const; | |
7c913512 | 469 | |
23324ae1 | 470 | /** |
42013f4c FM |
471 | Returns @true if the event handler is enabled, @false otherwise. |
472 | ||
473 | @see SetEvtHandlerEnabled() | |
23324ae1 | 474 | */ |
42013f4c | 475 | bool GetEvtHandlerEnabled() const; |
23324ae1 FM |
476 | |
477 | /** | |
42013f4c | 478 | Returns the pointer to the next handler in the chain. |
1f1d2182 | 479 | |
42013f4c FM |
480 | @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(), |
481 | wxWindow::PushEventHandler, wxWindow::PopEventHandler | |
23324ae1 | 482 | */ |
42013f4c | 483 | wxEvtHandler* GetNextHandler() const; |
23324ae1 FM |
484 | |
485 | /** | |
42013f4c | 486 | Returns the pointer to the previous handler in the chain. |
1f1d2182 | 487 | |
42013f4c FM |
488 | @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(), |
489 | wxWindow::PushEventHandler, wxWindow::PopEventHandler | |
23324ae1 | 490 | */ |
42013f4c | 491 | wxEvtHandler* GetPreviousHandler() const; |
23324ae1 | 492 | |
42013f4c FM |
493 | /** |
494 | Processes an event, searching event tables and calling zero or more suitable | |
495 | event handler function(s). | |
23324ae1 | 496 | |
42013f4c FM |
497 | Normally, your application would not call this function: it is called in the |
498 | wxWidgets implementation to dispatch incoming user interface events to the | |
499 | framework (and application). | |
500 | ||
501 | However, you might need to call it if implementing new functionality | |
502 | (such as a new control) where you define new event types, as opposed to | |
503 | allowing the user to override virtual functions. | |
504 | ||
505 | An instance where you might actually override the ProcessEvent function is where | |
506 | you want to direct event processing to event handlers not normally noticed by | |
507 | wxWidgets. For example, in the document/view architecture, documents and views | |
508 | are potential event handlers. When an event reaches a frame, ProcessEvent will | |
509 | need to be called on the associated document and view in case event handler functions | |
510 | are associated with these objects. The property classes library (wxProperty) also | |
511 | overrides ProcessEvent for similar reasons. | |
512 | ||
513 | The normal order of event table searching is as follows: | |
514 | -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled) | |
515 | the function skips to step (6). | |
516 | -# If the object is a wxWindow, ProcessEvent() is recursively called on the | |
517 | window's wxValidator. If this returns @true, the function exits. | |
518 | -# SearchEventTable() is called for this event handler. If this fails, the base | |
519 | class table is tried, and so on until no more tables exist or an appropriate | |
520 | function was found, in which case the function exits. | |
521 | -# The search is applied down the entire chain of event handlers (usually the | |
522 | chain has a length of one). If this succeeds, the function exits. | |
523 | -# If the object is a wxWindow and the event is a wxCommandEvent, ProcessEvent() | |
524 | is recursively applied to the parent window's event handler. | |
525 | If this returns true, the function exits. | |
526 | -# Finally, ProcessEvent() is called on the wxApp object. | |
e54c96f1 | 527 | |
42013f4c FM |
528 | @param event |
529 | Event to process. | |
7c913512 | 530 | |
d29a9a8a | 531 | @return @true if a suitable event handler function was found and |
42013f4c | 532 | executed, and the function did not call wxEvent::Skip. |
7c913512 | 533 | |
42013f4c FM |
534 | @see SearchEventTable() |
535 | */ | |
536 | virtual bool ProcessEvent(wxEvent& event); | |
1f1d2182 | 537 | |
42013f4c FM |
538 | /** |
539 | Processes an event by calling ProcessEvent() and handles any exceptions | |
540 | that occur in the process. | |
541 | If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called. | |
1f1d2182 | 542 | |
42013f4c FM |
543 | @param event |
544 | Event to process. | |
7c913512 | 545 | |
d29a9a8a | 546 | @return @true if the event was processed, @false if no handler was found |
42013f4c FM |
547 | or an exception was thrown. |
548 | ||
549 | @see wxWindow::HandleWindowEvent | |
23324ae1 | 550 | */ |
42013f4c | 551 | bool SafelyProcessEvent(wxEvent& event); |
23324ae1 | 552 | |
42013f4c FM |
553 | /** |
554 | Searches the event table, executing an event handler function if an appropriate | |
555 | one is found. | |
23324ae1 | 556 | |
42013f4c FM |
557 | @param table |
558 | Event table to be searched. | |
559 | @param event | |
560 | Event to be matched against an event table entry. | |
e54c96f1 | 561 | |
d29a9a8a | 562 | @return @true if a suitable event handler function was found and |
42013f4c | 563 | executed, and the function did not call wxEvent::Skip. |
7c913512 | 564 | |
42013f4c FM |
565 | @remarks This function looks through the object's event table and tries |
566 | to find an entry that will match the event. | |
567 | An entry will match if: | |
568 | @li The event type matches, and | |
569 | @li the identifier or identifier range matches, or the event table | |
570 | entry's identifier is zero. | |
571 | If a suitable function is called but calls wxEvent::Skip, this | |
572 | function will fail, and searching will continue. | |
1f1d2182 | 573 | |
42013f4c FM |
574 | @see ProcessEvent() |
575 | */ | |
576 | virtual bool SearchEventTable(wxEventTable& table, | |
577 | wxEvent& event); | |
7c913512 | 578 | |
42013f4c FM |
579 | /** |
580 | Sets user-supplied client data. | |
1f1d2182 | 581 | |
42013f4c FM |
582 | @param data |
583 | Data to be associated with the event handler. | |
584 | ||
585 | @remarks Normally, any extra data the programmer wishes to associate | |
586 | with the object should be made available by deriving a new | |
587 | class with new data members. You must not call this method | |
588 | and SetClientObject on the same class - only one of them. | |
589 | ||
590 | @see GetClientData() | |
591 | */ | |
592 | void SetClientData(void* data); | |
7c913512 | 593 | |
23324ae1 | 594 | /** |
42013f4c FM |
595 | Set the client data object. Any previous object will be deleted. |
596 | ||
597 | @see GetClientObject(), wxClientData | |
23324ae1 | 598 | */ |
42013f4c FM |
599 | void SetClientObject(wxClientData* data); |
600 | ||
601 | /** | |
602 | Enables or disables the event handler. | |
603 | ||
604 | @param enabled | |
605 | @true if the event handler is to be enabled, @false if it is to be disabled. | |
606 | ||
607 | @remarks You can use this function to avoid having to remove the event | |
608 | handler from the chain, for example when implementing a | |
609 | dialog editor and changing from edit to test mode. | |
610 | ||
611 | @see GetEvtHandlerEnabled() | |
612 | */ | |
613 | void SetEvtHandlerEnabled(bool enabled); | |
23324ae1 | 614 | |
42013f4c FM |
615 | /** |
616 | Sets the pointer to the next handler. | |
617 | ||
618 | @param handler | |
619 | Event handler to be set as the next handler. | |
620 | ||
621 | @see GetNextHandler(), SetPreviousHandler(), GetPreviousHandler(), | |
622 | wxWindow::PushEventHandler, wxWindow::PopEventHandler | |
623 | */ | |
624 | void SetNextHandler(wxEvtHandler* handler); | |
625 | ||
626 | /** | |
627 | Sets the pointer to the previous handler. | |
628 | ||
629 | @param handler | |
630 | Event handler to be set as the previous handler. | |
631 | */ | |
632 | void SetPreviousHandler(wxEvtHandler* handler); | |
633 | }; | |
23324ae1 | 634 | |
e54c96f1 | 635 | |
23324ae1 | 636 | /** |
42013f4c | 637 | @class wxKeyEvent |
23324ae1 | 638 | @wxheader{event.h} |
7c913512 | 639 | |
42013f4c | 640 | This event class contains information about keypress (character) events. |
7c913512 | 641 | |
42013f4c FM |
642 | Notice that there are three different kinds of keyboard events in wxWidgets: |
643 | key down and up events and char events. The difference between the first two | |
644 | is clear - the first corresponds to a key press and the second to a key | |
645 | release - otherwise they are identical. Just note that if the key is | |
646 | maintained in a pressed state you will typically get a lot of (automatically | |
647 | generated) down events but only one up so it is wrong to assume that there is | |
648 | one up event corresponding to each down one. | |
1f1d2182 | 649 | |
42013f4c FM |
650 | Both key events provide untranslated key codes while the char event carries |
651 | the translated one. The untranslated code for alphanumeric keys is always | |
652 | an upper case value. For the other keys it is one of @c WXK_XXX values | |
653 | from the @ref page_keycodes. | |
654 | The translated key is, in general, the character the user expects to appear | |
655 | as the result of the key combination when typing the text into a text entry | |
656 | zone, for example. | |
1f1d2182 | 657 | |
42013f4c FM |
658 | A few examples to clarify this (all assume that CAPS LOCK is unpressed |
659 | and the standard US keyboard): when the @c 'A' key is pressed, the key down | |
660 | event key code is equal to @c ASCII A == 65. But the char event key code | |
661 | is @c ASCII a == 97. On the other hand, if you press both SHIFT and | |
662 | @c 'A' keys simultaneously , the key code in key down event will still be | |
663 | just @c 'A' while the char event key code parameter will now be @c 'A' | |
664 | as well. | |
1f1d2182 | 665 | |
42013f4c FM |
666 | Although in this simple case it is clear that the correct key code could be |
667 | found in the key down event handler by checking the value returned by | |
668 | wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as | |
669 | for non-alphanumeric keys the translation is keyboard-layout dependent and | |
670 | can only be done properly by the system itself. | |
1f1d2182 | 671 | |
42013f4c FM |
672 | Another kind of translation is done when the control key is pressed: for |
673 | example, for CTRL-A key press the key down event still carries the | |
674 | same key code @c 'a' as usual but the char event will have key code of 1, | |
675 | the ASCII value of this key combination. | |
1f1d2182 | 676 | |
42013f4c FM |
677 | You may discover how the other keys on your system behave interactively by |
678 | running the @ref page_samples_text wxWidgets sample and pressing some keys | |
679 | in any of the text controls shown in it. | |
1f1d2182 | 680 | |
42013f4c FM |
681 | @b Tip: be sure to call @c event.Skip() for events that you don't process in |
682 | key event function, otherwise menu shortcuts may cease to work under Windows. | |
1f1d2182 | 683 | |
42013f4c FM |
684 | @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler |
685 | does not call @c event.Skip() then the corresponding char event | |
686 | (@c EVT_CHAR) will not happen. | |
687 | This is by design and enables the programs that handle both types of | |
688 | events to be a bit simpler. | |
1f1d2182 | 689 | |
42013f4c FM |
690 | @note For Windows programmers: The key and char events in wxWidgets are |
691 | similar to but slightly different from Windows @c WM_KEYDOWN and | |
692 | @c WM_CHAR events. In particular, Alt-x combination will generate a | |
693 | char event in wxWidgets (unless it is used as an accelerator). | |
1f1d2182 FM |
694 | |
695 | ||
42013f4c | 696 | @beginEventTable{wxKeyEvent} |
8c6791e4 | 697 | @event{EVT_KEY_DOWN(func)} |
42013f4c | 698 | Process a wxEVT_KEY_DOWN event (any key has been pressed). |
8c6791e4 | 699 | @event{EVT_KEY_UP(func)} |
42013f4c | 700 | Process a wxEVT_KEY_UP event (any key has been released). |
8c6791e4 | 701 | @event{EVT_CHAR(func)} |
42013f4c | 702 | Process a wxEVT_CHAR event. |
1f1d2182 | 703 | @endEventTable |
7c913512 | 704 | |
23324ae1 FM |
705 | @library{wxcore} |
706 | @category{events} | |
23324ae1 | 707 | */ |
42013f4c | 708 | class wxKeyEvent : public wxEvent |
23324ae1 FM |
709 | { |
710 | public: | |
711 | /** | |
712 | Constructor. | |
42013f4c | 713 | Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK. |
23324ae1 | 714 | */ |
42013f4c | 715 | wxKeyEvent(wxEventType keyEventType = wxEVT_NULL); |
23324ae1 | 716 | |
42013f4c FM |
717 | /** |
718 | Returns @true if the Alt key was down at the time of the key event. | |
23324ae1 | 719 | |
42013f4c FM |
720 | Notice that GetModifiers() is easier to use correctly than this function |
721 | so you should consider using it in new code. | |
722 | */ | |
723 | bool AltDown() const; | |
e54c96f1 | 724 | |
42013f4c FM |
725 | /** |
726 | CMD is a pseudo key which is the same as Control for PC and Unix | |
727 | platforms but the special APPLE (a.k.a as COMMAND) key under Macs: | |
728 | it makes often sense to use it instead of, say, ControlDown() because Cmd | |
729 | key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still | |
730 | exists, just not used for this purpose under Mac). So for non-Mac platforms | |
731 | this is the same as ControlDown() and under Mac this is the same as MetaDown(). | |
732 | */ | |
733 | bool CmdDown() const; | |
7c913512 | 734 | |
42013f4c FM |
735 | /** |
736 | Returns @true if the control key was down at the time of the key event. | |
1f1d2182 | 737 | |
42013f4c FM |
738 | Notice that GetModifiers() is easier to use correctly than this function |
739 | so you should consider using it in new code. | |
740 | */ | |
741 | bool ControlDown() const; | |
7c913512 | 742 | |
42013f4c FM |
743 | /** |
744 | Returns the virtual key code. ASCII events return normal ASCII values, | |
745 | while non-ASCII events return values such as @b WXK_LEFT for the left cursor | |
746 | key. See @ref page_keycodes for a full list of the virtual key codes. | |
747 | ||
748 | Note that in Unicode build, the returned value is meaningful only if the | |
749 | user entered a character that can be represented in current locale's default | |
750 | charset. You can obtain the corresponding Unicode character using GetUnicodeKey(). | |
751 | */ | |
752 | int GetKeyCode() const; | |
753 | ||
754 | /** | |
755 | Return the bitmask of modifier keys which were pressed when this event | |
756 | happened. See @ref page_keymodifiers for the full list of modifiers. | |
757 | ||
758 | Notice that this function is easier to use correctly than, for example, | |
759 | ControlDown() because when using the latter you also have to remember to | |
760 | test that none of the other modifiers is pressed: | |
761 | ||
762 | @code | |
763 | if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() ) | |
764 | ... handle Ctrl-XXX ... | |
765 | @endcode | |
766 | ||
767 | and forgetting to do it can result in serious program bugs (e.g. program | |
768 | not working with European keyboard layout where ALTGR key which is seen by | |
769 | the program as combination of CTRL and ALT is used). On the other hand, | |
770 | you can simply write: | |
771 | ||
772 | @code | |
773 | if ( GetModifiers() == wxMOD_CONTROL ) | |
774 | ... handle Ctrl-XXX ... | |
775 | @endcode | |
776 | ||
777 | with this function. | |
778 | */ | |
779 | int GetModifiers() const; | |
780 | ||
781 | //@{ | |
782 | /** | |
783 | Obtains the position (in client coordinates) at which the key was pressed. | |
784 | */ | |
785 | wxPoint GetPosition() const; | |
786 | void GetPosition(long* x, long* y) const; | |
787 | //@} | |
788 | ||
789 | /** | |
790 | Returns the raw key code for this event. This is a platform-dependent scan code | |
791 | which should only be used in advanced applications. | |
792 | ||
793 | @note Currently the raw key codes are not supported by all ports, use | |
794 | @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available. | |
795 | */ | |
796 | wxUint32 GetRawKeyCode() const; | |
797 | ||
798 | /** | |
799 | Returns the low level key flags for this event. The flags are | |
800 | platform-dependent and should only be used in advanced applications. | |
801 | ||
802 | @note Currently the raw key flags are not supported by all ports, use | |
803 | @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available. | |
804 | */ | |
805 | wxUint32 GetRawKeyFlags() const; | |
806 | ||
807 | /** | |
808 | Returns the Unicode character corresponding to this key event. | |
809 | ||
810 | This function is only available in Unicode build, i.e. when | |
811 | @c wxUSE_UNICODE is 1. | |
812 | */ | |
813 | wxChar GetUnicodeKey() const; | |
814 | ||
815 | /** | |
816 | Returns the X position (in client coordinates) of the event. | |
817 | */ | |
818 | wxCoord GetX() const; | |
819 | ||
820 | /** | |
821 | Returns the Y position (in client coordinates) of the event. | |
822 | */ | |
823 | wxCoord GetY() const; | |
824 | ||
825 | /** | |
826 | Returns @true if either CTRL or ALT keys was down at the time of the | |
827 | key event. | |
828 | ||
829 | Note that this function does not take into account neither SHIFT nor | |
830 | META key states (the reason for ignoring the latter is that it is | |
831 | common for NUMLOCK key to be configured as META under X but the key | |
832 | presses even while NUMLOCK is on should be still processed normally). | |
833 | */ | |
834 | bool HasModifiers() const; | |
835 | ||
836 | /** | |
837 | Returns @true if the Meta key was down at the time of the key event. | |
838 | ||
839 | Notice that GetModifiers() is easier to use correctly than this function | |
840 | so you should consider using it in new code. | |
841 | */ | |
842 | bool MetaDown() const; | |
7c913512 | 843 | |
23324ae1 | 844 | /** |
42013f4c FM |
845 | Returns @true if the shift key was down at the time of the key event. |
846 | ||
847 | Notice that GetModifiers() is easier to use correctly than this function | |
848 | so you should consider using it in new code. | |
23324ae1 | 849 | */ |
42013f4c | 850 | bool ShiftDown() const; |
23324ae1 FM |
851 | }; |
852 | ||
853 | ||
e54c96f1 | 854 | |
23324ae1 | 855 | /** |
42013f4c | 856 | @class wxJoystickEvent |
23324ae1 | 857 | @wxheader{event.h} |
7c913512 | 858 | |
42013f4c FM |
859 | This event class contains information about joystick events, particularly |
860 | events received by windows. | |
1f1d2182 | 861 | |
42013f4c | 862 | @beginEventTable{wxJoystickEvent} |
8c6791e4 | 863 | @style{EVT_JOY_BUTTON_DOWN(func)} |
42013f4c | 864 | Process a wxEVT_JOY_BUTTON_DOWN event. |
8c6791e4 | 865 | @style{EVT_JOY_BUTTON_UP(func)} |
42013f4c | 866 | Process a wxEVT_JOY_BUTTON_UP event. |
8c6791e4 | 867 | @style{EVT_JOY_MOVE(func)} |
42013f4c | 868 | Process a wxEVT_JOY_MOVE event. |
8c6791e4 | 869 | @style{EVT_JOY_ZMOVE(func)} |
42013f4c | 870 | Process a wxEVT_JOY_ZMOVE event. |
8c6791e4 | 871 | @style{EVT_JOYSTICK_EVENTS(func)} |
42013f4c | 872 | Processes all joystick events. |
1f1d2182 FM |
873 | @endEventTable |
874 | ||
23324ae1 FM |
875 | @library{wxcore} |
876 | @category{events} | |
7c913512 | 877 | |
42013f4c | 878 | @see wxJoystick |
23324ae1 | 879 | */ |
42013f4c | 880 | class wxJoystickEvent : public wxEvent |
23324ae1 FM |
881 | { |
882 | public: | |
883 | /** | |
884 | Constructor. | |
885 | */ | |
42013f4c FM |
886 | wxJoystickEvent(wxEventType eventType = wxEVT_NULL, int state = 0, |
887 | int joystick = wxJOYSTICK1, | |
888 | int change = 0); | |
23324ae1 FM |
889 | |
890 | /** | |
42013f4c FM |
891 | Returns @true if the event was a down event from the specified button |
892 | (or any button). | |
23324ae1 | 893 | |
42013f4c FM |
894 | @param button |
895 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to | |
896 | indicate any button down event. | |
23324ae1 | 897 | */ |
42013f4c | 898 | bool ButtonDown(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
899 | |
900 | /** | |
42013f4c | 901 | Returns @true if the specified button (or any button) was in a down state. |
23324ae1 | 902 | |
42013f4c FM |
903 | @param button |
904 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to | |
905 | indicate any button down event. | |
23324ae1 | 906 | */ |
42013f4c | 907 | bool ButtonIsDown(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
908 | |
909 | /** | |
42013f4c FM |
910 | Returns @true if the event was an up event from the specified button |
911 | (or any button). | |
912 | ||
913 | @param button | |
914 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to | |
915 | indicate any button down event. | |
23324ae1 | 916 | */ |
42013f4c | 917 | bool ButtonUp(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
918 | |
919 | /** | |
42013f4c FM |
920 | Returns the identifier of the button changing state. |
921 | ||
922 | This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. | |
23324ae1 | 923 | */ |
42013f4c | 924 | int GetButtonChange() const; |
23324ae1 FM |
925 | |
926 | /** | |
42013f4c FM |
927 | Returns the down state of the buttons. |
928 | ||
929 | This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. | |
23324ae1 | 930 | */ |
42013f4c | 931 | int GetButtonState() const; |
23324ae1 FM |
932 | |
933 | /** | |
42013f4c FM |
934 | Returns the identifier of the joystick generating the event - one of |
935 | wxJOYSTICK1 and wxJOYSTICK2. | |
23324ae1 | 936 | */ |
42013f4c | 937 | int GetJoystick() const; |
23324ae1 FM |
938 | |
939 | /** | |
42013f4c | 940 | Returns the x, y position of the joystick event. |
23324ae1 | 941 | */ |
42013f4c | 942 | wxPoint GetPosition() const; |
23324ae1 FM |
943 | |
944 | /** | |
42013f4c | 945 | Returns the z position of the joystick event. |
23324ae1 | 946 | */ |
42013f4c | 947 | int GetZPosition() const; |
23324ae1 FM |
948 | |
949 | /** | |
42013f4c FM |
950 | Returns @true if this was a button up or down event |
951 | (@e not 'is any button down?'). | |
23324ae1 | 952 | */ |
42013f4c | 953 | bool IsButton() const; |
23324ae1 FM |
954 | |
955 | /** | |
42013f4c | 956 | Returns @true if this was an x, y move event. |
23324ae1 | 957 | */ |
42013f4c | 958 | bool IsMove() const; |
23324ae1 FM |
959 | |
960 | /** | |
42013f4c | 961 | Returns @true if this was a z move event. |
23324ae1 | 962 | */ |
42013f4c FM |
963 | bool IsZMove() const; |
964 | }; | |
23324ae1 | 965 | |
3c4f71cc | 966 | |
23324ae1 | 967 | |
42013f4c FM |
968 | /** |
969 | @class wxScrollWinEvent | |
970 | @wxheader{event.h} | |
971 | ||
972 | A scroll event holds information about events sent from scrolling windows. | |
973 | ||
23324ae1 | 974 | |
42013f4c FM |
975 | @beginEventTable{wxScrollWinEvent} |
976 | You can use the EVT_SCROLLWIN* macros for intercepting scroll window events | |
977 | from the receiving window. | |
8c6791e4 | 978 | @event{EVT_SCROLLWIN(func)} |
42013f4c | 979 | Process all scroll events. |
8c6791e4 | 980 | @event{EVT_SCROLLWIN_TOP(func)} |
42013f4c | 981 | Process wxEVT_SCROLLWIN_TOP scroll-to-top events. |
8c6791e4 | 982 | @event{EVT_SCROLLWIN_BOTTOM(func)} |
42013f4c | 983 | Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events. |
8c6791e4 | 984 | @event{EVT_SCROLLWIN_LINEUP(func)} |
42013f4c | 985 | Process wxEVT_SCROLLWIN_LINEUP line up events. |
8c6791e4 | 986 | @event{EVT_SCROLLWIN_LINEDOWN(func)} |
42013f4c | 987 | Process wxEVT_SCROLLWIN_LINEDOWN line down events. |
8c6791e4 | 988 | @event{EVT_SCROLLWIN_PAGEUP(func)} |
42013f4c | 989 | Process wxEVT_SCROLLWIN_PAGEUP page up events. |
8c6791e4 | 990 | @event{EVT_SCROLLWIN_PAGEDOWN(func)} |
42013f4c | 991 | Process wxEVT_SCROLLWIN_PAGEDOWN page down events. |
8c6791e4 | 992 | @event{EVT_SCROLLWIN_THUMBTRACK(func)} |
42013f4c FM |
993 | Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events |
994 | (frequent events sent as the user drags the thumbtrack). | |
8c6791e4 | 995 | @event{EVT_SCROLLWIN_THUMBRELEASE(func)} |
42013f4c FM |
996 | Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events. |
997 | @endEventTable | |
998 | ||
999 | ||
1000 | @library{wxcore} | |
1001 | @category{events} | |
1002 | ||
1003 | @see wxScrollEvent, @ref overview_eventhandling | |
1004 | */ | |
1005 | class wxScrollWinEvent : public wxEvent | |
1006 | { | |
1007 | public: | |
23324ae1 | 1008 | /** |
42013f4c | 1009 | Constructor. |
23324ae1 | 1010 | */ |
42013f4c FM |
1011 | wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, int pos = 0, |
1012 | int orientation = 0); | |
23324ae1 FM |
1013 | |
1014 | /** | |
42013f4c FM |
1015 | Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the |
1016 | scrollbar. | |
1017 | ||
1018 | @todo wxHORIZONTAL and wxVERTICAL should go in their own enum | |
23324ae1 | 1019 | */ |
42013f4c | 1020 | int GetOrientation() const; |
23324ae1 FM |
1021 | |
1022 | /** | |
42013f4c FM |
1023 | Returns the position of the scrollbar for the thumb track and release events. |
1024 | ||
1025 | Note that this field can't be used for the other events, you need to query | |
1026 | the window itself for the current position in that case. | |
23324ae1 | 1027 | */ |
42013f4c | 1028 | int GetPosition() const; |
23324ae1 FM |
1029 | }; |
1030 | ||
1031 | ||
e54c96f1 | 1032 | |
23324ae1 | 1033 | /** |
42013f4c | 1034 | @class wxSysColourChangedEvent |
23324ae1 | 1035 | @wxheader{event.h} |
7c913512 | 1036 | |
42013f4c FM |
1037 | This class is used for system colour change events, which are generated |
1038 | when the user changes the colour settings using the control panel. | |
1039 | This is only appropriate under Windows. | |
7c913512 | 1040 | |
42013f4c FM |
1041 | @remarks |
1042 | The default event handler for this event propagates the event to child windows, | |
1043 | since Windows only sends the events to top-level windows. | |
1044 | If intercepting this event for a top-level window, remember to call the base | |
1045 | class handler, or to pass the event on to the window's children explicitly. | |
3d6c68c1 | 1046 | |
42013f4c | 1047 | @beginEventTable{wxSysColourChangedEvent} |
8c6791e4 | 1048 | @event{EVT_SYS_COLOUR_CHANGED(func)} |
42013f4c | 1049 | Process a wxEVT_SYS_COLOUR_CHANGED event. |
3d6c68c1 VS |
1050 | @endEventTable |
1051 | ||
23324ae1 FM |
1052 | @library{wxcore} |
1053 | @category{events} | |
7c913512 | 1054 | |
42013f4c | 1055 | @see @ref overview_eventhandling |
23324ae1 | 1056 | */ |
42013f4c | 1057 | class wxSysColourChangedEvent : public wxEvent |
23324ae1 FM |
1058 | { |
1059 | public: | |
1060 | /** | |
3d6c68c1 | 1061 | Constructor. |
23324ae1 | 1062 | */ |
42013f4c | 1063 | wxSysColourChangedEvent(); |
23324ae1 FM |
1064 | }; |
1065 | ||
1066 | ||
e54c96f1 | 1067 | |
23324ae1 | 1068 | /** |
42013f4c | 1069 | @class wxWindowCreateEvent |
23324ae1 | 1070 | @wxheader{event.h} |
7c913512 | 1071 | |
42013f4c FM |
1072 | This event is sent just after the actual window associated with a wxWindow |
1073 | object has been created. | |
7c913512 | 1074 | |
42013f4c FM |
1075 | Since it is derived from wxCommandEvent, the event propagates up |
1076 | the window hierarchy. | |
7c913512 | 1077 | |
42013f4c | 1078 | @beginEventTable{wxWindowCreateEvent} |
8c6791e4 | 1079 | @event{EVT_WINDOW_CREATE(func)} |
42013f4c FM |
1080 | Process a wxEVT_CREATE event. |
1081 | @endEventTable | |
7c913512 | 1082 | |
23324ae1 FM |
1083 | @library{wxcore} |
1084 | @category{events} | |
7c913512 | 1085 | |
42013f4c | 1086 | @see @ref overview_eventhandling, wxWindowDestroyEvent |
23324ae1 | 1087 | */ |
42013f4c | 1088 | class wxWindowCreateEvent : public wxCommandEvent |
23324ae1 FM |
1089 | { |
1090 | public: | |
1091 | /** | |
42013f4c FM |
1092 | Constructor. |
1093 | */ | |
1094 | wxWindowCreateEvent(wxWindow* win = NULL); | |
1095 | }; | |
3c4f71cc | 1096 | |
23324ae1 | 1097 | |
23324ae1 | 1098 | |
42013f4c FM |
1099 | /** |
1100 | @class wxPaintEvent | |
1101 | @wxheader{event.h} | |
23324ae1 | 1102 | |
42013f4c | 1103 | A paint event is sent when a window's contents needs to be repainted. |
23324ae1 | 1104 | |
42013f4c FM |
1105 | Please notice that in general it is impossible to change the drawing of a |
1106 | standard control (such as wxButton) and so you shouldn't attempt to handle | |
1107 | paint events for them as even if it might work on some platforms, this is | |
1108 | inherently not portable and won't work everywhere. | |
23324ae1 | 1109 | |
42013f4c FM |
1110 | @remarks |
1111 | Note that in a paint event handler, the application must always create a | |
1112 | wxPaintDC object, even if you do not use it. Otherwise, under MS Windows, | |
1113 | refreshing for this and other windows will go wrong. | |
1114 | For example: | |
1115 | @code | |
1116 | void MyWindow::OnPaint(wxPaintEvent& event) | |
1117 | { | |
1118 | wxPaintDC dc(this); | |
23324ae1 | 1119 | |
42013f4c FM |
1120 | DrawMyDocument(dc); |
1121 | } | |
1122 | @endcode | |
1123 | You can optimize painting by retrieving the rectangles that have been damaged | |
1124 | and only repainting these. The rectangles are in terms of the client area, | |
1125 | and are unscrolled, so you will need to do some calculations using the current | |
1126 | view position to obtain logical, scrolled units. | |
1127 | Here is an example of using the wxRegionIterator class: | |
1128 | @code | |
1129 | // Called when window needs to be repainted. | |
1130 | void MyWindow::OnPaint(wxPaintEvent& event) | |
1131 | { | |
1132 | wxPaintDC dc(this); | |
23324ae1 | 1133 | |
42013f4c FM |
1134 | // Find Out where the window is scrolled to |
1135 | int vbX,vbY; // Top left corner of client | |
1136 | GetViewStart(&vbX,&vbY); | |
23324ae1 | 1137 | |
42013f4c FM |
1138 | int vX,vY,vW,vH; // Dimensions of client area in pixels |
1139 | wxRegionIterator upd(GetUpdateRegion()); // get the update rect list | |
23324ae1 | 1140 | |
42013f4c FM |
1141 | while (upd) |
1142 | { | |
1143 | vX = upd.GetX(); | |
1144 | vY = upd.GetY(); | |
1145 | vW = upd.GetW(); | |
1146 | vH = upd.GetH(); | |
23324ae1 | 1147 | |
42013f4c FM |
1148 | // Alternatively we can do this: |
1149 | // wxRect rect(upd.GetRect()); | |
3c4f71cc | 1150 | |
42013f4c FM |
1151 | // Repaint this rectangle |
1152 | ...some code... | |
3c4f71cc | 1153 | |
42013f4c FM |
1154 | upd ++ ; |
1155 | } | |
1156 | } | |
1157 | @endcode | |
3c4f71cc | 1158 | |
3c4f71cc | 1159 | |
42013f4c | 1160 | @beginEventTable{wxPaintEvent} |
8c6791e4 | 1161 | @event{EVT_PAINT(func)} |
42013f4c FM |
1162 | Process a wxEVT_PAINT event. |
1163 | @endEventTable | |
3c4f71cc | 1164 | |
42013f4c FM |
1165 | @library{wxcore} |
1166 | @category{events} | |
3c4f71cc | 1167 | |
42013f4c FM |
1168 | @see @ref overview_eventhandling |
1169 | */ | |
1170 | class wxPaintEvent : public wxEvent | |
1171 | { | |
1172 | public: | |
1173 | /** | |
1174 | Constructor. | |
1175 | */ | |
1176 | wxPaintEvent(int id = 0); | |
1177 | }; | |
3c4f71cc | 1178 | |
3c4f71cc | 1179 | |
3c4f71cc | 1180 | |
42013f4c FM |
1181 | /** |
1182 | @class wxMaximizeEvent | |
1183 | @wxheader{event.h} | |
3c4f71cc | 1184 | |
42013f4c FM |
1185 | An event being sent when a top level window is maximized. Notice that it is |
1186 | not sent when the window is restored to its original size after it had been | |
1187 | maximized, only a normal wxSizeEvent is generated in this case. | |
3c4f71cc | 1188 | |
42013f4c | 1189 | @beginEventTable{wxMaximizeEvent} |
8c6791e4 | 1190 | @event{EVT_MAXIMIZE(func)} |
42013f4c FM |
1191 | Process a wxEVT_MAXIMIZE event. |
1192 | @endEventTable | |
3c4f71cc | 1193 | |
42013f4c FM |
1194 | @library{wxcore} |
1195 | @category{events} | |
23324ae1 | 1196 | |
42013f4c FM |
1197 | @see @ref overview_eventhandling, wxTopLevelWindow::Maximize, |
1198 | wxTopLevelWindow::IsMaximized | |
1199 | */ | |
1200 | class wxMaximizeEvent : public wxEvent | |
1201 | { | |
1202 | public: | |
23324ae1 | 1203 | /** |
42013f4c | 1204 | Constructor. Only used by wxWidgets internally. |
23324ae1 | 1205 | */ |
42013f4c FM |
1206 | wxMaximizeEvent(int id = 0); |
1207 | }; | |
23324ae1 | 1208 | |
42013f4c FM |
1209 | /** |
1210 | The possibles modes to pass to wxUpdateUIEvent::SetMode(). | |
1211 | */ | |
1212 | enum wxUpdateUIMode | |
1213 | { | |
1214 | /** Send UI update events to all windows. */ | |
1215 | wxUPDATE_UI_PROCESS_ALL, | |
23324ae1 | 1216 | |
42013f4c FM |
1217 | /** Send UI update events to windows that have |
1218 | the wxWS_EX_PROCESS_UI_UPDATES flag specified. */ | |
1219 | wxUPDATE_UI_PROCESS_SPECIFIED | |
1220 | }; | |
23324ae1 | 1221 | |
3c4f71cc | 1222 | |
42013f4c FM |
1223 | /** |
1224 | @class wxUpdateUIEvent | |
1225 | @wxheader{event.h} | |
23324ae1 | 1226 | |
42013f4c FM |
1227 | This class is used for pseudo-events which are called by wxWidgets |
1228 | to give an application the chance to update various user interface elements. | |
23324ae1 | 1229 | |
42013f4c FM |
1230 | Without update UI events, an application has to work hard to check/uncheck, |
1231 | enable/disable, show/hide, and set the text for elements such as menu items | |
1232 | and toolbar buttons. The code for doing this has to be mixed up with the code | |
1233 | that is invoked when an action is invoked for a menu item or button. | |
3c4f71cc | 1234 | |
42013f4c FM |
1235 | With update UI events, you define an event handler to look at the state of the |
1236 | application and change UI elements accordingly. wxWidgets will call your member | |
1237 | functions in idle time, so you don't have to worry where to call this code. | |
23324ae1 | 1238 | |
42013f4c FM |
1239 | In addition to being a clearer and more declarative method, it also means you don't |
1240 | have to worry whether you're updating a toolbar or menubar identifier. The same | |
1241 | handler can update a menu item and toolbar button, if the identifier is the same. | |
1242 | Instead of directly manipulating the menu or button, you call functions in the event | |
1243 | object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a | |
1244 | call has been made, and which UI element to update. | |
23324ae1 | 1245 | |
42013f4c FM |
1246 | These events will work for popup menus as well as menubars. Just before a menu is |
1247 | popped up, wxMenu::UpdateUI is called to process any UI events for the window that | |
1248 | owns the menu. | |
23324ae1 | 1249 | |
42013f4c FM |
1250 | If you find that the overhead of UI update processing is affecting your application, |
1251 | you can do one or both of the following: | |
1252 | @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED, | |
1253 | and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should | |
1254 | receive update events. No other windows will receive update events. | |
1255 | @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay | |
1256 | between updates. You may need to call wxWindow::UpdateWindowUI at critical points, | |
1257 | for example when a dialog is about to be shown, in case the user sees a slight | |
1258 | delay before windows are updated. | |
3c4f71cc | 1259 | |
42013f4c FM |
1260 | Note that although events are sent in idle time, defining a wxIdleEvent handler |
1261 | for a window does not affect this because the events are sent from wxWindow::OnInternalIdle | |
1262 | which is always called in idle time. | |
23324ae1 | 1263 | |
42013f4c FM |
1264 | wxWidgets tries to optimize update events on some platforms. |
1265 | On Windows and GTK+, events for menubar items are only sent when the menu is about | |
1266 | to be shown, and not in idle time. | |
23324ae1 | 1267 | |
23324ae1 | 1268 | |
42013f4c | 1269 | @beginEventTable{wxUpdateUIEvent} |
8c6791e4 | 1270 | @event{EVT_UPDATE_UI(id, func)} |
42013f4c | 1271 | Process a wxEVT_UPDATE_UI event for the command with the given id. |
8c6791e4 | 1272 | @event{EVT_UPDATE_UI_RANGE(id1, id2, func)} |
42013f4c FM |
1273 | Process a wxEVT_UPDATE_UI event for any command with id included in the given range. |
1274 | @endEventTable | |
23324ae1 | 1275 | |
42013f4c FM |
1276 | @library{wxcore} |
1277 | @category{events} | |
23324ae1 | 1278 | |
42013f4c FM |
1279 | @see @ref overview_eventhandling |
1280 | */ | |
1281 | class wxUpdateUIEvent : public wxCommandEvent | |
1282 | { | |
1283 | public: | |
23324ae1 | 1284 | /** |
42013f4c | 1285 | Constructor. |
23324ae1 | 1286 | */ |
42013f4c | 1287 | wxUpdateUIEvent(wxWindowID commandId = 0); |
23324ae1 FM |
1288 | |
1289 | /** | |
42013f4c FM |
1290 | Returns @true if it is appropriate to update (send UI update events to) |
1291 | this window. | |
23324ae1 | 1292 | |
42013f4c FM |
1293 | This function looks at the mode used (see wxUpdateUIEvent::SetMode), |
1294 | the wxWS_EX_PROCESS_UI_UPDATES flag in @a window, the time update events | |
1295 | were last sent in idle time, and the update interval, to determine whether | |
1296 | events should be sent to this window now. By default this will always | |
1297 | return @true because the update mode is initially wxUPDATE_UI_PROCESS_ALL | |
1298 | and the interval is set to 0; so update events will be sent as often as | |
1299 | possible. You can reduce the frequency that events are sent by changing the | |
1300 | mode and/or setting an update interval. | |
23324ae1 | 1301 | |
42013f4c | 1302 | @see ResetUpdateTime(), SetUpdateInterval(), SetMode() |
23324ae1 | 1303 | */ |
42013f4c | 1304 | static bool CanUpdate(wxWindow* window); |
23324ae1 FM |
1305 | |
1306 | /** | |
42013f4c | 1307 | Check or uncheck the UI element. |
23324ae1 | 1308 | */ |
42013f4c | 1309 | void Check(bool check); |
23324ae1 FM |
1310 | |
1311 | /** | |
42013f4c | 1312 | Enable or disable the UI element. |
23324ae1 | 1313 | */ |
42013f4c | 1314 | void Enable(bool enable); |
23324ae1 FM |
1315 | |
1316 | /** | |
42013f4c | 1317 | Returns @true if the UI element should be checked. |
23324ae1 | 1318 | */ |
42013f4c | 1319 | bool GetChecked() const; |
23324ae1 FM |
1320 | |
1321 | /** | |
42013f4c | 1322 | Returns @true if the UI element should be enabled. |
23324ae1 | 1323 | */ |
42013f4c | 1324 | bool GetEnabled() const; |
23324ae1 FM |
1325 | |
1326 | /** | |
42013f4c FM |
1327 | Static function returning a value specifying how wxWidgets will send update |
1328 | events: to all windows, or only to those which specify that they will process | |
1329 | the events. | |
23324ae1 | 1330 | |
42013f4c | 1331 | @see SetMode() |
23324ae1 | 1332 | */ |
42013f4c | 1333 | static wxUpdateUIMode GetMode(); |
23324ae1 FM |
1334 | |
1335 | /** | |
42013f4c FM |
1336 | Returns @true if the application has called Check(). |
1337 | For wxWidgets internal use only. | |
23324ae1 | 1338 | */ |
42013f4c | 1339 | bool GetSetChecked() const; |
23324ae1 FM |
1340 | |
1341 | /** | |
42013f4c FM |
1342 | Returns @true if the application has called Enable(). |
1343 | For wxWidgets internal use only. | |
23324ae1 | 1344 | */ |
42013f4c | 1345 | bool GetSetEnabled() const; |
23324ae1 FM |
1346 | |
1347 | /** | |
42013f4c FM |
1348 | Returns @true if the application has called Show(). |
1349 | For wxWidgets internal use only. | |
23324ae1 | 1350 | */ |
42013f4c | 1351 | bool GetSetShown() const; |
23324ae1 FM |
1352 | |
1353 | /** | |
42013f4c FM |
1354 | Returns @true if the application has called SetText(). |
1355 | For wxWidgets internal use only. | |
23324ae1 | 1356 | */ |
42013f4c | 1357 | bool GetSetText() const; |
23324ae1 FM |
1358 | |
1359 | /** | |
42013f4c | 1360 | Returns @true if the UI element should be shown. |
23324ae1 | 1361 | */ |
42013f4c | 1362 | bool GetShown() const; |
23324ae1 FM |
1363 | |
1364 | /** | |
42013f4c | 1365 | Returns the text that should be set for the UI element. |
23324ae1 | 1366 | */ |
42013f4c | 1367 | wxString GetText() const; |
23324ae1 FM |
1368 | |
1369 | /** | |
42013f4c FM |
1370 | Returns the current interval between updates in milliseconds. |
1371 | The value -1 disables updates, 0 updates as frequently as possible. | |
23324ae1 | 1372 | |
42013f4c | 1373 | @see SetUpdateInterval(). |
23324ae1 | 1374 | */ |
42013f4c | 1375 | static long GetUpdateInterval(); |
23324ae1 FM |
1376 | |
1377 | /** | |
42013f4c | 1378 | Used internally to reset the last-updated time to the current time. |
23324ae1 | 1379 | |
42013f4c FM |
1380 | It is assumed that update events are normally sent in idle time, so this |
1381 | is called at the end of idle processing. | |
23324ae1 | 1382 | |
42013f4c | 1383 | @see CanUpdate(), SetUpdateInterval(), SetMode() |
23324ae1 | 1384 | */ |
42013f4c | 1385 | static void ResetUpdateTime(); |
23324ae1 FM |
1386 | |
1387 | /** | |
42013f4c FM |
1388 | Specify how wxWidgets will send update events: to all windows, or only to |
1389 | those which specify that they will process the events. | |
23324ae1 | 1390 | |
42013f4c FM |
1391 | @param mode |
1392 | this parameter may be one of the ::wxUpdateUIMode enumeration values. | |
1393 | The default mode is wxUPDATE_UI_PROCESS_ALL. | |
23324ae1 | 1394 | */ |
42013f4c | 1395 | static void SetMode(wxUpdateUIMode mode); |
23324ae1 FM |
1396 | |
1397 | /** | |
42013f4c | 1398 | Sets the text for this UI element. |
23324ae1 | 1399 | */ |
42013f4c | 1400 | void SetText(const wxString& text); |
23324ae1 FM |
1401 | |
1402 | /** | |
42013f4c | 1403 | Sets the interval between updates in milliseconds. |
23324ae1 | 1404 | |
42013f4c FM |
1405 | Set to -1 to disable updates, or to 0 to update as frequently as possible. |
1406 | The default is 0. | |
23324ae1 | 1407 | |
42013f4c FM |
1408 | Use this to reduce the overhead of UI update events if your application |
1409 | has a lot of windows. If you set the value to -1 or greater than 0, | |
1410 | you may also need to call wxWindow::UpdateWindowUI at appropriate points | |
1411 | in your application, such as when a dialog is about to be shown. | |
23324ae1 | 1412 | */ |
42013f4c | 1413 | static void SetUpdateInterval(long updateInterval); |
23324ae1 FM |
1414 | |
1415 | /** | |
42013f4c | 1416 | Show or hide the UI element. |
23324ae1 | 1417 | */ |
42013f4c FM |
1418 | void Show(bool show); |
1419 | }; | |
23324ae1 FM |
1420 | |
1421 | ||
23324ae1 | 1422 | |
42013f4c FM |
1423 | /** |
1424 | @class wxClipboardTextEvent | |
1425 | @wxheader{event.h} | |
23324ae1 | 1426 | |
42013f4c FM |
1427 | This class represents the events generated by a control (typically a |
1428 | wxTextCtrl but other windows can generate these events as well) when its | |
1429 | content gets copied or cut to, or pasted from the clipboard. | |
23324ae1 | 1430 | |
42013f4c FM |
1431 | There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY, |
1432 | wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE. | |
23324ae1 | 1433 | |
42013f4c FM |
1434 | If any of these events is processed (without being skipped) by an event |
1435 | handler, the corresponding operation doesn't take place which allows to | |
1436 | prevent the text from being copied from or pasted to a control. It is also | |
1437 | possible to examine the clipboard contents in the PASTE event handler and | |
1438 | transform it in some way before inserting in a control -- for example, | |
1439 | changing its case or removing invalid characters. | |
23324ae1 | 1440 | |
42013f4c FM |
1441 | Finally notice that a CUT event is always preceded by the COPY event which |
1442 | makes it possible to only process the latter if it doesn't matter if the | |
1443 | text was copied or cut. | |
23324ae1 | 1444 | |
42013f4c FM |
1445 | @note |
1446 | These events are currently only generated by wxTextCtrl under GTK+. | |
1447 | They are generated by all controls under Windows. | |
23324ae1 | 1448 | |
42013f4c | 1449 | @beginEventTable{wxClipboardTextEvent} |
8c6791e4 | 1450 | @event{EVT_TEXT_COPY(id, func)} |
42013f4c | 1451 | Some or all of the controls content was copied to the clipboard. |
8c6791e4 | 1452 | @event{EVT_TEXT_CUT(id, func)} |
42013f4c FM |
1453 | Some or all of the controls content was cut (i.e. copied and |
1454 | deleted). | |
8c6791e4 | 1455 | @event{EVT_TEXT_PASTE(id, func)} |
42013f4c FM |
1456 | Clipboard content was pasted into the control. |
1457 | @endEventTable | |
23324ae1 | 1458 | |
23324ae1 | 1459 | |
42013f4c FM |
1460 | @library{wxcore} |
1461 | @category{events} | |
23324ae1 | 1462 | |
42013f4c FM |
1463 | @see wxClipboard |
1464 | */ | |
1465 | class wxClipboardTextEvent : public wxCommandEvent | |
1466 | { | |
1467 | public: | |
23324ae1 | 1468 | /** |
42013f4c | 1469 | Constructor. |
23324ae1 | 1470 | */ |
42013f4c | 1471 | wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
1472 | }; |
1473 | ||
1474 | ||
e54c96f1 | 1475 | |
23324ae1 | 1476 | /** |
42013f4c | 1477 | @class wxMouseEvent |
23324ae1 | 1478 | @wxheader{event.h} |
7c913512 | 1479 | |
42013f4c FM |
1480 | This event class contains information about the events generated by the mouse: |
1481 | they include mouse buttons press and release events and mouse move events. | |
7c913512 | 1482 | |
42013f4c FM |
1483 | All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the |
1484 | left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and | |
1485 | @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more | |
1486 | buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events | |
1487 | can also be generated. Note that not all mice have even a middle button so a | |
1488 | portable application should avoid relying on the events from it (but the right | |
1489 | button click can be emulated using the left mouse button with the control key | |
1490 | under Mac platforms with a single button mouse). | |
1491 | ||
1492 | For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events | |
1493 | purposes, the mouse is considered to be inside the window if it is in the | |
1494 | window client area and not inside one of its children. In other words, the | |
1495 | parent window receives @c wxEVT_LEAVE_WINDOW event not only when the | |
1496 | mouse leaves the window entirely but also when it enters one of its children. | |
1497 | ||
1498 | @note Note that under Windows CE mouse enter and leave events are not natively | |
1499 | supported by the system but are generated by wxWidgets itself. This has several | |
1500 | drawbacks: the LEAVE_WINDOW event might be received some time after the mouse | |
1501 | left the window and the state variables for it may have changed during this time. | |
1502 | ||
1503 | @note Note the difference between methods like wxMouseEvent::LeftDown and | |
1504 | wxMouseEvent::LeftIsDown: the former returns @true when the event corresponds | |
1505 | to the left mouse button click while the latter returns @true if the left | |
1506 | mouse button is currently being pressed. For example, when the user is dragging | |
1507 | the mouse you can use wxMouseEvent::LeftIsDown to test whether the left mouse | |
1508 | button is (still) depressed. Also, by convention, if wxMouseEvent::LeftDown | |
1509 | returns @true, wxMouseEvent::LeftIsDown will also return @true in wxWidgets | |
1510 | whatever the underlying GUI behaviour is (which is platform-dependent). | |
1511 | The same applies, of course, to other mouse buttons as well. | |
1512 | ||
1513 | ||
1514 | @beginEventTable{wxMouseEvent} | |
8c6791e4 | 1515 | @event{EVT_LEFT_DOWN(func)} |
42013f4c FM |
1516 | Process a wxEVT_LEFT_DOWN event. The handler of this event should normally |
1517 | call event.Skip() to allow the default processing to take place as otherwise | |
1518 | the window under mouse wouldn't get the focus. | |
8c6791e4 | 1519 | @event{EVT_LEFT_UP(func)} |
42013f4c | 1520 | Process a wxEVT_LEFT_UP event. |
8c6791e4 | 1521 | @event{EVT_LEFT_DCLICK(func)} |
42013f4c | 1522 | Process a wxEVT_LEFT_DCLICK event. |
8c6791e4 | 1523 | @event{EVT_MIDDLE_DOWN(func)} |
42013f4c | 1524 | Process a wxEVT_MIDDLE_DOWN event. |
8c6791e4 | 1525 | @event{EVT_MIDDLE_UP(func)} |
42013f4c | 1526 | Process a wxEVT_MIDDLE_UP event. |
8c6791e4 | 1527 | @event{EVT_MIDDLE_DCLICK(func)} |
42013f4c | 1528 | Process a wxEVT_MIDDLE_DCLICK event. |
8c6791e4 | 1529 | @event{EVT_RIGHT_DOWN(func)} |
42013f4c | 1530 | Process a wxEVT_RIGHT_DOWN event. |
8c6791e4 | 1531 | @event{EVT_RIGHT_UP(func)} |
42013f4c | 1532 | Process a wxEVT_RIGHT_UP event. |
8c6791e4 | 1533 | @event{EVT_RIGHT_DCLICK(func)} |
42013f4c | 1534 | Process a wxEVT_RIGHT_DCLICK event. |
8c6791e4 | 1535 | @event{EVT_MOUSE_AUX1_DOWN(func)} |
42013f4c | 1536 | Process a wxEVT_MOUSE_AUX1_DOWN event. |
8c6791e4 | 1537 | @event{EVT_MOUSE_AUX1_UP(func)} |
42013f4c | 1538 | Process a wxEVT_MOUSE_AUX1_UP event. |
8c6791e4 | 1539 | @event{EVT_MOUSE_AUX1_DCLICK(func)} |
42013f4c | 1540 | Process a wxEVT_MOUSE_AUX1_DCLICK event. |
8c6791e4 | 1541 | @event{EVT_MOUSE_AUX2_DOWN(func)} |
42013f4c | 1542 | Process a wxEVT_MOUSE_AUX2_DOWN event. |
8c6791e4 | 1543 | @event{EVT_MOUSE_AUX2_UP(func)} |
42013f4c | 1544 | Process a wxEVT_MOUSE_AUX2_UP event. |
8c6791e4 | 1545 | @event{EVT_MOUSE_AUX2_DCLICK(func)} |
42013f4c | 1546 | Process a wxEVT_MOUSE_AUX2_DCLICK event. |
8c6791e4 | 1547 | @event{EVT_MOTION(func)} |
42013f4c | 1548 | Process a wxEVT_MOTION event. |
8c6791e4 | 1549 | @event{EVT_ENTER_WINDOW(func)} |
42013f4c | 1550 | Process a wxEVT_ENTER_WINDOW event. |
8c6791e4 | 1551 | @event{EVT_LEAVE_WINDOW(func)} |
42013f4c | 1552 | Process a wxEVT_LEAVE_WINDOW event. |
8c6791e4 | 1553 | @event{EVT_MOUSEWHEEL(func)} |
42013f4c | 1554 | Process a wxEVT_MOUSEWHEEL event. |
8c6791e4 | 1555 | @event{EVT_MOUSE_EVENTS(func)} |
42013f4c FM |
1556 | Process all mouse events. |
1557 | @endEventTable | |
7c913512 | 1558 | |
23324ae1 FM |
1559 | @library{wxcore} |
1560 | @category{events} | |
7c913512 | 1561 | |
42013f4c | 1562 | @see wxKeyEvent::CmdDown |
23324ae1 | 1563 | */ |
42013f4c | 1564 | class wxMouseEvent : public wxEvent |
23324ae1 FM |
1565 | { |
1566 | public: | |
1567 | /** | |
42013f4c | 1568 | Constructor. Valid event types are: |
23324ae1 | 1569 | |
42013f4c FM |
1570 | @li wxEVT_ENTER_WINDOW |
1571 | @li wxEVT_LEAVE_WINDOW | |
1572 | @li wxEVT_LEFT_DOWN | |
1573 | @li wxEVT_LEFT_UP | |
1574 | @li wxEVT_LEFT_DCLICK | |
1575 | @li wxEVT_MIDDLE_DOWN | |
1576 | @li wxEVT_MIDDLE_UP | |
1577 | @li wxEVT_MIDDLE_DCLICK | |
1578 | @li wxEVT_RIGHT_DOWN | |
1579 | @li wxEVT_RIGHT_UP | |
1580 | @li wxEVT_RIGHT_DCLICK | |
1581 | @li wxEVT_MOUSE_AUX1_DOWN | |
1582 | @li wxEVT_MOUSE_AUX1_UP | |
1583 | @li wxEVT_MOUSE_AUX1_DCLICK | |
1584 | @li wxEVT_MOUSE_AUX2_DOWN | |
1585 | @li wxEVT_MOUSE_AUX2_UP | |
1586 | @li wxEVT_MOUSE_AUX2_DCLICK | |
1587 | @li wxEVT_MOTION | |
1588 | @li wxEVT_MOUSEWHEEL | |
1589 | */ | |
1590 | wxMouseEvent(wxEventType mouseEventType = wxEVT_NULL); | |
23324ae1 FM |
1591 | |
1592 | /** | |
42013f4c | 1593 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 1594 | */ |
42013f4c | 1595 | bool AltDown() const; |
23324ae1 FM |
1596 | |
1597 | /** | |
42013f4c | 1598 | Returns @true if the event was a first extra button double click. |
23324ae1 | 1599 | */ |
42013f4c | 1600 | bool Aux1DClick() const; |
23324ae1 FM |
1601 | |
1602 | /** | |
42013f4c | 1603 | Returns @true if the first extra button mouse button changed to down. |
23324ae1 | 1604 | */ |
42013f4c | 1605 | bool Aux1Down() const; |
7c913512 | 1606 | |
23324ae1 | 1607 | /** |
42013f4c FM |
1608 | Returns @true if the first extra button mouse button is currently down, |
1609 | independent of the current event type. | |
23324ae1 | 1610 | */ |
42013f4c | 1611 | bool Aux1IsDown() const; |
23324ae1 FM |
1612 | |
1613 | /** | |
42013f4c | 1614 | Returns @true if the first extra button mouse button changed to up. |
23324ae1 | 1615 | */ |
42013f4c | 1616 | bool Aux1Up() const; |
23324ae1 FM |
1617 | |
1618 | /** | |
42013f4c | 1619 | Returns @true if the event was a second extra button double click. |
23324ae1 | 1620 | */ |
42013f4c | 1621 | bool Aux2DClick() const; |
23324ae1 FM |
1622 | |
1623 | /** | |
42013f4c | 1624 | Returns @true if the second extra button mouse button changed to down. |
23324ae1 | 1625 | */ |
42013f4c | 1626 | bool Aux2Down() const; |
23324ae1 FM |
1627 | |
1628 | /** | |
42013f4c FM |
1629 | Returns @true if the second extra button mouse button is currently down, |
1630 | independent of the current event type. | |
23324ae1 | 1631 | */ |
42013f4c | 1632 | bool Aux2IsDown() const; |
23324ae1 FM |
1633 | |
1634 | /** | |
42013f4c | 1635 | Returns @true if the second extra button mouse button changed to up. |
23324ae1 | 1636 | */ |
42013f4c | 1637 | bool Aux2Up() const; |
23324ae1 FM |
1638 | |
1639 | /** | |
42013f4c FM |
1640 | Returns @true if the identified mouse button is changing state. |
1641 | Valid values of @a button are: | |
1642 | ||
1643 | @li @c wxMOUSE_BTN_LEFT: check if left button was pressed | |
1644 | @li @c wxMOUSE_BTN_MIDDLE: check if middle button was pressed | |
1645 | @li @c wxMOUSE_BTN_RIGHT: check if right button was pressed | |
1646 | @li @c wxMOUSE_BTN_AUX1: check if the first extra button was pressed | |
1647 | @li @c wxMOUSE_BTN_AUX2: check if the second extra button was pressed | |
1648 | @li @c wxMOUSE_BTN_ANY: check if any button was pressed | |
1649 | ||
1650 | @todo introduce wxMouseButton enum | |
23324ae1 | 1651 | */ |
42013f4c | 1652 | bool Button(int button) const; |
23324ae1 FM |
1653 | |
1654 | /** | |
42013f4c FM |
1655 | If the argument is omitted, this returns @true if the event was a mouse |
1656 | double click event. Otherwise the argument specifies which double click event | |
1657 | was generated (see Button() for the possible values). | |
23324ae1 | 1658 | */ |
42013f4c | 1659 | bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
1660 | |
1661 | /** | |
42013f4c FM |
1662 | If the argument is omitted, this returns @true if the event was a mouse |
1663 | button down event. Otherwise the argument specifies which button-down event | |
1664 | was generated (see Button() for the possible values). | |
23324ae1 | 1665 | */ |
42013f4c | 1666 | bool ButtonDown(int = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
1667 | |
1668 | /** | |
42013f4c FM |
1669 | If the argument is omitted, this returns @true if the event was a mouse |
1670 | button up event. Otherwise the argument specifies which button-up event | |
1671 | was generated (see Button() for the possible values). | |
23324ae1 | 1672 | */ |
42013f4c | 1673 | bool ButtonUp(int = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
1674 | |
1675 | /** | |
42013f4c FM |
1676 | Same as MetaDown() under Mac, same as ControlDown() elsewhere. |
1677 | ||
1678 | @see wxKeyEvent::CmdDown | |
23324ae1 | 1679 | */ |
42013f4c | 1680 | bool CmdDown() const; |
23324ae1 FM |
1681 | |
1682 | /** | |
42013f4c | 1683 | Returns @true if the control key was down at the time of the event. |
23324ae1 | 1684 | */ |
42013f4c | 1685 | bool ControlDown() const; |
23324ae1 FM |
1686 | |
1687 | /** | |
42013f4c FM |
1688 | Returns @true if this was a dragging event (motion while a button is depressed). |
1689 | ||
1690 | @see Moving() | |
23324ae1 | 1691 | */ |
42013f4c | 1692 | bool Dragging() const; |
23324ae1 FM |
1693 | |
1694 | /** | |
42013f4c FM |
1695 | Returns @true if the mouse was entering the window. |
1696 | ||
1697 | @see Leaving() | |
23324ae1 | 1698 | */ |
42013f4c | 1699 | bool Entering() const; |
23324ae1 FM |
1700 | |
1701 | /** | |
42013f4c FM |
1702 | Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE |
1703 | if no button is involved (for mouse move, enter or leave event, for example). | |
1704 | Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and | |
1705 | double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT | |
1706 | for the same events for the middle and the right buttons respectively. | |
23324ae1 | 1707 | */ |
42013f4c | 1708 | int GetButton() const; |
e54c96f1 | 1709 | |
42013f4c FM |
1710 | /** |
1711 | Returns the number of mouse clicks for this event: 1 for a simple click, 2 | |
1712 | for a double-click, 3 for a triple-click and so on. | |
7c913512 | 1713 | |
42013f4c FM |
1714 | Currently this function is implemented only in wxMac and returns -1 for the |
1715 | other platforms (you can still distinguish simple clicks from double-clicks as | |
1716 | they generate different kinds of events however). | |
7c913512 | 1717 | |
1e24c2af | 1718 | @since 2.9.0 |
42013f4c FM |
1719 | */ |
1720 | int GetClickCount() const; | |
7c913512 | 1721 | |
23324ae1 | 1722 | /** |
42013f4c FM |
1723 | Returns the configured number of lines (or whatever) to be scrolled per |
1724 | wheel action. Defaults to three. | |
23324ae1 | 1725 | */ |
42013f4c | 1726 | int GetLinesPerAction() const; |
23324ae1 FM |
1727 | |
1728 | /** | |
42013f4c FM |
1729 | Returns the logical mouse position in pixels (i.e. translated according to the |
1730 | translation set for the DC, which usually indicates that the window has been | |
1731 | scrolled). | |
23324ae1 | 1732 | */ |
42013f4c | 1733 | wxPoint GetLogicalPosition(const wxDC& dc) const; |
23324ae1 | 1734 | |
42013f4c FM |
1735 | //@{ |
1736 | /** | |
1737 | Sets *x and *y to the position at which the event occurred. | |
1738 | Returns the physical mouse position in pixels. | |
e54c96f1 | 1739 | |
42013f4c FM |
1740 | Note that if the mouse event has been artificially generated from a special |
1741 | keyboard combination (e.g. under Windows when the "menu" key is pressed), the | |
1742 | returned position is ::wxDefaultPosition. | |
1743 | */ | |
1744 | wxPoint GetPosition() const; | |
1745 | void GetPosition(wxCoord* x, wxCoord* y) const; | |
1746 | void GetPosition(long* x, long* y) const; | |
1747 | //@} | |
7c913512 | 1748 | |
42013f4c FM |
1749 | /** |
1750 | Get wheel delta, normally 120. | |
7c913512 | 1751 | |
42013f4c FM |
1752 | This is the threshold for action to be taken, and one such action |
1753 | (for example, scrolling one increment) should occur for each delta. | |
1754 | */ | |
1755 | int GetWheelDelta() const; | |
7c913512 | 1756 | |
42013f4c FM |
1757 | /** |
1758 | Get wheel rotation, positive or negative indicates direction of rotation. | |
7c913512 | 1759 | |
42013f4c FM |
1760 | Current devices all send an event when rotation is at least +/-WheelDelta, but |
1761 | finer resolution devices can be created in the future. | |
7c913512 | 1762 | |
42013f4c FM |
1763 | Because of this you shouldn't assume that one event is equal to 1 line, but you |
1764 | should be able to either do partial line scrolling or wait until several | |
1765 | events accumulate before scrolling. | |
23324ae1 | 1766 | */ |
42013f4c | 1767 | int GetWheelRotation() const; |
23324ae1 FM |
1768 | |
1769 | /** | |
42013f4c | 1770 | Returns X coordinate of the physical mouse event position. |
23324ae1 | 1771 | */ |
42013f4c | 1772 | wxCoord GetX() const; |
23324ae1 FM |
1773 | |
1774 | /** | |
42013f4c | 1775 | Returns Y coordinate of the physical mouse event position. |
23324ae1 | 1776 | */ |
42013f4c | 1777 | wxCoord GetY() const; |
7c913512 | 1778 | |
23324ae1 | 1779 | /** |
42013f4c FM |
1780 | Returns @true if the event was a mouse button event (not necessarily a button |
1781 | down event - that may be tested using ButtonDown()). | |
23324ae1 | 1782 | */ |
42013f4c | 1783 | bool IsButton() const; |
23324ae1 FM |
1784 | |
1785 | /** | |
42013f4c FM |
1786 | Returns @true if the system has been setup to do page scrolling with |
1787 | the mouse wheel instead of line scrolling. | |
23324ae1 | 1788 | */ |
42013f4c | 1789 | bool IsPageScroll() const; |
7c913512 | 1790 | |
42013f4c FM |
1791 | /** |
1792 | Returns @true if the mouse was leaving the window. | |
7c913512 | 1793 | |
42013f4c FM |
1794 | @see Entering(). |
1795 | */ | |
1796 | bool Leaving() const; | |
7c913512 | 1797 | |
23324ae1 | 1798 | /** |
42013f4c | 1799 | Returns @true if the event was a left double click. |
23324ae1 | 1800 | */ |
42013f4c | 1801 | bool LeftDClick() const; |
23324ae1 FM |
1802 | |
1803 | /** | |
42013f4c | 1804 | Returns @true if the left mouse button changed to down. |
23324ae1 | 1805 | */ |
42013f4c | 1806 | bool LeftDown() const; |
7c913512 | 1807 | |
42013f4c FM |
1808 | /** |
1809 | Returns @true if the left mouse button is currently down, independent | |
1810 | of the current event type. | |
7c913512 | 1811 | |
42013f4c FM |
1812 | Please notice that it is not the same as LeftDown() which returns @true if the |
1813 | event was generated by the left mouse button being pressed. Rather, it simply | |
1814 | describes the state of the left mouse button at the time when the event was | |
1815 | generated (so while it will be @true for a left click event, it can also be @true | |
1816 | for a right click if it happened while the left mouse button was pressed). | |
7c913512 | 1817 | |
42013f4c FM |
1818 | This event is usually used in the mouse event handlers which process "move |
1819 | mouse" messages to determine whether the user is (still) dragging the mouse. | |
1820 | */ | |
1821 | bool LeftIsDown() const; | |
1822 | ||
1823 | /** | |
1824 | Returns @true if the left mouse button changed to up. | |
1825 | */ | |
1826 | bool LeftUp() const; | |
7c913512 | 1827 | |
23324ae1 | 1828 | /** |
42013f4c FM |
1829 | Returns @true if the Meta key was down at the time of the event. |
1830 | */ | |
1831 | bool MetaDown() const; | |
3c4f71cc | 1832 | |
42013f4c FM |
1833 | /** |
1834 | Returns @true if the event was a middle double click. | |
23324ae1 | 1835 | */ |
42013f4c | 1836 | bool MiddleDClick() const; |
23324ae1 FM |
1837 | |
1838 | /** | |
42013f4c | 1839 | Returns @true if the middle mouse button changed to down. |
23324ae1 | 1840 | */ |
42013f4c | 1841 | bool MiddleDown() const; |
23324ae1 | 1842 | |
42013f4c FM |
1843 | /** |
1844 | Returns @true if the middle mouse button is currently down, independent | |
1845 | of the current event type. | |
1846 | */ | |
1847 | bool MiddleIsDown() const; | |
23324ae1 | 1848 | |
42013f4c FM |
1849 | /** |
1850 | Returns @true if the middle mouse button changed to up. | |
1851 | */ | |
1852 | bool MiddleUp() const; | |
e54c96f1 | 1853 | |
42013f4c FM |
1854 | /** |
1855 | Returns @true if this was a motion event and no mouse buttons were pressed. | |
1856 | If any mouse button is held pressed, then this method returns @false and | |
1857 | Dragging() returns @true. | |
1858 | */ | |
1859 | bool Moving() const; | |
7c913512 | 1860 | |
42013f4c FM |
1861 | /** |
1862 | Returns @true if the event was a right double click. | |
1863 | */ | |
1864 | bool RightDClick() const; | |
7c913512 | 1865 | |
42013f4c FM |
1866 | /** |
1867 | Returns @true if the right mouse button changed to down. | |
1868 | */ | |
1869 | bool RightDown() const; | |
7c913512 | 1870 | |
42013f4c FM |
1871 | /** |
1872 | Returns @true if the right mouse button is currently down, independent | |
1873 | of the current event type. | |
1874 | */ | |
1875 | bool RightIsDown() const; | |
7c913512 | 1876 | |
42013f4c FM |
1877 | /** |
1878 | Returns @true if the right mouse button changed to up. | |
1879 | */ | |
1880 | bool RightUp() const; | |
7c913512 | 1881 | |
23324ae1 | 1882 | /** |
42013f4c | 1883 | Returns @true if the shift key was down at the time of the event. |
23324ae1 | 1884 | */ |
42013f4c | 1885 | bool ShiftDown() const; |
23324ae1 FM |
1886 | }; |
1887 | ||
1888 | ||
e54c96f1 | 1889 | |
23324ae1 | 1890 | /** |
42013f4c | 1891 | @class wxDropFilesEvent |
23324ae1 | 1892 | @wxheader{event.h} |
7c913512 | 1893 | |
42013f4c FM |
1894 | This class is used for drop files events, that is, when files have been dropped |
1895 | onto the window. This functionality is currently only available under Windows. | |
7c913512 | 1896 | |
42013f4c FM |
1897 | The window must have previously been enabled for dropping by calling |
1898 | wxWindow::DragAcceptFiles(). | |
1899 | ||
1900 | Important note: this is a separate implementation to the more general drag and drop | |
1901 | implementation documented in the @ref overview_dnd. It uses the older, Windows | |
1902 | message-based approach of dropping files. | |
1903 | ||
1904 | @beginEventTable{wxDropFilesEvent} | |
8c6791e4 | 1905 | @event{EVT_DROP_FILES(func)} |
42013f4c FM |
1906 | Process a wxEVT_DROP_FILES event. |
1907 | @endEventTable | |
1908 | ||
1909 | @onlyfor{wxmsw} | |
7c913512 | 1910 | |
23324ae1 FM |
1911 | @library{wxcore} |
1912 | @category{events} | |
7c913512 | 1913 | |
42013f4c | 1914 | @see @ref overview_eventhandling |
23324ae1 | 1915 | */ |
42013f4c | 1916 | class wxDropFilesEvent : public wxEvent |
23324ae1 FM |
1917 | { |
1918 | public: | |
1919 | /** | |
42013f4c | 1920 | Constructor. |
23324ae1 | 1921 | */ |
42013f4c FM |
1922 | wxDropFilesEvent(wxEventType id = 0, int noFiles = 0, |
1923 | wxString* files = NULL); | |
23324ae1 FM |
1924 | |
1925 | /** | |
42013f4c | 1926 | Returns an array of filenames. |
23324ae1 | 1927 | */ |
42013f4c | 1928 | wxString* GetFiles() const; |
23324ae1 FM |
1929 | |
1930 | /** | |
42013f4c | 1931 | Returns the number of files dropped. |
23324ae1 | 1932 | */ |
42013f4c | 1933 | int GetNumberOfFiles() const; |
23324ae1 FM |
1934 | |
1935 | /** | |
42013f4c FM |
1936 | Returns the position at which the files were dropped. |
1937 | Returns an array of filenames. | |
23324ae1 | 1938 | */ |
42013f4c | 1939 | wxPoint GetPosition() const; |
23324ae1 FM |
1940 | }; |
1941 | ||
1942 | ||
e54c96f1 | 1943 | |
23324ae1 | 1944 | /** |
42013f4c | 1945 | @class wxCommandEvent |
23324ae1 | 1946 | @wxheader{event.h} |
7c913512 | 1947 | |
42013f4c FM |
1948 | This event class contains information about command events, which originate |
1949 | from a variety of simple controls. | |
1950 | ||
1951 | More complex controls, such as wxTreeCtrl, have separate command event classes. | |
1952 | ||
1953 | @beginEventTable{wxCommandEvent} | |
8c6791e4 | 1954 | @event{EVT_COMMAND(id, event, func)} |
42013f4c FM |
1955 | Process a command, supplying the window identifier, command event identifier, |
1956 | and member function. | |
8c6791e4 | 1957 | @event{EVT_COMMAND_RANGE(id1, id2, event, func)} |
42013f4c FM |
1958 | Process a command for a range of window identifiers, supplying the minimum and |
1959 | maximum window identifiers, command event identifier, and member function. | |
8c6791e4 | 1960 | @event{EVT_BUTTON(id, func)} |
42013f4c | 1961 | Process a wxEVT_COMMAND_BUTTON_CLICKED command, which is generated by a wxButton control. |
8c6791e4 | 1962 | @event{EVT_CHECKBOX(id, func)} |
42013f4c | 1963 | Process a wxEVT_COMMAND_CHECKBOX_CLICKED command, which is generated by a wxCheckBox control. |
8c6791e4 | 1964 | @event{EVT_CHOICE(id, func)} |
42013f4c | 1965 | Process a wxEVT_COMMAND_CHOICE_SELECTED command, which is generated by a wxChoice control. |
8c6791e4 | 1966 | @event{EVT_COMBOBOX(id, func)} |
42013f4c | 1967 | Process a wxEVT_COMMAND_COMBOBOX_SELECTED command, which is generated by a wxComboBox control. |
8c6791e4 | 1968 | @event{EVT_LISTBOX(id, func)} |
42013f4c | 1969 | Process a wxEVT_COMMAND_LISTBOX_SELECTED command, which is generated by a wxListBox control. |
8c6791e4 | 1970 | @event{EVT_LISTBOX_DCLICK(id, func)} |
42013f4c | 1971 | Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED command, which is generated by a wxListBox control. |
8c6791e4 | 1972 | @event{EVT_MENU(id, func)} |
42013f4c | 1973 | Process a wxEVT_COMMAND_MENU_SELECTED command, which is generated by a menu item. |
8c6791e4 | 1974 | @event{EVT_MENU_RANGE(id1, id2, func)} |
42013f4c | 1975 | Process a wxEVT_COMMAND_MENU_RANGE command, which is generated by a range of menu items. |
8c6791e4 | 1976 | @event{EVT_CONTEXT_MENU(func)} |
42013f4c FM |
1977 | Process the event generated when the user has requested a popup menu to appear by |
1978 | pressing a special keyboard key (under Windows) or by right clicking the mouse. | |
8c6791e4 | 1979 | @event{EVT_RADIOBOX(id, func)} |
42013f4c | 1980 | Process a wxEVT_COMMAND_RADIOBOX_SELECTED command, which is generated by a wxRadioBox control. |
8c6791e4 | 1981 | @event{EVT_RADIOBUTTON(id, func)} |
42013f4c | 1982 | Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED command, which is generated by a wxRadioButton control. |
8c6791e4 | 1983 | @event{EVT_SCROLLBAR(id, func)} |
42013f4c FM |
1984 | Process a wxEVT_COMMAND_SCROLLBAR_UPDATED command, which is generated by a wxScrollBar |
1985 | control. This is provided for compatibility only; more specific scrollbar event macros | |
1986 | should be used instead (see wxScrollEvent). | |
8c6791e4 | 1987 | @event{EVT_SLIDER(id, func)} |
42013f4c | 1988 | Process a wxEVT_COMMAND_SLIDER_UPDATED command, which is generated by a wxSlider control. |
8c6791e4 | 1989 | @event{EVT_TEXT(id, func)} |
42013f4c | 1990 | Process a wxEVT_COMMAND_TEXT_UPDATED command, which is generated by a wxTextCtrl control. |
8c6791e4 | 1991 | @event{EVT_TEXT_ENTER(id, func)} |
42013f4c FM |
1992 | Process a wxEVT_COMMAND_TEXT_ENTER command, which is generated by a wxTextCtrl control. |
1993 | Note that you must use wxTE_PROCESS_ENTER flag when creating the control if you want it | |
1994 | to generate such events. | |
8c6791e4 | 1995 | @event{EVT_TEXT_MAXLEN(id, func)} |
42013f4c FM |
1996 | Process a wxEVT_COMMAND_TEXT_MAXLEN command, which is generated by a wxTextCtrl control |
1997 | when the user tries to enter more characters into it than the limit previously set | |
1998 | with SetMaxLength(). | |
8c6791e4 | 1999 | @event{EVT_TOGGLEBUTTON(id, func)} |
42013f4c | 2000 | Process a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event. |
8c6791e4 | 2001 | @event{EVT_TOOL(id, func)} |
42013f4c FM |
2002 | Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED). |
2003 | Pass the id of the tool. | |
8c6791e4 | 2004 | @event{EVT_TOOL_RANGE(id1, id2, func)} |
42013f4c | 2005 | Process a wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. Pass the ids of the tools. |
8c6791e4 | 2006 | @event{EVT_TOOL_RCLICKED(id, func)} |
42013f4c | 2007 | Process a wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool. |
8c6791e4 | 2008 | @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)} |
42013f4c | 2009 | Process a wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools. |
8c6791e4 | 2010 | @event{EVT_TOOL_ENTER(id, func)} |
42013f4c FM |
2011 | Process a wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar itself. |
2012 | The value of wxCommandEvent::GetSelection() is the tool id, or -1 if the mouse cursor | |
2013 | has moved off a tool. | |
8c6791e4 | 2014 | @event{EVT_COMMAND_LEFT_CLICK(id, func)} |
42013f4c | 2015 | Process a wxEVT_COMMAND_LEFT_CLICK command, which is generated by a control (Windows 95 and NT only). |
8c6791e4 | 2016 | @event{EVT_COMMAND_LEFT_DCLICK(id, func)} |
42013f4c | 2017 | Process a wxEVT_COMMAND_LEFT_DCLICK command, which is generated by a control (Windows 95 and NT only). |
8c6791e4 | 2018 | @event{EVT_COMMAND_RIGHT_CLICK(id, func)} |
42013f4c | 2019 | Process a wxEVT_COMMAND_RIGHT_CLICK command, which is generated by a control (Windows 95 and NT only). |
8c6791e4 | 2020 | @event{EVT_COMMAND_SET_FOCUS(id, func)} |
42013f4c | 2021 | Process a wxEVT_COMMAND_SET_FOCUS command, which is generated by a control (Windows 95 and NT only). |
8c6791e4 | 2022 | @event{EVT_COMMAND_KILL_FOCUS(id, func)} |
42013f4c | 2023 | Process a wxEVT_COMMAND_KILL_FOCUS command, which is generated by a control (Windows 95 and NT only). |
8c6791e4 | 2024 | @event{EVT_COMMAND_ENTER(id, func)} |
42013f4c FM |
2025 | Process a wxEVT_COMMAND_ENTER command, which is generated by a control. |
2026 | @endEventTable | |
7c913512 | 2027 | |
23324ae1 | 2028 | @library{wxcore} |
1f1d2182 | 2029 | @category{events} |
23324ae1 | 2030 | */ |
42013f4c | 2031 | class wxCommandEvent : public wxEvent |
23324ae1 FM |
2032 | { |
2033 | public: | |
2034 | /** | |
2035 | Constructor. | |
2036 | */ | |
42013f4c | 2037 | wxCommandEvent(wxEventType commandEventType = 0, int id = 0); |
23324ae1 FM |
2038 | |
2039 | /** | |
42013f4c FM |
2040 | Returns client data pointer for a listbox or choice selection event |
2041 | (not valid for a deselection). | |
2042 | */ | |
2043 | void* GetClientData() const; | |
3c4f71cc | 2044 | |
42013f4c FM |
2045 | /** |
2046 | Returns client object pointer for a listbox or choice selection event | |
2047 | (not valid for a deselection). | |
2048 | */ | |
2049 | wxClientData* GetClientObject() const; | |
3c4f71cc | 2050 | |
42013f4c FM |
2051 | /** |
2052 | Returns extra information dependant on the event objects type. | |
3c4f71cc | 2053 | |
42013f4c FM |
2054 | If the event comes from a listbox selection, it is a boolean |
2055 | determining whether the event was a selection (@true) or a | |
2056 | deselection (@false). A listbox deselection only occurs for | |
2057 | multiple-selection boxes, and in this case the index and string values | |
2058 | are indeterminate and the listbox must be examined by the application. | |
2059 | */ | |
2060 | long GetExtraLong() const; | |
3c4f71cc | 2061 | |
42013f4c FM |
2062 | /** |
2063 | Returns the integer identifier corresponding to a listbox, choice or | |
2064 | radiobox selection (only if the event was a selection, not a deselection), | |
2065 | or a boolean value representing the value of a checkbox. | |
2066 | */ | |
2067 | int GetInt() const; | |
3c4f71cc | 2068 | |
42013f4c FM |
2069 | /** |
2070 | Returns item index for a listbox or choice selection event (not valid for | |
2071 | a deselection). | |
23324ae1 | 2072 | */ |
42013f4c | 2073 | int GetSelection() const; |
23324ae1 FM |
2074 | |
2075 | /** | |
85339748 RR |
2076 | Returns item string for a listbox or choice selection event. If one |
2077 | or several items have been deselected, returns the index of the first | |
2078 | deselected item. If some items have been selected and others deselected | |
2079 | at the same time, it will return the index of the first selected item. | |
23324ae1 | 2080 | */ |
42013f4c | 2081 | wxString GetString() const; |
23324ae1 FM |
2082 | |
2083 | /** | |
42013f4c FM |
2084 | This method can be used with checkbox and menu events: for the checkboxes, the |
2085 | method returns @true for a selection event and @false for a deselection one. | |
2086 | For the menu events, this method indicates if the menu item just has become | |
2087 | checked or unchecked (and thus only makes sense for checkable menu items). | |
3c4f71cc | 2088 | |
42013f4c | 2089 | Notice that this method can not be used with wxCheckListBox currently. |
23324ae1 | 2090 | */ |
42013f4c | 2091 | bool IsChecked() const; |
23324ae1 FM |
2092 | |
2093 | /** | |
85339748 RR |
2094 | For a listbox or similar event, returns @true if it is a selection, @false |
2095 | if it is a deselection. If some items have been selected and others deselected | |
2096 | at the same time, it will return @true. | |
23324ae1 | 2097 | */ |
42013f4c | 2098 | bool IsSelection() const; |
e54c96f1 | 2099 | |
42013f4c FM |
2100 | /** |
2101 | Sets the client data for this event. | |
2102 | */ | |
2103 | void SetClientData(void* clientData); | |
7c913512 | 2104 | |
42013f4c FM |
2105 | /** |
2106 | Sets the client object for this event. The client object is not owned by the | |
2107 | event object and the event object will not delete the client object in its destructor. | |
7c913512 | 2108 | |
42013f4c FM |
2109 | The client object must be owned and deleted by another object (e.g. a control) |
2110 | that has longer life time than the event object. | |
2111 | */ | |
2112 | void SetClientObject(wxClientData* clientObject); | |
7c913512 | 2113 | |
23324ae1 | 2114 | /** |
42013f4c | 2115 | Sets the @b m_extraLong member. |
23324ae1 | 2116 | */ |
42013f4c | 2117 | void SetExtraLong(long extraLong); |
23324ae1 FM |
2118 | |
2119 | /** | |
42013f4c | 2120 | Sets the @b m_commandInt member. |
23324ae1 | 2121 | */ |
42013f4c | 2122 | void SetInt(int intCommand); |
23324ae1 FM |
2123 | |
2124 | /** | |
42013f4c | 2125 | Sets the @b m_commandString member. |
23324ae1 | 2126 | */ |
42013f4c | 2127 | void SetString(const wxString& string); |
23324ae1 FM |
2128 | }; |
2129 | ||
2130 | ||
e54c96f1 | 2131 | |
23324ae1 | 2132 | /** |
42013f4c | 2133 | @class wxActivateEvent |
23324ae1 | 2134 | @wxheader{event.h} |
7c913512 | 2135 | |
42013f4c FM |
2136 | An activate event is sent when a window or application is being activated |
2137 | or deactivated. | |
7c913512 | 2138 | |
42013f4c | 2139 | @beginEventTable{wxActivateEvent} |
8c6791e4 | 2140 | @event{EVT_ACTIVATE(func)} |
42013f4c | 2141 | Process a wxEVT_ACTIVATE event. |
8c6791e4 | 2142 | @event{EVT_ACTIVATE_APP(func)} |
42013f4c | 2143 | Process a wxEVT_ACTIVATE_APP event. |
8c6791e4 | 2144 | @event{EVT_HIBERNATE(func)} |
42013f4c FM |
2145 | Process a hibernate event, supplying the member function. This event applies |
2146 | to wxApp only, and only on Windows SmartPhone and PocketPC. | |
2147 | It is generated when the system is low on memory; the application should free | |
2148 | up as much memory as possible, and restore full working state when it receives | |
2149 | a wxEVT_ACTIVATE or wxEVT_ACTIVATE_APP event. | |
2150 | @endEventTable | |
2151 | ||
2152 | ||
2153 | @library{wxcore} | |
23324ae1 | 2154 | @category{events} |
7c913512 | 2155 | |
42013f4c | 2156 | @see @ref overview_eventhandling, wxApp::IsActive |
23324ae1 | 2157 | */ |
42013f4c | 2158 | class wxActivateEvent : public wxEvent |
23324ae1 FM |
2159 | { |
2160 | public: | |
2161 | /** | |
2162 | Constructor. | |
2163 | */ | |
42013f4c FM |
2164 | wxActivateEvent(wxEventType eventType = wxEVT_NULL, bool active = true, |
2165 | int id = 0); | |
23324ae1 FM |
2166 | |
2167 | /** | |
42013f4c | 2168 | Returns @true if the application or window is being activated, @false otherwise. |
23324ae1 | 2169 | */ |
42013f4c | 2170 | bool GetActive() const; |
23324ae1 FM |
2171 | }; |
2172 | ||
2173 | ||
e54c96f1 | 2174 | |
23324ae1 | 2175 | /** |
42013f4c | 2176 | @class wxContextMenuEvent |
23324ae1 | 2177 | @wxheader{event.h} |
7c913512 | 2178 | |
42013f4c FM |
2179 | This class is used for context menu events, sent to give |
2180 | the application a chance to show a context (popup) menu. | |
2181 | ||
2182 | Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this | |
2183 | means that the event originated from a keyboard context button event, and you | |
2184 | should compute a suitable position yourself, for example by calling wxGetMousePosition(). | |
2185 | ||
2186 | When a keyboard context menu button is pressed on Windows, a right-click event | |
2187 | with default position is sent first, and if this event is not processed, the | |
2188 | context menu event is sent. So if you process mouse events and you find your | |
2189 | context menu event handler is not being called, you could call wxEvent::Skip() | |
2190 | for mouse right-down events. | |
2191 | ||
2192 | @beginEventTable{wxContextMenuEvent} | |
8c6791e4 | 2193 | @event{EVT_CONTEXT_MENU(func)} |
42013f4c FM |
2194 | A right click (or other context menu command depending on platform) has been detected. |
2195 | @endEventTable | |
2196 | ||
7c913512 | 2197 | |
23324ae1 FM |
2198 | @library{wxcore} |
2199 | @category{events} | |
7c913512 | 2200 | |
42013f4c | 2201 | @see wxCommandEvent, @ref overview_eventhandling |
23324ae1 | 2202 | */ |
42013f4c | 2203 | class wxContextMenuEvent : public wxCommandEvent |
23324ae1 FM |
2204 | { |
2205 | public: | |
2206 | /** | |
2207 | Constructor. | |
2208 | */ | |
42013f4c FM |
2209 | wxContextMenuEvent(wxEventType id = wxEVT_NULL, int id = 0, |
2210 | const wxPoint& pos = wxDefaultPosition); | |
2211 | ||
2212 | /** | |
2213 | Returns the position in screen coordinates at which the menu should be shown. | |
2214 | Use wxWindow::ScreenToClient to convert to client coordinates. | |
2215 | ||
2216 | You can also omit a position from wxWindow::PopupMenu in order to use | |
2217 | the current mouse pointer position. | |
2218 | ||
2219 | If the event originated from a keyboard event, the value returned from this | |
2220 | function will be wxDefaultPosition. | |
2221 | */ | |
2222 | const wxPoint& GetPosition() const; | |
2223 | ||
2224 | /** | |
2225 | Sets the position at which the menu should be shown. | |
2226 | */ | |
2227 | void SetPosition(const wxPoint& point); | |
23324ae1 FM |
2228 | }; |
2229 | ||
2230 | ||
e54c96f1 | 2231 | |
23324ae1 | 2232 | /** |
42013f4c | 2233 | @class wxEraseEvent |
23324ae1 | 2234 | @wxheader{event.h} |
7c913512 | 2235 | |
42013f4c | 2236 | An erase event is sent when a window's background needs to be repainted. |
7c913512 | 2237 | |
42013f4c FM |
2238 | On some platforms, such as GTK+, this event is simulated (simply generated just |
2239 | before the paint event) and may cause flicker. It is therefore recommended that | |
2240 | you set the text background colour explicitly in order to prevent flicker. | |
2241 | The default background colour under GTK+ is grey. | |
2242 | ||
2243 | To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table | |
2244 | definition. | |
2245 | ||
2246 | You must call wxEraseEvent::GetDC and use the returned device context if it is | |
2247 | non-@NULL. If it is @NULL, create your own temporary wxClientDC object. | |
2248 | ||
2249 | @remarks | |
2250 | Use the device context returned by GetDC to draw on, don't create | |
2251 | a wxPaintDC in the event handler. | |
7c913512 | 2252 | |
42013f4c | 2253 | @beginEventTable{wxEraseEvent} |
8c6791e4 | 2254 | @event{EVT_ERASE_BACKGROUND(func)} |
42013f4c FM |
2255 | Process a wxEVT_ERASE_BACKGROUND event. |
2256 | @endEventTable | |
7c913512 | 2257 | |
23324ae1 FM |
2258 | @library{wxcore} |
2259 | @category{events} | |
7c913512 | 2260 | |
42013f4c | 2261 | @see @ref overview_eventhandling |
23324ae1 | 2262 | */ |
42013f4c | 2263 | class wxEraseEvent : public wxEvent |
23324ae1 FM |
2264 | { |
2265 | public: | |
2266 | /** | |
2267 | Constructor. | |
2268 | */ | |
42013f4c FM |
2269 | wxEraseEvent(int id = 0, wxDC* dc = NULL); |
2270 | ||
2271 | /** | |
2272 | Returns the device context associated with the erase event to draw on. | |
2273 | */ | |
2274 | wxDC* GetDC() const; | |
23324ae1 FM |
2275 | }; |
2276 | ||
2277 | ||
e54c96f1 | 2278 | |
23324ae1 | 2279 | /** |
42013f4c | 2280 | @class wxFocusEvent |
23324ae1 | 2281 | @wxheader{event.h} |
7c913512 | 2282 | |
42013f4c FM |
2283 | A focus event is sent when a window's focus changes. The window losing focus |
2284 | receives a "kill focus" event while the window gaining it gets a "set focus" one. | |
7c913512 | 2285 | |
42013f4c FM |
2286 | Notice that the set focus event happens both when the user gives focus to the |
2287 | window (whether using the mouse or keyboard) and when it is done from the | |
2288 | program itself using wxWindow::SetFocus. | |
2289 | ||
2290 | @beginEventTable{wxFocusEvent} | |
8c6791e4 | 2291 | @event{EVT_SET_FOCUS(func)} |
42013f4c | 2292 | Process a wxEVT_SET_FOCUS event. |
8c6791e4 | 2293 | @event{EVT_KILL_FOCUS(func)} |
42013f4c FM |
2294 | Process a wxEVT_KILL_FOCUS event. |
2295 | @endEventTable | |
7c913512 | 2296 | |
23324ae1 FM |
2297 | @library{wxcore} |
2298 | @category{events} | |
7c913512 | 2299 | |
42013f4c | 2300 | @see @ref overview_eventhandling |
23324ae1 | 2301 | */ |
42013f4c | 2302 | class wxFocusEvent : public wxEvent |
23324ae1 FM |
2303 | { |
2304 | public: | |
23324ae1 FM |
2305 | /** |
2306 | Constructor. | |
2307 | */ | |
42013f4c | 2308 | wxFocusEvent(wxEventType eventType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
2309 | |
2310 | /** | |
42013f4c FM |
2311 | Returns the window associated with this event, that is the window which had the |
2312 | focus before for the @c wxEVT_SET_FOCUS event and the window which is | |
2313 | going to receive focus for the @c wxEVT_KILL_FOCUS one. | |
23324ae1 | 2314 | |
42013f4c | 2315 | Warning: the window pointer may be @NULL! |
23324ae1 | 2316 | */ |
42013f4c FM |
2317 | wxWindow *GetWindow() const; |
2318 | }; | |
23324ae1 | 2319 | |
23324ae1 | 2320 | |
23324ae1 | 2321 | |
42013f4c FM |
2322 | /** |
2323 | @class wxChildFocusEvent | |
2324 | @wxheader{event.h} | |
23324ae1 | 2325 | |
42013f4c FM |
2326 | A child focus event is sent to a (parent-)window when one of its child windows |
2327 | gains focus, so that the window could restore the focus back to its corresponding | |
2328 | child if it loses it now and regains later. | |
23324ae1 | 2329 | |
42013f4c FM |
2330 | Notice that child window is the direct child of the window receiving event. |
2331 | Use wxWindow::FindFocus() to retreive the window which is actually getting focus. | |
2332 | ||
2333 | @beginEventTable{wxChildFocusEvent} | |
8c6791e4 | 2334 | @event{EVT_CHILD_FOCUS(func)} |
42013f4c FM |
2335 | Process a wxEVT_CHILD_FOCUS event. |
2336 | @endEventTable | |
2337 | ||
2338 | @library{wxcore} | |
2339 | @category{events} | |
23324ae1 | 2340 | |
42013f4c FM |
2341 | @see @ref overview_eventhandling |
2342 | */ | |
2343 | class wxChildFocusEvent : public wxCommandEvent | |
2344 | { | |
2345 | public: | |
23324ae1 | 2346 | /** |
42013f4c FM |
2347 | Constructor. |
2348 | ||
2349 | @param win | |
2350 | The direct child which is (or which contains the window which is) receiving | |
2351 | the focus. | |
23324ae1 | 2352 | */ |
42013f4c | 2353 | wxChildFocusEvent(wxWindow* win = NULL); |
23324ae1 FM |
2354 | |
2355 | /** | |
42013f4c FM |
2356 | Returns the direct child which receives the focus, or a (grand-)parent of the |
2357 | control receiving the focus. | |
2358 | ||
2359 | To get the actually focused control use wxWindow::FindFocus. | |
23324ae1 | 2360 | */ |
42013f4c | 2361 | wxWindow *GetWindow() const; |
23324ae1 FM |
2362 | }; |
2363 | ||
2364 | ||
e54c96f1 | 2365 | |
23324ae1 | 2366 | /** |
42013f4c | 2367 | @class wxMouseCaptureLostEvent |
23324ae1 | 2368 | @wxheader{event.h} |
7c913512 | 2369 | |
42013f4c FM |
2370 | An mouse capture lost event is sent to a window that obtained mouse capture, |
2371 | which was subsequently loss due to "external" event, for example when a dialog | |
2372 | box is shown or if another application captures the mouse. | |
2373 | ||
2374 | If this happens, this event is sent to all windows that are on capture stack | |
2375 | (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is | |
2376 | not sent if the capture changes because of a call to CaptureMouse or | |
2377 | ReleaseMouse. | |
2378 | ||
2379 | This event is currently emitted under Windows only. | |
2380 | ||
2381 | @beginEventTable{wxMouseCaptureLostEvent} | |
8c6791e4 | 2382 | @event{EVT_MOUSE_CAPTURE_LOST(func)} |
42013f4c FM |
2383 | Process a wxEVT_MOUSE_CAPTURE_LOST event. |
2384 | @endEventTable | |
7c913512 | 2385 | |
42013f4c | 2386 | @onlyfor{wxmsw} |
7c913512 | 2387 | |
23324ae1 FM |
2388 | @library{wxcore} |
2389 | @category{events} | |
7c913512 | 2390 | |
42013f4c | 2391 | @see wxMouseCaptureChangedEvent, @ref overview_eventhandling, |
4cc4bfaf | 2392 | wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture |
23324ae1 | 2393 | */ |
42013f4c | 2394 | class wxMouseCaptureLostEvent : public wxEvent |
23324ae1 FM |
2395 | { |
2396 | public: | |
2397 | /** | |
2398 | Constructor. | |
2399 | */ | |
42013f4c | 2400 | wxMouseCaptureLostEvent(wxWindowID windowId = 0); |
23324ae1 FM |
2401 | }; |
2402 | ||
2403 | ||
e54c96f1 | 2404 | |
23324ae1 | 2405 | /** |
42013f4c | 2406 | @class wxNotifyEvent |
23324ae1 | 2407 | @wxheader{event.h} |
7c913512 | 2408 | |
42013f4c FM |
2409 | This class is not used by the event handlers by itself, but is a base class |
2410 | for other event classes (such as wxNotebookEvent). | |
7c913512 | 2411 | |
42013f4c FM |
2412 | It (or an object of a derived class) is sent when the controls state is being |
2413 | changed and allows the program to wxNotifyEvent::Veto() this change if it wants | |
2414 | to prevent it from happening. | |
7c913512 | 2415 | |
23324ae1 FM |
2416 | @library{wxcore} |
2417 | @category{events} | |
7c913512 | 2418 | |
42013f4c | 2419 | @see wxNotebookEvent |
23324ae1 | 2420 | */ |
42013f4c | 2421 | class wxNotifyEvent : public wxCommandEvent |
23324ae1 FM |
2422 | { |
2423 | public: | |
2424 | /** | |
42013f4c | 2425 | Constructor (used internally by wxWidgets only). |
23324ae1 | 2426 | */ |
42013f4c | 2427 | wxNotifyEvent(wxEventType eventType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
2428 | |
2429 | /** | |
42013f4c FM |
2430 | This is the opposite of Veto(): it explicitly allows the event to be processed. |
2431 | For most events it is not necessary to call this method as the events are allowed | |
2432 | anyhow but some are forbidden by default (this will be mentioned in the corresponding | |
2433 | event description). | |
23324ae1 | 2434 | */ |
42013f4c | 2435 | void Allow(); |
23324ae1 FM |
2436 | |
2437 | /** | |
42013f4c FM |
2438 | Returns @true if the change is allowed (Veto() hasn't been called) or @false |
2439 | otherwise (if it was). | |
23324ae1 | 2440 | */ |
42013f4c | 2441 | bool IsAllowed() const; |
23324ae1 FM |
2442 | |
2443 | /** | |
42013f4c | 2444 | Prevents the change announced by this event from happening. |
23324ae1 | 2445 | |
42013f4c FM |
2446 | It is in general a good idea to notify the user about the reasons for vetoing |
2447 | the change because otherwise the applications behaviour (which just refuses to | |
2448 | do what the user wants) might be quite surprising. | |
23324ae1 | 2449 | */ |
42013f4c FM |
2450 | void Veto(); |
2451 | }; | |
2452 | ||
23324ae1 | 2453 | |
23324ae1 | 2454 | |
23324ae1 | 2455 | |
42013f4c FM |
2456 | /** |
2457 | Indicates how a wxHelpEvent was generated. | |
2458 | */ | |
2459 | enum wxHelpEventOrigin | |
2460 | { | |
2461 | wxHE_ORIGIN_UNKNOWN = -1, /**< unrecognized event source. */ | |
2462 | wxHE_ORIGIN_KEYBOARD, /**< event generated from F1 key press. */ | |
23324ae1 | 2463 | |
42013f4c FM |
2464 | /** event generated by wxContextHelp or from the [?] button on |
2465 | the title bar (Windows). */ | |
2466 | wxHE_ORIGIN_HELPBUTTON | |
2467 | }; | |
e54c96f1 | 2468 | |
23324ae1 | 2469 | /** |
42013f4c | 2470 | @class wxHelpEvent |
23324ae1 | 2471 | @wxheader{event.h} |
7c913512 | 2472 | |
42013f4c FM |
2473 | A help event is sent when the user has requested context-sensitive help. |
2474 | This can either be caused by the application requesting context-sensitive help mode | |
2475 | via wxContextHelp, or (on MS Windows) by the system generating a WM_HELP message when | |
2476 | the user pressed F1 or clicked on the query button in a dialog caption. | |
7c913512 | 2477 | |
42013f4c FM |
2478 | A help event is sent to the window that the user clicked on, and is propagated |
2479 | up the window hierarchy until the event is processed or there are no more event | |
2480 | handlers. | |
2481 | ||
2482 | The application should call wxEvent::GetId to check the identity of the | |
2483 | clicked-on window, and then either show some suitable help or call wxEvent::Skip() | |
2484 | if the identifier is unrecognised. | |
2485 | ||
2486 | Calling Skip is important because it allows wxWidgets to generate further | |
2487 | events for ancestors of the clicked-on window. Otherwise it would be impossible to | |
2488 | show help for container windows, since processing would stop after the first window | |
2489 | found. | |
2490 | ||
2491 | @beginEventTable{wxHelpEvent} | |
8c6791e4 | 2492 | @event{EVT_HELP(id, func)} |
42013f4c | 2493 | Process a wxEVT_HELP event. |
8c6791e4 | 2494 | @event{EVT_HELP_RANGE(id1, id2, func)} |
42013f4c FM |
2495 | Process a wxEVT_HELP event for a range of ids. |
2496 | @endEventTable | |
7c913512 | 2497 | |
23324ae1 FM |
2498 | @library{wxcore} |
2499 | @category{events} | |
7c913512 | 2500 | |
42013f4c | 2501 | @see wxContextHelp, wxDialog, @ref overview_eventhandling |
23324ae1 | 2502 | */ |
42013f4c | 2503 | class wxHelpEvent : public wxCommandEvent |
23324ae1 FM |
2504 | { |
2505 | public: | |
2506 | /** | |
2507 | Constructor. | |
2508 | */ | |
42013f4c FM |
2509 | wxHelpEvent(wxEventType type = wxEVT_NULL, |
2510 | wxWindowID winid = 0, | |
2511 | const wxPoint& pt = wxDefaultPosition, | |
2512 | wxHelpEventOrigin origin = wxHE_ORIGIN_UNKNOWN); | |
2513 | ||
2514 | /** | |
2515 | Returns the origin of the help event which is one of the ::wxHelpEventOrigin | |
2516 | values. | |
2517 | ||
2518 | The application may handle events generated using the keyboard or mouse | |
2519 | differently, e.g. by using wxGetMousePosition() for the mouse events. | |
2520 | ||
2521 | @see SetOrigin() | |
2522 | */ | |
2523 | wxHelpEventOrigin GetOrigin() const; | |
23324ae1 FM |
2524 | |
2525 | /** | |
42013f4c FM |
2526 | Returns the left-click position of the mouse, in screen coordinates. |
2527 | This allows the application to position the help appropriately. | |
23324ae1 | 2528 | */ |
42013f4c | 2529 | const wxPoint& GetPosition() const; |
23324ae1 FM |
2530 | |
2531 | /** | |
42013f4c FM |
2532 | Set the help event origin, only used internally by wxWidgets normally. |
2533 | ||
2534 | @see GetOrigin() | |
23324ae1 | 2535 | */ |
42013f4c | 2536 | void SetOrigin(wxHelpEventOrigin); |
23324ae1 FM |
2537 | |
2538 | /** | |
42013f4c | 2539 | Sets the left-click position of the mouse, in screen coordinates. |
23324ae1 | 2540 | */ |
42013f4c | 2541 | void SetPosition(const wxPoint& pt); |
23324ae1 FM |
2542 | }; |
2543 | ||
2544 | ||
e54c96f1 | 2545 | |
23324ae1 | 2546 | /** |
42013f4c | 2547 | @class wxScrollEvent |
23324ae1 | 2548 | @wxheader{event.h} |
7c913512 | 2549 | |
42013f4c FM |
2550 | A scroll event holds information about events sent from stand-alone |
2551 | scrollbars (see wxScrollBar) and sliders (see wxSlider). | |
7c913512 | 2552 | |
42013f4c FM |
2553 | Note that scrolled windows send the wxScrollWinEvent which does not derive from |
2554 | wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of | |
2555 | events and use the event table macros mentioned below only for the scrollbar-like | |
2556 | controls. | |
7c913512 | 2557 | |
42013f4c | 2558 | @section wxscrollevent_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED |
7c913512 | 2559 | |
42013f4c FM |
2560 | The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb |
2561 | using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed | |
2562 | by an EVT_SCROLL_CHANGED event). | |
7c913512 | 2563 | |
42013f4c FM |
2564 | The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change the thumb |
2565 | position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE | |
2566 | event does not happen). | |
7c913512 | 2567 | |
42013f4c FM |
2568 | In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving has finished |
2569 | independently of the way it had started. Please see the widgets sample ("Slider" page) | |
2570 | to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action. | |
2571 | ||
2572 | @remarks | |
2573 | Note that unless specifying a scroll control identifier, you will need to test for scrollbar | |
2574 | orientation with wxScrollEvent::GetOrientation, since horizontal and vertical scroll events | |
2575 | are processed using the same event handler. | |
2576 | ||
2577 | @beginEventTable{wxScrollEvent} | |
2578 | You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting | |
2579 | scroll events from controls, or EVT_SCROLL... macros without window IDs for | |
2580 | intercepting scroll events from the receiving window -- except for this, the | |
2581 | macros behave exactly the same. | |
8c6791e4 | 2582 | @event{EVT_SCROLL(func)} |
42013f4c | 2583 | Process all scroll events. |
8c6791e4 | 2584 | @event{EVT_SCROLL_TOP(func)} |
42013f4c | 2585 | Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position). |
8c6791e4 | 2586 | @event{EVT_SCROLL_BOTTOM(func)} |
42013f4c | 2587 | Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position). |
8c6791e4 | 2588 | @event{EVT_SCROLL_LINEUP(func)} |
42013f4c | 2589 | Process wxEVT_SCROLL_LINEUP line up events. |
8c6791e4 | 2590 | @event{EVT_SCROLL_LINEDOWN(func)} |
42013f4c | 2591 | Process wxEVT_SCROLL_LINEDOWN line down events. |
8c6791e4 | 2592 | @event{EVT_SCROLL_PAGEUP(func)} |
42013f4c | 2593 | Process wxEVT_SCROLL_PAGEUP page up events. |
8c6791e4 | 2594 | @event{EVT_SCROLL_PAGEDOWN(func)} |
42013f4c | 2595 | Process wxEVT_SCROLL_PAGEDOWN page down events. |
8c6791e4 | 2596 | @event{EVT_SCROLL_THUMBTRACK(func)} |
42013f4c FM |
2597 | Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the |
2598 | user drags the thumbtrack). | |
8c6791e4 | 2599 | @event{EVT_SCROLL_THUMBRELEASE(func)} |
42013f4c | 2600 | Process wxEVT_SCROLL_THUMBRELEASE thumb release events. |
8c6791e4 | 2601 | @event{EVT_SCROLL_CHANGED(func)} |
42013f4c | 2602 | Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only). |
8c6791e4 | 2603 | @event{EVT_COMMAND_SCROLL(id, func)} |
42013f4c | 2604 | Process all scroll events. |
8c6791e4 | 2605 | @event{EVT_COMMAND_SCROLL_TOP(id, func)} |
42013f4c | 2606 | Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position). |
8c6791e4 | 2607 | @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)} |
42013f4c | 2608 | Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position). |
8c6791e4 | 2609 | @event{EVT_COMMAND_SCROLL_LINEUP(id, func)} |
42013f4c | 2610 | Process wxEVT_SCROLL_LINEUP line up events. |
8c6791e4 | 2611 | @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)} |
42013f4c | 2612 | Process wxEVT_SCROLL_LINEDOWN line down events. |
8c6791e4 | 2613 | @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)} |
42013f4c | 2614 | Process wxEVT_SCROLL_PAGEUP page up events. |
8c6791e4 | 2615 | @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)} |
42013f4c | 2616 | Process wxEVT_SCROLL_PAGEDOWN page down events. |
8c6791e4 | 2617 | @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)} |
42013f4c FM |
2618 | Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent |
2619 | as the user drags the thumbtrack). | |
8c6791e4 | 2620 | @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)} |
42013f4c | 2621 | Process wxEVT_SCROLL_THUMBRELEASE thumb release events. |
8c6791e4 | 2622 | @event{EVT_COMMAND_SCROLL_CHANGED(func)} |
42013f4c FM |
2623 | Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only). |
2624 | @endEventTable | |
7c913512 | 2625 | |
23324ae1 | 2626 | @library{wxcore} |
1f1d2182 | 2627 | @category{events} |
7c913512 | 2628 | |
42013f4c | 2629 | @see wxScrollBar, wxSlider, wxSpinButton, wxScrollWinEvent, @ref overview_eventhandling |
23324ae1 | 2630 | */ |
42013f4c | 2631 | class wxScrollEvent : public wxCommandEvent |
23324ae1 FM |
2632 | { |
2633 | public: | |
2634 | /** | |
42013f4c | 2635 | Constructor. |
23324ae1 | 2636 | */ |
42013f4c FM |
2637 | wxScrollEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int pos = 0, |
2638 | int orientation = 0); | |
23324ae1 FM |
2639 | |
2640 | /** | |
42013f4c FM |
2641 | Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the |
2642 | scrollbar. | |
23324ae1 | 2643 | */ |
42013f4c | 2644 | int GetOrientation() const; |
23324ae1 FM |
2645 | |
2646 | /** | |
42013f4c | 2647 | Returns the position of the scrollbar. |
23324ae1 | 2648 | */ |
42013f4c | 2649 | int GetPosition() const; |
23324ae1 FM |
2650 | }; |
2651 | ||
42013f4c FM |
2652 | /** |
2653 | See wxIdleEvent::SetMode() for more info. | |
2654 | */ | |
2655 | enum wxIdleMode | |
2656 | { | |
2657 | /** Send idle events to all windows */ | |
2658 | wxIDLE_PROCESS_ALL, | |
2659 | ||
2660 | /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */ | |
2661 | wxIDLE_PROCESS_SPECIFIED | |
2662 | }; | |
23324ae1 | 2663 | |
e54c96f1 | 2664 | |
23324ae1 | 2665 | /** |
42013f4c | 2666 | @class wxIdleEvent |
23324ae1 | 2667 | @wxheader{event.h} |
7c913512 | 2668 | |
42013f4c FM |
2669 | This class is used for idle events, which are generated when the system becomes |
2670 | idle. Note that, unless you do something specifically, the idle events are not | |
2671 | sent if the system remains idle once it has become it, e.g. only a single idle | |
2672 | event will be generated until something else resulting in more normal events | |
2673 | happens and only then is the next idle event sent again. | |
2674 | ||
2675 | If you need to ensure a continuous stream of idle events, you can either use | |
2676 | wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically | |
2677 | (for example from a timer event handler), but note that both of these approaches | |
2678 | (and especially the first one) increase the system load and so should be avoided | |
2679 | if possible. | |
2680 | ||
2681 | By default, idle events are sent to all windows (and also wxApp, as usual). | |
2682 | If this is causing a significant overhead in your application, you can call | |
2683 | wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the | |
2684 | wxWS_EX_PROCESS_IDLE extra window style for every window which should receive | |
2685 | idle events. | |
2686 | ||
2687 | @beginEventTable{wxIdleEvent} | |
8c6791e4 | 2688 | @event{EVT_IDLE(func)} |
42013f4c FM |
2689 | Process a wxEVT_IDLE event. |
2690 | @endEventTable | |
7c913512 | 2691 | |
23324ae1 | 2692 | @library{wxbase} |
1f1d2182 | 2693 | @category{events} |
7c913512 | 2694 | |
42013f4c | 2695 | @see @ref overview_eventhandling, wxUpdateUIEvent, wxWindow::OnInternalIdle |
23324ae1 | 2696 | */ |
42013f4c | 2697 | class wxIdleEvent : public wxEvent |
23324ae1 FM |
2698 | { |
2699 | public: | |
2700 | /** | |
2701 | Constructor. | |
2702 | */ | |
42013f4c | 2703 | wxIdleEvent(); |
23324ae1 FM |
2704 | |
2705 | /** | |
42013f4c | 2706 | Returns @true if it is appropriate to send idle events to this window. |
23324ae1 | 2707 | |
42013f4c FM |
2708 | This function looks at the mode used (see wxIdleEvent::SetMode), |
2709 | and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle | |
2710 | events should be sent to this window now. | |
3c4f71cc | 2711 | |
42013f4c FM |
2712 | By default this will always return @true because the update mode is initially |
2713 | wxIDLE_PROCESS_ALL. You can change the mode to only send idle events to | |
2714 | windows with the wxWS_EX_PROCESS_IDLE extra window style set. | |
3c4f71cc | 2715 | |
42013f4c | 2716 | @see SetMode() |
23324ae1 | 2717 | */ |
42013f4c | 2718 | static bool CanSend(wxWindow* window); |
23324ae1 | 2719 | |
23324ae1 | 2720 | /** |
42013f4c FM |
2721 | Static function returning a value specifying how wxWidgets will send idle |
2722 | events: to all windows, or only to those which specify that they | |
2723 | will process the events. | |
3c4f71cc | 2724 | |
42013f4c | 2725 | @see SetMode(). |
23324ae1 | 2726 | */ |
42013f4c | 2727 | static wxIdleMode GetMode(); |
23324ae1 | 2728 | |
23324ae1 | 2729 | /** |
42013f4c FM |
2730 | Returns @true if the OnIdle function processing this event requested more |
2731 | processing time. | |
3c4f71cc | 2732 | |
42013f4c | 2733 | @see RequestMore() |
23324ae1 | 2734 | */ |
42013f4c | 2735 | bool MoreRequested() const; |
23324ae1 FM |
2736 | |
2737 | /** | |
42013f4c | 2738 | Tells wxWidgets that more processing is required. |
3c4f71cc | 2739 | |
42013f4c FM |
2740 | This function can be called by an OnIdle handler for a window or window event |
2741 | handler to indicate that wxApp::OnIdle should forward the OnIdle event once | |
2742 | more to the application windows. | |
3c4f71cc | 2743 | |
42013f4c FM |
2744 | If no window calls this function during OnIdle, then the application will |
2745 | remain in a passive event loop (not calling OnIdle) until a new event is | |
2746 | posted to the application by the windowing system. | |
2747 | ||
2748 | @see MoreRequested() | |
23324ae1 | 2749 | */ |
42013f4c | 2750 | void RequestMore(bool needMore = true); |
23324ae1 FM |
2751 | |
2752 | /** | |
42013f4c FM |
2753 | Static function for specifying how wxWidgets will send idle events: to |
2754 | all windows, or only to those which specify that they will process the events. | |
3c4f71cc | 2755 | |
42013f4c FM |
2756 | @param mode |
2757 | Can be one of the ::wxIdleMode values. | |
2758 | The default is wxIDLE_PROCESS_ALL. | |
23324ae1 | 2759 | */ |
42013f4c FM |
2760 | static void SetMode(wxIdleMode mode); |
2761 | }; | |
23324ae1 | 2762 | |
3c4f71cc | 2763 | |
23324ae1 | 2764 | |
42013f4c FM |
2765 | /** |
2766 | @class wxInitDialogEvent | |
2767 | @wxheader{event.h} | |
3c4f71cc | 2768 | |
42013f4c FM |
2769 | A wxInitDialogEvent is sent as a dialog or panel is being initialised. |
2770 | Handlers for this event can transfer data to the window. | |
23324ae1 | 2771 | |
42013f4c | 2772 | The default handler calls wxWindow::TransferDataToWindow. |
3c4f71cc | 2773 | |
42013f4c | 2774 | @beginEventTable{wxInitDialogEvent} |
8c6791e4 | 2775 | @event{EVT_INIT_DIALOG(func)} |
42013f4c FM |
2776 | Process a wxEVT_INIT_DIALOG event. |
2777 | @endEventTable | |
2778 | ||
2779 | @library{wxcore} | |
2780 | @category{events} | |
23324ae1 | 2781 | |
42013f4c FM |
2782 | @see @ref overview_eventhandling |
2783 | */ | |
2784 | class wxInitDialogEvent : public wxEvent | |
2785 | { | |
2786 | public: | |
23324ae1 | 2787 | /** |
42013f4c FM |
2788 | Constructor. |
2789 | */ | |
2790 | wxInitDialogEvent(int id = 0); | |
2791 | }; | |
3c4f71cc | 2792 | |
3c4f71cc | 2793 | |
3c4f71cc | 2794 | |
42013f4c FM |
2795 | /** |
2796 | @class wxWindowDestroyEvent | |
2797 | @wxheader{event.h} | |
3c4f71cc | 2798 | |
42013f4c FM |
2799 | This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a |
2800 | window is destroyed. | |
23324ae1 | 2801 | |
42013f4c FM |
2802 | When a class derived from wxWindow is destroyed its destructor will have |
2803 | already run by the time this event is sent. Therefore this event will not | |
2804 | usually be received at all. | |
3c4f71cc | 2805 | |
42013f4c FM |
2806 | To receive this event wxEvtHandler::Connect() must be used (using an event |
2807 | table macro will not work). Since it is received after the destructor has run, | |
2808 | an object should not handle its own wxWindowDestroyEvent, but it can be used | |
2809 | to get notification of the destruction of another window. | |
3c4f71cc | 2810 | |
42013f4c FM |
2811 | @library{wxcore} |
2812 | @category{events} | |
3c4f71cc | 2813 | |
42013f4c FM |
2814 | @see @ref overview_eventhandling, wxWindowCreateEvent |
2815 | */ | |
2816 | class wxWindowDestroyEvent : public wxCommandEvent | |
2817 | { | |
2818 | public: | |
2819 | /** | |
2820 | Constructor. | |
23324ae1 | 2821 | */ |
42013f4c FM |
2822 | wxWindowDestroyEvent(wxWindow* win = NULL); |
2823 | }; | |
23324ae1 | 2824 | |
3c4f71cc | 2825 | |
42013f4c FM |
2826 | /** |
2827 | The possible flag values for a wxNavigationKeyEvent. | |
2828 | */ | |
2829 | enum wxNavigationKeyEventFlags | |
2830 | { | |
2831 | wxNKEF_IS_BACKWARD = 0x0000, | |
2832 | wxNKEF_IS_FORWARD = 0x0001, | |
2833 | wxNKEF_WINCHANGE = 0x0002, | |
2834 | wxNKEF_FROMTAB = 0x0004 | |
2835 | }; | |
3c4f71cc | 2836 | |
3c4f71cc | 2837 | |
42013f4c FM |
2838 | /** |
2839 | @class wxNavigationKeyEvent | |
2840 | @wxheader{event.h} | |
3c4f71cc | 2841 | |
42013f4c FM |
2842 | This event class contains information about navigation events, |
2843 | generated by navigation keys such as tab and page down. | |
23324ae1 | 2844 | |
42013f4c FM |
2845 | This event is mainly used by wxWidgets implementations. |
2846 | A wxNavigationKeyEvent handler is automatically provided by wxWidgets | |
2847 | when you make a class into a control container with the macro | |
2848 | WX_DECLARE_CONTROL_CONTAINER. | |
3c4f71cc | 2849 | |
42013f4c | 2850 | @beginEventTable{wxNavigationKeyEvent} |
8c6791e4 | 2851 | @event{EVT_NAVIGATION_KEY(func)} |
42013f4c FM |
2852 | Process a navigation key event. |
2853 | @endEventTable | |
3c4f71cc | 2854 | |
42013f4c FM |
2855 | @library{wxcore} |
2856 | @category{events} | |
3c4f71cc | 2857 | |
42013f4c FM |
2858 | @see wxWindow::Navigate, wxWindow::NavigateIn |
2859 | */ | |
2860 | class wxNavigationKeyEvent : public wxEvent | |
2861 | { | |
2862 | public: | |
2863 | wxNavigationKeyEvent(); | |
2864 | wxNavigationKeyEvent(const wxNavigationKeyEvent& event); | |
23324ae1 FM |
2865 | |
2866 | /** | |
42013f4c | 2867 | Returns the child that has the focus, or @NULL. |
23324ae1 | 2868 | */ |
42013f4c | 2869 | wxWindow* GetCurrentFocus() const; |
23324ae1 FM |
2870 | |
2871 | /** | |
42013f4c FM |
2872 | Returns @true if the navigation was in the forward direction. |
2873 | */ | |
2874 | bool GetDirection() const; | |
3c4f71cc | 2875 | |
42013f4c FM |
2876 | /** |
2877 | Returns @true if the navigation event was from a tab key. | |
2878 | This is required for proper navigation over radio buttons. | |
2879 | */ | |
2880 | bool IsFromTab() const; | |
3c4f71cc | 2881 | |
42013f4c FM |
2882 | /** |
2883 | Returns @true if the navigation event represents a window change | |
2884 | (for example, from Ctrl-Page Down in a notebook). | |
23324ae1 | 2885 | */ |
42013f4c | 2886 | bool IsWindowChange() const; |
23324ae1 FM |
2887 | |
2888 | /** | |
42013f4c FM |
2889 | Sets the current focus window member. |
2890 | */ | |
2891 | void SetCurrentFocus(wxWindow* currentFocus); | |
3c4f71cc | 2892 | |
42013f4c FM |
2893 | /** |
2894 | Sets the direction to forward if @a direction is @true, or backward | |
2895 | if @false. | |
2896 | */ | |
2897 | void SetDirection(bool direction); | |
3c4f71cc | 2898 | |
42013f4c FM |
2899 | /** |
2900 | Sets the flags for this event. | |
2901 | The @a flags can be a combination of the ::wxNavigationKeyEventFlags values. | |
23324ae1 | 2902 | */ |
42013f4c | 2903 | void SetFlags(long flags); |
23324ae1 FM |
2904 | |
2905 | /** | |
42013f4c FM |
2906 | Marks the navigation event as from a tab key. |
2907 | */ | |
2908 | void SetFromTab(bool fromTab); | |
3c4f71cc | 2909 | |
42013f4c FM |
2910 | /** |
2911 | Marks the event as a window change event. | |
23324ae1 | 2912 | */ |
42013f4c | 2913 | void SetWindowChange(bool windowChange); |
23324ae1 FM |
2914 | }; |
2915 | ||
2916 | ||
e54c96f1 | 2917 | |
23324ae1 | 2918 | /** |
42013f4c | 2919 | @class wxMouseCaptureChangedEvent |
23324ae1 | 2920 | @wxheader{event.h} |
7c913512 | 2921 | |
42013f4c FM |
2922 | An mouse capture changed event is sent to a window that loses its |
2923 | mouse capture. This is called even if wxWindow::ReleaseCapture | |
2924 | was called by the application code. Handling this event allows | |
2925 | an application to cater for unexpected capture releases which | |
2926 | might otherwise confuse mouse handling code. | |
7c913512 | 2927 | |
42013f4c FM |
2928 | @onlyfor{wxmsw} |
2929 | ||
2930 | @beginEventTable{wxMouseCaptureChangedEvent} | |
8c6791e4 | 2931 | @event{EVT_MOUSE_CAPTURE_CHANGED(func)} |
42013f4c FM |
2932 | Process a wxEVT_MOUSE_CAPTURE_CHANGED event. |
2933 | @endEventTable | |
7c913512 | 2934 | |
23324ae1 FM |
2935 | @library{wxcore} |
2936 | @category{events} | |
7c913512 | 2937 | |
42013f4c FM |
2938 | @see wxMouseCaptureLostEvent, @ref overview_eventhandling, |
2939 | wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture | |
23324ae1 | 2940 | */ |
42013f4c | 2941 | class wxMouseCaptureChangedEvent : public wxEvent |
23324ae1 FM |
2942 | { |
2943 | public: | |
2944 | /** | |
2945 | Constructor. | |
2946 | */ | |
42013f4c FM |
2947 | wxMouseCaptureChangedEvent(wxWindowID windowId = 0, |
2948 | wxWindow* gainedCapture = NULL); | |
23324ae1 FM |
2949 | |
2950 | /** | |
42013f4c FM |
2951 | Returns the window that gained the capture, or @NULL if it was a |
2952 | non-wxWidgets window. | |
23324ae1 | 2953 | */ |
42013f4c | 2954 | wxWindow* GetCapturedWindow() const; |
23324ae1 FM |
2955 | }; |
2956 | ||
2957 | ||
e54c96f1 | 2958 | |
23324ae1 | 2959 | /** |
42013f4c | 2960 | @class wxCloseEvent |
23324ae1 | 2961 | @wxheader{event.h} |
7c913512 | 2962 | |
42013f4c FM |
2963 | This event class contains information about window and session close events. |
2964 | ||
2965 | The handler function for EVT_CLOSE is called when the user has tried to close a | |
2966 | a frame or dialog box using the window manager (X) or system menu (Windows). | |
2967 | It can also be invoked by the application itself programmatically, for example by | |
2968 | calling the wxWindow::Close function. | |
2969 | ||
2970 | You should check whether the application is forcing the deletion of the window | |
2971 | using wxCloseEvent::CanVeto. If this is @false, you @e must destroy the window | |
2972 | using wxWindow::Destroy. | |
2973 | ||
2974 | If the return value is @true, it is up to you whether you respond by destroying | |
2975 | the window. | |
2976 | ||
2977 | If you don't destroy the window, you should call wxCloseEvent::Veto to | |
2978 | let the calling code know that you did not destroy the window. | |
2979 | This allows the wxWindow::Close function to return @true or @false depending | |
2980 | on whether the close instruction was honoured or not. | |
2981 | ||
9fb99466 VZ |
2982 | The EVT_END_SESSION event is slightly different as it is sent by the system |
2983 | when the user session is ending (e.g. because of log out or shutdown) and | |
2984 | so all windows are being forcefully closed. At least under MSW, after the | |
2985 | handler for this event is executed the program is simply killed by the | |
2986 | system. Because of this, the default handler for this event provided by | |
2987 | wxWidgets calls all the usual cleanup code (including wxApp::OnExit()) so | |
2988 | that it could still be executed and exit()s the process itself, without | |
2989 | waiting for being killed. If this behaviour is for some reason undesirable, | |
2990 | make sure that you define a handler for this event in your wxApp-derived | |
2991 | class and do not call @c event.Skip() in it (but be aware that the system | |
2992 | will still kill your application). | |
2993 | ||
42013f4c | 2994 | @beginEventTable{wxCloseEvent} |
8c6791e4 | 2995 | @event{EVT_CLOSE(func)} |
42013f4c FM |
2996 | Process a close event, supplying the member function. |
2997 | This event applies to wxFrame and wxDialog classes. | |
8c6791e4 | 2998 | @event{EVT_QUERY_END_SESSION(func)} |
42013f4c | 2999 | Process a query end session event, supplying the member function. |
9fb99466 | 3000 | This event can be handled in wxApp-derived class only. |
8c6791e4 | 3001 | @event{EVT_END_SESSION(func)} |
42013f4c | 3002 | Process an end session event, supplying the member function. |
9fb99466 | 3003 | This event can be handled in wxApp-derived class only. |
42013f4c | 3004 | @endEventTable |
7c913512 | 3005 | |
23324ae1 FM |
3006 | @library{wxcore} |
3007 | @category{events} | |
7c913512 | 3008 | |
42013f4c | 3009 | @see wxWindow::Close, @ref overview_windowdeletion |
23324ae1 | 3010 | */ |
42013f4c | 3011 | class wxCloseEvent : public wxEvent |
23324ae1 FM |
3012 | { |
3013 | public: | |
3014 | /** | |
3015 | Constructor. | |
3016 | */ | |
42013f4c | 3017 | wxCloseEvent(wxEventType commandEventType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
3018 | |
3019 | /** | |
42013f4c FM |
3020 | Returns @true if you can veto a system shutdown or a window close event. |
3021 | Vetoing a window close event is not possible if the calling code wishes to | |
3022 | force the application to exit, and so this function must be called to check this. | |
23324ae1 | 3023 | */ |
42013f4c FM |
3024 | bool CanVeto() const; |
3025 | ||
3026 | /** | |
3027 | Returns @true if the user is just logging off or @false if the system is | |
3028 | shutting down. This method can only be called for end session and query end | |
3029 | session events, it doesn't make sense for close window event. | |
3030 | */ | |
3031 | bool GetLoggingOff() const; | |
3032 | ||
3033 | /** | |
3034 | Sets the 'can veto' flag. | |
3035 | */ | |
3036 | void SetCanVeto(bool canVeto); | |
3037 | ||
3038 | /** | |
3039 | Sets the 'force' flag. | |
3040 | */ | |
3041 | void SetForce(bool force) const; | |
3042 | ||
3043 | /** | |
3044 | Sets the 'logging off' flag. | |
3045 | */ | |
3046 | void SetLoggingOff(bool loggingOff); | |
3047 | ||
3048 | /** | |
3049 | Call this from your event handler to veto a system shutdown or to signal | |
3050 | to the calling application that a window close did not happen. | |
3051 | ||
3052 | You can only veto a shutdown if CanVeto() returns @true. | |
3053 | */ | |
3054 | void Veto(bool veto = true); | |
23324ae1 FM |
3055 | }; |
3056 | ||
3057 | ||
e54c96f1 | 3058 | |
23324ae1 | 3059 | /** |
42013f4c | 3060 | @class wxMenuEvent |
23324ae1 | 3061 | @wxheader{event.h} |
7c913512 | 3062 | |
42013f4c FM |
3063 | This class is used for a variety of menu-related events. Note that |
3064 | these do not include menu command events, which are | |
3065 | handled using wxCommandEvent objects. | |
7c913512 | 3066 | |
42013f4c FM |
3067 | The default handler for wxEVT_MENU_HIGHLIGHT displays help |
3068 | text in the first field of the status bar. | |
7c913512 | 3069 | |
42013f4c | 3070 | @beginEventTable{wxMenuEvent} |
8c6791e4 | 3071 | @event{EVT_MENU_OPEN(func)} |
42013f4c FM |
3072 | A menu is about to be opened. On Windows, this is only sent once for each |
3073 | navigation of the menubar (up until all menus have closed). | |
8c6791e4 | 3074 | @event{EVT_MENU_CLOSE(func)} |
42013f4c | 3075 | A menu has been just closed. |
8c6791e4 | 3076 | @event{EVT_MENU_HIGHLIGHT(id, func)} |
42013f4c FM |
3077 | The menu item with the specified id has been highlighted: used to show |
3078 | help prompts in the status bar by wxFrame | |
8c6791e4 | 3079 | @event{EVT_MENU_HIGHLIGHT_ALL(func)} |
42013f4c FM |
3080 | A menu item has been highlighted, i.e. the currently selected menu item has changed. |
3081 | @endEventTable | |
7c913512 | 3082 | |
42013f4c | 3083 | @library{wxcore} |
23324ae1 | 3084 | @category{events} |
7c913512 | 3085 | |
42013f4c | 3086 | @see wxCommandEvent, @ref overview_eventhandling |
23324ae1 | 3087 | */ |
42013f4c | 3088 | class wxMenuEvent : public wxEvent |
23324ae1 FM |
3089 | { |
3090 | public: | |
3091 | /** | |
42013f4c | 3092 | Constructor. |
23324ae1 | 3093 | */ |
42013f4c | 3094 | wxMenuEvent(wxEventType id = wxEVT_NULL, int id = 0, wxMenu* menu = NULL); |
23324ae1 FM |
3095 | |
3096 | /** | |
42013f4c FM |
3097 | Returns the menu which is being opened or closed. This method should only be |
3098 | used with the @c OPEN and @c CLOSE events and even for them the | |
3099 | returned pointer may be @NULL in some ports. | |
23324ae1 | 3100 | */ |
42013f4c | 3101 | wxMenu* GetMenu() const; |
23324ae1 FM |
3102 | |
3103 | /** | |
42013f4c FM |
3104 | Returns the menu identifier associated with the event. |
3105 | This method should be only used with the @c HIGHLIGHT events. | |
23324ae1 | 3106 | */ |
42013f4c | 3107 | int GetMenuId() const; |
23324ae1 FM |
3108 | |
3109 | /** | |
42013f4c FM |
3110 | Returns @true if the menu which is being opened or closed is a popup menu, |
3111 | @false if it is a normal one. | |
23324ae1 | 3112 | |
42013f4c | 3113 | This method should only be used with the @c OPEN and @c CLOSE events. |
23324ae1 | 3114 | */ |
42013f4c FM |
3115 | bool IsPopup() const; |
3116 | }; | |
23324ae1 | 3117 | |
23324ae1 | 3118 | |
42013f4c FM |
3119 | /** |
3120 | @class wxIconizeEvent | |
3121 | @wxheader{event.h} | |
23324ae1 | 3122 | |
42013f4c | 3123 | An event being sent when the frame is iconized (minimized) or restored. |
23324ae1 | 3124 | |
42013f4c | 3125 | Currently only wxMSW and wxGTK generate such events. |
23324ae1 | 3126 | |
42013f4c | 3127 | @onlyfor{wxmsw,wxgtk} |
23324ae1 | 3128 | |
42013f4c | 3129 | @beginEventTable{wxIconizeEvent} |
8c6791e4 | 3130 | @event{EVT_ICONIZE(func)} |
42013f4c FM |
3131 | Process a wxEVT_ICONIZE event. |
3132 | @endEventTable | |
23324ae1 | 3133 | |
42013f4c FM |
3134 | @library{wxcore} |
3135 | @category{events} | |
23324ae1 | 3136 | |
42013f4c FM |
3137 | @see @ref overview_eventhandling, wxTopLevelWindow::Iconize, |
3138 | wxTopLevelWindow::IsIconized | |
3139 | */ | |
3140 | class wxIconizeEvent : public wxEvent | |
3141 | { | |
3142 | public: | |
23324ae1 | 3143 | /** |
42013f4c | 3144 | Constructor. |
23324ae1 | 3145 | */ |
42013f4c | 3146 | wxIconizeEvent(int id = 0, bool iconized = true); |
23324ae1 FM |
3147 | |
3148 | /** | |
42013f4c FM |
3149 | Returns @true if the frame has been iconized, @false if it has been |
3150 | restored. | |
23324ae1 | 3151 | */ |
42013f4c FM |
3152 | bool Iconized() const; |
3153 | }; | |
23324ae1 | 3154 | |
23324ae1 | 3155 | |
42013f4c FM |
3156 | |
3157 | /** | |
3158 | @class wxMoveEvent | |
3159 | @wxheader{event.h} | |
3160 | ||
3161 | A move event holds information about move change events. | |
3162 | ||
3163 | @beginEventTable{wxMoveEvent} | |
8c6791e4 | 3164 | @event{EVT_MOVE(func)} |
42013f4c | 3165 | Process a wxEVT_MOVE event, which is generated when a window is moved. |
8c6791e4 | 3166 | @event{EVT_MOVE_START(func)} |
42013f4c FM |
3167 | Process a wxEVT_MOVE_START event, which is generated when the user starts |
3168 | to move or size a window. wxMSW only. | |
8c6791e4 | 3169 | @event{EVT_MOVE_END(func)} |
42013f4c FM |
3170 | Process a wxEVT_MOVE_END event, which is generated when the user stops |
3171 | moving or sizing a window. wxMSW only. | |
3172 | @endEventTable | |
3173 | ||
3174 | @library{wxcore} | |
3175 | @category{events} | |
3176 | ||
3177 | @see wxPoint, @ref overview_eventhandling | |
3178 | */ | |
3179 | class wxMoveEvent : public wxEvent | |
3180 | { | |
3181 | public: | |
23324ae1 | 3182 | /** |
42013f4c | 3183 | Constructor. |
23324ae1 | 3184 | */ |
42013f4c | 3185 | wxMoveEvent(const wxPoint& pt, int id = 0); |
23324ae1 FM |
3186 | |
3187 | /** | |
42013f4c | 3188 | Returns the position of the window generating the move change event. |
23324ae1 | 3189 | */ |
42013f4c | 3190 | wxPoint GetPosition() const; |
23324ae1 FM |
3191 | }; |
3192 | ||
3193 | ||
3194 | /** | |
3195 | @class wxSizeEvent | |
3196 | @wxheader{event.h} | |
7c913512 | 3197 | |
23324ae1 | 3198 | A size event holds information about size change events. |
7c913512 | 3199 | |
23324ae1 | 3200 | The EVT_SIZE handler function will be called when the window has been resized. |
7c913512 | 3201 | |
42013f4c | 3202 | You may wish to use this for frames to resize their child windows as appropriate. |
7c913512 | 3203 | |
42013f4c FM |
3204 | Note that the size passed is of the whole window: call wxWindow::GetClientSize |
3205 | for the area which may be used by the application. | |
7c913512 | 3206 | |
23324ae1 | 3207 | When a window is resized, usually only a small part of the window is damaged |
42013f4c FM |
3208 | and you may only need to repaint that area. However, if your drawing depends on the |
3209 | size of the window, you may need to clear the DC explicitly and repaint the whole window. | |
3210 | In which case, you may need to call wxWindow::Refresh to invalidate the entire window. | |
3211 | ||
3212 | @beginEventTable{wxSizeEvent} | |
8c6791e4 | 3213 | @event{EVT_SIZE(func)} |
42013f4c FM |
3214 | Process a wxEVT_SIZE event. |
3215 | @endEventTable | |
7c913512 | 3216 | |
23324ae1 FM |
3217 | @library{wxcore} |
3218 | @category{events} | |
7c913512 | 3219 | |
1f1d2182 | 3220 | @see wxSize, @ref overview_eventhandling |
23324ae1 FM |
3221 | */ |
3222 | class wxSizeEvent : public wxEvent | |
3223 | { | |
3224 | public: | |
3225 | /** | |
3226 | Constructor. | |
3227 | */ | |
3228 | wxSizeEvent(const wxSize& sz, int id = 0); | |
3229 | ||
3230 | /** | |
3231 | Returns the entire size of the window generating the size change event. | |
3232 | */ | |
328f5751 | 3233 | wxSize GetSize() const; |
23324ae1 FM |
3234 | }; |
3235 | ||
3236 | ||
e54c96f1 | 3237 | |
23324ae1 FM |
3238 | /** |
3239 | @class wxSetCursorEvent | |
3240 | @wxheader{event.h} | |
7c913512 | 3241 | |
23324ae1 | 3242 | A SetCursorEvent is generated when the mouse cursor is about to be set as a |
42013f4c FM |
3243 | result of mouse motion. |
3244 | ||
3245 | This event gives the application the chance to perform specific mouse cursor | |
3246 | processing based on the current position of the mouse within the window. | |
3247 | Use wxSetCursorEvent::SetCursor to specify the cursor you want to be displayed. | |
3248 | ||
3249 | @beginEventTable{wxSetCursorEvent} | |
8c6791e4 | 3250 | @event{EVT_SET_CURSOR(func)} |
42013f4c FM |
3251 | Process a wxEVT_SET_CURSOR event. |
3252 | @endEventTable | |
7c913512 | 3253 | |
23324ae1 | 3254 | @library{wxcore} |
1f1d2182 | 3255 | @category{events} |
7c913512 | 3256 | |
e54c96f1 | 3257 | @see ::wxSetCursor, wxWindow::wxSetCursor |
23324ae1 FM |
3258 | */ |
3259 | class wxSetCursorEvent : public wxEvent | |
3260 | { | |
3261 | public: | |
3262 | /** | |
3263 | Constructor, used by the library itself internally to initialize the event | |
3264 | object. | |
3265 | */ | |
3266 | wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0); | |
3267 | ||
3268 | /** | |
3269 | Returns a reference to the cursor specified by this event. | |
3270 | */ | |
a6052817 | 3271 | const wxCursor& GetCursor() const; |
23324ae1 FM |
3272 | |
3273 | /** | |
3274 | Returns the X coordinate of the mouse in client coordinates. | |
3275 | */ | |
328f5751 | 3276 | wxCoord GetX() const; |
23324ae1 FM |
3277 | |
3278 | /** | |
3279 | Returns the Y coordinate of the mouse in client coordinates. | |
3280 | */ | |
328f5751 | 3281 | wxCoord GetY() const; |
23324ae1 FM |
3282 | |
3283 | /** | |
3284 | Returns @true if the cursor specified by this event is a valid cursor. | |
3c4f71cc | 3285 | |
23324ae1 | 3286 | @remarks You cannot specify wxNullCursor with this event, as it is not |
4cc4bfaf | 3287 | considered a valid cursor. |
23324ae1 | 3288 | */ |
328f5751 | 3289 | bool HasCursor() const; |
23324ae1 FM |
3290 | |
3291 | /** | |
3292 | Sets the cursor associated with this event. | |
3293 | */ | |
3294 | void SetCursor(const wxCursor& cursor); | |
3295 | }; | |
e54c96f1 | 3296 | |
39fb8056 FM |
3297 | |
3298 | ||
7fa7088e BP |
3299 | // ============================================================================ |
3300 | // Global functions/macros | |
3301 | // ============================================================================ | |
3302 | ||
3303 | /** @ingroup group_funcmacro_misc */ | |
3304 | //@{ | |
3305 | ||
39fb8056 FM |
3306 | /** |
3307 | In a GUI application, this function posts @a event to the specified @e dest | |
7fa7088e BP |
3308 | object using wxEvtHandler::AddPendingEvent(). |
3309 | ||
3310 | Otherwise, it dispatches @a event immediately using | |
3311 | wxEvtHandler::ProcessEvent(). See the respective documentation for details | |
c3f94162 VZ |
3312 | (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent() |
3313 | this function is not thread-safe for event objects having wxString fields, | |
3314 | use wxQueueEvent() instead. | |
39fb8056 | 3315 | |
7fa7088e | 3316 | @header{wx/event.h} |
39fb8056 | 3317 | */ |
c3f94162 VZ |
3318 | void wxPostEvent(wxEvtHandler* dest, const wxEvent& event); |
3319 | ||
3320 | /** | |
3321 | Queue an event for processing on the given object. | |
3322 | ||
3323 | This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation | |
3324 | for more details. | |
3325 | ||
3326 | @header{wx/event.h} | |
3327 | ||
3328 | @param dest | |
3329 | The object to queue the event on, can't be @c NULL. | |
3330 | @param event | |
3331 | The heap-allocated and non-@c NULL event to queue, the function takes | |
3332 | ownership of it. | |
3333 | */ | |
3334 | void wxQueueEvent(wxEvtHandler* dest, wxEvent *event); | |
7fa7088e BP |
3335 | |
3336 | //@} | |
3337 |