/////////////////////////////////////////////////////////////////////////////
-// Name: event.cpp
+// Name: src/common/event.cpp
// Purpose: Event classes
// Author: Julian Smart
// Modified by:
#pragma hdrstop
#endif
+#include "wx/event.h"
+
#ifndef WX_PRECOMP
- #include "wx/defs.h"
- #include "wx/app.h"
#include "wx/list.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/stopwatch.h"
+ #include "wx/module.h"
#if wxUSE_GUI
#include "wx/control.h"
- #include "wx/utils.h"
#include "wx/dc.h"
#include "wx/textctrl.h"
+ #include "wx/validate.h"
#endif // wxUSE_GUI
#endif
-#include "wx/event.h"
-#include "wx/module.h"
-
-#if wxUSE_GUI
- #include "wx/validate.h"
-#if wxUSE_STOPWATCH
- #include "wx/stopwatch.h"
-#endif
-#endif // wxUSE_GUI
-
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent, wxCommandEvent)
IMPLEMENT_DYNAMIC_CLASS(wxContextMenuEvent, wxCommandEvent)
IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureChangedEvent, wxEvent)
+ IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureLostEvent, wxEvent)
+ IMPLEMENT_DYNAMIC_CLASS(wxClipboardTextEvent, wxCommandEvent)
#endif // wxUSE_GUI
#if wxUSE_BASE
DEFINE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE)
DEFINE_EVENT_TYPE(wxEVT_SCROLL_CHANGED)
-// see comments in wx/event.h, near wxEVT_SCROLL_ENDSCROLL declaration
-#if wxCHECK_VERSION(2, 7, 0)
- #error "Remove the lines below, not needed any more"
-#endif
-#undef wxEVT_SCROLL_ENDSCROLL
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_SCROLL_ENDSCROLL;
-const wxEventType wxEVT_SCROLL_ENDSCROLL = wxEVT_SCROLL_CHANGED;
-
// Scroll events from wxWindow
DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP)
DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_BOTTOM)
DEFINE_EVENT_TYPE(wxEVT_ICONIZE)
DEFINE_EVENT_TYPE(wxEVT_MAXIMIZE)
DEFINE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_LOST)
DEFINE_EVENT_TYPE(wxEVT_PAINT)
DEFINE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND)
DEFINE_EVENT_TYPE(wxEVT_NC_PAINT)
DEFINE_EVENT_TYPE(wxEVT_INIT_DIALOG)
DEFINE_EVENT_TYPE(wxEVT_UPDATE_UI)
+// Clipboard events
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE)
+
// Generic command events
// Note: a click is a higher-level event than button down/up
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LEFT_CLICK)
#endif
}
+#if WXWIN_COMPATIBILITY_2_6
long wxKeyEvent::KeyCode() const
{
return m_keyCode;
}
+#endif // WXWIN_COMPATIBILITY_2_6
wxWindowCreateEvent::wxWindowCreateEvent(wxWindow *win)
{
SetEventObject(win);
}
+// ----------------------------------------------------------------------------
+// wxHelpEvent
+// ----------------------------------------------------------------------------
+
+/* static */
+wxHelpEvent::Origin wxHelpEvent::GuessOrigin(Origin origin)
+{
+ if ( origin == Origin_Unknown )
+ {
+ // assume that the event comes from the help button if it's not from
+ // keyboard and that pressing F1 always results in the help event
+ origin = wxGetKeyState(WXK_F1) ? Origin_Keyboard : Origin_HelpButton;
+ }
+
+ return origin;
+}
+
#endif // wxUSE_GUI
m_eventsLocker = new wxCriticalSection;
# endif
#endif
+
// no client data (yet)
m_clientData = NULL;
m_clientDataType = wxClientData_None;
delete m_dynamicEvents;
};
+ if (m_pendingEvents)
+ m_pendingEvents->DeleteContents(true);
delete m_pendingEvents;
#if wxUSE_THREADS
delete m_eventsLocker;
m_eventsLocker = NULL;
#endif
-};
+}
#endif // wxUSE_THREADS
wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
- // 3) Inform the system that new pending events are somwehere,
+ // 3) Inform the system that new pending events are somewhere,
// and that these should be processed in idle time.
wxWakeUpIdle();
}
void wxEvtHandler::ProcessPendingEvents()
{
- // this method is only called by wxApp if this handler does have pending
- // events
+ // this method is only called by wxApp if this handler does have
+ // pending events
wxCHECK_RET( m_pendingEvents,
wxT("Please call wxApp::ProcessPendingEvents() instead") );
-
+
wxENTER_CRIT_SECT( Lock() );
// we leave the loop once we have processed all events that were present at
{
wxEvent *event = (wxEvent *)node->GetData();
+ // It's importan we remove event from list before processing it.
+ // Else a nested event loop, for example from a modal dialog, might
+ // process the same event again.
+
m_pendingEvents->Erase(node);
wxLEAVE_CRIT_SECT( Lock() );
ProcessEvent(*event);
+
delete event;
wxENTER_CRIT_SECT( Lock() );
- if ( !--n )
+ if ( --n == 0 )
break;
}
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
+ // get next node before (maybe) calling the event handler as it could
+ // call Disconnect() invalidating the current node
+ node = node->GetNext();
+
if ((event.GetEventType() == entry->m_eventType) && (entry->m_fn != 0))
{
wxEvtHandler *handler =
return true;
}
}
-
- node = node->GetNext();
}
return false;
-};
+}
void wxEvtHandler::DoSetClientObject( wxClientData *data )
{