#include "wx/defs.h"
#include "wx/object.h"
+#include "wx/clntdata.h"
#if wxUSE_GUI
#include "wx/gdicmn.h"
class WXDLLEXPORT wxList;
#if wxUSE_GUI
- class WXDLLEXPORT wxClientData;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxWindow;
#define DECLARE_EVENT_TYPE(name, value) name = wxEVT_FIRST + value,
#define DECLARE_LOCAL_EVENT_TYPE(name, value) name = wxEVT_FIRST + value,
#define DEFINE_EVENT_TYPE(name)
+#define DEFINE_LOCAL_EVENT_TYPE(name)
#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
extern const wxEventType WXDLLEXPORT name;
#define DECLARE_LOCAL_EVENT_TYPE(name, value) extern const wxEventType name;
#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
+#define DEFINE_LOCAL_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
// generate a new unique event type
extern WXDLLEXPORT wxEventType wxNewEventType();
public:
wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0)
- { m_eventType = type; m_menuId = id; }
+ { m_eventType = type; m_menuId = id; m_id = id; }
int GetMenuId() const { return m_menuId; }
wxEVT_COMPARE_ITEM
*/
+
// ============================================================================
// event handler and related classes
// ============================================================================
wxObject *userData = (wxObject *) NULL )
{ return Disconnect(id, -1, eventType, func, userData); }
+
+ // User data can be associated with each wxEvtHandler
+ void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
+ wxClientData *GetClientObject() const { return DoGetClientObject(); }
+
+ void SetClientData( void *data ) { DoSetClientData(data); }
+ void *GetClientData() const { return DoGetClientData(); }
+
+
// implementation from now on
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
// Is event handler enabled?
bool m_enabled;
+
+ // The user data: either an object which will be deleted by the container
+ // when it's deleted or some raw pointer which we do nothing with - only
+ // one type of data can be used with the given window (i.e. you cannot set
+ // the void data and then associate the container with wxClientData or vice
+ // versa)
+ union
+ {
+ wxClientData *m_clientObject;
+ void *m_clientData;
+ };
+
+ // what kind of data do we have?
+ wxClientDataType m_clientDataType;
+
+ // client data accessors
+ virtual void DoSetClientObject( wxClientData *data );
+ virtual wxClientData *DoGetClientObject() const;
+
+ virtual void DoSetClientData( void *data );
+ virtual void *DoGetClientData() const;
+
+
private:
DECLARE_DYNAMIC_CLASS(wxEvtHandler)
};