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