X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d33aec94c9217b94ada107fbd125db4c51c22ab..a315cec9685964e73d833f4c8cf6b38828780899:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index c13191c6f8..2a2f03b2e3 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -224,26 +224,27 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND, 417) DECLARE_EVENT_TYPE(wxEVT_NC_PAINT, 418) DECLARE_EVENT_TYPE(wxEVT_PAINT_ICON, 419) - DECLARE_EVENT_TYPE(wxEVT_MENU_CHAR, 420) - DECLARE_EVENT_TYPE(wxEVT_MENU_INIT, 421) + DECLARE_EVENT_TYPE(wxEVT_MENU_OPEN, 420) + DECLARE_EVENT_TYPE(wxEVT_MENU_CLOSE, 421) DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 422) - DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423) + // DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423) -- free slot DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424) DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425) - DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 426) - DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 427) - DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 428) - DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 429) - DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 430) - DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 431) - DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 432) - DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 433) - DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 434) - DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 435) - DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 436) - DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 437) - DECLARE_EVENT_TYPE(wxEVT_IDLE, 438) - DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 439) + DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426) + DECLARE_EVENT_TYPE(wxEVT_SETTING_CHANGED, 427) + DECLARE_EVENT_TYPE(wxEVT_QUERY_NEW_PALETTE, 428) + DECLARE_EVENT_TYPE(wxEVT_PALETTE_CHANGED, 429) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_DOWN, 430) + DECLARE_EVENT_TYPE(wxEVT_JOY_BUTTON_UP, 431) + DECLARE_EVENT_TYPE(wxEVT_JOY_MOVE, 432) + DECLARE_EVENT_TYPE(wxEVT_JOY_ZMOVE, 433) + DECLARE_EVENT_TYPE(wxEVT_DROP_FILES, 434) + DECLARE_EVENT_TYPE(wxEVT_DRAW_ITEM, 435) + DECLARE_EVENT_TYPE(wxEVT_MEASURE_ITEM, 436) + DECLARE_EVENT_TYPE(wxEVT_COMPARE_ITEM, 437) + DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438) + DECLARE_EVENT_TYPE(wxEVT_IDLE, 439) + DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440) // Generic command events // Note: a click is a higher-level event than button down/up @@ -359,8 +360,10 @@ public: // exists only for optimization purposes. bool IsCommandEvent() const { return m_isCommandEvent; } - // specialized clone function since it is done a lot - virtual wxEvent *Clone() const { return new wxEvent(*this); } + // 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; public: wxObject* m_eventObject; @@ -1045,26 +1048,29 @@ private: // Miscellaneous menu event class /* - wxEVT_MENU_CHAR, - wxEVT_MENU_INIT, + wxEVT_MENU_OPEN, + wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT, - wxEVT_POPUP_MENU_INIT, */ class WXDLLEXPORT wxMenuEvent : public wxEvent { public: wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0) - { m_eventType = type; m_menuId = id; m_id = id; } + : wxEvent(id, type) + { m_menuId = id; } + // only for wxEVT_MENU_HIGHLIGHT int GetMenuId() const { return m_menuId; } + // only for wxEVT_MENU_OPEN/CLOSE + bool IsPopup() const { return m_menuId == -1; } + virtual wxEvent *Clone() const { return new wxMenuEvent(*this); } private: int m_menuId; -private: DECLARE_DYNAMIC_CLASS(wxMenuEvent) }; @@ -1282,18 +1288,35 @@ class WXDLLEXPORT wxDropFilesEvent : public wxEvent public: int m_noFiles; wxPoint m_pos; - wxString* m_files; // Memory (de)allocated by code calling ProcessEvent + wxString* m_files; wxDropFilesEvent(wxEventType type = wxEVT_NULL, int noFiles = 0, wxString *files = (wxString *) NULL) { m_eventType = type; m_noFiles = noFiles; m_files = files; } + // we need a copy ctor to avoid deleting m_files pointer twice + wxDropFilesEvent(const wxDropFilesEvent& other) + : m_pos(other.m_pos) + { + m_noFiles = other.m_noFiles; + m_files = new wxString[m_noFiles]; + for ( int n = 0; n < m_noFiles; n++ ) + { + m_files[n] = other.m_files[n]; + } + } + + virtual ~wxDropFilesEvent() + { + delete [] m_files; + } + wxPoint GetPosition() const { return m_pos; } int GetNumberOfFiles() const { return m_noFiles; } wxString *GetFiles() const { return m_files; } - virtual wxEvent *Clone() const { wxFAIL_MSG("error"); return NULL; } + virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); } private: DECLARE_DYNAMIC_CLASS(wxDropFilesEvent) @@ -1361,6 +1384,21 @@ private: DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent) }; +/* + wxEVT_DISPLAY_CHANGED + */ +class WXDLLEXPORT wxDisplayChangedEvent : public wxEvent +{ +private: + DECLARE_DYNAMIC_CLASS(wxDisplayChangedEvent) + +public: + wxDisplayChangedEvent() + { m_eventType = wxEVT_DISPLAY_CHANGED; } + + virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); } +}; + /* wxEVT_PALETTE_CHANGED */ @@ -1856,8 +1894,8 @@ protected: virtual void DoSetClientData( void *data ); virtual void *DoGetClientData() const; - private: + DECLARE_NO_COPY_CLASS(wxEvtHandler) DECLARE_DYNAMIC_CLASS(wxEvtHandler) }; @@ -1880,6 +1918,7 @@ typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&); typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&); typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&); typedef void (wxEvtHandler::*wxSysColourChangedFunction)(wxSysColourChangedEvent&); +typedef void (wxEvtHandler::*wxDisplayChangedFunction)(wxDisplayChangedEvent&); typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&); typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&); typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&); @@ -1937,6 +1976,8 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); #define EVT_KEY_DOWN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ), #define EVT_KEY_UP(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ), #define EVT_CHAR_HOOK(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHAR_HOOK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, NULL ), +#define EVT_MENU_OPEN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_OPEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ), +#define EVT_MENU_CLOSE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_CLOSE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ), #define EVT_MENU_HIGHLIGHT(id, func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_HIGHLIGHT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ), #define EVT_MENU_HIGHLIGHT_ALL(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_HIGHLIGHT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ), #define EVT_SET_FOCUS(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SET_FOCUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxFocusEventFunction) & func, (wxObject *) NULL ), @@ -1949,6 +1990,7 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); #define EVT_DROP_FILES(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DROP_FILES, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDropFilesEventFunction) & func, (wxObject *) NULL ), #define EVT_INIT_DIALOG(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_INIT_DIALOG, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxInitDialogEventFunction) & func, (wxObject *) NULL ), #define EVT_SYS_COLOUR_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SYS_COLOUR_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSysColourChangedFunction) & func, (wxObject *) NULL ), +#define EVT_DISPLAY_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DISPLAY_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDisplayChangedFunction) & func, (wxObject *) NULL ), #define EVT_SHOW(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SHOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxShowEventFunction) & func, (wxObject *) NULL ), #define EVT_MAXIMIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MAXIMIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMaximizeEventFunction) & func, (wxObject *) NULL ), #define EVT_ICONIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ICONIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIconizeEventFunction) & func, (wxObject *) NULL ),