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