]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/event.h
added short col/row resizing overview
[wxWidgets.git] / include / wx / event.h
index 51b34461ce881e473f7bc1603de95d647b27a0d8..5bf02f36070e5a71a24e9e349b95ee0a83abf296 100644 (file)
@@ -78,7 +78,7 @@ typedef int wxEventType;
 #define wxStaticCastEvent(type, val) static_cast<type>(val)
 
 #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
-    wxEventTableEntry(type, winid, idLast, wxNewEventFunctor(type, fn), obj)
+    wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj)
 
 #define DECLARE_EVENT_TABLE_TERMINATOR() \
     wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0)
@@ -124,7 +124,7 @@ extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
     // Declare a local (not exported) wxEventType-based event type:
 
     #define wxDECLARE_EVENT( name, type ) \
-        wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type );
+        wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
 
 #else
     // Define/Declare a templatized event type with the corresponding event as
@@ -149,7 +149,7 @@ extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
     // Declare a local (not exported) templatized event type:
 
     #define wxDECLARE_EVENT( name, type ) \
-        wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type );
+        wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
 
 #endif
 
@@ -258,17 +258,23 @@ private:
 
 #if wxEVENTS_COMPATIBILITY_2_8
 
-// Create a functor for the legacy events: handler can be NULL and its default
-// value is used by the event table macros
-
+// Create a functor for the legacy events: used by Connect()
 inline wxObjectEventFunctor *
 wxNewEventFunctor(const wxEventType& WXUNUSED(evtType),
                   wxObjectEventFunction method,
-                  wxEvtHandler *handler = NULL)
+                  wxEvtHandler *handler)
 {
     return new wxObjectEventFunctor(method, handler);
 }
 
+// This version is used by DECLARE_EVENT_TABLE_ENTRY()
+inline wxObjectEventFunctor *
+wxNewEventTableFunctor(const wxEventType& WXUNUSED(evtType),
+                       wxObjectEventFunction method)
+{
+    return new wxObjectEventFunctor(method, NULL);
+}
+
 inline wxObjectEventFunctor
 wxMakeEventFunctor(const wxEventType& WXUNUSED(evtType),
                         wxObjectEventFunction method,
@@ -381,7 +387,7 @@ struct HandlerImpl<T, A, false>
 // allowed to handle different events in the same handler taking wxEvent&, for
 // example
 template
-  <typename EventTag, typename Class, typename EventArg, typename ObjClass>
+  <typename EventTag, typename Class, typename EventArg, typename EventHandler>
 class wxEventFunctorMethod
     : public wxEventFunctor,
       private wxPrivate::HandlerImpl
@@ -399,7 +405,7 @@ public:
     typedef typename wxPrivate::EventClassOf<EventTag>::type EventClass;
 
 
-    wxEventFunctorMethod(void (Class::*method)(EventArg&), ObjClass *handler)
+    wxEventFunctorMethod(void (Class::*method)(EventArg&), EventHandler *handler)
     {
         wxASSERT_MSG( handler || this->IsEvtHandler(),
                       "handlers defined in non-wxEvtHandler-derived classes "
@@ -457,7 +463,7 @@ public:
     }
 
 private:
-    ObjClass *m_handler;
+    EventHandler *m_handler;
     void (Class::*m_method)(EventArg&);
 };
 
@@ -486,46 +492,38 @@ wxMakeEventFunctor(const EventTag&, Functor func)
 
 // Create functors for methods:
 template
-  <typename EventTag, typename Class, typename EventArg, typename ObjClass>
-inline wxEventFunctorMethod<EventTag, Class, EventArg, ObjClass> *
+  <typename EventTag, typename Class, typename EventArg, typename EventHandler>
+inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler> *
 wxNewEventFunctor(const EventTag&,
                   void (Class::*method)(EventArg&),
-                  ObjClass *handler)
+                  EventHandler *handler)
 {
-    return new wxEventFunctorMethod<EventTag, Class, EventArg, ObjClass>(
+    return new wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>(
                 method, handler);
 }
 
 template
-    <typename EventTag, typename Class, typename EventArg, typename ObjClass>
-inline wxEventFunctorMethod<EventTag, Class, EventArg, ObjClass>
+    <typename EventTag, typename Class, typename EventArg, typename EventHandler>
+inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>
 wxMakeEventFunctor(const EventTag&,
                    void (Class::*method)(EventArg&),
-                   ObjClass *handler)
+                   EventHandler *handler)
 {
-    return wxEventFunctorMethod<EventTag, Class, EventArg, ObjClass>(
+    return wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>(
                 method, handler);
 }
 
-// Special case for the wxNewEventFunctor() calls used inside the event table
-// macros: they don't specify the handler so ObjClass can't be deduced
+// Create an event functor for the event table via DECLARE_EVENT_TABLE_ENTRY:
+// in this case we don't have the handler (as it's always the same as the
+// object which generated the event) so we must use Class as its type
 template <typename EventTag, typename Class, typename EventArg>
 inline wxEventFunctorMethod<EventTag, Class, EventArg, Class> *
-wxNewEventFunctor(const EventTag&, void (Class::*method)(EventArg&))
+wxNewEventTableFunctor(const EventTag&, void (Class::*method)(EventArg&))
 {
     return new wxEventFunctorMethod<EventTag, Class, EventArg, Class>(
                     method, NULL);
 }
 
-template
-    <typename EventTag, typename Class, typename EventArg, typename ObjClass>
-inline wxEventFunctorMethod<EventTag, Class, EventArg, Class>
-wxMakeEventFunctor(const EventTag&, void (Class::*method)(EventArg&))
-{
-    return wxEventFunctorMethod<EventTag, Class, EventArg, Class>(
-                method, NULL);
-}
-
 #endif // !wxEVENTS_COMPATIBILITY_2_8
 
 
@@ -3005,32 +3003,32 @@ public:
     }
 
 
-    // Bind a method of a class (called on the specified eventSink which must
+    // Bind a method of a class (called on the specified handler which must
     // be convertible to this class) object to an event:
 
-    template <typename EventTag, typename Class, typename EventArg, typename ObjClass>
+    template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
     void Bind(const EventTag &eventType,
               void (Class::*method)(EventArg &),
-              ObjClass *eventSink,
+              EventHandler *handler,
               int winid = wxID_ANY,
               int lastId = wxID_ANY,
               wxObject *userData = NULL)
     {
         DoConnect(winid, lastId, eventType,
-                  wxNewEventFunctor(eventType, method, eventSink),
+                  wxNewEventFunctor(eventType, method, handler),
                   userData);
     }
 
-    template <typename EventTag, typename Class, typename EventArg, typename ObjClass>
+    template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
     bool Unbind(const EventTag &eventType,
                 void (Class::*method)(EventArg&),
-                ObjClass *eventSink,
+                EventHandler *handler,
                 int winid = wxID_ANY,
                 int lastId = wxID_ANY,
                 wxObject *userData = NULL )
     {
         return DoDisconnect(winid, lastId, eventType,
-                            wxMakeEventFunctor(eventType, method, eventSink),
+                            wxMakeEventFunctor(eventType, method, handler),
                             userData);
     }
 #endif // !wxEVENTS_COMPATIBILITY_2_8
@@ -3156,7 +3154,7 @@ protected:
     virtual void *DoGetClientData() const;
 
     // Search tracker objects for event connection with this sink
-    wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *eventSink);
+    wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *handler);
 
 private:
     // pass the event to wxTheApp instance, called from TryAfter()