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