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