X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73fb82f3f3c1e722ad874d487c85249f6e866fbf..c330a2cf9369d3ae2bdb3bd67e995517288b353d:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 1c58d1541c..8defe804d3 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -50,6 +50,9 @@ const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED = wxEVT_FIRST + 15; const wxEventType wxEVT_COMMAND_TOOL_RCLICKED = wxEVT_FIRST + 16; const wxEventType wxEVT_COMMAND_TOOL_ENTER = wxEVT_FIRST + 17; +/* Sockets send events, too */ +const wxEventType wxEVT_SOCKET = wxEVT_FIRST + 50; + /* Mouse event types */ const wxEventType wxEVT_LEFT_DOWN = wxEVT_FIRST + 100; const wxEventType wxEVT_LEFT_UP = wxEVT_FIRST + 101; @@ -66,7 +69,7 @@ const wxEventType wxEVT_RIGHT_DCLICK = wxEVT_FIRST + 111; const wxEventType wxEVT_SET_FOCUS = wxEVT_FIRST + 112; const wxEventType wxEVT_KILL_FOCUS = wxEVT_FIRST + 113; - // Non-client mouse events + /* Non-client mouse events */ const wxEventType wxEVT_NC_LEFT_DOWN = wxEVT_FIRST + 200; const wxEventType wxEVT_NC_LEFT_UP = wxEVT_FIRST + 201; const wxEventType wxEVT_NC_MIDDLE_DOWN = wxEVT_FIRST + 202; @@ -82,7 +85,10 @@ const wxEventType wxEVT_NC_RIGHT_DCLICK = wxEVT_FIRST + 211; /* Character input event type */ const wxEventType wxEVT_CHAR = wxEVT_FIRST + 212; -const wxEventType wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 213; +const wxEventType wxEVT_CHAR_HOOK = wxEVT_FIRST + 213; +const wxEventType wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 214; +const wxEventType wxEVT_KEY_DOWN = wxEVT_FIRST + 215; +const wxEventType wxEVT_KEY_UP = wxEVT_FIRST + 216; /* * Scrollbar event identifiers @@ -102,8 +108,6 @@ const wxEventType wxEVT_END_SESSION = wxEVT_FIRST + 403; const wxEventType wxEVT_QUERY_END_SESSION = wxEVT_FIRST + 404; const wxEventType wxEVT_ACTIVATE_APP = wxEVT_FIRST + 405; const wxEventType wxEVT_POWER = wxEVT_FIRST + 406; -const wxEventType wxEVT_CHAR_HOOK = wxEVT_FIRST + 407; -const wxEventType wxEVT_KEY_UP = wxEVT_FIRST + 408; const wxEventType wxEVT_ACTIVATE = wxEVT_FIRST + 409; const wxEventType wxEVT_CREATE = wxEVT_FIRST + 410; const wxEventType wxEVT_DESTROY = wxEVT_FIRST + 411; @@ -139,8 +143,7 @@ const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439; const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440; /* Generic command events */ - // Note: a click is a higher-level event - // than button down/up + /* Note: a click is a higher-level event than button down/up */ const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500; const wxEventType wxEVT_COMMAND_LEFT_DCLICK = wxEVT_FIRST + 501; const wxEventType wxEVT_COMMAND_RIGHT_CLICK = wxEVT_FIRST + 502; @@ -164,6 +167,7 @@ const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610; const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611; 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; /* List control event types */ const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700; @@ -179,14 +183,26 @@ const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709; const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710; const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711; const wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712; +const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713; +const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714; +const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715; /* Tab and notebook control event types */ const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800; const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING = wxEVT_FIRST + 801; + +#if defined(__BORLANDC__) && defined(__WIN16__) +/* For 16-bit BC++, these 2 are identical (truncated) */ +const wxEventType wxEVT_COMMAND_NB_PAGE_CHANGED = wxEVT_FIRST + 802; +const wxEventType wxEVT_COMMAND_NB_PAGE_CHANGING = wxEVT_FIRST + 803; +#else const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxEVT_FIRST + 802; const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxEVT_FIRST + 803; +#endif -// Compatibility +const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; + +/* Compatibility */ #if WXWIN_COMPATIBILITY @@ -294,6 +310,8 @@ public: wxEVT_COMMAND_COMBOBOX_SELECTED */ +class WXDLLEXPORT wxClientData; + class WXDLLEXPORT wxCommandEvent: public wxEvent { DECLARE_DYNAMIC_CLASS(wxCommandEvent) @@ -306,9 +324,13 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent * */ - // Set/Get listbox/choice client data - inline void SetClientData(char* clientData) { m_clientData = clientData; } - inline char *GetClientData() const { return m_clientData; } + // Set/Get client data from controls + inline void SetClientData(void* clientData) { m_clientData = clientData; } + inline void *GetClientData() const { return m_clientData; } + + // Set/Get client object from controls + inline void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; } + inline void *GetClientObject() const { return m_clientObject; } // Get listbox selection if single-choice inline int GetSelection() const { return m_commandInt; } @@ -332,8 +354,29 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent public: char* m_commandString; // String event argument int m_commandInt; - long m_extraLong; // Additional information (e.g. select/deselect) - char* m_clientData; // Arbitrary client data + long m_extraLong; // Additional information (e.g. select/deselect) + void* m_clientData; // Arbitrary client data + wxClientData* m_clientObject; // Arbitrary client object +}; + +// this class adds a possibility to react (from the user) code to a control +// notification: allow or veto the operation being reported. +class WXDLLEXPORT wxNotifyEvent : public wxCommandEvent +{ +public: + wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int id = 0) + : wxCommandEvent(commandType, id) { m_bAllow = TRUE; } + + // veto the operation (by default it's allowed) + void Veto() { m_bAllow = FALSE; } + + // for implementation code only: is the operation allowed? + bool IsAllowed() const { return m_bAllow; } + +private: + bool m_bAllow; + + DECLARE_DYNAMIC_CLASS(wxNotifyEvent) }; // Scroll event class @@ -447,7 +490,7 @@ class WXDLLEXPORT wxMouseEvent: public wxEvent inline bool RightIsDown(void) const { return m_rightDown; } // True if a button is down and the mouse is moving - inline bool Dragging(void) const { return ((m_eventType == wxEVENT_TYPE_MOTION) && (LeftIsDown() || MiddleIsDown() || RightIsDown())); } + inline bool Dragging(void) const { return ((m_eventType == wxEVT_MOTION) && (LeftIsDown() || MiddleIsDown() || RightIsDown())); } // True if the mouse is moving, and no button is down inline bool Moving(void) const { return (m_eventType == wxEVT_MOTION); } @@ -495,6 +538,7 @@ public: /* wxEVT_CHAR wxEVT_CHAR_HOOK + wxEVT_KEY_DOWN wxEVT_KEY_UP */ @@ -678,22 +722,27 @@ class WXDLLEXPORT wxCloseEvent: public wxEvent public: inline wxCloseEvent(wxEventType type = wxEVT_NULL, int id = 0) - { m_eventType = type; m_sessionEnding = TRUE; m_loggingOff = TRUE; m_veto = FALSE; - m_id = id; m_force = FALSE; } + { m_eventType = type; m_loggingOff = TRUE; m_veto = FALSE; + m_id = id; m_force = FALSE; m_canVeto = FALSE; } - inline bool GetSessionEnding(void) const { return m_sessionEnding; } + inline void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } inline bool GetLoggingOff(void) const { return m_loggingOff; } inline void Veto(bool veto = TRUE) { m_veto = veto; } + inline void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } + inline bool CanVeto() const { return m_canVeto; } inline bool GetVeto(void) const { return m_veto; } + + // This is probably obsolete now, since we use CanVeto instead, in + // both OnCloseWindow and OnQueryEndSession. + // m_force == ! m_canVeto i.e., can't veto means we must force it to close. inline void SetForce(bool force) { m_force = force; } inline bool GetForce(void) const { return m_force; } protected: - bool m_sessionEnding; bool m_loggingOff; bool m_veto; bool m_force; - + bool m_canVeto; }; /* @@ -972,7 +1021,7 @@ public: // the child which has the focus currently (may be NULL - use // wxWindow::FindFocus then) wxWindow* GetCurrentFocus() const { return (wxWindow *)m_clientData; } - void SetCurrentFocus(wxWindow *win) { m_clientData = (char *)win; } + void SetCurrentFocus(wxWindow *win) { m_clientData = (void *)win; } }; /* TODO @@ -1035,16 +1084,18 @@ class WXDLLEXPORT wxEvtHandler: public wxObject virtual bool OnClose(void); - inline char *GetClientData(void) const { return m_clientData; } - inline void SetClientData(char *clientData) { m_clientData = clientData; } - virtual bool ProcessEvent(wxEvent& event); virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); - - void Connect( int id, int lastId, - int eventType, + + // Dynamic association of a member function handler with the event handler, id and event type + void Connect( int id, int lastId, wxEventType eventType, wxObjectEventFunction func, wxObject *userData = (wxObject *) NULL ); + + // Convenience function: take just one id + inline void Connect( int id, wxEventType eventType, + wxObjectEventFunction func, + wxObject *userData = (wxObject *) NULL ) { Connect(id, -1, eventType, func, userData); } bool SearchDynamicEventTable( wxEvent& event ); @@ -1056,7 +1107,6 @@ protected: protected: wxEvtHandler* m_nextHandler; wxEvtHandler* m_previousHandler; - char* m_clientData; // Any user client data bool m_enabled; // Is event handler enabled? wxList* m_dynamicEvents; @@ -1105,7 +1155,7 @@ const wxEventTable theClass::sm_eventTable =\ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ #define END_EVENT_TABLE() \ - { 0, 0, 0, 0 } }; + { 0, 0, 0, 0, 0 } }; /* * Event table macros @@ -1119,9 +1169,13 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ #define EVT_SIZE(func) { wxEVT_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) & func, (wxObject *) NULL }, #define EVT_MOVE(func) { wxEVT_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMoveEventFunction) & func, (wxObject *) NULL }, #define EVT_CLOSE(func) { wxEVT_CLOSE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL }, +#define EVT_END_SESSION(func) { wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL }, +#define EVT_QUERY_END_SESSION(func) { wxEVT_QUERY_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL }, #define EVT_PAINT(func) { wxEVT_PAINT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaintEventFunction) & func, (wxObject *) NULL }, #define EVT_ERASE_BACKGROUND(func) { wxEVT_ERASE_BACKGROUND, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxEraseEventFunction) & func, (wxObject *) NULL }, #define EVT_CHAR(func) { wxEVT_CHAR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL }, +#define EVT_KEY_DOWN(func) { wxEVT_KEY_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL }, +#define EVT_KEY_UP(func) { wxEVT_KEY_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL }, #define EVT_CHAR_HOOK(func) { wxEVT_CHAR_HOOK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, NULL }, #define EVT_MENU_HIGHLIGHT(id, func) { wxEVT_MENU_HIGHLIGHT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL }, #define EVT_MENU_HIGHLIGHT_ALL(func) { wxEVT_MENU_HIGHLIGHT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL }, @@ -1172,7 +1226,7 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ // EVT_COMMAND #define EVT_COMMAND(id, cmd, fn) { cmd, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, -#define EVT_COMMAND_RANGE(id1, id2, cmd, fn) { cmd, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, N(wxObject *) ULL }, +#define EVT_COMMAND_RANGE(id1, id2, cmd, fn) { cmd, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, // Scrolling #define EVT_SCROLL(func) \