fix remaining cases of wxWindow::ProcessEvent() calls; add convenient ProcessWindowEvent() wrapper and document it; also document this (incompatible) change itself

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-01-28 13:41:43 +00:00
parent edea2c4af5
commit 3b7fa2069b
7 changed files with 41 additions and 12 deletions

View File

@ -119,6 +119,10 @@ Changes in behaviour which may result in compilation errors
need to review them as wxDC doesn't have any virtual methods any longer and need to review them as wxDC doesn't have any virtual methods any longer and
uses delegation instead of inheritance to present different behaviours. uses delegation instead of inheritance to present different behaviours.
- wxWindow::ProcessEvent() has been made protected to prevent wrongly using it
instead of correct GetEventHandler()->ProcessEvent(). New ProcessWindowEvent()
was added for convenience.
- Return type of wxString::operator[] and wxString::iterator::operator* is no - Return type of wxString::operator[] and wxString::iterator::operator* is no
longer wxChar (i.e. char or wchar_t), but wxUniChar. This is not a problem longer wxChar (i.e. char or wchar_t), but wxUniChar. This is not a problem
in vast majority of cases because of conversion operators, but it can break in vast majority of cases because of conversion operators, but it can break

View File

@ -806,6 +806,13 @@ public:
// be there) // be there)
bool RemoveEventHandler(wxEvtHandler *handler); bool RemoveEventHandler(wxEvtHandler *handler);
// Process an event by calling GetEventHandler()->ProcessEvent(): this
// is a straightforward replacement for ProcessEvent() itself which
// shouldn't be used directly with windows as it doesn't take into
// account any event handlers associated with the window
bool ProcessWindowEvent(wxEvent& event)
{ return GetEventHandler()->ProcessEvent(event); }
// Process an event by calling GetEventHandler()->ProcessEvent() and // Process an event by calling GetEventHandler()->ProcessEvent() and
// handling any exceptions thrown by event handlers. It's mostly useful // handling any exceptions thrown by event handlers. It's mostly useful
// when processing wx events when called from C code (e.g. in GTK+ // when processing wx events when called from C code (e.g. in GTK+

View File

@ -1650,9 +1650,21 @@ public:
@code @code
GetEventHandler()->SafelyProcessEvent(event); GetEventHandler()->SafelyProcessEvent(event);
@endcode @endcode
@see ProcessWindowEvent()
*/ */
bool HandleWindowEvent(wxEvent& event) const; bool HandleWindowEvent(wxEvent& event) const;
/**
Convenient wrapper for ProcessEvent().
This is the same as writing @code GetEventHandler()->ProcessEvent(event);
@endcode but more convenient. Notice that ProcessEvent() itself can't
be called for wxWindow objects as it ignores the event handlers
associated with the window, use this function instead.
*/
bool ProcessWindowEvent(wxEvent& event);
/** /**
Removes and returns the top-most event handler on the event handler stack. Removes and returns the top-most event handler on the event handler stack.
@ -3052,14 +3064,18 @@ protected:
//@{ //@{
/** /**
This function is public in wxEvtHandler but is protected in wxWindow because These functions are public in wxEvtHandler but protected in wxWindow
for wxWindows you should always use this function on the pointer returned because for wxWindows you should always use this function on the
by GetEventHandler() and not on the wxWindow object itself. pointer returned by GetEventHandler() and not on the wxWindow object
itself.
For convenience, a ProcessWindowEvent() method is provided as a synonym
for @code GetEventHandler()->ProcessEvent() @endcode.
Note that it's still possible to call these functions directly on the Note that it's still possible to call these functions directly on the
wxWindow object (e.g. downcasting it to wxEvtHandler) but doing that wxWindow object (e.g. casting it to wxEvtHandler) but doing that will
will create subtle bugs when windows with event handlers pushed on them create subtle bugs when windows with event handlers pushed on them are
are involved. involved.
*/ */
virtual bool ProcessEvent(wxEvent& event); virtual bool ProcessEvent(wxEvent& event);
bool SafelyProcessEvent(wxEvent& event); bool SafelyProcessEvent(wxEvent& event);

View File

@ -464,7 +464,7 @@ void wxPopupComboWindow::OnDismiss()
void wxPopupComboWindow::OnKeyDown(wxKeyEvent& event) void wxPopupComboWindow::OnKeyDown(wxKeyEvent& event)
{ {
m_combo->ProcessEvent(event); m_combo->ProcessWindowEvent(event);
} }
#endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) #endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)

View File

@ -372,7 +372,7 @@ bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event)
m_childHandler = m_currentChild; m_childHandler = m_currentChild;
wxON_BLOCK_EXIT_NULL(m_childHandler); wxON_BLOCK_EXIT_NULL(m_childHandler);
if ( m_currentChild->ProcessEvent(event) ) if ( m_currentChild->ProcessWindowEvent(event) )
return true; return true;
} }
} }

View File

@ -565,15 +565,17 @@ void wxNotebook::OnSetFocus(wxFocusEvent& event)
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
{ {
if ( event.IsWindowChange() ) { if ( event.IsWindowChange() )
{
// change pages // change pages
AdvanceSelection(event.GetDirection()); AdvanceSelection(event.GetDirection());
} }
else { else {
// pass to the parent // pass to the parent
if ( GetParent() ) { if ( GetParent() )
{
event.SetCurrentFocus(this); event.SetCurrentFocus(this);
GetParent()->ProcessEvent(event); GetParent()->ProcessWindowEvent(event);
} }
} }
} }

View File

@ -185,7 +185,7 @@ void wxComboListBox::OnLeftUp(wxMouseEvent& event)
wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId()); wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId());
evt.SetInt(wxListBox::GetSelection()); evt.SetInt(wxListBox::GetSelection());
evt.SetEventObject(m_combo); evt.SetEventObject(m_combo);
m_combo->ProcessEvent(evt); m_combo->ProcessWindowEvent(evt);
event.Skip(); event.Skip();
} }