]> git.saurik.com Git - wxWidgets.git/commitdiff
Replace public wxEvtHandler::ProcessEventHere() with private TryHere().
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 May 2010 14:55:46 +0000 (14:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 May 2010 14:55:46 +0000 (14:55 +0000)
ProcessEventHere() doesn't have to be public any more now that we have
ProcessEventLocally() which is safe to call from the outside (i.e. doesn't
forget about the chained event handlers and validators).

Still keep this function because it makes the code more modular and also
because we might want to make it virtual for consistency with TryBefore() and
TryAfter() later. Also rename it to TryHere() to make the symmetry with these
functions more manifest.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/event.h
interface/wx/event.h
interface/wx/window.h
src/common/event.cpp
src/common/wincmn.cpp

index 2ce70e70a5f3ab887f9e8ae6f27bc2b574b467ee..e7536eb9ce3ac25d701159b12412defc9a484b02 100644 (file)
@@ -1026,8 +1026,8 @@ protected:
     bool m_wasProcessed;
 
     // this flag is used by ProcessEventLocally() to prevent ProcessEvent()
-    // from doing its usual stuff and force it to just call ProcessEventHere()
-    // instead, see the comment there explaining why is this needed
+    // from doing its usual stuff and force it to just call TryHere() instead,
+    // see the comment there explaining why is this needed
     bool m_processHereOnly;
 
 protected:
@@ -3232,13 +3232,6 @@ public:
     void OnSinkDestroyed( wxEvtHandler *sink );
 
 
-    // The method tries to process the event in this event handler.
-    //
-    // It is called from ProcessEventLocally() and normally shouldn't be called
-    // directly as doing it would ignore any chained event handlers.
-    bool ProcessEventHere(wxEvent& event);
-
-
 private:
     void DoBind(int winid,
                    int lastId,
@@ -3263,6 +3256,12 @@ protected:
     // validators.
     virtual bool TryBefore(wxEvent& event);
 
+    // this one is not a hook but just a helper which looks up the handler in
+    // this object itself called from ProcessEventLocally() and normally
+    // shouldn't be called directly as doing it would ignore any chained event
+    // handlers
+    bool TryHere(wxEvent& event);
+
     // this one is called after failing to find the event handle in our own
     // table to give a chance to the other windows to process it
     //
index 4a10ad18cece7ff4d4bd2a4a3f875eec9d9ad54c..b64a12265ea023ceb3962401532375ebbad968cd 100644 (file)
@@ -512,9 +512,9 @@ public:
         the chain until the event is processed or the chain is exhausted.
 
         This function is called from ProcessEvent() and, in turn, calls
-        ProcessEventHere() for each handler in turn. It is not virtual and so
-        cannot be overridden but can, and should, be called to forward an event
-        to another handler instead of ProcessEvent() which would result in a
+        TryThis() for each handler in turn. It is not virtual and so cannot be
+        overridden but can, and should, be called to forward an event to
+        another handler instead of ProcessEvent() which would result in a
         duplicate call to TryAfter(), e.g. resulting in all unprocessed events
         being sent to the application object multiple times.
 
@@ -528,25 +528,6 @@ public:
      */
     bool ProcessEventLocally(wxEvent& event);
 
-    /**
-        Try to process the event in this event handler.
-
-        This method is called from ProcessEventLocally() and thus,
-        indirectly, from ProcessEvent(), please see the detailed description of
-        the event processing logic there.
-
-        It is @em not virtual and so may not be overridden.
-
-        @since 2.9.1
-
-        @param event
-            Event to process.
-        @return
-            @true if this object itself defines a handler for this event and
-            the handler didn't skip the event.
-     */
-    bool ProcessEventHere(wxEvent& event);
-
     /**
         Processes an event by calling ProcessEvent() and handles any exceptions
         that occur in the process.
@@ -1111,10 +1092,29 @@ protected:
         };
         @endcode
 
-        @see ProcessEvent(), ProcessEventHere()
+        @see ProcessEvent()
      */
     virtual bool TryBefore(wxEvent& event);
 
+    /**
+        Try to process the event in this event handler.
+
+        This method is called from ProcessEventLocally() and thus, indirectly,
+        from ProcessEvent(), please see the detailed description of the event
+        processing logic there.
+
+        It is currently @em not virtual and so may not be overridden.
+
+        @since 2.9.1
+
+        @param event
+            Event to process.
+        @return
+            @true if this object itself defines a handler for this event and
+            the handler didn't skip the event.
+     */
+    bool TryThis(wxEvent& event);
+
     /**
         Method called by ProcessEvent() as last resort.
 
@@ -1140,7 +1140,7 @@ protected:
         };
         @endcode
 
-        @see ProcessEvent(), ProcessEventHere()
+        @see ProcessEvent()
      */
     virtual bool TryAfter(wxEvent& event);
 };
index ffa3548aec30e15c2f321e8d02148d56337a207d..e3780555a2096d777d1f72dba24a88e6541d41dc 100644 (file)
@@ -1846,8 +1846,8 @@ public:
         This method is similar to ProcessWindowEvent() but can be used to
         search for the event handler only in this window and any event handlers
         pushed on top of it. Unlike ProcessWindowEvent() it won't propagate the
-        event upwards. But unlike wxEvtHandler::ProcessEventHere() it will use
-        the event handlers associated with this window.
+        event upwards. But it will use the validator and event handlers
+        associated with this window, if any.
 
         @since 2.9.1
      */
index ba5e9c29bef17f48e11684690c8ee630757a3eab..b6c0144752529d3bc6fae6a13971db34c6030464 100644 (file)
@@ -1379,7 +1379,7 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
     // Short circuit the event processing logic if we're requested to process
     // this event in this handler only, see DoTryChain() for more details.
     if ( event.ShouldProcessHereOnly() )
-        return ProcessEventHere(event);
+        return TryHere(event);
 
 
     // Try to process the event in this handler itself.
@@ -1405,7 +1405,7 @@ bool wxEvtHandler::ProcessEventLocally(wxEvent& event)
     // Then try this handler itself, notice that we should not call
     // ProcessEvent() on this one as we're already called from it, which
     // explains why we do it here and not in DoTryChain()
-    if ( ProcessEventHere(event) )
+    if ( TryHere(event) )
         return true;
 
     // Finally try the event handlers chained to this one,
@@ -1426,16 +1426,16 @@ bool wxEvtHandler::DoTryChain(wxEvent& event)
         // ProcessEvent() from which we were called or will be done by it when
         // we return.
         //
-        // However we must call ProcessEvent() and not ProcessEventHere()
-        // because the existing code (including some in wxWidgets itself)
-        // expects the overridden ProcessEvent() in its custom event handlers
-        // pushed on a window to be called.
+        // However we must call ProcessEvent() and not TryHere() because the
+        // existing code (including some in wxWidgets itself) expects the
+        // overridden ProcessEvent() in its custom event handlers pushed on a
+        // window to be called.
         //
         // So we must call ProcessEvent() but it must not do what it usually
         // does. To resolve this paradox we pass a special "process here only"
         // flag to ProcessEvent() via the event object itself. This ensures
         // that if our own, base class, version is called, it will just call
-        // ProcessEventHere() and won't do anything else, just as we want it to.
+        // TryHere() and won't do anything else, just as we want it to.
         wxEventProcessHereOnly processHereOnly(event);
         if ( h->ProcessEvent(event) )
             return true;
@@ -1444,7 +1444,7 @@ bool wxEvtHandler::DoTryChain(wxEvent& event)
     return false;
 }
 
-bool wxEvtHandler::ProcessEventHere(wxEvent& event)
+bool wxEvtHandler::TryHere(wxEvent& event)
 {
     // If the event handler is disabled it doesn't process any events
     if ( !GetEvtHandlerEnabled() )
index dda93253469dfdc74a61ca07ca8fc613e013f23e..74cfe913ffad5f61b7486cffa431898001a9b762 100644 (file)
@@ -2983,7 +2983,7 @@ bool wxWindowBase::TryBefore(wxEvent& event)
     if ( event.GetEventObject() == this )
     {
         wxValidator * const validator = GetValidator();
-        if ( validator && validator->ProcessEventHere(event) )
+        if ( validator && validator->ProcessEventLocally(event) )
         {
             return true;
         }