X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e6feb95a79834836e88143b15d9f424ebe79621..d2a533a059cb69c68ce3930556d802db0089d577:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index a327e06d6e..aa9a3b1425 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -18,6 +18,7 @@ #include "wx/defs.h" #include "wx/object.h" +#include "wx/clntdata.h" #if wxUSE_GUI #include "wx/gdicmn.h" @@ -33,7 +34,6 @@ class WXDLLEXPORT wxList; #if wxUSE_GUI - class WXDLLEXPORT wxClientData; class WXDLLEXPORT wxDC; class WXDLLEXPORT wxMenu; class WXDLLEXPORT wxWindow; @@ -104,7 +104,7 @@ BEGIN_DECLARE_EVENT_TYPES() #else // !WXWIN_COMPATIBILITY_EVENT_TYPES // it is important to still have these as constants to avoid // initialization order related problems - DECLARE_EVENT_TYPE(wxEVT_NULL,0); + DECLARE_EVENT_TYPE(wxEVT_NULL,0); const wxEventType wxEVT_FIRST = 10000; const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES @@ -115,8 +115,13 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_SELECTED, 4) DECLARE_EVENT_TYPE(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 5) DECLARE_EVENT_TYPE(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 6) + // now they are in wx/textctrl.h +#if WXWIN_COMPATIBILITY_EVENT_TYPES DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7) DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14) +#endif // WXWIN_COMPATIBILITY_EVENT_TYPES DECLARE_EVENT_TYPE(wxEVT_COMMAND_MENU_SELECTED, 9) DECLARE_EVENT_TYPE(wxEVT_COMMAND_SLIDER_UPDATED, 10) DECLARE_EVENT_TYPE(wxEVT_COMMAND_RADIOBOX_SELECTED, 11) @@ -151,7 +156,8 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_RIGHT_DCLICK, 111) DECLARE_EVENT_TYPE(wxEVT_SET_FOCUS, 112) DECLARE_EVENT_TYPE(wxEVT_KILL_FOCUS, 113) - DECLARE_EVENT_TYPE(wxEVT_MOUSEWHEEL, 114) + DECLARE_EVENT_TYPE(wxEVT_CHILD_FOCUS, 114) + DECLARE_EVENT_TYPE(wxEVT_MOUSEWHEEL, 115) // Non-client mouse events DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN, 200) @@ -256,7 +262,17 @@ END_DECLARE_EVENT_TYPES() // these 2 events are the same #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_COMMAND_MENU_SELECTED +// ---------------------------------------------------------------------------- // Compatibility +// ---------------------------------------------------------------------------- + +// this event is also used by wxComboBox and wxSpinCtrl which don't include +// wx/textctrl.h in all ports [yet], so declare it here as well +// +// still, any new code using it should include wx/textctrl.h explicitly +#if !WXWIN_COMPATIBILITY_EVENT_TYPES + extern const wxEventType WXDLLEXPORT wxEVT_COMMAND_TEXT_UPDATED; +#endif #if WXWIN_COMPATIBILITY @@ -419,7 +435,7 @@ public: void CopyObject(wxObject& obj) const; -#ifdef WXWIN_COMPATIBILITY_2 +#if WXWIN_COMPATIBILITY_2 bool Checked() const { return IsChecked(); } #endif // WXWIN_COMPATIBILITY_2 @@ -764,7 +780,10 @@ public: bool AltDown() const { return m_altDown; } bool ShiftDown() const { return m_shiftDown; } - bool HasModifiers() const { return ControlDown() || AltDown() || MetaDown(); } + // exclude MetaDown() from HasModifiers() because NumLock under X is often + // configured as mod2 modifier, yet the key events even when it is pressed + // should be processed normally, not like Ctrl- or Alt-key + bool HasModifiers() const { return ControlDown() || AltDown(); } // get the key code: an ASCII7 char or an element of wxKeyCode enum int GetKeyCode() const { return (int)m_keyCode; } @@ -945,6 +964,18 @@ private: DECLARE_DYNAMIC_CLASS(wxFocusEvent) }; +// wxChildFocusEvent notifies the parent that a child has got the focus: unlike +// wxFocusEvent it is propgated upwards the window chain +class WXDLLEXPORT wxChildFocusEvent : public wxCommandEvent +{ +public: + wxChildFocusEvent(wxWindow *win = NULL); + + wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); } + + DECLARE_DYNAMIC_CLASS(wxChildFocusEvent) +}; + // Activate event class /* wxEVT_ACTIVATE @@ -1485,8 +1516,6 @@ private: DECLARE_DYNAMIC_CLASS(wxContextMenuEvent) }; -#endif // wxUSE_GUI - // Idle event /* wxEVT_IDLE @@ -1509,6 +1538,8 @@ protected: bool m_requestMore; }; +#endif // wxUSE_GUI + /* TODO wxEVT_POWER, wxEVT_MOUSE_CAPTURE_CHANGED, @@ -1520,6 +1551,7 @@ protected: wxEVT_COMPARE_ITEM */ + // ============================================================================ // event handler and related classes // ============================================================================ @@ -1619,7 +1651,7 @@ struct WXDLLEXPORT wxEventTable // wxEvtHandler: the base class for all objects handling wxWindows events // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxEvtHandler : public wxObject +class WXDLLEXPORT wxEvtHandler : public wxObject, public wxClientDataContainer { public: wxEvtHandler(); @@ -1745,6 +1777,7 @@ typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&); typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&); typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&); typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&); +typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&); typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&); typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&); typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&); @@ -1812,6 +1845,7 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); #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 ), #define EVT_KILL_FOCUS(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KILL_FOCUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxFocusEventFunction) & func, (wxObject *) NULL ), +#define EVT_CHILD_FOCUS(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHILD_FOCUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxChildFocusEventFunction) & func, (wxObject *) NULL ), #define EVT_ACTIVATE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ACTIVATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxActivateEventFunction) & func, (wxObject *) NULL ), #define EVT_ACTIVATE_APP(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ACTIVATE_APP, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxActivateEventFunction) & func, (wxObject *) NULL ), #define EVT_END_SESSION(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_END_SESSION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ), @@ -1930,8 +1964,6 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); #define EVT_CHOICE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_CHOICE_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), #define EVT_LISTBOX(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LISTBOX_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), #define EVT_LISTBOX_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), -#define EVT_TEXT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), -#define EVT_TEXT_ENTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), #define EVT_MENU(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_MENU_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), #define EVT_MENU_RANGE(id1, id2, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_MENU_SELECTED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), #define EVT_SLIDER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_SLIDER_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),