X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fbfb8bcc3fa17e079d4219655b173f8ed2ccc65a..7d01c54d7f264b14e75d67b0b590271b138be7ab:/include/wx/event.h?ds=sidebyside diff --git a/include/wx/event.h b/include/wx/event.h index 7d6f0a0076..909ffbc405 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -211,9 +211,7 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_SCROLL_PAGEDOWN, 305) DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBTRACK, 306) DECLARE_EVENT_TYPE(wxEVT_SCROLL_THUMBRELEASE, 307) -#if wxABI_VERSION >= 20601 DECLARE_EVENT_TYPE(wxEVT_SCROLL_CHANGED, 308) -#endif // Scroll events from wxWindow DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP, 320) @@ -506,14 +504,6 @@ private: }; #endif -#ifdef __VISUALC__ - // 'this' : used in base member initializer list (for m_commandString) - #if _MSC_VER > 1100 - #pragma warning(push) - #endif - #pragma warning(disable:4355) -#endif - class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent { public: @@ -556,7 +546,7 @@ public: long GetExtraLong() const { return m_extraLong; } void SetInt(int i) { m_commandInt = i; } - long GetInt() const { return m_commandInt; } + int GetInt() const { return m_commandInt; } virtual wxEvent *Clone() const { return new wxCommandEvent(*this); } @@ -576,10 +566,6 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) }; -#if defined(__VISUALC__) && (_MSC_VER > 1100) - #pragma warning(pop) -#endif - #if WXWIN_COMPATIBILITY_2_4 inline void wxCommandEventStringHelper::operator=(const wxString &str) { @@ -949,11 +935,22 @@ public: wxKeyEvent(wxEventType keyType = wxEVT_NULL); wxKeyEvent(const wxKeyEvent& evt); + // can be used check if the key event has exactly the given modifiers: + // "GetModifiers() = wxMOD_CONTROL" is easier to write than "ControlDown() + // && !MetaDown() && !AltDown() && !ShiftDown()" + int GetModifiers() const + { + return (m_controlDown ? wxMOD_CONTROL : 0) | + (m_shiftDown ? wxMOD_SHIFT : 0) | + (m_metaDown ? wxMOD_META : 0) | + (m_altDown ? wxMOD_ALT : 0); + } + // Find state of shift/control keys bool ControlDown() const { return m_controlDown; } + bool ShiftDown() const { return m_shiftDown; } bool MetaDown() const { return m_metaDown; } bool AltDown() const { return m_altDown; } - bool ShiftDown() const { return m_shiftDown; } // "Cmd" is a pseudo key which is Control for PC and Unix platforms but // Apple ("Command") key under Macs: it makes often sense to use it instead @@ -1010,8 +1007,10 @@ public: // Get Y position wxCoord GetY() const { return m_y; } +#if WXWIN_COMPATIBILITY_2_6 // deprecated, Use GetKeyCode instead. wxDEPRECATED( long KeyCode() const ); +#endif // WXWIN_COMPATIBILITY_2_6 virtual wxEvent *Clone() const { return new wxKeyEvent(*this); } @@ -1043,10 +1042,13 @@ public: long m_keyCode; + // TODO: replace those with a single m_modifiers bitmask of wxMOD_XXX? bool m_controlDown; bool m_shiftDown; bool m_altDown; bool m_metaDown; + + // FIXME: what is this for? relation to m_rawXXX? bool m_scanCode; #if wxUSE_UNICODE @@ -1667,7 +1669,9 @@ public: { m_checked = m_enabled = + m_shown = m_setEnabled = + m_setShown = m_setText = m_setChecked = false; } @@ -1675,7 +1679,9 @@ public: : wxCommandEvent(event), m_checked(event.m_checked), m_enabled(event.m_enabled), + m_shown(event.m_shown), m_setEnabled(event.m_setEnabled), + m_setShown(event.m_setShown), m_setText(event.m_setText), m_setChecked(event.m_setChecked), m_text(event.m_text) @@ -1683,13 +1689,16 @@ public: bool GetChecked() const { return m_checked; } bool GetEnabled() const { return m_enabled; } + bool GetShown() const { return m_shown; } wxString GetText() const { return m_text; } bool GetSetText() const { return m_setText; } bool GetSetChecked() const { return m_setChecked; } bool GetSetEnabled() const { return m_setEnabled; } + bool GetSetShown() const { return m_setShown; } void Check(bool check) { m_checked = check; m_setChecked = true; } void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; } + void Show(bool show) { m_shown = show; m_setShown = true; } void SetText(const wxString& text) { m_text = text; m_setText = true; } // Sets the interval between updates in milliseconds. @@ -1719,7 +1728,9 @@ public: protected: bool m_checked; bool m_enabled; + bool m_shown; bool m_setEnabled; + bool m_setShown; bool m_setText; bool m_setChecked; wxString m_text; @@ -2629,6 +2640,111 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC { return theClass::sm_eventHashTable; } \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ +#define BEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + +#define BEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ + template \ + const wxEventTable theClass::sm_eventTable = \ + { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ + template \ + const wxEventTable *theClass::GetEventTable() const \ + { return &theClass::sm_eventTable; } \ + template \ + wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \ + template \ + wxEventHashTable &theClass::GetEventHashTable() const \ + { return theClass::sm_eventHashTable; } \ + template \ + const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ + #define END_EVENT_TABLE() DECLARE_EVENT_TABLE_ENTRY( wxEVT_NULL, 0, 0, 0, 0 ) }; /* @@ -2772,12 +2888,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func)) #define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func)) #define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func)) -#if wxABI_VERSION >= 20601 #define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func)) -#define wx__EVT_SCROLL_CHANGED(func) EVT_SCROLL_CHANGED(func) -#else -#define wx__EVT_SCROLL_CHANGED(func) -#endif #define EVT_SCROLL(func) \ EVT_SCROLL_TOP(func) \ @@ -2788,7 +2899,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC EVT_SCROLL_PAGEDOWN(func) \ EVT_SCROLL_THUMBTRACK(func) \ EVT_SCROLL_THUMBRELEASE(func) \ - wx__EVT_SCROLL_CHANGED(func) + EVT_SCROLL_CHANGED(func) // Scrolling from wxSlider and wxScrollBar, with an id #define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func)) @@ -2799,12 +2910,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func)) #define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func)) #define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func)) -#if wxABI_VERSION >= 20601 #define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func)) -#define wx__EVT_COMMAND_SCROLL_CHANGED(winid, func) EVT_COMMAND_SCROLL_CHANGED(winid, func) -#else -#define wx__EVT_COMMAND_SCROLL_CHANGED(winid, func) -#endif #define EVT_COMMAND_SCROLL(winid, func) \ EVT_COMMAND_SCROLL_TOP(winid, func) \ @@ -2815,20 +2921,14 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \ EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \ EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \ - wx__EVT_COMMAND_SCROLL_CHANGED(winid, func) + EVT_COMMAND_SCROLL_CHANGED(winid, func) -// compatibility macros for the old name, to be deprecated in 2.8 -// -// note that simply #defines suffice for the macro names as they're only -// present in the source code and macros are enough to maintain source -// backwards compatibility, but that we have to ensure that we also have -// wxEVT_SCROLL_ENDSCROLL inside the library for binary backwards compatibility -// and this is done in event.cpp -#if wxABI_VERSION >= 20601 -#define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED -#define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED -#define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED -#endif +#if WXWIN_COMPATIBILITY_2_6 + // compatibility macros for the old name, deprecated in 2.8 + #define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED + #define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED + #define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED +#endif // WXWIN_COMPATIBILITY_2_6 // Convenience macros for commonly-used commands #define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_CHECKBOX_CLICKED, winid, wxCommandEventHandler(func)) @@ -2921,9 +3021,8 @@ extern WXDLLIMPEXP_BASE wxList *wxPendingEvents; // Find a window with the focus, that is also a descendant of the given window. // This is used to determine the window to initially send commands to. -wxWindow* wxFindFocusDescendant(wxWindow* ancestor); +WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor); #endif // wxUSE_GUI #endif // _WX_EVENT_H__ -