// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_EVENTH__
-#define _WX_EVENTH__
+#ifndef _WX_EVENT_H__
+#define _WX_EVENT_H__
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "event.h"
#include "wx/thread.h"
+#include "wx/dynarray.h"
+
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
-class WXDLLEXPORT_BASE wxList;
+class WXDLLIMPEXP_BASE wxList;
#if wxUSE_GUI
- class WXDLLEXPORT_CORE wxDC;
- class WXDLLEXPORT_CORE wxMenu;
- class WXDLLEXPORT_CORE wxWindow;
+ class WXDLLIMPEXP_CORE wxDC;
+ class WXDLLIMPEXP_CORE wxMenu;
+ class WXDLLIMPEXP_CORE wxWindow;
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
wxEventTableEntry(type, winid, idLast, fn, obj)
+#define EMPTY_PARAMETER_VALUE /* Fake macro parameter value */
+
#define BEGIN_DECLARE_EVENT_TYPES()
#define END_DECLARE_EVENT_TYPES()
#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
extern expdecl const wxEventType name;
#define DECLARE_EVENT_TYPE(name, value) \
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_CORE, name, value)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
#define DECLARE_LOCAL_EVENT_TYPE(name, value) \
- DECLARE_EXPORTED_EVENT_TYPE(/* */, name, value)
+ DECLARE_EXPORTED_EVENT_TYPE(EMPTY_PARAMETER_VALUE, name, value)
#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name)
// generate a new unique event type
-extern WXDLLEXPORT_BASE wxEventType wxNewEventType();
+extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
// it is important to still have these as constants to avoid
// initialization order related problems
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_BASE, wxEVT_NULL, 0)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_BASE, wxEVT_FIRST, 10000)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_BASE, wxEVT_USER_FIRST, wxEVT_FIRST + 2000)
+ 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_SPINCTRL_UPDATED, 18)
// Sockets and timers send events, too
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_BASE, wxEVT_SOCKET, 50)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_SOCKET, 50)
DECLARE_EVENT_TYPE(wxEVT_TIMER , 80)
// Mouse event types
DECLARE_EVENT_TYPE(wxEVT_NAVIGATION_KEY, 214)
DECLARE_EVENT_TYPE(wxEVT_KEY_DOWN, 215)
DECLARE_EVENT_TYPE(wxEVT_KEY_UP, 216)
-
+#if wxUSE_HOTKEY
+ DECLARE_EVENT_TYPE(wxEVT_HOTKEY, 217)
+#endif
// Set cursor event
DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR, 230)
DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436)
DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437)
DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438)
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLEXPORT_BASE, wxEVT_IDLE, 439)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_IDLE, 439)
DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440)
DECLARE_EVENT_TYPE(wxEVT_SIZING, 441)
DECLARE_EVENT_TYPE(wxEVT_MOVING, 4442)
//
// still, any new code using it should include wx/textctrl.h explicitly
#if !WXWIN_COMPATIBILITY_EVENT_TYPES
- extern const wxEventType WXDLLEXPORT_CORE wxEVT_COMMAND_TEXT_UPDATED;
+ extern const wxEventType WXDLLIMPEXP_CORE wxEVT_COMMAND_TEXT_UPDATED;
#endif
#if WXWIN_COMPATIBILITY
#endif // WXWIN_COMPATIBILITY
+// the predefined constants for the number of times we propagate event
+// upwards window child-parent chain
+enum Propagation_state
+{
+ // don't propagate it at all
+ wxEVENT_PROPAGATE_NONE = 0,
+
+ // propagate it until it is processed
+ wxEVENT_PROPAGATE_MAX = INT_MAX
+};
+
/*
* wxWindows events, covering all interesting things that might happen
* (button clicking, resizing, setting text in widgets, etc.).
*
*/
-class WXDLLEXPORT_BASE wxEvent : public wxObject
+class WXDLLIMPEXP_BASE wxEvent : public wxObject
{
private:
wxEvent& operator=(const wxEvent&);
void Skip(bool skip = TRUE) { m_skipped = skip; }
bool GetSkipped() const { return m_skipped; };
- // Implementation only: this test is explicitlty anti OO and this functions
- // exists only for optimization purposes.
- bool IsCommandEvent() const { return m_isCommandEvent; }
-
// this function is used to create a copy of the event polymorphically and
// all derived classes must implement it because otherwise wxPostEvent()
// for them wouldn't work (it needs to do a copy of the event)
virtual wxEvent *Clone() const = 0;
+ // Implementation only: this test is explicitlty anti OO and this functions
+ // exists only for optimization purposes.
+ bool IsCommandEvent() const { return m_isCommandEvent; }
+
+ // Determine if this event should be propagating to the parent window.
+ bool ShouldPropagate() const
+ { return m_propagationLevel != wxEVENT_PROPAGATE_NONE; }
+
+ // Stop an event from propagating to its parent window, returns the old
+ // propagation level value
+ int StopPropagation()
+ {
+ int propagationLevel = m_propagationLevel;
+ m_propagationLevel = wxEVENT_PROPAGATE_NONE;
+ return propagationLevel;
+ }
+
+ // Resume the event propagation by restoring the propagation level
+ // (returned by StopPropagation())
+ void ResumePropagation(int propagationLevel)
+ {
+ m_propagationLevel = propagationLevel;
+ }
+
public:
wxObject* m_eventObject;
wxEventType m_eventType;
long m_timeStamp;
int m_id;
wxObject* m_callbackUserData;
+
+protected:
+ // the propagation level: while it is positive, we propagate the event to
+ // the parent window (if any)
+ //
+ // this one doesn't have to be public, we don't have to worry about
+ // backwards compatibility as it is new
+ int m_propagationLevel;
+
+public:
bool m_skipped;
bool m_isCommandEvent;
-
+
private:
+ // it needs to access our m_propagationLevel
+ friend class WXDLLIMPEXP_BASE wxPropagateOnce;
+
DECLARE_ABSTRACT_CLASS(wxEvent)
};
+/*
+ * Helper class to temporarily change an event not to propagate.
+ */
+class WXDLLIMPEXP_BASE wxPropagationDisabler
+{
+public:
+ wxPropagationDisabler(wxEvent& event) : m_event(event)
+ {
+ m_propagationLevelOld = m_event.StopPropagation();
+ }
+
+ ~wxPropagationDisabler()
+ {
+ m_event.ResumePropagation(m_propagationLevelOld);
+ }
+
+private:
+ wxEvent& m_event;
+ int m_propagationLevelOld;
+};
+
+/*
+ * Another one to temporarily lower propagation level.
+ */
+class WXDLLIMPEXP_BASE wxPropagateOnce
+{
+public:
+ wxPropagateOnce(wxEvent& event) : m_event(event)
+ {
+ wxASSERT_MSG( m_event.m_propagationLevel > 0,
+ _T("shouldn't be used unless ShouldPropagate()!") );
+
+ m_event.m_propagationLevel--;
+ }
+
+ ~wxPropagateOnce()
+ {
+ m_event.m_propagationLevel++;
+ }
+
+private:
+ wxEvent& m_event;
+};
+
#if wxUSE_GUI
+
// Item or menu event class
/*
wxEVT_COMMAND_BUTTON_CLICKED
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED
*/
-class WXDLLEXPORT_CORE wxCommandEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent
{
private:
wxCommandEvent& operator=(const wxCommandEvent& event);
// this class adds a possibility to react (from the user) code to a control
// notification: allow or veto the operation being reported.
-class WXDLLEXPORT_CORE wxNotifyEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent
{
public:
wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
wxEVT_SCROLL_ENDSCROLL
*/
-class WXDLLEXPORT_CORE wxScrollEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent
{
public:
wxScrollEvent(wxEventType commandType = wxEVT_NULL,
wxEVT_SCROLLWIN_THUMBRELEASE
*/
-class WXDLLEXPORT_CORE wxScrollWinEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent
{
public:
wxScrollWinEvent(wxEventType commandType = wxEVT_NULL,
wxMOUSE_BTN_RIGHT = 2
};
-class WXDLLEXPORT_CORE wxMouseEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent
{
public:
wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
wxEVT_SET_CURSOR
*/
-class WXDLLEXPORT_CORE wxSetCursorEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent
{
public:
wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0)
wxEVT_CHAR_HOOK
wxEVT_KEY_DOWN
wxEVT_KEY_UP
+ wxEVT_HOTKEY
*/
-class WXDLLEXPORT_CORE wxKeyEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent
{
public:
wxKeyEvent(wxEventType keyType = wxEVT_NULL);
wxEVT_SIZE
*/
-class WXDLLEXPORT_CORE wxSizeEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
{
public:
wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
wxEVT_MOVE
*/
-class WXDLLEXPORT_CORE wxMoveEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
{
public:
wxMoveEvent()
#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__))
// see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
- extern WXDLLEXPORT_CORE int g_isPainting;
+ extern WXDLLIMPEXP_CORE int g_isPainting;
#endif // debug
-class WXDLLEXPORT_CORE wxPaintEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
{
public:
wxPaintEvent(int Id = 0)
DECLARE_DYNAMIC_CLASS(wxPaintEvent)
};
-class WXDLLEXPORT_CORE wxNcPaintEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
{
public:
wxNcPaintEvent(int winid = 0)
wxEVT_ERASE_BACKGROUND
*/
-class WXDLLEXPORT_CORE wxEraseEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
{
private:
wxEraseEvent& operator=(const wxEraseEvent& event);
wxEVT_KILL_FOCUS
*/
-class WXDLLEXPORT_CORE wxFocusEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
{
private:
wxFocusEvent& operator=(const wxFocusEvent& event);
};
// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
-// wxFocusEvent it is propgated upwards the window chain
-class WXDLLEXPORT_CORE wxChildFocusEvent : public wxCommandEvent
+// wxFocusEvent it is propagated upwards the window chain
+class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent
{
public:
wxChildFocusEvent(wxWindow *win = NULL);
wxEVT_ACTIVATE_APP
*/
-class WXDLLEXPORT_CORE wxActivateEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent
{
public:
wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = TRUE, int Id = 0)
wxEVT_INIT_DIALOG
*/
-class WXDLLEXPORT_CORE wxInitDialogEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent
{
public:
wxInitDialogEvent(int Id = 0)
wxEVT_MENU_HIGHLIGHT,
*/
-class WXDLLEXPORT_CORE wxMenuEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent
{
public:
- wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0)
+ wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL)
: wxEvent(winid, type)
- { m_menuId = winid; }
+ { m_menuId = winid; m_menu = NULL; }
wxMenuEvent(const wxMenuEvent & event)
: wxEvent(event)
- { m_menuId = event.m_menuId; }
+ { m_menuId = event.m_menuId; m_menu = event.m_menu; }
// only for wxEVT_MENU_HIGHLIGHT
int GetMenuId() const { return m_menuId; }
// only for wxEVT_MENU_OPEN/CLOSE
bool IsPopup() const { return m_menuId == -1; }
+ // only for wxEVT_MENU_OPEN/CLOSE
+ wxMenu* GetMenu() const { return m_menu; }
+
virtual wxEvent *Clone() const { return new wxMenuEvent(*this); }
private:
- int m_menuId;
+ int m_menuId;
+ wxMenu* m_menu;
DECLARE_DYNAMIC_CLASS(wxMenuEvent)
};
wxEVT_QUERY_END_SESSION
*/
-class WXDLLEXPORT_CORE wxCloseEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent
{
public:
wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0)
wxEVT_SHOW
*/
-class WXDLLEXPORT_CORE wxShowEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent
{
public:
wxShowEvent(int winid = 0, bool show = FALSE)
wxEVT_ICONIZE
*/
-class WXDLLEXPORT_CORE wxIconizeEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent
{
public:
wxIconizeEvent(int winid = 0, bool iconized = TRUE)
wxEVT_MAXIMIZE
*/
-class WXDLLEXPORT_CORE wxMaximizeEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent
{
public:
wxMaximizeEvent(int winid = 0)
wxJOY_BUTTON4 = 8
};
-class WXDLLEXPORT_CORE wxJoystickEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent
{
public:
wxPoint m_pos;
wxEVT_DROP_FILES
*/
-class WXDLLEXPORT_CORE wxDropFilesEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent
{
private:
wxDropFilesEvent& operator=(const wxDropFilesEvent& event);
wxEVT_UPDATE_UI
*/
-class WXDLLEXPORT_CORE wxUpdateUIEvent : public wxCommandEvent
+// Whether to always send update events to windows, or
+// to only send update events to those with the
+// wxWS_EX_PROCESS_UI_UPDATES style.
+
+enum wxUpdateUIMode
+{
+ // Send UI update events to all windows
+ wxUPDATE_UI_PROCESS_ALL,
+
+ // Send UI update events to windows that have
+ // the wxWS_EX_PROCESS_UI_UPDATES flag specified
+ wxUPDATE_UI_PROCESS_SPECIFIED
+};
+
+class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
{
public:
wxUpdateUIEvent(wxWindowID commandId = 0)
void Enable(bool enable) { m_enabled = enable; m_setEnabled = TRUE; }
void SetText(const wxString& text) { m_text = text; m_setText = TRUE; }
+ // Sets the interval between updates in milliseconds.
+ // Set to -1 to disable updates, or to 0 to update as frequently as possible.
+ static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
+
+ // Returns the current interval between updates in milliseconds
+ static long GetUpdateInterval() { return sm_updateInterval ; }
+
+ // Can we update this window?
+ static bool CanUpdate(wxWindow* win) ;
+
+ // Reset the update time to provide a delay until the next
+ // time we should update
+ static void ResetUpdateTime() ;
+
+ // Specify how wxWindows will send update events: to
+ // all windows, or only to those which specify that they
+ // will process the events.
+ static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
+
+ // Returns the UI update mode
+ static wxUpdateUIMode GetMode() { return sm_updateMode ; }
+
virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); }
protected:
bool m_setText;
bool m_setChecked;
wxString m_text;
+#if wxUSE_LONGLONG
+ static wxLongLong sm_lastUpdate;
+#endif
+ static long sm_updateInterval;
+ static wxUpdateUIMode sm_updateMode;
private:
DECLARE_DYNAMIC_CLASS(wxUpdateUIEvent)
*/
// TODO: shouldn't all events record the window ID?
-class WXDLLEXPORT_CORE wxSysColourChangedEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent
{
public:
wxSysColourChangedEvent()
(even if it released the capture itself).
*/
-class WXDLLEXPORT_CORE wxMouseCaptureChangedEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent
{
private:
wxMouseCaptureChangedEvent operator=(const wxMouseCaptureChangedEvent& event);
/*
wxEVT_DISPLAY_CHANGED
*/
-class WXDLLEXPORT_CORE wxDisplayChangedEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent
{
private:
DECLARE_DYNAMIC_CLASS(wxDisplayChangedEvent)
wxEVT_PALETTE_CHANGED
*/
-class WXDLLEXPORT_CORE wxPaletteChangedEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent
{
private:
wxPaletteChangedEvent& operator=(const wxPaletteChangedEvent& event);
Indicates the window is getting keyboard focus and should re-do its palette.
*/
-class WXDLLEXPORT_CORE wxQueryNewPaletteEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent
{
public:
wxQueryNewPaletteEvent(wxWindowID winid = 0)
wxEVT_NAVIGATION_KEY
*/
// NB: don't derive from command event to avoid being propagated to the parent
-class WXDLLEXPORT_CORE wxNavigationKeyEvent : public wxEvent
+class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent
{
private:
wxNavigationKeyEvent& operator=(const wxNavigationKeyEvent& event);
wxEVT_DESTROY
*/
-class WXDLLEXPORT_CORE wxWindowCreateEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent
{
public:
wxWindowCreateEvent(wxWindow *win = NULL);
DECLARE_DYNAMIC_CLASS(wxWindowCreateEvent)
};
-class WXDLLEXPORT_CORE wxWindowDestroyEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent
{
public:
wxWindowDestroyEvent(wxWindow *win = NULL);
wxEVT_DETAILED_HELP
*/
-class WXDLLEXPORT_CORE wxHelpEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent
{
public:
wxHelpEvent(wxEventType type = wxEVT_NULL,
wxEVT_CONTEXT_MENU
*/
-class WXDLLEXPORT_CORE wxContextMenuEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent
{
public:
wxContextMenuEvent(wxEventType type = wxEVT_NULL,
wxEVT_IDLE
*/
-class WXDLLEXPORT_CORE wxIdleEvent : public wxEvent
+// Whether to always send idle events to windows, or
+// to only send update events to those with the
+// wxWS_EX_PROCESS_IDLE style.
+
+enum wxIdleMode
+{
+ // Send idle events to all windows
+ wxIDLE_PROCESS_ALL,
+
+ // Send idle events to windows that have
+ // the wxWS_EX_PROCESS_IDLE flag specified
+ wxIDLE_PROCESS_SPECIFIED
+};
+
+class WXDLLIMPEXP_CORE wxIdleEvent : public wxEvent
{
public:
wxIdleEvent()
virtual wxEvent *Clone() const { return new wxIdleEvent(*this); }
+ // Specify how wxWindows will send idle events: to
+ // all windows, or only to those which specify that they
+ // will process the events.
+ static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
+
+ // Returns the idle event mode
+ static wxIdleMode GetMode() { return sm_idleMode ; }
+
+ // Can we send an idle event?
+ static bool CanSend(wxWindow* win) ;
+
protected:
bool m_requestMore;
+ static wxIdleMode sm_idleMode;
private:
DECLARE_DYNAMIC_CLASS(wxIdleEvent)
// we have to keep both versions
#if WXWIN_COMPATIBILITY_EVENT_TYPES
-struct WXDLLEXPORT_BASE wxEventTableEntry
+struct WXDLLIMPEXP_BASE wxEventTableEntry
{
// For some reason, this can't be wxEventType, or VC++ complains.
int m_eventType; // main event type
// struct containing the members common to static and dynamic event tables
// entries
-struct WXDLLEXPORT_BASE wxEventTableEntryBase
+struct WXDLLIMPEXP_BASE wxEventTableEntryBase
{
private:
wxEventTableEntryBase& operator=(const wxEventTableEntryBase& event);
};
// an entry from a static event table
-struct WXDLLEXPORT_BASE wxEventTableEntry : public wxEventTableEntryBase
+struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase
{
wxEventTableEntry(const int& evType, int winid, int idLast,
wxObjectEventFunction fn, wxObject *data)
const int& m_eventType;
};
-class WXDLLEXPORT_BASE wxEvtHandler;
+class WXDLLIMPEXP_BASE wxEvtHandler;
// an entry used in dynamic event table managed by wxEvtHandler::Connect()
-struct WXDLLEXPORT_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
+struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
{
wxDynamicEventTableEntry(int evType, int winid, int idLast,
wxObjectEventFunction fn, wxObject *data, wxEvtHandler* eventSink)
// wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
// ----------------------------------------------------------------------------
-struct WXDLLEXPORT_BASE wxEventTable
+struct WXDLLIMPEXP_BASE wxEventTable
{
const wxEventTable *baseTable; // base event table (next in chain)
const wxEventTableEntry *entries; // bottom of entry array
};
+// ----------------------------------------------------------------------------
+// wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
+// ----------------------------------------------------------------------------
+
+WX_DEFINE_ARRAY_NO_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray);
+class WXDLLIMPEXP_BASE wxEvtHandler;
+
+class WXDLLIMPEXP_BASE wxEventHashTable
+{
+private:
+ // Internal data structs
+ struct EventTypeTable
+ {
+ wxEventType eventType;
+ wxEventTableEntryPointerArray eventEntryTable;
+ };
+ typedef EventTypeTable* EventTypeTablePointer;
+
+public:
+ // Constructor, needs the event table it needs to hash later on.
+ // Note: hashing of the event table is not done in the constructor as it
+ // can be that the event table is not yet full initialize, the hash
+ // will gets initialized when handling the first event look-up request.
+ wxEventHashTable(const wxEventTable &table);
+ // Destructor.
+ ~wxEventHashTable();
+
+ // Handle the given event, in other words search the event table hash
+ // and call self->ProcessEvent() if a match was found.
+ bool HandleEvent(wxEvent &event, wxEvtHandler *self);
+
+protected:
+ // Init the hash table with the entries of the static event table.
+ void InitHashTable();
+ // Helper funtion of InitHashTable() to insert 1 entry into the hash table.
+ void AddEntry(const wxEventTableEntry &entry);
+ // Allocate and init with null pointers the base hash table.
+ void AllocEventTypeTable(size_t size);
+ // Grow the hash table in size and transfer all items currently
+ // in the table to the correct location in the new table.
+ void GrowEventTypeTable();
+
+protected:
+ const wxEventTable &m_table;
+ bool m_rebuildHash;
+
+ size_t m_size;
+ EventTypeTablePointer *m_eventTypeTable;
+};
+
// ----------------------------------------------------------------------------
// wxEvtHandler: the base class for all objects handling wxWindows events
// ----------------------------------------------------------------------------
-class WXDLLEXPORT_BASE wxEvtHandler : public wxObject
+class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
{
public:
wxEvtHandler();
virtual bool TryParent(wxEvent& event);
- static const wxEventTable sm_eventTable;
-
+ static const wxEventTable sm_eventTable;
virtual const wxEventTable *GetEventTable() const;
+ static wxEventHashTable sm_eventHashTable;
+ virtual wxEventHashTable& GetEventHashTable() const;
+
wxEvtHandler* m_nextHandler;
wxEvtHandler* m_previousHandler;
wxList* m_dynamicEvents;
static const wxEventTableEntry sm_eventTableEntries[]; \
protected: \
static const wxEventTable sm_eventTable; \
- virtual const wxEventTable* GetEventTable() const;
+ virtual const wxEventTable* GetEventTable() const; \
+ static wxEventHashTable sm_eventHashTable; \
+ virtual wxEventHashTable& GetEventHashTable() const;
+
+// N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize
+// sm_eventTable before using it in GetEventTable() or the compiler gives
+// E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews)
#define BEGIN_EVENT_TABLE(theClass, baseClass) \
- const wxEventTable *theClass::GetEventTable() const \
- { return &theClass::sm_eventTable; } \
const wxEventTable theClass::sm_eventTable = \
{ &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \
+ const wxEventTable *theClass::GetEventTable() const \
+ { return &theClass::sm_eventTable; } \
+ wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
+ wxEventHashTable &theClass::GetEventHashTable() const \
+ { return theClass::sm_eventHashTable; } \
const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
#define END_EVENT_TABLE() DECLARE_EVENT_TABLE_ENTRY( wxEVT_NULL, 0, 0, 0, 0 ) };
#define EVT_CHAR(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHAR, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
#define EVT_KEY_DOWN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_DOWN, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
#define EVT_KEY_UP(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_UP, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
+#if wxUSE_HOTKEY
+#define EVT_HOTKEY(id, func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_HOTKEY, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
+#endif
#define EVT_CHAR_HOOK(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHAR_HOOK, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, NULL ),
#define EVT_MENU_OPEN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_OPEN, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
#define EVT_MENU_CLOSE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_CLOSE, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
// for pending event processing - notice that there is intentionally no
// WXDLLEXPORT here
-extern WXDLLEXPORT_BASE wxList *wxPendingEvents;
+extern WXDLLIMPEXP_BASE wxList *wxPendingEvents;
#if wxUSE_THREADS
- extern WXDLLEXPORT_BASE wxCriticalSection *wxPendingEventsLocker;
+ extern WXDLLIMPEXP_BASE wxCriticalSection *wxPendingEventsLocker;
#endif
// ----------------------------------------------------------------------------
#endif // wxUSE_GUI
-#endif
- // _WX_EVENTH__
+#endif // _WX_EVENT_H__
+