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