]> git.saurik.com Git - wxWidgets.git/commitdiff
fix remaining cases of wxWindow::ProcessEvent() calls; add convenient ProcessWindowEv...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 28 Jan 2009 13:41:43 +0000 (13:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 28 Jan 2009 13:41:43 +0000 (13:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/window.h
interface/wx/window.h
src/common/popupcmn.cpp
src/generic/mdig.cpp
src/generic/notebook.cpp
src/univ/combobox.cpp

index 240cf9af5019a584a13d70359ed8e346be7a29eb..9bfdfdc5869862b1b80d238c6ad8b88f03ebc860 100644 (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
   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
   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
index 3454055f9a5796ff730b4a0bb3262d1b3fb4856a..ba5f596d78f350b1dcc0bae56bbef8d72fff674f 100644 (file)
@@ -806,6 +806,13 @@ public:
         // be there)
     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
         // handling any exceptions thrown by event handlers. It's mostly useful
         // when processing wx events when called from C code (e.g. in GTK+
index d1844645bca20fcbd497b2fdabf961edb433e7f8..c0503b5ee3ed0669a5ef166f008c664a909e2117 100644 (file)
@@ -1650,9 +1650,21 @@ public:
         @code
         GetEventHandler()->SafelyProcessEvent(event);
         @endcode
+
+        @see ProcessWindowEvent()
     */
     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.
 
@@ -3052,14 +3064,18 @@ protected:
 
     //@{
     /**
-        This function is public in wxEvtHandler but is protected in wxWindow because
-        for wxWindows you should always use this function on the pointer returned
-        by GetEventHandler() and not on the wxWindow object itself.
+        These functions are public in wxEvtHandler but protected in wxWindow
+        because for wxWindows you should always use this function on the
+        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
-        wxWindow object (e.g. downcasting it to wxEvtHandler) but doing that
-        will create subtle bugs when windows with event handlers pushed on them
-        are involved.
+        wxWindow object (e.g. casting it to wxEvtHandler) but doing that will
+        create subtle bugs when windows with event handlers pushed on them are
+        involved.
     */
     virtual bool ProcessEvent(wxEvent& event);
     bool SafelyProcessEvent(wxEvent& event);
index 1638ce5760b8dfe62935bb74fb250f12277c8bff..a0480aea56e14017457ca45438123f8069bf8f1e 100644 (file)
@@ -464,7 +464,7 @@ void wxPopupComboWindow::OnDismiss()
 
 void wxPopupComboWindow::OnKeyDown(wxKeyEvent& event)
 {
-    m_combo->ProcessEvent(event);
+    m_combo->ProcessWindowEvent(event);
 }
 
 #endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)
index bc81b3c8d15434a96ffe194a4082c81a7fc191c6..3326c0592c0bb77da611b2b74458129d18602ad6 100644 (file)
@@ -372,7 +372,7 @@ bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event)
             m_childHandler = m_currentChild;
             wxON_BLOCK_EXIT_NULL(m_childHandler);
 
-            if ( m_currentChild->ProcessEvent(event) )
+            if ( m_currentChild->ProcessWindowEvent(event) )
                 return true;
         }
     }
index 29b5a4137d7638c669aa72a3591475f0f1909528..0d2a77c6e05e811679f1a5fedce96696e6c83431 100644 (file)
@@ -565,15 +565,17 @@ void wxNotebook::OnSetFocus(wxFocusEvent& event)
 
 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
 {
-    if ( event.IsWindowChange() ) {
+    if ( event.IsWindowChange() )
+    {
         // change pages
         AdvanceSelection(event.GetDirection());
     }
     else {
         // pass to the parent
-        if ( GetParent() ) {
+        if ( GetParent() )
+        {
             event.SetCurrentFocus(this);
-            GetParent()->ProcessEvent(event);
+            GetParent()->ProcessWindowEvent(event);
         }
     }
 }
index 80ff466793f9df42625764e4ab092e3df1b22f0b..4b4953f462a6551ce6b10fd0592f1bffc7821b34 100644 (file)
@@ -185,7 +185,7 @@ void wxComboListBox::OnLeftUp(wxMouseEvent& event)
     wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId());
     evt.SetInt(wxListBox::GetSelection());
     evt.SetEventObject(m_combo);
-    m_combo->ProcessEvent(evt);
+    m_combo->ProcessWindowEvent(evt);
 
     event.Skip();
 }