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