X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ff4504866553ba7672efd8efa9f6120af18fc5ec..9e610e1caf91dee9e074551149e3ae5e08df9c09:/interface/wx/event.h diff --git a/interface/wx/event.h b/interface/wx/event.h index 863ee56c23..3bcdf8f45f 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -318,6 +318,29 @@ public: +/** + Helper class to temporarily change an event to not propagate. +*/ +class wxPropagationDisabler +{ +public: + wxPropagationDisabler(wxEvent& event); + ~wxPropagationDisabler(); +}; + + +/** + Helper class to temporarily lower propagation level. +*/ +class wxPropagateOnce +{ +public: + wxPropagateOnce(wxEvent& event); + ~wxPropagateOnce(); +}; + + + /** @class wxEvtHandler @@ -473,7 +496,7 @@ public: that it didn't handle the event in which case the search continues. -# Static events table of the handlers bound using event table macros is searched for this event handler. If this fails, the base - class event table table is tried, and so on until no more tables + class event table is tried, and so on until no more tables exist or an appropriate function was found. If a handler is found, the same logic as in the previous step applies. -# The search is applied down the entire chain of event handlers (usually the @@ -779,7 +802,7 @@ public: more flexible as it also allows you to use ordinary functions and arbitrary functors as event handlers. It is also less restrictive then Connect() because you can use an arbitrary method as an event handler, - where as Connect() requires a wxEvtHandler derived handler. + whereas Connect() requires a wxEvtHandler derived handler. See @ref overview_events_bind for more detailed explanation of this function and the @ref page_samples_event sample for usage @@ -1065,6 +1088,40 @@ public: //@} + /** + @name Global event filters. + + Methods for working with the global list of event filters. + + Event filters can be defined to pre-process all the events that happen + in an application, see wxEventFilter documentation for more information. + */ + //@{ + + /** + Add an event filter whose FilterEvent() method will be called for each + and every event processed by wxWidgets. + + The filters are called in LIFO order and wxApp is registered as an + event filter by default. The pointer must remain valid until it's + removed with RemoveFilter() and is not deleted by wxEvtHandler. + + @since 2.9.3 + */ + static void AddFilter(wxEventFilter* filter); + + /** + Remove a filter previously installed with AddFilter(). + + It's an error to remove a filter that hadn't been previously added or + was already removed. + + @since 2.9.3 + */ + static void RemoveFilter(wxEventFilter* filter); + + //@} + protected: /** Method called by ProcessEvent() before examining this object event @@ -1252,6 +1309,8 @@ enum wxKeyCategoryFlags Notice that currently no translation is done for the presses of @c [, @c \\, @c ], @c ^ and @c _ keys which might be mapped to ASCII values from 27 to 31. + Since version 2.9.2, the enum values @c WXK_CONTROL_A - @c WXK_CONTROL_Z + can be used instead of the non-descriptive constant values 1-26. Finally, modifier keys only generate key events but no char events at all. The modifiers keys are @c WXK_SHIFT, @c WXK_CONTROL, @c WXK_ALT and various @@ -1298,20 +1357,35 @@ enum wxKeyCategoryFlags @beginEventTable{wxKeyEvent} @event{EVT_KEY_DOWN(func)} - Process a @c wxEVT_KEY_DOWN event (any key has been pressed). + Process a @c wxEVT_KEY_DOWN event (any key has been pressed). If this + event is handled and not skipped, @c wxEVT_CHAR will not be generated + at all for this key press (but @c wxEVT_KEY_UP will be). @event{EVT_KEY_UP(func)} Process a @c wxEVT_KEY_UP event (any key has been released). @event{EVT_CHAR(func)} Process a @c wxEVT_CHAR event. @event{EVT_CHAR_HOOK(func)} - Process a @c wxEVT_CHAR_HOOK event which is sent to the active - wxTopLevelWindow (i.e. the one containing the currently focused window) - or wxApp global object if there is no active window before any other - keyboard events are generated giving the parent window the opportunity - to intercept all the keyboard entry. If the event is handled, i.e. the - handler doesn't call wxEvent::Skip(), no further keyboard events are - generated. Notice that this event is currently not generated by - wxOSX/Cocoa port. + Process a @c wxEVT_CHAR_HOOK event. Unlike all the other key events, + this event is propagated upwards the window hierarchy which allows + intercepting it in the parent window of the focused window to which it + is sent initially (if there is no focused window, this event is sent to + the wxApp global object). It is also generated before any other key + events and so gives the parent window an opportunity to modify the + keyboard handling of its children, e.g. it is used internally by + wxWidgets in some ports to intercept pressing Esc key in any child of a + dialog to close the dialog itself when it's pressed. By default, if + this event is handled, i.e. the handler doesn't call wxEvent::Skip(), + neither @c wxEVT_KEY_DOWN nor @c wxEVT_CHAR events will be generated + (although @c wxEVT_KEY_UP still will be), i.e. it replaces the normal + key events. However by calling the special DoAllowNextEvent() method + you can handle @c wxEVT_CHAR_HOOK and still allow normal events + generation. This is something that is rarely useful but can be required + if you need to prevent a parent @c wxEVT_CHAR_HOOK handler from running + without suppressing the normal key events. Finally notice that this + event is not generated when the mouse is captured as it is considered + that the window which has the capture should receive all the keyboard + events too without allowing its parent wxTopLevelWindow to interfere + with their processing. @endEventTable @see wxKeyboardState @@ -1454,10 +1528,55 @@ public: Returns the Y position (in client coordinates) of the event. */ wxCoord GetY() const; + + /** + Allow normal key events generation. + + Can be called from @c wxEVT_CHAR_HOOK handler to indicate that the + generation of normal events should @em not be suppressed, as it happens + by default when this event is handled. + + The intended use of this method is to allow some window object to + prevent @c wxEVT_CHAR_HOOK handler in its parent window from running by + defining its own handler for this event. Without calling this method, + this would result in not generating @c wxEVT_KEY_DOWN nor @c wxEVT_CHAR + events at all but by calling it you can ensure that these events would + still be generated, even if @c wxEVT_CHAR_HOOK event was handled. + + @since 2.9.3 + */ + void DoAllowNextEvent(); + + /** + Returns @true if DoAllowNextEvent() had been called, @false by default. + + This method is used by wxWidgets itself to determine whether the normal + key events should be generated after @c wxEVT_CHAR_HOOK processing. + + @since 2.9.3 + */ + bool IsNextEventAllowed() const; }; +enum +{ + wxJOYSTICK1, + wxJOYSTICK2 +}; + +// Which button is down? +enum +{ + wxJOY_BUTTON_ANY = -1, + wxJOY_BUTTON1 = 1, + wxJOY_BUTTON2 = 2, + wxJOY_BUTTON3 = 4, + wxJOY_BUTTON4 = 8 +}; + + /** @class wxJoystickEvent @@ -1543,11 +1662,15 @@ public: /** Returns the x, y position of the joystick event. + + These coordinates are valid for all the events except wxEVT_JOY_ZMOVE. */ wxPoint GetPosition() const; /** Returns the z position of the joystick event. + + This method can only be used for wxEVT_JOY_ZMOVE events. */ int GetZPosition() const; @@ -1698,7 +1821,7 @@ public: */ wxWindowCreateEvent(wxWindow* win = NULL); - /// Retutn the window being created. + /// Return the window being created. wxWindow *GetWindow() const; }; @@ -2603,6 +2726,10 @@ public: Returns the integer identifier corresponding to a listbox, choice or radiobox selection (only if the event was a selection, not a deselection), or a boolean value representing the value of a checkbox. + + For a menu item, this method returns -1 if the item is not checkable or + a boolean value (true or false) for checkable items indicating the new + state of the item. */ int GetInt() const; @@ -2626,7 +2753,7 @@ public: For the menu events, this method indicates if the menu item just has become checked or unchecked (and thus only makes sense for checkable menu items). - Notice that this method can not be used with wxCheckListBox currently. + Notice that this method cannot be used with wxCheckListBox currently. */ bool IsChecked() const; @@ -2780,12 +2907,8 @@ public: To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table definition. - You must call wxEraseEvent::GetDC and use the returned device context if it is - non-@NULL. If it is @NULL, create your own temporary wxClientDC object. - - @remarks - Use the device context returned by GetDC to draw on, don't create - a wxPaintDC in the event handler. + You must use the device context returned by GetDC() to draw on, don't create + a wxPaintDC in the event handler. @beginEventTable{wxEraseEvent} @event{EVT_ERASE_BACKGROUND(func)} @@ -2807,6 +2930,8 @@ public: /** Returns the device context associated with the erase event to draw on. + + The returned pointer is never @NULL. */ wxDC* GetDC() const; }; @@ -2865,7 +2990,7 @@ public: child if it loses it now and regains later. Notice that child window is the direct child of the window receiving event. - Use wxWindow::FindFocus() to retreive the window which is actually getting focus. + Use wxWindow::FindFocus() to retrieve the window which is actually getting focus. @beginEventTable{wxChildFocusEvent} @event{EVT_CHILD_FOCUS(func)} @@ -2903,11 +3028,11 @@ public: /** @class wxMouseCaptureLostEvent - An mouse capture lost event is sent to a window that obtained mouse capture, - which was subsequently loss due to "external" event, for example when a dialog - box is shown or if another application captures the mouse. + A mouse capture lost event is sent to a window that had obtained mouse capture, + which was subsequently lost due to an "external" event (for example, when a dialog + box is shown or if another application captures the mouse). - If this happens, this event is sent to all windows that are on capture stack + If this happens, this event is sent to all windows that are on the capture stack (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is not sent if the capture changes because of a call to CaptureMouse or ReleaseMouse. @@ -3018,27 +3143,29 @@ public: /** @class wxThreadEvent - This class adds some simple functionalities to wxCommandEvent coinceived - for inter-threads communications. + This class adds some simple functionality to wxEvent to facilitate + inter-thread communication. - This event is not natively emitted by any control/class: this is just - an helper class for the user. + This event is not natively emitted by any control/class: it is just + a helper class for the user. Its most important feature is the GetEventCategory() implementation which - allows thread events to @b NOT be processed by wxEventLoopBase::YieldFor calls + allows thread events @b NOT to be processed by wxEventLoopBase::YieldFor calls (unless the @c wxEVT_CATEGORY_THREAD is specified - which is never in wx code). @library{wxcore} @category{events,threading} @see @ref overview_thread, wxEventLoopBase::YieldFor + + @since 2.9.0 */ -class wxThreadEvent : public wxCommandEvent +class wxThreadEvent : public wxEvent { public: /** Constructor. */ - wxThreadEvent(wxEventType eventType = wxEVT_COMMAND_THREAD, int id = wxID_ANY); + wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY); /** Clones this event making sure that all internal members which use @@ -3085,6 +3212,37 @@ public: */ template T GetPayload() const; + + /** + Returns extra information integer value. + */ + long GetExtraLong() const; + + /** + Returns stored integer value. + */ + int GetInt() const; + + /** + Returns stored string value. + */ + wxString GetString() const; + + + /** + Sets the extra information value. + */ + void SetExtraLong(long extraLong); + + /** + Sets the integer value. + */ + void SetInt(int intCommand); + + /** + Sets the string value. + */ + void SetString(const wxString& string); }; @@ -3314,11 +3472,19 @@ enum wxIdleMode (and especially the first one) increase the system load and so should be avoided if possible. - By default, idle events are sent to all windows (and also wxApp, as usual). - If this is causing a significant overhead in your application, you can call - wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the - wxWS_EX_PROCESS_IDLE extra window style for every window which should receive - idle events. + By default, idle events are sent to all windows, including even the hidden + ones because they may be shown if some condition is met from their @c + wxEVT_IDLE (or related @c wxEVT_UPDATE_UI) handler. The children of hidden + windows do not receive idle events however as they can't change their state + in any way noticeable by the user. Finally, the global wxApp object also + receives these events, as usual, so it can be used for any global idle time + processing. + + If sending idle events to all windows is causing a significant overhead in + your application, you can call wxIdleEvent::SetMode with the value + wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra window + style for every window which should receive idle events, all the other ones + will not receive them in this case. @beginEventTable{wxIdleEvent} @event{EVT_IDLE(func)} @@ -3446,7 +3612,7 @@ public: */ wxWindowDestroyEvent(wxWindow* win = NULL); - /// Retutn the window being destroyed. + /// Return the window being destroyed. wxWindow *GetWindow() const; }; @@ -3459,8 +3625,8 @@ public: This event is mainly used by wxWidgets implementations. A wxNavigationKeyEvent handler is automatically provided by wxWidgets - when you make a class into a control container with the macro - WX_DECLARE_CONTROL_CONTAINER. + when you enable keyboard navigation inside a window by inheriting it from + wxNavigationEnabled<>. @beginEventTable{wxNavigationKeyEvent} @event{EVT_NAVIGATION_KEY(func)} @@ -3733,9 +3899,12 @@ public: wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL); /** - Returns the menu which is being opened or closed. This method should only be - used with the @c OPEN and @c CLOSE events and even for them the - returned pointer may be @NULL in some ports. + Returns the menu which is being opened or closed. + + This method can only be used with the @c OPEN and @c CLOSE events. + + The returned value is never @NULL in the ports implementing this + function, which currently includes all the major ones. */ wxMenu* GetMenu() const; @@ -3764,8 +3933,6 @@ public: Notice that the event is not triggered when the application is iconized (minimized) or restored under wxMSW. - Currently only wxMSW, wxGTK and wxOS2 generate such events. - @onlyfor{wxmsw,wxgtk,wxos2} @beginEventTable{wxShowEvent} @@ -3862,6 +4029,9 @@ public: @event{EVT_MOVE_START(func)} Process a @c wxEVT_MOVE_START event, which is generated when the user starts to move or size a window. wxMSW only. + @event{EVT_MOVING(func)} + Process a @c wxEVT_MOVING event, which is generated while the user is + moving the window. wxMSW only. @event{EVT_MOVE_END(func)} Process a @c wxEVT_MOVE_END event, which is generated when the user stops moving or sizing a window. wxMSW only. @@ -3908,6 +4078,10 @@ public: size of the window, you may need to clear the DC explicitly and repaint the whole window. In which case, you may need to call wxWindow::Refresh to invalidate the entire window. + @b Important : Sizers ( see @ref overview_sizer ) rely on size events to function + correctly. Therefore, in a sizer-based layout, do not forget to call Skip on all + size events you catch (and don't catch size events at all when you don't need to). + @beginEventTable{wxSizeEvent} @event{EVT_SIZE(func)} Process a @c wxEVT_SIZE event. @@ -4241,7 +4415,7 @@ wxEventType wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED; wxEventType wxEVT_COMMAND_TOOL_ENTER; wxEventType wxEVT_COMMAND_COMBOBOX_DROPDOWN; wxEventType wxEVT_COMMAND_COMBOBOX_CLOSEUP; -wxEventType wxEVT_COMMAND_THREAD; +wxEventType wxEVT_THREAD; wxEventType wxEVT_LEFT_DOWN; wxEventType wxEVT_LEFT_UP; wxEventType wxEVT_MIDDLE_DOWN; @@ -4343,6 +4517,7 @@ wxEventType wxEVT_HELP; wxEventType wxEVT_DETAILED_HELP; wxEventType wxEVT_COMMAND_TEXT_UPDATED; wxEventType wxEVT_COMMAND_TOOL_CLICKED; +wxEventType wxEVT_WINDOW_MODAL_DIALOG_CLOSED;