// it is important to still have these as constants to avoid
// initialization order related problems
DECLARE_EVENT_TYPE(wxEVT_NULL, 0)
- const wxEventType wxEVT_FIRST = 10000;
- const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
+ DECLARE_EVENT_TYPE(wxEVT_FIRST, 10000)
+ DECLARE_EVENT_TYPE(wxEVT_USER_FIRST, wxEVT_FIRST + 2000)
#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1)
m_size(event.m_size), m_rect(event.m_rect)
{ }
wxSizeEvent(const wxRect& rect, int id = 0)
- : m_rect(rect), m_size(rect.GetSize())
+ : m_size(rect.GetSize()), m_rect(rect)
{ m_eventType = wxEVT_SIZING; m_id = id; }
wxSize GetSize() const { return m_size; }
const int& m_eventType;
};
+class WXDLLEXPORT wxEvtHandler;
+
// an entry used in dynamic event table managed by wxEvtHandler::Connect()
struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntryBase
{
wxDynamicEventTableEntry(int evType, int winid, int idLast,
- wxObjectEventFunction fn, wxObject *data)
+ wxObjectEventFunction fn, wxObject *data, wxEvtHandler* eventSink)
: wxEventTableEntryBase(winid, idLast, fn, data),
- m_eventType(evType)
+ m_eventType(evType),
+ m_eventSink(eventSink)
{ }
// not a reference here as we can't keep a reference to a temporary int
// created to wrap the constant value typically passed to Connect() - nor
// do we need it
int m_eventType;
+
+ // Pointer to object whose function is fn - so we don't assume the
+ // EventFunction is always a member of the EventHandler receiving the
+ // message
+ wxEvtHandler* m_eventSink;
};
#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
// winid and event type
void Connect( int winid, int lastId, int eventType,
wxObjectEventFunction func,
- wxObject *userData = (wxObject *) NULL );
+ wxObject *userData = (wxObject *) NULL,
+ wxEvtHandler *eventSink = (wxEvtHandler *) NULL );
// Convenience function: take just one id
void Connect( int winid, int eventType,
wxObjectEventFunction func,
- wxObject *userData = (wxObject *) NULL )
- { Connect(winid, wxID_ANY, eventType, func, userData); }
+ wxObject *userData = (wxObject *) NULL,
+ wxEvtHandler *eventSink = (wxEvtHandler *) NULL )
+ { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }
bool Disconnect( int winid, int lastId, wxEventType eventType,
wxObjectEventFunction func = NULL,
- wxObject *userData = (wxObject *) NULL );
+ wxObject *userData = (wxObject *) NULL,
+ wxEvtHandler *eventSink = (wxEvtHandler *) NULL );
// Convenience function: take just one id
bool Disconnect( int winid, wxEventType eventType = wxEVT_NULL,
wxObjectEventFunction func = NULL,
- wxObject *userData = (wxObject *) NULL )
- { return Disconnect(winid, wxID_ANY, eventType, func, userData); }
+ wxObject *userData = (wxObject *) NULL,
+ wxEvtHandler *eventSink = (wxEvtHandler *) NULL )
+ { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }
// User data can be associated with each wxEvtHandler
static const wxEventTableEntry sm_eventTableEntries[];
protected:
+ // hooks for wxWindow used by ProcessEvent()
+ // -----------------------------------------
+
+ // this one is called before trying our own event table to allow plugging
+ // in the validators
+#if wxUSE_VALIDATORS
+ virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; }
+#endif // wxUSE_VALIDATORS
+
+ // 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
+ //
+ // base class implementation passes the event to wxTheApp
+ virtual bool TryParent(wxEvent& event);
+
+
static const wxEventTable sm_eventTable;
virtual const wxEventTable *GetEventTable() const;
# endif
#endif
- // optimization: instead of using costly IsKindOf() to decide whether we're
- // a window (which is true in 99% of cases), use this flag
- bool m_isWindow;
-
// Is event handler enabled?
bool m_enabled;
DECLARE_DYNAMIC_CLASS(wxEvtHandler)
};
+// Post a message to the given eventhandler which will be processed during the
+// next event loop iteration
+inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event)
+{
+ wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
+
+ dest->AddPendingEvent(event);
+}
+
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
#if wxUSE_GUI
typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);