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