Added optional event sink for use with dynamic event tables
Removed comments and commented-out code re. focus window processing from wxToolBarBase git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d48568a5ec
commit
65b17727e6
@ -1969,19 +1969,27 @@ struct WXDLLEXPORT wxEventTableEntry : public wxEventTableEntryBase
|
|||||||
const int& m_eventType;
|
const int& m_eventType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxEvtHandler;
|
||||||
|
|
||||||
// an entry used in dynamic event table managed by wxEvtHandler::Connect()
|
// an entry used in dynamic event table managed by wxEvtHandler::Connect()
|
||||||
struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntryBase
|
struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntryBase
|
||||||
{
|
{
|
||||||
wxDynamicEventTableEntry(int evType, int winid, int idLast,
|
wxDynamicEventTableEntry(int evType, int winid, int idLast,
|
||||||
wxObjectEventFunction fn, wxObject *data)
|
wxObjectEventFunction fn, wxObject *data, wxEvtHandler* eventSink)
|
||||||
: wxEventTableEntryBase(winid, idLast, fn, data),
|
: 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
|
// 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
|
// created to wrap the constant value typically passed to Connect() - nor
|
||||||
// do we need it
|
// do we need it
|
||||||
int m_eventType;
|
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
|
#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
|
||||||
@ -2031,23 +2039,27 @@ public:
|
|||||||
// winid and event type
|
// winid and event type
|
||||||
void Connect( int winid, int lastId, int eventType,
|
void Connect( int winid, int lastId, int eventType,
|
||||||
wxObjectEventFunction func,
|
wxObjectEventFunction func,
|
||||||
wxObject *userData = (wxObject *) NULL );
|
wxObject *userData = (wxObject *) NULL,
|
||||||
|
wxEvtHandler *eventSink = (wxEvtHandler *) NULL );
|
||||||
|
|
||||||
// Convenience function: take just one id
|
// Convenience function: take just one id
|
||||||
void Connect( int winid, int eventType,
|
void Connect( int winid, int eventType,
|
||||||
wxObjectEventFunction func,
|
wxObjectEventFunction func,
|
||||||
wxObject *userData = (wxObject *) NULL )
|
wxObject *userData = (wxObject *) NULL,
|
||||||
{ Connect(winid, wxID_ANY, eventType, func, userData); }
|
wxEvtHandler *eventSink = (wxEvtHandler *) NULL )
|
||||||
|
{ Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }
|
||||||
|
|
||||||
bool Disconnect( int winid, int lastId, wxEventType eventType,
|
bool Disconnect( int winid, int lastId, wxEventType eventType,
|
||||||
wxObjectEventFunction func = NULL,
|
wxObjectEventFunction func = NULL,
|
||||||
wxObject *userData = (wxObject *) NULL );
|
wxObject *userData = (wxObject *) NULL,
|
||||||
|
wxEvtHandler *eventSink = (wxEvtHandler *) NULL );
|
||||||
|
|
||||||
// Convenience function: take just one id
|
// Convenience function: take just one id
|
||||||
bool Disconnect( int winid, wxEventType eventType = wxEVT_NULL,
|
bool Disconnect( int winid, wxEventType eventType = wxEVT_NULL,
|
||||||
wxObjectEventFunction func = NULL,
|
wxObjectEventFunction func = NULL,
|
||||||
wxObject *userData = (wxObject *) NULL )
|
wxObject *userData = (wxObject *) NULL,
|
||||||
{ return Disconnect(winid, wxID_ANY, eventType, func, userData); }
|
wxEvtHandler *eventSink = (wxEvtHandler *) NULL )
|
||||||
|
{ return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }
|
||||||
|
|
||||||
|
|
||||||
// User data can be associated with each wxEvtHandler
|
// User data can be associated with each wxEvtHandler
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
// Note: this is intended to be used in wxDC at some point to replace
|
// 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.
|
// the current system of scaling/translation. It is not yet used.
|
||||||
|
|
||||||
//:defenition
|
//:definition
|
||||||
// A 3x3 matrix to do 2D transformations.
|
// A 3x3 matrix to do 2D transformations.
|
||||||
// It can be used to map data to window coordinates.
|
// It can be used to map data to window coordinates,
|
||||||
// But also for manipulating your own data.
|
// and also for manipulating your own data.
|
||||||
// For example drawing a picture (composed of several primitives)
|
// For example drawing a picture (composed of several primitives)
|
||||||
// at a certain coordinate and angle within another parent picture.
|
// 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.
|
// At all times m_isIdentity is set if the matrix itself is an Identity matrix.
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
There is no wxRadioButtonBase class as wxRadioButton interface is the same
|
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.
|
derives from wxCheckBox and on the others it doesn't.
|
||||||
|
|
||||||
The pseudo-declaration of wxRadioButtonBase would look like this:
|
The pseudo-declaration of wxRadioButtonBase would look like this:
|
||||||
|
@ -903,7 +903,8 @@ bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
|
|||||||
void wxEvtHandler::Connect( int id, int lastId,
|
void wxEvtHandler::Connect( int id, int lastId,
|
||||||
int eventType,
|
int eventType,
|
||||||
wxObjectEventFunction func,
|
wxObjectEventFunction func,
|
||||||
wxObject *userData )
|
wxObject *userData,
|
||||||
|
wxEvtHandler* eventSink )
|
||||||
{
|
{
|
||||||
#if WXWIN_COMPATIBILITY_EVENT_TYPES
|
#if WXWIN_COMPATIBILITY_EVENT_TYPES
|
||||||
wxEventTableEntry *entry = new wxEventTableEntry;
|
wxEventTableEntry *entry = new wxEventTableEntry;
|
||||||
@ -914,7 +915,7 @@ void wxEvtHandler::Connect( int id, int lastId,
|
|||||||
entry->m_callbackUserData = userData;
|
entry->m_callbackUserData = userData;
|
||||||
#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
|
#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
|
||||||
wxDynamicEventTableEntry *entry =
|
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
|
#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
|
||||||
|
|
||||||
if (!m_dynamicEvents)
|
if (!m_dynamicEvents)
|
||||||
@ -926,7 +927,8 @@ void wxEvtHandler::Connect( int id, int lastId,
|
|||||||
|
|
||||||
bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
|
bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
|
||||||
wxObjectEventFunction func,
|
wxObjectEventFunction func,
|
||||||
wxObject *userData )
|
wxObject *userData,
|
||||||
|
wxEvtHandler* eventSink )
|
||||||
{
|
{
|
||||||
if (!m_dynamicEvents)
|
if (!m_dynamicEvents)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -944,6 +946,7 @@ bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
|
|||||||
((entry->m_lastId == lastId) || (lastId == -1)) &&
|
((entry->m_lastId == lastId) || (lastId == -1)) &&
|
||||||
((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
|
((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
|
||||||
((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
|
((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
|
||||||
|
((entry->m_eventSink == eventSink) || (eventSink == (wxEvtHandler*)NULL)) &&
|
||||||
((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
|
((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
|
||||||
{
|
{
|
||||||
if (entry->m_callbackUserData)
|
if (entry->m_callbackUserData)
|
||||||
@ -985,7 +988,12 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
|
|||||||
event.Skip(FALSE);
|
event.Skip(FALSE);
|
||||||
event.m_callbackUserData = entry->m_callbackUserData;
|
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() )
|
if ( ! event.GetSkipped() )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -591,21 +591,7 @@ void wxToolBarBase::OnIdle(wxIdleEvent& event)
|
|||||||
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
|
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
|
||||||
void wxToolBarBase::DoToolbarUpdates()
|
void wxToolBarBase::DoToolbarUpdates()
|
||||||
{
|
{
|
||||||
wxWindow* parent = this;
|
wxEvtHandler* evtHandler = GetEventHandler() ;
|
||||||
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() ;
|
|
||||||
|
|
||||||
for ( wxToolBarToolsList::Node* node = m_tools.GetFirst();
|
for ( wxToolBarToolsList::Node* node = m_tools.GetFirst();
|
||||||
node;
|
node;
|
||||||
|
Loading…
Reference in New Issue
Block a user