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