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