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
// Note: this is intended to be used in wxDC at some point to replace
// the current system of scaling/translation. It is not yet used.
-//:defenition
+//:definition
// A 3x3 matrix to do 2D transformations.
-// It can be used to map data to window coordinates.
-// But also for manipulating your own data.
+// It can be used to map data to window coordinates,
+// and also for manipulating your own data.
// For example drawing a picture (composed of several primitives)
// at a certain coordinate and angle within another parent picture.
// At all times m_isIdentity is set if the matrix itself is an Identity matrix.
/*
There is no wxRadioButtonBase class as wxRadioButton interface is the same
- as of wxCheckBox(Base), but under some platforms wxRadioButton really
+ as wxCheckBox(Base), but under some platforms wxRadioButton really
derives from wxCheckBox and on the others it doesn't.
The pseudo-declaration of wxRadioButtonBase would look like this:
void wxEvtHandler::Connect( int id, int lastId,
int eventType,
wxObjectEventFunction func,
- wxObject *userData )
+ wxObject *userData,
+ wxEvtHandler* eventSink )
{
#if WXWIN_COMPATIBILITY_EVENT_TYPES
wxEventTableEntry *entry = new wxEventTableEntry;
entry->m_callbackUserData = userData;
#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
wxDynamicEventTableEntry *entry =
- new wxDynamicEventTableEntry(eventType, id, lastId, func, userData);
+ new wxDynamicEventTableEntry(eventType, id, lastId, func, userData, eventSink);
#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
if (!m_dynamicEvents)
bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
wxObjectEventFunction func,
- wxObject *userData )
+ wxObject *userData,
+ wxEvtHandler* eventSink )
{
if (!m_dynamicEvents)
return FALSE;
((entry->m_lastId == lastId) || (lastId == -1)) &&
((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
+ ((entry->m_eventSink == eventSink) || (eventSink == (wxEvtHandler*)NULL)) &&
((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
{
if (entry->m_callbackUserData)
event.Skip(FALSE);
event.m_callbackUserData = entry->m_callbackUserData;
- (this->*((wxEventFunction) (entry->m_fn)))(event);
+#if !WXWIN_COMPATIBILITY_EVENT_TYPES
+ if (entry->m_eventSink)
+ ((entry->m_eventSink)->*((wxEventFunction) (entry->m_fn)))(event);
+ else
+#endif
+ (this->*((wxEventFunction) (entry->m_fn)))(event);
if ( ! event.GetSkipped() )
return TRUE;
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
void wxToolBarBase::DoToolbarUpdates()
{
- wxWindow* parent = this;
- while (parent->GetParent())
- parent = parent->GetParent();
-
-// This kind of #ifdef is a good way to annoy people. It breaks
-// apps, but only on one platform and due to a hack in officially
-// platform independent code. It took me hours to fix this. RR.
-//
-// #ifdef __WXMSW__
-// wxWindow* focusWin = wxFindFocusDescendant(parent);
-// #else
- wxWindow* focusWin = (wxWindow*) NULL;
-// #endif
-
- wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;
+ wxEvtHandler* evtHandler = GetEventHandler() ;
for ( wxToolBarToolsList::Node* node = m_tools.GetFirst();
node;