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