X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/669f7a111f10417afb0b7ad3ead11bab301b20bb..7b30ac82dd01b5ca4fd1db2f2889b7714ad1577c:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 9d047f12cb..e349b45b8d 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: event.h +// Name: wx/event.h // Purpose: Event classes // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) +// Copyright: (c) wxWindows team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -283,7 +283,7 @@ enum wxEVT_PLOT_AREA_SEL_CREATED = wxEVT_FIRST + 1015, wxEVT_PLOT_AREA_SEL_CHANGING = wxEVT_FIRST + 1016, wxEVT_PLOT_AREA_SEL_CHANGED = wxEVT_FIRST + 1017, - wxEVT_PLOT_BEGIN_X_LABEL_EDIT = wxEVT_FIRST + 1020, + wxEVT_PLOT_BEGIN_X_LABEL_EDIT = wxEVT_FIRST + 1020, wxEVT_PLOT_END_X_LABEL_EDIT = wxEVT_FIRST + 1021, wxEVT_PLOT_BEGIN_Y_LABEL_EDIT = wxEVT_FIRST + 1022, wxEVT_PLOT_END_Y_LABEL_EDIT = wxEVT_FIRST + 1023, @@ -291,6 +291,10 @@ enum wxEVT_PLOT_END_TITLE_EDIT = wxEVT_FIRST + 1025, wxEVT_PLOT_AREA_CREATE = wxEVT_FIRST + 1026, + /* Help events */ + wxEVT_HELP = wxEVT_FIRST + 1050, + wxEVT_DETAILED_HELP, + wxEVT_USER_FIRST = wxEVT_FIRST + 2000 }; @@ -443,7 +447,7 @@ public: wxString GetString() const { return m_commandString; } // Get checkbox value - bool Checked() const { return (m_commandInt != 0); } + bool IsChecked() const { return m_commandInt != 0; } // TRUE if the listbox event was a selection. bool IsSelection() const { return (m_extraLong != 0); } @@ -456,6 +460,10 @@ public: void CopyObject(wxObject& obj) const; +#ifdef WXWIN_COMPATIBILITY_2 + bool Checked() const { return IsChecked(); } +#endif // WXWIN_COMPATIBILITY_2 + public: wxString m_commandString; // String event argument int m_commandInt; @@ -768,7 +776,11 @@ public: bool MetaDown() const { return m_metaDown; } bool AltDown() const { return m_altDown; } bool ShiftDown() const { return m_shiftDown; } - long KeyCode() const { return m_keyCode; } + + bool HasModifiers() const { return ControlDown() || AltDown() || MetaDown(); } + + // get the key code: an ASCII7 char or an element of wxKeyCode enum + int GetKeyCode() const { return (int)m_keyCode; } // Find the position of the event void GetPosition(wxCoord *xpos, wxCoord *ypos) const @@ -796,6 +808,9 @@ public: void CopyObject(wxObject& obj) const; + // deprecated + long KeyCode() const { return m_keyCode; } + public: wxCoord m_x, m_y; @@ -860,9 +875,9 @@ public: wxEVT_PAINT_ICON */ -#if defined(__WXDEBUG__) && defined(__WXMSW__) - // see comments in src/msw/dcclient.cpp where g_isPainting is defined - extern int g_isPainting; +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) + // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined + extern WXDLLEXPORT int g_isPainting; #endif // debug class WXDLLEXPORT wxPaintEvent : public wxEvent @@ -875,13 +890,13 @@ public: m_eventType = wxEVT_PAINT; m_id = Id; -#if defined(__WXDEBUG__) && defined(__WXMSW__) +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) // set the internal flag for the duration of processing of WM_PAINT g_isPainting++; #endif // debug } -#if defined(__WXDEBUG__) && defined(__WXMSW__) +#if defined(__WXDEBUG__) && (defined(__WXMSW__) || defined(__WXPM__)) ~wxPaintEvent() { g_isPainting--; @@ -1369,7 +1384,7 @@ private: wxEVT_DESTROY */ -class WXDLLEXPORT wxWindowCreateEvent : public wxEvent +class WXDLLEXPORT wxWindowCreateEvent : public wxCommandEvent { DECLARE_DYNAMIC_CLASS(wxWindowCreateEvent) @@ -1379,7 +1394,7 @@ public: wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } }; -class WXDLLEXPORT wxWindowDestroyEvent : public wxEvent +class WXDLLEXPORT wxWindowDestroyEvent : public wxCommandEvent { DECLARE_DYNAMIC_CLASS(wxWindowDestroyEvent) @@ -1389,6 +1404,45 @@ public: wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } }; +// A help event is sent when the user clicks on a window in context-help mode. +/* + wxEVT_HELP + wxEVT_DETAILED_HELP +*/ + +class WXDLLEXPORT wxHelpEvent : public wxCommandEvent +{ +public: + wxHelpEvent(wxEventType type = wxEVT_NULL, + wxWindowID id = 0, + const wxPoint& pt = wxDefaultPosition) + { + m_eventType = type; + m_id = id; + m_pos = pt; + } + + // Position of event (in screen coordinates) + const wxPoint& GetPosition() const { return m_pos; } + void SetPosition(const wxPoint& pos) { m_pos = pos; } + + // Optional link to further help + const wxString& GetLink() const { return m_link; } + void SetLink(const wxString& link) { m_link = link; } + + // Optional target to display help in. E.g. a window specification + const wxString& GetTarget() const { return m_target; } + void SetTarget(const wxString& target) { m_target = target; } + +protected: + wxPoint m_pos; + wxString m_target; + wxString m_link; + +private: + DECLARE_DYNAMIC_CLASS(wxHelpEvent) +}; + #endif // wxUSE_GUI // Idle event @@ -1499,7 +1553,7 @@ public: wxObjectEventFunction func = NULL, wxObject *userData = (wxObject *) NULL ) { return Disconnect(id, -1, eventType, func, userData); } - + // implementation from now on virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); bool SearchDynamicEventTable( wxEvent& event ); @@ -1592,6 +1646,7 @@ typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&); typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&); typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&); typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&); +typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&); #endif // wxUSE_GUI // N.B. In GNU-WIN32, you *have* to take the address of a member function @@ -1795,15 +1850,30 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ { wxEVT_JOY_BUTTON_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL },\ { wxEVT_JOY_BUTTON_UP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL },\ { wxEVT_JOY_MOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL },\ - { wxEVT_JOY_ZMOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_JOY_ZMOVE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxJoystickEventFunction) & func, (wxObject *) NULL }, // Idle event #define EVT_IDLE(func) \ - { wxEVT_IDLE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIdleEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_IDLE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxIdleEventFunction) & func, (wxObject *) NULL }, // Update UI event #define EVT_UPDATE_UI(id, func) \ - { wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL },\ + { wxEVT_UPDATE_UI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxUpdateUIEventFunction) & func, (wxObject *) NULL }, +#define EVT_UPDATE_UI_RANGE(id1, id2, func) \ + { wxEVT_UPDATE_UI, id1, id2, (wxObjectEventFunction)(wxEventFunction)(wxUpdateUIEventFunction)&func, (wxObject *) NULL }, + +// Help events +#define EVT_HELP(id, func) \ + { wxEVT_HELP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL }, + +#define EVT_HELP_RANGE(id1, id2, func) \ + { wxEVT_HELP, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL }, + +#define EVT_DETAILED_HELP(id, func) \ + { wxEVT_DETAILED_HELP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL }, + +#define EVT_DETAILED_HELP_RANGE(id1, id2, func) \ + { wxEVT_DETAILED_HELP, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxHelpEventFunction) & func, (wxObject *) NULL }, // ---------------------------------------------------------------------------- // Global data