#include "wx/defs.h"
#include "wx/object.h"
#include "wx/gdicmn.h"
+#if wxUSE_THREADS
+#include "wx/thread.h"
+#endif
/*
* Event types
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; }
+
+ wxObject *Clone() const;
+
public:
bool m_skipped;
wxObject* m_eventObject;
long m_timeStamp;
int m_id;
wxObject* m_callbackUserData;
+
+ // optimization: instead of using costly IsKindOf() we keep a flag telling
+ // whether we're a command event (by far the most common case)
+ bool m_isCommandEvent;
};
// Item or menu event class
int GetSelection() const { return m_commandInt; }
// Set/Get listbox/choice selection string
- void SetString(char* s) { m_commandString = s; }
- char *GetString() const { return m_commandString; }
+ void SetString(const wxString& s) { m_commandString = s; }
+ wxString GetString() const { return m_commandString; }
// Get checkbox value
bool Checked() const { return (m_commandInt != 0); }
long GetInt() const { return m_commandInt ; }
public:
- char* m_commandString; // String event argument
+ wxString m_commandString; // String event argument
int m_commandInt;
long m_extraLong; // Additional information (e.g. select/deselect)
void* m_clientData; // Arbitrary client data
bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
// Find the position of the event
+ void GetPosition(long *xpos, long *ypos) const { *xpos = m_x; *ypos = m_y; }
void Position(long *xpos, long *ypos) const { *xpos = m_x; *ypos = m_y; }
// Find the position of the event
bool ShiftDown() const { return m_shiftDown; }
long KeyCode() const { return m_keyCode; }
-#if WXWIN_COMPATIBILITY
// Find the position of the event
- void Position(float *xpos, float *ypos) const
- { *xpos = (float)m_x; *ypos = (float)m_y; }
+ void GetPosition(long *xpos, long *ypos) const
+ { *xpos = m_x; *ypos = m_y; }
+
+ wxPoint GetPosition() const
+ { return wxPoint(m_x, m_y); }
// Get X position
- float GetX() const { return (float)m_x; }
+ long GetX() const { return m_x; }
// Get Y position
- float GetY() const { return (float)m_y; }
-
-#endif // WXWIN_COMPATIBILITY
+ long GetY() const { return m_y; }
public:
long m_x;
{
// GetVeto() will return FALSE anyhow...
wxCHECK_RET( m_canVeto,
- "call to Veto() ignored (can't veto this event)" );
+ _T("call to Veto() ignored (can't veto this event)") );
m_veto = veto;
}
virtual bool OnClose();
#endif
+#if wxUSE_THREADS
+ bool ProcessThreadEvent(wxEvent& event);
+ void ProcessPendingEvents();
+#endif
virtual bool ProcessEvent(wxEvent& event);
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
+#if wxUSE_THREADS
+ void ClearEventLocker() { delete m_eventsLocker; m_eventsLocker = NULL; };
+#endif
+
private:
static const wxEventTableEntry sm_eventTableEntries[];
protected:
- static const wxEventTable sm_eventTable;
- virtual const wxEventTable* GetEventTable() const;
+ static const wxEventTable sm_eventTable;
+
+ virtual const wxEventTable *GetEventTable() const;
+
protected:
- wxEvtHandler* m_nextHandler;
- wxEvtHandler* m_previousHandler;
- bool m_enabled; // Is event handler enabled?
- wxList* m_dynamicEvents;
+ wxEvtHandler* m_nextHandler;
+ wxEvtHandler* m_previousHandler;
+ bool m_enabled; // Is event handler enabled?
+ wxList* m_dynamicEvents;
+ wxList* m_pendingEvents;
+#if wxUSE_THREADS
+ wxCriticalSection* m_eventsLocker;
+#endif
+
+ // optimization: instead of using costly IsKindOf() to decide whether we're
+ // a window (which is true in 99% of cases), use this flag
+ bool m_isWindow;
};
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
// EVT_COMMAND
#define EVT_COMMAND(id, event, fn) { event, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
-#define EVT_COMMAND_RANGE(id1, id2, event, fn) { eventId, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_COMMAND_RANGE(id1, id2, event, fn) { event, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
// Scrolling
#define EVT_SCROLL(func) \
#define EVT_UPDATE_UI(id, func) \
{ wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL },\
+/*
+ * Helper functions
+ */
+
+// Find a window with the focus, that is also a descendant of the given window.
+// This is used to determine the window to initially send commands to.
+wxWindow* wxFindFocusDescendant(wxWindow* ancestor);
+
#endif
// _WX_EVENTH__