// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_EVENT_H__
-#define _WX_EVENT_H__
+#ifndef _WX_EVENT_H_
+#define _WX_EVENT_H_
#include "wx/defs.h"
#include "wx/cpp.h"
#include "wx/cursor.h"
#endif
-#include "wx/thread.h"
-
#include "wx/dynarray.h"
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_BASE wxList;
-
+#if wxUSE_THREADS
+ class WXDLLIMPEXP_FWD_BASE wxCriticalSection;
+#endif
#if wxUSE_GUI
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxMenu;
// handler only a function with proper parameter list can be given.
#define wxStaticCastEvent(type, val) wx_static_cast(type, val)
-// in previous versions of wxWidgets the event types used to be constants
-// which created difficulties with custom/user event types definition
-//
-// starting from wxWidgets 2.4 the event types are now dynamically assigned
-// using wxNewEventType() which solves this problem, however at price of
-// several incompatibilities:
-//
-// a) event table macros declaration changed, it now uses wxEventTableEntry
-// ctor instead of initialisation from an agregate - the macro
-// DECLARE_EVENT_TABLE_ENTRY may be used to write code which can compile
-// with all versions of wxWidgets
-//
-// b) event types can't be used as switch() cases as they're not really
-// constant any more - there is no magic solution here, you just have to
-// change the switch()es to if()s
-//
-// if these are real problems for you, define WXWIN_COMPATIBILITY_EVENT_TYPES
-// as 1 to get 100% old behaviour, however you won't be able to use the
-// libraries using the new dynamic event type allocation in such case, so avoid
-// it if possible.
-#ifndef WXWIN_COMPATIBILITY_EVENT_TYPES
- #define WXWIN_COMPATIBILITY_EVENT_TYPES 0
-#endif
-
-#if WXWIN_COMPATIBILITY_EVENT_TYPES
-
-#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
- { type, winid, idLast, fn, obj }
-
-#define BEGIN_DECLARE_EVENT_TYPES() enum {
-#define END_DECLARE_EVENT_TYPES() };
-#define DECLARE_EVENT_TYPE(name, value) name = wxEVT_FIRST + value,
-#define DECLARE_LOCAL_EVENT_TYPE(name, value) name = wxEVT_USER_FIRST + value,
-#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
- DECLARE_LOCAL_EVENT_TYPE(name, value)
-#define DEFINE_EVENT_TYPE(name)
-#define DEFINE_LOCAL_EVENT_TYPE(name)
-
-
-#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
-
#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
wxEventTableEntry(type, winid, idLast, fn, obj)
// generate a new unique event type
extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
-#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
-
BEGIN_DECLARE_EVENT_TYPES()
-
-#if WXWIN_COMPATIBILITY_EVENT_TYPES
- wxEVT_NULL = 0,
- wxEVT_FIRST = 10000,
- wxEVT_USER_FIRST = wxEVT_FIRST + 2000,
-#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
// it is important to still have these as constants to avoid
// initialization order related problems
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_NULL, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_FIRST, 10000)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_USER_FIRST, wxEVT_FIRST + 2000)
-#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKBOX_CLICKED, 2)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED, 4)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 5)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 6)
- // now they are in wx/textctrl.h
-#if WXWIN_COMPATIBILITY_EVENT_TYPES
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14)
-#endif // WXWIN_COMPATIBILITY_EVENT_TYPES
DECLARE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED, 9)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED, 10)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED, 11)
DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440)
DECLARE_EVENT_TYPE(wxEVT_SIZING, 441)
DECLARE_EVENT_TYPE(wxEVT_MOVING, 442)
- DECLARE_EVENT_TYPE(wxEVT_HIBERNATE, 443)
+ DECLARE_EVENT_TYPE(wxEVT_MOVE_START, 443)
+ DECLARE_EVENT_TYPE(wxEVT_MOVE_END, 444)
+ DECLARE_EVENT_TYPE(wxEVT_HIBERNATE, 445)
// more power events follow -- see wx/power.h
// Clipboard events
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY, 444)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT, 445)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE, 446)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY, 446)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT, 447)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE, 448)
// Generic command events
// Note: a click is a higher-level event than button down/up
// wx/textctrl.h in all ports [yet], so declare it here as well
//
// still, any new code using it should include wx/textctrl.h explicitly
-#if !WXWIN_COMPATIBILITY_EVENT_TYPES
- extern const wxEventType WXDLLIMPEXP_CORE wxEVT_COMMAND_TEXT_UPDATED;
-#endif
+extern const wxEventType WXDLLIMPEXP_CORE wxEVT_COMMAND_TEXT_UPDATED;
// the predefined constants for the number of times we propagate event
// upwards window child-parent chain
{
public:
wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
- wxMouseEvent(const wxMouseEvent& event) : wxEvent(event)
+ wxMouseEvent(const wxMouseEvent& event) : wxEvent(event)
{ Assign(event); }
// Was it a button event? (*doesn't* mean: is any button *down*?)
// True if the mouse is just leaving the window
bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
+ // Returns the number of mouse clicks associated with this event.
+ int GetClickCount() const { return m_clickCount; }
+
+
// Find the position of the event
void GetPosition(wxCoord *xpos, wxCoord *ypos) const
{
// Returns the configured number of lines (or whatever) to be scrolled per
// wheel action. Defaults to one.
int GetLinesPerAction() const { return m_linesPerAction; }
-
+
// Is the system set to do page scrolling?
bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
bool m_shiftDown;
bool m_altDown;
bool m_metaDown;
-
+
+ int m_clickCount;
+
int m_wheelAxis;
int m_wheelRotation;
int m_wheelDelta;
// Get Y position
wxCoord GetY() const { return m_y; }
-#if WXWIN_COMPATIBILITY_2_6
- // deprecated, Use GetKeyCode instead.
- wxDEPRECATED( long KeyCode() const );
-#endif // WXWIN_COMPATIBILITY_2_6
-
virtual wxEvent *Clone() const { return new wxKeyEvent(*this); }
// we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
// as a wxObject method even though it can only be a wxEvtHandler one
typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
-// we can't have ctors nor base struct in backwards compatibility mode or
-// otherwise we won't be able to initialize the objects with an agregate, so
-// we have to keep both versions
-#if WXWIN_COMPATIBILITY_EVENT_TYPES
-
-struct WXDLLIMPEXP_BASE wxEventTableEntry
-{
- // For some reason, this can't be wxEventType, or VC++ complains.
- int m_eventType; // main event type
- int m_id; // control/menu/toolbar id
- int m_lastId; // used for ranges of ids
- wxObjectEventFunction m_fn; // function to call: not wxEventFunction,
- // because of dependency problems
-
- wxObject* m_callbackUserData;
-};
-
-#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
-
// struct containing the members common to static and dynamic event tables
// entries
struct WXDLLIMPEXP_BASE wxEventTableEntryBase
DECLARE_NO_COPY_CLASS(wxDynamicEventTableEntry)
};
-#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
-
// ----------------------------------------------------------------------------
// wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
// ----------------------------------------------------------------------------
// Clear table
void Clear();
-#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
+#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
// Clear all tables
static void ClearAll();
#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING
// process an event right now
virtual bool ProcessEvent(wxEvent& event);
+ // Process an event by calling ProcessEvent and handling any exceptions
+ // thrown by event handlers. It's mostly useful when processing wx events
+ // when called from C code (e.g. in GTK+ callback) when the exception
+ // wouldn't correctly propagate to wxEventLoop.
+ bool SafelyProcessEvent(wxEvent& event);
+
// add an event to be processed later
virtual void AddPendingEvent(const wxEvent& event);
#define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func))
#define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func))
#define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func))
+#define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func))
+#define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func))
#define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))
#define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
#define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
#endif // wxUSE_GUI
-#endif // _WX_EVENT_H__
+#endif // _WX_EVENT_H_