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