X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e554d626b7d4164b1cca6a206e11ce376475f01c..2aebd278e374af02a3761201e2187a91d3f92832:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index d2515fc74d..4fc87804d0 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -12,18 +12,8 @@ #ifndef _WX_EVENT_H__ #define _WX_EVENT_H__ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__) -// Some older compilers (such as EMX) cannot handle -// #pragma interface/implementation correctly, iff -// #pragma implementation is used in _two_ translation -// units (as created by e.g. event.cpp compiled for -// libwx_base and event.cpp compiled for libwx_gui_core). -// So we must not use those pragmas for those compilers in -// such files. - #pragma interface "event.h" -#endif - #include "wx/defs.h" +#include "wx/cpp.h" #include "wx/object.h" #include "wx/clntdata.h" @@ -40,21 +30,25 @@ // forward declarations // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxList; +class WXDLLIMPEXP_FWD_BASE wxList; #if wxUSE_GUI - class WXDLLIMPEXP_CORE wxDC; - class WXDLLIMPEXP_CORE wxMenu; - class WXDLLIMPEXP_CORE wxWindow; - class WXDLLIMPEXP_CORE wxWindowBase; + class WXDLLIMPEXP_FWD_CORE wxDC; + class WXDLLIMPEXP_FWD_CORE wxMenu; + class WXDLLIMPEXP_FWD_CORE wxWindow; + class WXDLLIMPEXP_FWD_CORE wxWindowBase; #endif // wxUSE_GUI +class WXDLLIMPEXP_FWD_BASE wxEvtHandler; + // ---------------------------------------------------------------------------- // Event types // ---------------------------------------------------------------------------- typedef int wxEventType; +#define wxEVT_ANY ((wxEventType)-1) + // this is used to make the event table entry type safe, so that for an event // handler only a function with proper parameter list can be given. #define wxStaticCastEvent(type, val) wx_static_cast(type, val) @@ -76,9 +70,12 @@ typedef int wxEventType; // change the switch()es to if()s // // if these are real problems for you, define WXWIN_COMPATIBILITY_EVENT_TYPES -// to get 100% old behaviour, however you won't be able to use the libraries -// using the new dynamic event type allocation in such case, so avoid it if -// possible. +// as 1 to get 100% old behaviour, however you won't be able to use the +// libraries using the new dynamic event type allocation in such case, so avoid +// it if possible. +#ifndef WXWIN_COMPATIBILITY_EVENT_TYPES + #define WXWIN_COMPATIBILITY_EVENT_TYPES 0 +#endif #if WXWIN_COMPATIBILITY_EVENT_TYPES @@ -100,8 +97,6 @@ typedef int wxEventType; #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ wxEventTableEntry(type, winid, idLast, fn, obj) -#define EMPTY_PARAMETER_VALUE /* Fake macro parameter value */ - #define BEGIN_DECLARE_EVENT_TYPES() #define END_DECLARE_EVENT_TYPES() #define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ @@ -109,7 +104,7 @@ typedef int wxEventType; #define DECLARE_EVENT_TYPE(name, value) \ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) #define DECLARE_LOCAL_EVENT_TYPE(name, value) \ - DECLARE_EXPORTED_EVENT_TYPE(EMPTY_PARAMETER_VALUE, name, value) + DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); #define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) @@ -160,9 +155,12 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_ENTER, 17) DECLARE_EVENT_TYPE(wxEVT_COMMAND_SPINCTRL_UPDATED, 18) + // Toolbar dropdown arrows + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, 19) + // Sockets and timers send events, too DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_SOCKET, 50) - DECLARE_EVENT_TYPE(wxEVT_TIMER , 80) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE, wxEVT_TIMER , 80) // Mouse event types DECLARE_EVENT_TYPE(wxEVT_LEFT_DOWN, 100) @@ -181,6 +179,12 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_KILL_FOCUS, 113) DECLARE_EVENT_TYPE(wxEVT_CHILD_FOCUS, 114) DECLARE_EVENT_TYPE(wxEVT_MOUSEWHEEL, 115) + DECLARE_EVENT_TYPE(wxEVT_AUX1_DOWN, 116) + DECLARE_EVENT_TYPE(wxEVT_AUX1_UP, 117) + DECLARE_EVENT_TYPE(wxEVT_AUX1_DCLICK, 118) + DECLARE_EVENT_TYPE(wxEVT_AUX2_DOWN, 119) + DECLARE_EVENT_TYPE(wxEVT_AUX2_UP, 120) + DECLARE_EVENT_TYPE(wxEVT_AUX2_DCLICK, 121) // Non-client mouse events DECLARE_EVENT_TYPE(wxEVT_NC_LEFT_DOWN, 200) @@ -217,7 +221,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) - DECLARE_EVENT_TYPE(wxEVT_SCROLL_ENDSCROLL, 308) + DECLARE_EVENT_TYPE(wxEVT_SCROLL_CHANGED, 308) // Scroll events from wxWindow DECLARE_EVENT_TYPE(wxEVT_SCROLLWIN_TOP, 320) @@ -236,7 +240,7 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_END_SESSION, 403) DECLARE_EVENT_TYPE(wxEVT_QUERY_END_SESSION, 404) DECLARE_EVENT_TYPE(wxEVT_ACTIVATE_APP, 405) - DECLARE_EVENT_TYPE(wxEVT_POWER, 406) + // 406..408 are power events DECLARE_EVENT_TYPE(wxEVT_ACTIVATE, 409) DECLARE_EVENT_TYPE(wxEVT_CREATE, 410) DECLARE_EVENT_TYPE(wxEVT_DESTROY, 411) @@ -244,14 +248,14 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_ICONIZE, 413) DECLARE_EVENT_TYPE(wxEVT_MAXIMIZE, 414) DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_CHANGED, 415) - DECLARE_EVENT_TYPE(wxEVT_PAINT, 416) - 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_OPEN, 420) - DECLARE_EVENT_TYPE(wxEVT_MENU_CLOSE, 421) - DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 422) - // DECLARE_EVENT_TYPE(wxEVT_POPUP_MENU_INIT, 423) -- free slot + DECLARE_EVENT_TYPE(wxEVT_MOUSE_CAPTURE_LOST, 416) + DECLARE_EVENT_TYPE(wxEVT_PAINT, 417) + DECLARE_EVENT_TYPE(wxEVT_ERASE_BACKGROUND, 418) + DECLARE_EVENT_TYPE(wxEVT_NC_PAINT, 419) + DECLARE_EVENT_TYPE(wxEVT_PAINT_ICON, 420) + DECLARE_EVENT_TYPE(wxEVT_MENU_OPEN, 421) + DECLARE_EVENT_TYPE(wxEVT_MENU_CLOSE, 422) + DECLARE_EVENT_TYPE(wxEVT_MENU_HIGHLIGHT, 423) DECLARE_EVENT_TYPE(wxEVT_CONTEXT_MENU, 424) DECLARE_EVENT_TYPE(wxEVT_SYS_COLOUR_CHANGED, 425) DECLARE_EVENT_TYPE(wxEVT_DISPLAY_CHANGED, 426) @@ -271,6 +275,15 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440) DECLARE_EVENT_TYPE(wxEVT_SIZING, 441) DECLARE_EVENT_TYPE(wxEVT_MOVING, 442) + DECLARE_EVENT_TYPE(wxEVT_MOVE_START, 443) + DECLARE_EVENT_TYPE(wxEVT_MOVE_END, 444) + DECLARE_EVENT_TYPE(wxEVT_HIBERNATE, 445) + // more power events follow -- see wx/power.h + + // Clipboard events + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_COPY, 446) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_CUT, 447) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_PASTE, 448) // Generic command events // Note: a click is a higher-level event than button down/up @@ -351,7 +364,7 @@ public: // to allow the event processing by the base classes (calling event.Skip() // is the analog of calling the base class version of a virtual function) void Skip(bool skip = true) { m_skipped = skip; } - bool GetSkipped() const { return m_skipped; }; + bool GetSkipped() const { return m_skipped; } // this function is used to create a copy of the event polymorphically and // all derived classes must implement it because otherwise wxPostEvent() @@ -382,11 +395,7 @@ public: m_propagationLevel = propagationLevel; } -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif wxObject* m_eventObject; wxEventType m_eventType; long m_timeStamp; @@ -404,17 +413,13 @@ protected: // backwards compatibility as it is new int m_propagationLevel; -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif bool m_skipped; bool m_isCommandEvent; private: // it needs to access our m_propagationLevel - friend class WXDLLIMPEXP_BASE wxPropagateOnce; + friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce; DECLARE_ABSTRACT_CLASS(wxEvent) }; @@ -467,6 +472,7 @@ private: DECLARE_NO_COPY_CLASS(wxPropagateOnce) }; + #if wxUSE_GUI @@ -489,31 +495,6 @@ private: wxEVT_COMMAND_TOGGLEBUTTON_CLICKED */ -#if WXWIN_COMPATIBILITY_2_4 -// Backwards compatibility for wxCommandEvent::m_commandString, will lead to compilation errors in some cases of usage -class WXDLLIMPEXP_CORE wxCommandEvent; - -class WXDLLIMPEXP_CORE wxCommandEventStringHelper -{ -public: - wxCommandEventStringHelper(wxCommandEvent * evt) - : m_evt(evt) - { } - - void operator=(const wxString &str); - operator wxString(); - const wxChar* c_str() const; - -private: - wxCommandEvent* m_evt; -}; -#endif - -#ifdef __VISUALC__ - // 'this' : used in base member initializer list (for m_commandString) - #pragma warning(disable:4355) -#endif - class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent { public: @@ -521,9 +502,6 @@ public: wxCommandEvent(const wxCommandEvent& event) : wxEvent(event), -#if WXWIN_COMPATIBILITY_2_4 - m_commandString(this), -#endif m_cmdString(event.m_cmdString), m_commandInt(event.m_commandInt), m_extraLong(event.m_extraLong), @@ -556,16 +534,11 @@ 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); } -#if WXWIN_COMPATIBILITY_2_4 -public: - wxCommandEventStringHelper m_commandString; -#else protected: -#endif wxString m_cmdString; // String event argument int m_commandInt; long m_extraLong; // Additional information (e.g. select/deselect) @@ -576,27 +549,6 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent) }; -#ifdef __VISUALC__ - #pragma warning(default:4355) -#endif - -#if WXWIN_COMPATIBILITY_2_4 -inline void wxCommandEventStringHelper::operator=(const wxString &str) -{ - m_evt->SetString(str); -} - -inline wxCommandEventStringHelper::operator wxString() -{ - return m_evt->GetString(); -} - -inline const wxChar* wxCommandEventStringHelper::c_str() const -{ - return m_evt->GetString().c_str(); -} -#endif - // this class adds a possibility to react (from the user) code to a control // notification: allow or veto the operation being reported. class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent @@ -639,7 +591,7 @@ private: wxEVT_SCROLL_PAGEDOWN wxEVT_SCROLL_THUMBTRACK wxEVT_SCROLL_THUMBRELEASE - wxEVT_SCROLL_ENDSCROLL + wxEVT_SCROLL_CHANGED */ class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent @@ -688,11 +640,7 @@ public: virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); } -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif int m_commandInt; long m_extraLong; @@ -736,7 +684,10 @@ enum wxMOUSE_BTN_NONE = 0, wxMOUSE_BTN_LEFT = 1, wxMOUSE_BTN_MIDDLE = 2, - wxMOUSE_BTN_RIGHT = 3 + wxMOUSE_BTN_RIGHT = 3, + wxMOUSE_BTN_AUX1 = 4, + wxMOUSE_BTN_AUX2 = 5, + wxMOUSE_BTN_MAX }; class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent @@ -785,20 +736,28 @@ public: bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); } bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); } bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); } + bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); } + bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); } bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); } bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); } bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); } + bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); } + bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); } bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); } bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); } bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); } + bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_UP); } + bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_UP); } // Find the current state of the mouse buttons (regardless // of current event type) bool LeftIsDown() const { return m_leftDown; } bool MiddleIsDown() const { return m_middleDown; } bool RightIsDown() const { return m_rightDown; } + bool Aux1IsDown() const { return m_aux1Down; } + bool Aux2IsDown() const { return m_aux2Down; } // True if a button is down and the mouse is moving bool Dragging() const @@ -861,6 +820,11 @@ public: // should occur for each delta. int GetWheelDelta() const { return m_wheelDelta; } + // Gets the axis the wheel operation concerns, 0 being the y axis as on + // most mouse wheels, 1 is the x axis for things like MightyMouse scrolls + // or horizontal trackpad scrolling + int GetWheelAxis() const { return m_wheelAxis; } + // Returns the configured number of lines (or whatever) to be scrolled per // wheel action. Defaults to one. int GetLinesPerAction() const { return m_linesPerAction; } @@ -878,12 +842,15 @@ public: bool m_leftDown; bool m_middleDown; bool m_rightDown; + bool m_aux1Down; + bool m_aux2Down; bool m_controlDown; bool m_shiftDown; bool m_altDown; bool m_metaDown; + int m_wheelAxis; int m_wheelRotation; int m_wheelDelta; int m_linesPerAction; @@ -949,11 +916,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 +988,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 +1023,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 @@ -1088,7 +1071,7 @@ public: wxSize GetSize() const { return m_size; } wxRect GetRect() const { return m_rect; } - void SetRect(wxRect rect) { m_rect = rect; } + void SetRect(const wxRect& rect) { m_rect = rect; } virtual wxEvent *Clone() const { return new wxSizeEvent(*this); } @@ -1128,15 +1111,11 @@ public: wxPoint GetPosition() const { return m_pos; } void SetPosition(const wxPoint& pos) { m_pos = pos; } wxRect GetRect() const { return m_rect; } - void SetRect(wxRect rect) { m_rect = rect; } + void SetRect(const wxRect& rect) { m_rect = rect; } virtual wxEvent *Clone() const { return new wxMoveEvent(*this); } -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif wxPoint m_pos; wxRect m_rect; @@ -1177,7 +1156,7 @@ public: g_isPainting++; } - ~wxPaintEvent() + virtual ~wxPaintEvent() { g_isPainting--; } @@ -1224,11 +1203,7 @@ public: virtual wxEvent *Clone() const { return new wxEraseEvent(*this); } -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif wxDC *m_dc; private: @@ -1286,6 +1261,7 @@ private: /* wxEVT_ACTIVATE wxEVT_ACTIVATE_APP + wxEVT_HIBERNATE */ class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent @@ -1385,7 +1361,15 @@ public: m_canVeto(event.m_canVeto) {} void SetLoggingOff(bool logOff) { m_loggingOff = logOff; } - bool GetLoggingOff() const { return m_loggingOff; } + bool GetLoggingOff() const + { + // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it + // doesn't make sense for wxEVT_CLOSE_WINDOW + wxASSERT_MSG( m_eventType != wxEVT_CLOSE_WINDOW, + _T("this flag is for end session events only") ); + + return m_loggingOff; + } void Veto(bool veto = true) { @@ -1396,19 +1380,18 @@ public: m_veto = veto; } void SetCanVeto(bool canVeto) { m_canVeto = canVeto; } - // No more asserts here please, the one you put here was wrong. bool CanVeto() const { return m_canVeto; } bool GetVeto() const { return m_canVeto && m_veto; } virtual wxEvent *Clone() const { return new wxCloseEvent(*this); } protected: - bool m_loggingOff; - bool m_veto, m_canVeto; + bool m_loggingOff, + m_veto, + m_canVeto; private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent) - }; /* @@ -1506,11 +1489,7 @@ enum class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent { -#if WXWIN_COMPATIBILITY_2_4 -public: -#else protected: -#endif wxPoint m_pos; int m_zPosition; int m_buttonChange; // Which button changed? @@ -1659,7 +1638,9 @@ public: { m_checked = m_enabled = + m_shown = m_setEnabled = + m_setShown = m_setText = m_setChecked = false; } @@ -1667,7 +1648,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) @@ -1675,13 +1658,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. @@ -1711,7 +1697,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; @@ -1764,7 +1752,7 @@ public: virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); } - wxWindow* GetCapturedWindow() const { return m_gainedCapture; }; + wxWindow* GetCapturedWindow() const { return m_gainedCapture; } private: wxWindow* m_gainedCapture; @@ -1772,6 +1760,29 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent) }; +/* + wxEVT_MOUSE_CAPTURE_LOST + The window losing the capture receives this message, unless it released it + it itself or unless wxWindow::CaptureMouse was called on another window + (and so capture will be restored when the new capturer releases it). + */ + +class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent +{ +public: + wxMouseCaptureLostEvent(wxWindowID winid = 0) + : wxEvent(winid, wxEVT_MOUSE_CAPTURE_LOST) + {} + + wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent& event) + : wxEvent(event) + {} + + virtual wxEvent *Clone() const { return new wxMouseCaptureLostEvent(*this); } + + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent) +}; + /* wxEVT_DISPLAY_CHANGED */ @@ -1857,7 +1868,7 @@ class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent public: wxNavigationKeyEvent() : wxEvent(0, wxEVT_NAVIGATION_KEY), - m_flags(IsForward), // defaults are for TAB + m_flags(IsForward | FromTab), // defaults are for TAB m_focus((wxWindow *)NULL) { m_propagationLevel = wxEVENT_PROPAGATE_NONE; @@ -1882,6 +1893,13 @@ public: void SetWindowChange(bool bIs) { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; } + // Set to true under MSW if the event was generated using the tab key. + // This is required for proper navogation over radio buttons + bool IsFromTab() const + { return (m_flags & FromTab) != 0; } + void SetFromTab(bool bIs) + { if ( bIs ) m_flags |= FromTab; else m_flags &= ~FromTab; } + // the child which has the focus currently (may be NULL - use // wxWindow::FindFocus then) wxWindow* GetCurrentFocus() const { return m_focus; } @@ -1896,7 +1914,8 @@ public: { IsBackward = 0x0000, IsForward = 0x0001, - WinChange = 0x0002 + WinChange = 0x0002, + FromTab = 0x0004 }; long m_flags; @@ -1951,17 +1970,28 @@ private: class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent { public: + // how was this help event generated? + enum Origin + { + Origin_Unknown, // unrecognized event source + Origin_Keyboard, // event generated from F1 key press + Origin_HelpButton // event from [?] button on the title bar (Windows) + }; + wxHelpEvent(wxEventType type = wxEVT_NULL, wxWindowID winid = 0, - const wxPoint& pt = wxDefaultPosition) + const wxPoint& pt = wxDefaultPosition, + Origin origin = Origin_Unknown) : wxCommandEvent(type, winid), - m_pos(pt), m_target(), m_link() + m_pos(pt), + m_origin(GuessOrigin(origin)) { } wxHelpEvent(const wxHelpEvent & event) : wxCommandEvent(event), m_pos(event.m_pos), m_target(event.m_target), - m_link(event.m_link) + m_link(event.m_link), + m_origin(event.m_origin) { } // Position of event (in screen coordinates) @@ -1978,15 +2008,52 @@ public: virtual wxEvent *Clone() const { return new wxHelpEvent(*this); } + // optional indication of the event source + Origin GetOrigin() const { return m_origin; } + void SetOrigin(Origin origin) { m_origin = origin; } + protected: wxPoint m_pos; wxString m_target; wxString m_link; + Origin m_origin; + + // we can try to guess the event origin ourselves, even if none is + // specified in the ctor + static Origin GuessOrigin(Origin origin); private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent) }; +// A Clipboard Text event is sent when a window intercepts text copy/cut/paste +// message, i.e. the user has cut/copied/pasted data from/into a text control +// via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc. +// NOTE : under windows these events are *NOT* generated automatically +// for a Rich Edit text control. +/* +wxEVT_COMMAND_TEXT_COPY +wxEVT_COMMAND_TEXT_CUT +wxEVT_COMMAND_TEXT_PASTE +*/ + +class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent +{ +public: + wxClipboardTextEvent(wxEventType type = wxEVT_NULL, + wxWindowID winid = 0) + : wxCommandEvent(type, winid) + { } + wxClipboardTextEvent(const wxClipboardTextEvent & event) + : wxCommandEvent(event) + { } + + virtual wxEvent *Clone() const { return new wxClipboardTextEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent) +}; + // A Context event is sent when the user right clicks on a window or // presses Shift-F10 // NOTE : Under windows this is a repackaged WM_CONTETXMENU message @@ -2022,6 +2089,8 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent) }; +#endif // wxUSE_GUI + // Idle event /* wxEVT_IDLE @@ -2041,7 +2110,7 @@ enum wxIdleMode wxIDLE_PROCESS_SPECIFIED }; -class WXDLLIMPEXP_CORE wxIdleEvent : public wxEvent +class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent { public: wxIdleEvent() @@ -2066,9 +2135,6 @@ public: // Returns the idle event mode static wxIdleMode GetMode() { return sm_idleMode; } - // Can we send an idle event? - static bool CanSend(wxWindow* win); - protected: bool m_requestMore; static wxIdleMode sm_idleMode; @@ -2077,10 +2143,7 @@ private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent) }; -#endif // wxUSE_GUI - /* TODO - wxEVT_POWER, wxEVT_MOUSE_CAPTURE_CHANGED, wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95) // wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate @@ -2095,6 +2158,9 @@ private: // event handler and related classes // ============================================================================ +// for backwards compatibility and to prevent eVC 4 for ARM from crashing with +// internal compiler error when compiling wx, we define wxObjectEventFunction +// as a wxObject method even though it can only be a wxEvtHandler one typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); // we can't have ctors nor base struct in backwards compatibility mode or @@ -2172,8 +2238,6 @@ private: wxEventTableEntry& operator=(const wxEventTableEntry&); }; -class WXDLLIMPEXP_BASE wxEvtHandler; - // an entry used in dynamic event table managed by wxEvtHandler::Connect() struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase { @@ -2214,7 +2278,6 @@ struct WXDLLIMPEXP_BASE wxEventTable // ---------------------------------------------------------------------------- WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray); -class WXDLLIMPEXP_BASE wxEvtHandler; class WXDLLIMPEXP_BASE wxEventHashTable { @@ -2243,8 +2306,10 @@ public: // Clear table void Clear(); +#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING // Clear all tables static void ClearAll(); +#endif // __WXDEBUG__ && wxUSE_MEMORY_TRACING protected: // Init the hash table with the entries of the static event table. @@ -2293,13 +2358,12 @@ public: virtual bool ProcessEvent(wxEvent& event); // add an event to be processed later - void AddPendingEvent(wxEvent& event); + virtual void AddPendingEvent(const wxEvent& event); - // process all pending events void ProcessPendingEvents(); #if wxUSE_THREADS - bool ProcessThreadEvent(wxEvent& event); + bool ProcessThreadEvent(const wxEvent& event); #endif // Dynamic association of a member function handler with the event handler, @@ -2340,6 +2404,11 @@ public: wxEvtHandler *eventSink = (wxEvtHandler *) NULL) { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); } + bool Disconnect(wxEventType eventType, + wxObjectEventFunction func, + wxObject *userData = (wxObject *) NULL, + wxEvtHandler *eventSink = (wxEvtHandler *) NULL) + { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); } wxList* GetDynamicEventTable() const { return m_dynamicEvents ; } @@ -2383,7 +2452,7 @@ protected: // NB: This method is intentionally *not* inside wxUSE_VALIDATORS! // It is part of wxBase which doesn't use validators and the code // is compiled out when building wxBase w/o GUI classes, which affects - // binary compatiblity and wxBase library can't be used by GUI + // binary compatibility and wxBase library can't be used by GUI // ports. virtual bool TryValidator(wxEvent& WXUNUSED(event)) { return false; } @@ -2407,8 +2476,14 @@ protected: #if wxUSE_THREADS #if defined (__VISAGECPP__) + const wxCriticalSection& Lock() const { return m_eventsLocker; } + wxCriticalSection& Lock() { return m_eventsLocker; } + wxCriticalSection m_eventsLocker; # else + const wxCriticalSection& Lock() const { return *m_eventsLocker; } + wxCriticalSection& Lock() { return *m_eventsLocker; } + wxCriticalSection* m_eventsLocker; # endif #endif @@ -2444,7 +2519,7 @@ private: // Post a message to the given eventhandler which will be processed during the // next event loop iteration -inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event) +inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event) { wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") ); @@ -2458,6 +2533,30 @@ typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); #if wxUSE_GUI +// ---------------------------------------------------------------------------- +// wxEventBlocker: helper class to temporarily disable event handling for a window +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler +{ +public: + wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY); + virtual ~wxEventBlocker(); + + void Block(wxEventType type) + { + m_eventsToBlock.push_back(type); + } + + virtual bool ProcessEvent(wxEvent& event); + +protected: + wxArrayInt m_eventsToBlock; + wxWindow *m_window; + + DECLARE_NO_COPY_CLASS(wxEventBlocker) +}; + typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&); typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&); typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&); @@ -2493,86 +2592,85 @@ typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&); typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&); typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&); typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&); - -// these typedefs don't have the same name structure as the others, keep for -// backwards compatibility only -#if WXWIN_COMPATIBILITY_2_4 - typedef wxSysColourChangedEventFunction wxSysColourChangedFunction; - typedef wxDisplayChangedEventFunction wxDisplayChangedFunction; -#endif // WXWIN_COMPATIBILITY_2_4 +typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&); +typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&); #define wxCommandEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxCommandEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCommandEventFunction, &func) #define wxScrollEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxScrollEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollEventFunction, &func) #define wxScrollWinEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxScrollWinEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxScrollWinEventFunction, &func) #define wxSizeEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxSizeEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSizeEventFunction, &func) #define wxMoveEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxMoveEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMoveEventFunction, &func) #define wxPaintEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxPaintEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaintEventFunction, &func) #define wxNcPaintEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxNcPaintEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNcPaintEventFunction, &func) #define wxEraseEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxEraseEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxEraseEventFunction, &func) #define wxMouseEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxMouseEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseEventFunction, &func) #define wxCharEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxCharEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCharEventFunction, &func) #define wxKeyEventHandler(func) wxCharEventHandler(func) #define wxFocusEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxFocusEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFocusEventFunction, &func) #define wxChildFocusEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxChildFocusEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChildFocusEventFunction, &func) #define wxActivateEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxActivateEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActivateEventFunction, &func) #define wxMenuEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxMenuEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMenuEventFunction, &func) #define wxJoystickEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxJoystickEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxJoystickEventFunction, &func) #define wxDropFilesEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxDropFilesEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDropFilesEventFunction, &func) #define wxInitDialogEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxInitDialogEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxInitDialogEventFunction, &func) #define wxSysColourChangedEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxSysColourChangedEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSysColourChangedEventFunction, &func) #define wxDisplayChangedEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxDisplayChangedEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDisplayChangedEventFunction, &func) #define wxUpdateUIEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxUpdateUIEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxUpdateUIEventFunction, &func) #define wxIdleEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIdleEventFunction, &func) #define wxCloseEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxCloseEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCloseEventFunction, &func) #define wxShowEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxShowEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxShowEventFunction, &func) #define wxIconizeEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxIconizeEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxIconizeEventFunction, &func) #define wxMaximizeEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxMaximizeEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMaximizeEventFunction, &func) #define wxNavigationKeyEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxNavigationKeyEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNavigationKeyEventFunction, &func) #define wxPaletteChangedEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxPaletteChangedEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxPaletteChangedEventFunction, &func) #define wxQueryNewPaletteEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxQueryNewPaletteEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxQueryNewPaletteEventFunction, &func) #define wxWindowCreateEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxWindowCreateEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowCreateEventFunction, &func) #define wxWindowDestroyEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxWindowDestroyEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxWindowDestroyEventFunction, &func) #define wxSetCursorEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxSetCursorEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSetCursorEventFunction, &func) #define wxNotifyEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxNotifyEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNotifyEventFunction, &func) #define wxHelpEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxHelpEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHelpEventFunction, &func) #define wxContextMenuEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxContextMenuEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxContextMenuEventFunction, &func) #define wxMouseCaptureChangedEventHandler(func) \ - (wxObjectEventFunction)wxStaticCastEvent(wxMouseCaptureChangedEventFunction, &func) + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureChangedEventFunction, &func) +#define wxMouseCaptureLostEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMouseCaptureLostEventFunction, &func) +#define wxClipboardTextEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxClipboardTextEventFunction, &func) #endif // wxUSE_GUI @@ -2602,6 +2700,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 ) }; /* @@ -2630,9 +2833,9 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func)) // EVT_COMMAND -#define EVT_COMMAND(winid, event, fn) \ +#define EVT_COMMAND(winid, event, func) \ wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func)) -#define EVT_COMMAND_RANGE(id1, id2, event, fn) \ +#define EVT_COMMAND_RANGE(id1, id2, event, func) \ wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func)) #define EVT_NOTIFY(event, winid, func) \ @@ -2645,6 +2848,8 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func)) #define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func)) #define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func)) +#define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func)) +#define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func)) #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func)) #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func)) #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func)) @@ -2667,6 +2872,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_CHILD_FOCUS(func) wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func)) #define EVT_ACTIVATE(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func)) #define EVT_ACTIVATE_APP(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func)) +#define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func)) #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func)) #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func)) #define EVT_DROP_FILES(func) wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func)) @@ -2683,6 +2889,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func)) #define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func)) #define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func)) +#define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func)) // Mouse events #define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func)) @@ -2698,19 +2905,31 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func)) #define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func)) #define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func)) +#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func)) // All mouse events #define EVT_MOUSE_EVENTS(func) \ EVT_LEFT_DOWN(func) \ EVT_LEFT_UP(func) \ + EVT_LEFT_DCLICK(func) \ EVT_MIDDLE_DOWN(func) \ EVT_MIDDLE_UP(func) \ + EVT_MIDDLE_DCLICK(func) \ EVT_RIGHT_DOWN(func) \ EVT_RIGHT_UP(func) \ - EVT_MOTION(func) \ - EVT_LEFT_DCLICK(func) \ - EVT_MIDDLE_DCLICK(func) \ EVT_RIGHT_DCLICK(func) \ + EVT_MOUSE_AUX1_DOWN(func) \ + EVT_MOUSE_AUX1_UP(func) \ + EVT_MOUSE_AUX1_DCLICK(func) \ + EVT_MOUSE_AUX2_DOWN(func) \ + EVT_MOUSE_AUX2_UP(func) \ + EVT_MOUSE_AUX2_DCLICK(func) \ + EVT_MOTION(func) \ EVT_LEAVE_WINDOW(func) \ EVT_ENTER_WINDOW(func) \ EVT_MOUSEWHEEL(func) @@ -2744,7 +2963,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)) -#define EVT_SCROLL_ENDSCROLL(func) wx__DECLARE_EVT0(wxEVT_SCROLL_ENDSCROLL, wxScrollEventHandler(func)) +#define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func)) #define EVT_SCROLL(func) \ EVT_SCROLL_TOP(func) \ @@ -2754,7 +2973,8 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC EVT_SCROLL_PAGEUP(func) \ EVT_SCROLL_PAGEDOWN(func) \ EVT_SCROLL_THUMBTRACK(func) \ - EVT_SCROLL_THUMBRELEASE(func) + EVT_SCROLL_THUMBRELEASE(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)) @@ -2765,7 +2985,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)) -#define EVT_COMMAND_SCROLL_ENDSCROLL(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_ENDSCROLL, winid, wxScrollEventHandler(func)) +#define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func)) #define EVT_COMMAND_SCROLL(winid, func) \ EVT_COMMAND_SCROLL_TOP(winid, func) \ @@ -2775,7 +2995,15 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC EVT_COMMAND_SCROLL_PAGEUP(winid, func) \ EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \ EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \ - EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) + EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \ + EVT_COMMAND_SCROLL_CHANGED(winid, func) + +#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)) @@ -2797,6 +3025,7 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_VLBOX_SELECTED, winid, wxCommandEventHandler(func)) #define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_COMBOBOX_SELECTED, winid, wxCommandEventHandler(func)) #define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_CLICKED, winid, wxCommandEventHandler(func)) +#define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, winid, wxCommandEventHandler(func)) #define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_CLICKED, id1, id2, wxCommandEventHandler(func)) #define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TOOL_RCLICKED, winid, wxCommandEventHandler(func)) #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_COMMAND_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func)) @@ -2819,12 +3048,6 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func)) #define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func)) -// These are obsolete, see _BUTTON_ events -#if WXWIN_COMPATIBILITY_2_4 - #define EVT_JOY_DOWN(func) EVT_JOY_BUTTON_DOWN(func) - #define EVT_JOY_UP(func) EVT_JOY_BUTTON_UP(func) -#endif // WXWIN_COMPATIBILITY_2_4 - // All joystick events #define EVT_JOYSTICK_EVENTS(func) \ EVT_JOY_BUTTON_DOWN(func) \ @@ -2849,6 +3072,11 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC #define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func)) #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func)) +// Clipboard text Events +#define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_CUT, winid, wxClipboardTextEventHandler(func)) +#define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_COPY, winid, wxClipboardTextEventHandler(func)) +#define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_PASTE, winid, wxClipboardTextEventHandler(func)) + // ---------------------------------------------------------------------------- // Global data // ---------------------------------------------------------------------------- @@ -2868,9 +3096,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__ -