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