]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/event.h
Most of FM's wxDataViewCtrl patch.
[wxWidgets.git] / include / wx / event.h
index e04df5470756e078c5a9b6a80ec3262420bee02c..b3ac4bf845e09cdf85e516d1f6c865a1ba80e47b 100644 (file)
@@ -13,6 +13,7 @@
 #define _WX_EVENT_H__
 
 #include "wx/defs.h"
+#include "wx/cpp.h"
 #include "wx/object.h"
 #include "wx/clntdata.h"
 
@@ -46,6 +47,8 @@ class WXDLLIMPEXP_BASE wxEvtHandler;
 
 typedef int wxEventType;
 
+#define wxEVT_ANY           ((wxEventType)-1)
+
 // this is used to make the event table entry type safe, so that for an event
 // handler only a function with proper parameter list can be given.
 #define wxStaticCastEvent(type, val) wx_static_cast(type, val)
@@ -94,8 +97,6 @@ typedef int wxEventType;
 #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
     wxEventTableEntry(type, winid, idLast, fn, obj)
 
-#define EMPTY_PARAMETER_VALUE /* Fake macro parameter value */
-
 #define BEGIN_DECLARE_EVENT_TYPES()
 #define END_DECLARE_EVENT_TYPES()
 #define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
@@ -103,7 +104,7 @@ typedef int wxEventType;
 #define DECLARE_EVENT_TYPE(name, value) \
     DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
 #define DECLARE_LOCAL_EVENT_TYPE(name, value) \
-    DECLARE_EXPORTED_EVENT_TYPE(EMPTY_PARAMETER_VALUE, name, value)
+    DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value)
 #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
 #define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name)
 
@@ -468,6 +469,7 @@ private:
     DECLARE_NO_COPY_CLASS(wxPropagateOnce)
 };
 
+
 #if wxUSE_GUI
 
 
@@ -853,10 +855,15 @@ public:
     // should occur for each delta.
     int GetWheelDelta() const { return m_wheelDelta; }
 
+    // Gets the axis the wheel operation concerns, 0 being the y axis as on
+    // most mouse wheels, 1 is the x axis for things like MightyMouse scrolls
+    // or horizontal trackpad scrolling
+    int GetWheelAxis() const { return m_wheelAxis; }
+
     // Returns the configured number of lines (or whatever) to be scrolled per
     // wheel action.  Defaults to one.
     int GetLinesPerAction() const { return m_linesPerAction; }
-
+    
     // Is the system set to do page scrolling?
     bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
 
@@ -875,7 +882,8 @@ public:
     bool          m_shiftDown;
     bool          m_altDown;
     bool          m_metaDown;
-
+    
+    int           m_wheelAxis;
     int           m_wheelRotation;
     int           m_wheelDelta;
     int           m_linesPerAction;
@@ -2396,7 +2404,7 @@ public:
     virtual bool ProcessEvent(wxEvent& event);
 
     // add an event to be processed later
-    void AddPendingEvent(wxEvent& event);
+    virtual void AddPendingEvent(wxEvent& event);
 
     void ProcessPendingEvents();
 
@@ -2457,11 +2465,6 @@ public:
     void SetClientData( void *data ) { DoSetClientData(data); }
     void *GetClientData() const { return DoGetClientData(); }
 
-    // reentrance guard
-    void AllowReentrance( bool allow = true ) { m_reentranceAllowed = allow; }
-    bool IsReentranceAllowed()                { return m_reentranceAllowed; }
-    bool IsEventHandlingInProgress()          { return m_eventHandlingInProgress; } 
-    
     // check if the given event table entry matches this event and call the
     // handler if it does
     //
@@ -2531,9 +2534,6 @@ protected:
 #  endif
 #endif
 
-    bool                m_reentranceAllowed;          // Reentrance is allowed for this handler?
-    bool                m_eventHandlingInProgress;    // Eventhandling is in progress?
-    
     // Is event handler enabled?
     bool                m_enabled;
 
@@ -2579,6 +2579,30 @@ typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
 
 #if wxUSE_GUI
 
+// ----------------------------------------------------------------------------
+// wxEventBlocker: helper class to temporarily disable event handling for a window
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler
+{
+public:
+    wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY);
+    virtual ~wxEventBlocker();
+
+    void Block(wxEventType type)
+    {
+        m_eventsToBlock.push_back(type);
+    }
+
+    virtual bool ProcessEvent(wxEvent& event);
+
+protected:
+    wxArrayInt m_eventsToBlock;
+    wxWindow *m_window;
+
+    DECLARE_NO_COPY_CLASS(wxEventBlocker)
+};
+
 typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
 typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&);
 typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&);