#include "wx/gdicmn.h"
#endif
-#if wxUSE_THREADS
- #include "wx/thread.h"
-#endif
+#include "wx/thread.h"
// ----------------------------------------------------------------------------
// forward declarations
class WXDLLEXPORT wxClientData;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxMenu;
+ class WXDLLEXPORT wxWindow;
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612;
const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613;
const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614;
+const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxEVT_FIRST + 615;
+const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 616;
/* List control event types */
const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700;
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; }
+ void GetPosition(wxCoord *xpos, wxCoord *ypos) const
+ {
+ if (xpos)
+ *xpos = m_x;
+ if (ypos)
+ *ypos = m_y;
+ }
+
+#ifndef __WIN16__
+ void GetPosition(long *xpos, long *ypos) const
+ {
+ if (xpos)
+ *xpos = (long)m_x;
+ if (ypos)
+ *ypos = (long)m_y;
+ }
+#endif
// Find the position of the event
wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
// Compatibility
#if WXWIN_COMPATIBILITY
+ void Position(long *xpos, long *ypos) const
+ {
+ if (xpos)
+ *xpos = (long)m_x;
+ if (ypos)
+ *ypos = (long)m_y;
+ }
+
void Position(float *xpos, float *ypos) const
{
*xpos = (float) m_x; *ypos = (float) m_y;
void CopyObject(wxObject& obj) const;
public:
- long m_x;
- long m_y;
+ wxCoord m_x, m_y;
+
bool m_leftDown;
bool m_middleDown;
bool m_rightDown;
long KeyCode() const { return m_keyCode; }
// Find the position of the event
+ void GetPosition(wxCoord *xpos, wxCoord *ypos) const
+ {
+ if (xpos) *xpos = m_x;
+ if (ypos) *ypos = m_y;
+ }
+
+#ifndef __WIN16__
void GetPosition(long *xpos, long *ypos) const
- { *xpos = m_x; *ypos = m_y; }
+ {
+ if (xpos) *xpos = (long)m_x;
+ if (ypos) *ypos = (long)m_y;
+ }
+#endif
wxPoint GetPosition() const
{ return wxPoint(m_x, m_y); }
// Get X position
- long GetX() const { return m_x; }
+ wxCoord GetX() const { return m_x; }
// Get Y position
- long GetY() const { return m_y; }
+ wxCoord GetY() const { return m_y; }
void CopyObject(wxObject& obj) const;
public:
- long m_x;
- long m_y;
+ wxCoord m_x, m_y;
+
long m_keyCode;
+
bool m_controlDown;
bool m_shiftDown;
bool m_altDown;
{
// GetVeto() will return FALSE anyhow...
wxCHECK_RET( m_canVeto,
- T("call to Veto() ignored (can't veto this event)") );
+ wxT("call to Veto() ignored (can't veto this event)") );
m_veto = veto;
}
wxEVT_COMPARE_ITEM
*/
+// ============================================================================
+// event handler and related classes
+// ============================================================================
+
typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
struct WXDLLEXPORT wxEventTableEntry
void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
- void SetEvtHandlerEnabled(bool en) { m_enabled = en; }
+ void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
bool GetEvtHandlerEnabled() const { return m_enabled; }
-#if WXWIN_COMPATIBILITY_2
- virtual void OnCommand(wxWindow& WXUNUSED(win),
- wxCommandEvent& WXUNUSED(event))
- {
- wxFAIL_MSG(T("shouldn't be called any more"));
- }
+ // process an event right now
+ virtual bool ProcessEvent(wxEvent& event);
- // Called if child control has no callback function
- virtual long Default()
- { return GetNextHandler() ? GetNextHandler()->Default() : 0; };
-#endif // WXWIN_COMPATIBILITY_2
+ // add an event to be processed later
+ void AddPendingEvent(wxEvent& event);
-#if WXWIN_COMPATIBILITY
- virtual bool OnClose();
-#endif
+ // process all pending events
+ void ProcessPendingEvents();
+ // add a
#if wxUSE_THREADS
bool ProcessThreadEvent(wxEvent& event);
- void ProcessPendingEvents();
#endif
- virtual bool ProcessEvent(wxEvent& event);
- virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
// Dynamic association of a member function handler with the event handler,
// id and event type
wxObject *userData = (wxObject *) NULL )
{ Connect(id, -1, eventType, func, userData); }
+ // implementation from now on
+ virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
#if wxUSE_THREADS
void ClearEventLocker() { delete m_eventsLocker; m_eventsLocker = NULL; };
#endif
+ // old stuff
+
+#if WXWIN_COMPATIBILITY_2
+ virtual void OnCommand(wxWindow& WXUNUSED(win),
+ wxCommandEvent& WXUNUSED(event))
+ {
+ wxFAIL_MSG(wxT("shouldn't be called any more"));
+ }
+
+ // Called if child control has no callback function
+ virtual long Default()
+ { return GetNextHandler() ? GetNextHandler()->Default() : 0; };
+#endif // WXWIN_COMPATIBILITY_2
+
+#if WXWIN_COMPATIBILITY
+ virtual bool OnClose();
+#endif
+
private:
- static const wxEventTableEntry sm_eventTableEntries[];
+ static const wxEventTableEntry sm_eventTableEntries[];
protected:
static const wxEventTable sm_eventTable;
protected:
wxEvtHandler* m_nextHandler;
wxEvtHandler* m_previousHandler;
- bool m_enabled; // Is event handler enabled?
wxList* m_dynamicEvents;
wxList* m_pendingEvents;
#if wxUSE_THREADS
// 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;
+
+ // Is event handler enabled?
+ bool m_enabled;
};
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
#define EVT_UPDATE_UI(id, func) \
{ wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL },\
+// ----------------------------------------------------------------------------
+// Global data
+// ----------------------------------------------------------------------------
+
+// for pending event processing - notice that there is intentionally no
+// WXDLLEXPORT here
+extern wxList *wxPendingEvents;
+#if wxUSE_THREADS
+ extern wxCriticalSection *wxPendingEventsLocker;
+#endif
+
// ----------------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------------