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