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