+ virtual void Execute()
+ {
+ (m_object->*m_method)();
+ }
+
+private:
+ ObjectType* const m_object;
+ const MethodType m_method;
+};
+
+// This is a version for calling methods with a single parameter.
+template <typename T, typename T1>
+class wxAsyncMethodCallEvent1 : public wxAsyncMethodCallEvent
+{
+public:
+ typedef T ObjectType;
+ typedef void (ObjectType::*MethodType)(T1 x1);
+ typedef typename wxRemoveRef<T1>::type ParamType1;
+
+ wxAsyncMethodCallEvent1(ObjectType* object,
+ MethodType method,
+ const ParamType1& x1)
+ : wxAsyncMethodCallEvent(object),
+ m_object(object),
+ m_method(method),
+ m_param1(x1)
+ {
+ }
+
+ wxAsyncMethodCallEvent1(const wxAsyncMethodCallEvent1& other)
+ : wxAsyncMethodCallEvent(other),
+ m_object(other.m_object),
+ m_method(other.m_method),
+ m_param1(other.m_param1)
+ {
+ }
+
+ virtual wxEvent *Clone() const
+ {
+ return new wxAsyncMethodCallEvent1(*this);
+ }
+
+ virtual void Execute()
+ {
+ (m_object->*m_method)(m_param1);
+ }
+
+private:
+ ObjectType* const m_object;
+ const MethodType m_method;
+ const ParamType1 m_param1;
+};
+
+// This is a version for calling methods with two parameters.
+template <typename T, typename T1, typename T2>
+class wxAsyncMethodCallEvent2 : public wxAsyncMethodCallEvent
+{
+public:
+ typedef T ObjectType;
+ typedef void (ObjectType::*MethodType)(T1 x1, T2 x2);
+ typedef typename wxRemoveRef<T1>::type ParamType1;
+ typedef typename wxRemoveRef<T2>::type ParamType2;
+
+ wxAsyncMethodCallEvent2(ObjectType* object,
+ MethodType method,
+ const ParamType1& x1,
+ const ParamType2& x2)
+ : wxAsyncMethodCallEvent(object),
+ m_object(object),
+ m_method(method),
+ m_param1(x1),
+ m_param2(x2)
+ {
+ }
+
+ wxAsyncMethodCallEvent2(const wxAsyncMethodCallEvent2& other)
+ : wxAsyncMethodCallEvent(other),
+ m_object(other.m_object),
+ m_method(other.m_method),
+ m_param1(other.m_param1),
+ m_param2(other.m_param2)
+ {
+ }
+
+ virtual wxEvent *Clone() const
+ {
+ return new wxAsyncMethodCallEvent2(*this);
+ }
+
+ virtual void Execute()
+ {
+ (m_object->*m_method)(m_param1, m_param2);
+ }
+
+private:
+ ObjectType* const m_object;
+ const MethodType m_method;
+ const ParamType1 m_param1;
+ const ParamType2 m_param2;
+};
+
+#endif // wxHAS_CALL_AFTER
+
+
+#if wxUSE_GUI
+
+
+// Item or menu event class
+/*
+ wxEVT_BUTTON
+ wxEVT_CHECKBOX
+ wxEVT_CHOICE
+ wxEVT_LISTBOX
+ wxEVT_LISTBOX_DCLICK
+ wxEVT_TEXT
+ wxEVT_TEXT_ENTER
+ wxEVT_MENU
+ wxEVT_SLIDER
+ wxEVT_RADIOBOX
+ wxEVT_RADIOBUTTON
+ wxEVT_SCROLLBAR
+ wxEVT_VLBOX
+ wxEVT_COMBOBOX
+ wxEVT_TOGGLEBUTTON
+*/
+
+class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent,
+ public wxEventBasicPayloadMixin
+{
+public:
+ wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
+
+ wxCommandEvent(const wxCommandEvent& event)
+ : wxEvent(event),
+ wxEventBasicPayloadMixin(event),
+ m_clientData(event.m_clientData),
+ m_clientObject(event.m_clientObject)
+ {
+ // Because GetString() can retrieve the string text only on demand, we
+ // need to copy it explicitly.
+ if ( m_cmdString.empty() )
+ m_cmdString = event.GetString();
+ }
+
+ // Set/Get client data from controls
+ void SetClientData(void* clientData) { m_clientData = clientData; }
+ void *GetClientData() const { return m_clientData; }
+
+ // Set/Get client object from controls
+ void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; }
+ wxClientData *GetClientObject() const { return m_clientObject; }
+
+ // Note: this shadows wxEventBasicPayloadMixin::GetString(), because it does some
+ // GUI-specific hacks
+ wxString GetString() const;
+
+ // Get listbox selection if single-choice
+ int GetSelection() const { return m_commandInt; }
+
+ // Get checkbox value
+ bool IsChecked() const { return m_commandInt != 0; }
+
+ // true if the listbox event was a selection.
+ bool IsSelection() const { return (m_extraLong != 0); }
+
+ virtual wxEvent *Clone() const { return new wxCommandEvent(*this); }
+ virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
+
+protected:
+ void* m_clientData; // Arbitrary client data
+ wxClientData* m_clientObject; // Arbitrary client object
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent)
+};
+
+// 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
+{
+public:
+ wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
+ : wxCommandEvent(commandType, winid)
+ { m_bAllow = true; }
+
+ wxNotifyEvent(const wxNotifyEvent& event)
+ : wxCommandEvent(event)
+ { m_bAllow = event.m_bAllow; }
+
+ // veto the operation (usually it's allowed by default)
+ void Veto() { m_bAllow = false; }
+
+ // allow the operation if it was disabled by default
+ void Allow() { m_bAllow = true; }
+
+ // for implementation code only: is the operation allowed?
+ bool IsAllowed() const { return m_bAllow; }
+
+ virtual wxEvent *Clone() const { return new wxNotifyEvent(*this); }
+
+private:
+ bool m_bAllow;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent)
+};
+
+
+// Scroll event class, derived form wxCommandEvent. wxScrollEvents are
+// sent by wxSlider and wxScrollBar.
+/*
+ wxEVT_SCROLL_TOP
+ wxEVT_SCROLL_BOTTOM
+ wxEVT_SCROLL_LINEUP
+ wxEVT_SCROLL_LINEDOWN
+ wxEVT_SCROLL_PAGEUP
+ wxEVT_SCROLL_PAGEDOWN
+ wxEVT_SCROLL_THUMBTRACK
+ wxEVT_SCROLL_THUMBRELEASE
+ wxEVT_SCROLL_CHANGED
+*/
+
+class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent
+{
+public:
+ wxScrollEvent(wxEventType commandType = wxEVT_NULL,
+ int winid = 0, int pos = 0, int orient = 0);
+
+ int GetOrientation() const { return (int) m_extraLong; }
+ int GetPosition() const { return m_commandInt; }
+ void SetOrientation(int orient) { m_extraLong = (long) orient; }
+ void SetPosition(int pos) { m_commandInt = pos; }
+
+ virtual wxEvent *Clone() const { return new wxScrollEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent)
+};
+
+// ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
+// are sent by wxWindow.
+/*
+ wxEVT_SCROLLWIN_TOP
+ wxEVT_SCROLLWIN_BOTTOM
+ wxEVT_SCROLLWIN_LINEUP
+ wxEVT_SCROLLWIN_LINEDOWN
+ wxEVT_SCROLLWIN_PAGEUP
+ wxEVT_SCROLLWIN_PAGEDOWN
+ wxEVT_SCROLLWIN_THUMBTRACK
+ wxEVT_SCROLLWIN_THUMBRELEASE
+*/
+
+class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent
+{
+public:
+ wxScrollWinEvent(wxEventType commandType = wxEVT_NULL,
+ int pos = 0, int orient = 0);
+ wxScrollWinEvent(const wxScrollWinEvent& event) : wxEvent(event)
+ { m_commandInt = event.m_commandInt;
+ m_extraLong = event.m_extraLong; }
+
+ int GetOrientation() const { return (int) m_extraLong; }
+ int GetPosition() const { return m_commandInt; }
+ void SetOrientation(int orient) { m_extraLong = (long) orient; }
+ void SetPosition(int pos) { m_commandInt = pos; }
+
+ virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); }
+
+protected:
+ int m_commandInt;
+ long m_extraLong;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent)
+};
+
+
+
+// Mouse event class
+
+/*
+ wxEVT_LEFT_DOWN
+ wxEVT_LEFT_UP
+ wxEVT_MIDDLE_DOWN
+ wxEVT_MIDDLE_UP
+ wxEVT_RIGHT_DOWN
+ wxEVT_RIGHT_UP
+ wxEVT_MOTION
+ wxEVT_ENTER_WINDOW
+ wxEVT_LEAVE_WINDOW
+ wxEVT_LEFT_DCLICK
+ wxEVT_MIDDLE_DCLICK
+ wxEVT_RIGHT_DCLICK
+*/
+
+enum wxMouseWheelAxis
+{
+ wxMOUSE_WHEEL_VERTICAL,
+ wxMOUSE_WHEEL_HORIZONTAL
+};
+
+class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent,
+ public wxMouseState
+{
+public:
+ wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
+ wxMouseEvent(const wxMouseEvent& event)
+ : wxEvent(event),
+ wxMouseState(event)
+ {
+ Assign(event);
+ }
+
+ // Was it a button event? (*doesn't* mean: is any button *down*?)
+ bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
+
+ // Was it a down event from this (or any) button?
+ bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
+
+ // Was it a dclick event from this (or any) button?
+ bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
+
+ // Was it a up event from this (or any) button?
+ bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
+
+ // Was this event generated by the given button?
+ bool Button(int but) const;
+
+ // Get the button which is changing state (wxMOUSE_BTN_NONE if none)
+ int GetButton() const;
+
+ // Find which event was just generated
+ 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_DCLICK); }
+ bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
+
+ // True if a button is down and the mouse is moving
+ bool Dragging() const
+ {
+ return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY);
+ }
+
+ // True if the mouse is moving, and no button is down
+ bool Moving() const
+ {
+ return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY);
+ }
+
+ // True if the mouse is just entering the window
+ bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); }
+
+ // True if the mouse is just leaving the window
+ bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
+
+ // Returns the number of mouse clicks associated with this event.
+ int GetClickCount() const { return m_clickCount; }
+
+ // Find the logical position of the event given the DC
+ wxPoint GetLogicalPosition(const wxDC& dc) const;
+
+ // Get wheel rotation, positive or negative indicates direction of
+ // rotation. Current devices all send an event when rotation is equal to
+ // +/-WheelDelta, but this allows for finer resolution devices to be
+ // created in the future. Because of this you shouldn't assume that one
+ // event is equal to 1 line or whatever, but you should be able to either
+ // do partial line scrolling or wait until +/-WheelDelta rotation values
+ // have been accumulated before scrolling.
+ int GetWheelRotation() const { return m_wheelRotation; }
+
+ // Get wheel delta, normally 120. This is the threshold for action to be
+ // taken, and one such action (for example, scrolling one increment)
+ // should occur for each delta.
+ int GetWheelDelta() const { return m_wheelDelta; }
+
+ // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL
+ // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling
+ // using e.g. a trackpad).
+ wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; }
+
+ // Returns the configured number of lines (or whatever) to be scrolled per
+ // wheel action. Defaults to three.
+ int GetLinesPerAction() const { return m_linesPerAction; }
+
+ // Returns the configured number of columns (or whatever) to be scrolled per
+ // wheel action. Defaults to three.
+ int GetColumnsPerAction() const { return m_columnsPerAction; }
+
+ // Is the system set to do page scrolling?
+ bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
+
+ virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
+ virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
+
+ wxMouseEvent& operator=(const wxMouseEvent& event)
+ {
+ if (&event != this)
+ Assign(event);
+ return *this;
+ }
+
+public:
+ int m_clickCount;
+
+ wxMouseWheelAxis m_wheelAxis;
+ int m_wheelRotation;
+ int m_wheelDelta;
+ int m_linesPerAction;
+ int m_columnsPerAction;
+
+protected:
+ void Assign(const wxMouseEvent& evt);
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxMouseEvent)
+};
+
+// Cursor set event
+
+/*
+ wxEVT_SET_CURSOR
+ */
+
+class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent
+{
+public:
+ wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0)
+ : wxEvent(0, wxEVT_SET_CURSOR),
+ m_x(x), m_y(y), m_cursor()
+ { }
+
+ wxSetCursorEvent(const wxSetCursorEvent& event)
+ : wxEvent(event),
+ m_x(event.m_x),
+ m_y(event.m_y),
+ m_cursor(event.m_cursor)
+ { }
+
+ wxCoord GetX() const { return m_x; }
+ wxCoord GetY() const { return m_y; }
+
+ void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
+ const wxCursor& GetCursor() const { return m_cursor; }
+ bool HasCursor() const { return m_cursor.IsOk(); }
+
+ virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); }
+
+private:
+ wxCoord m_x, m_y;
+ wxCursor m_cursor;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent)
+};
+
+// Keyboard input event class
+
+/*
+ wxEVT_CHAR
+ wxEVT_CHAR_HOOK
+ wxEVT_KEY_DOWN
+ wxEVT_KEY_UP
+ wxEVT_HOTKEY
+ */
+
+// key categories: the bit flags for IsKeyInCategory() function
+//
+// the enum values used may change in future version of wx
+// use the named constants only, or bitwise combinations thereof
+enum wxKeyCategoryFlags
+{
+ // arrow keys, on and off numeric keypads
+ WXK_CATEGORY_ARROW = 1,
+
+ // page up and page down keys, on and off numeric keypads
+ WXK_CATEGORY_PAGING = 2,
+
+ // home and end keys, on and off numeric keypads
+ WXK_CATEGORY_JUMP = 4,
+
+ // tab key, on and off numeric keypads
+ WXK_CATEGORY_TAB = 8,
+
+ // backspace and delete keys, on and off numeric keypads
+ WXK_CATEGORY_CUT = 16,
+
+ // all keys usually used for navigation
+ WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW |
+ WXK_CATEGORY_PAGING |
+ WXK_CATEGORY_JUMP
+};
+
+class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent,
+ public wxKeyboardState
+{
+public:
+ wxKeyEvent(wxEventType keyType = wxEVT_NULL);
+
+ // Normal copy ctor and a ctor creating a new event for the same key as the
+ // given one but a different event type (this is used in implementation
+ // code only, do not use outside of the library).
+ wxKeyEvent(const wxKeyEvent& evt);
+ wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt);
+
+ // get the key code: an ASCII7 char or an element of wxKeyCode enum
+ int GetKeyCode() const { return (int)m_keyCode; }
+
+ // returns true iff this event's key code is of a certain type
+ bool IsKeyInCategory(int category) const;
+
+#if wxUSE_UNICODE
+ // get the Unicode character corresponding to this key
+ wxChar GetUnicodeKey() const { return m_uniChar; }
+#endif // wxUSE_UNICODE
+
+ // get the raw key code (platform-dependent)
+ wxUint32 GetRawKeyCode() const { return m_rawCode; }
+
+ // get the raw key flags (platform-dependent)
+ wxUint32 GetRawKeyFlags() const { return m_rawFlags; }
+
+ // Find the position of the event
+ void GetPosition(wxCoord *xpos, wxCoord *ypos) const
+ {
+ if (xpos)
+ *xpos = GetX();
+ if (ypos)
+ *ypos = GetY();
+ }
+
+ // This version if provided only for backwards compatiblity, don't use.
+ void GetPosition(long *xpos, long *ypos) const
+ {
+ if (xpos)
+ *xpos = GetX();
+ if (ypos)
+ *ypos = GetY();
+ }
+
+ wxPoint GetPosition() const
+ { return wxPoint(GetX(), GetY()); }
+
+ // Get X position
+ wxCoord GetX() const;
+
+ // Get Y position
+ wxCoord GetY() const;
+
+ // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
+ // key events even though the event had been handled (by default they would
+ // not be generated in this case).
+ void DoAllowNextEvent() { m_allowNext = true; }
+
+ // Return the value of the "allow next" flag, for internal use only.
+ bool IsNextEventAllowed() const { return m_allowNext; }
+
+
+ virtual wxEvent *Clone() const { return new wxKeyEvent(*this); }
+ virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
+
+ // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
+ // example)
+ wxKeyEvent& operator=(const wxKeyEvent& evt)
+ {
+ if ( &evt != this )
+ {
+ wxEvent::operator=(evt);
+
+ // Borland C++ 5.82 doesn't compile an explicit call to an
+ // implicitly defined operator=() so need to do it this way:
+ *static_cast<wxKeyboardState *>(this) = evt;
+
+ DoAssignMembers(evt);
+ }
+ return *this;
+ }
+
+public:
+ // Do not use these fields directly, they are initialized on demand, so
+ // call GetX() and GetY() or GetPosition() instead.
+ wxCoord m_x, m_y;
+
+ long m_keyCode;
+
+#if wxUSE_UNICODE
+ // This contains the full Unicode character
+ // in a character events in Unicode mode
+ wxChar m_uniChar;
+#endif
+
+ // these fields contain the platform-specific information about
+ // key that was pressed
+ wxUint32 m_rawCode;
+ wxUint32 m_rawFlags;
+
+private:
+ // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK
+ // type. This is used by all ctors.
+ void InitPropagation()
+ {
+ if ( m_eventType == wxEVT_CHAR_HOOK )
+ m_propagationLevel = wxEVENT_PROPAGATE_MAX;
+
+ m_allowNext = false;
+ }
+
+ // Copy only the event data present in this class, this is used by
+ // AssignKeyData() and copy ctor.
+ void DoAssignMembers(const wxKeyEvent& evt)
+ {
+ m_x = evt.m_x;
+ m_y = evt.m_y;
+ m_hasPosition = evt.m_hasPosition;
+
+ m_keyCode = evt.m_keyCode;
+
+ m_rawCode = evt.m_rawCode;
+ m_rawFlags = evt.m_rawFlags;
+#if wxUSE_UNICODE
+ m_uniChar = evt.m_uniChar;
+#endif
+ }
+
+ // Initialize m_x and m_y using the current mouse cursor position if
+ // necessary.
+ void InitPositionIfNecessary() const;
+
+ // If this flag is true, the normal key events should still be generated
+ // even if wxEVT_CHAR_HOOK had been handled. By default it is false as
+ // handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
+ bool m_allowNext;
+
+ // If true, m_x and m_y were already initialized. If false, try to get them
+ // when they're requested.
+ bool m_hasPosition;
+
+ DECLARE_DYNAMIC_CLASS(wxKeyEvent)
+};
+
+// Size event class
+/*
+ wxEVT_SIZE
+ */
+
+class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
+{
+public:
+ wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
+ { }
+ wxSizeEvent(const wxSize& sz, int winid = 0)
+ : wxEvent(winid, wxEVT_SIZE),
+ m_size(sz)
+ { }
+ wxSizeEvent(const wxSizeEvent& event)
+ : wxEvent(event),
+ m_size(event.m_size), m_rect(event.m_rect)
+ { }
+ wxSizeEvent(const wxRect& rect, int id = 0)
+ : m_size(rect.GetSize()), m_rect(rect)
+ { m_eventType = wxEVT_SIZING; m_id = id; }
+
+ wxSize GetSize() const { return m_size; }
+ void SetSize(wxSize size) { m_size = size; }
+ wxRect GetRect() const { return m_rect; }
+ void SetRect(const wxRect& rect) { m_rect = rect; }
+
+ virtual wxEvent *Clone() const { return new wxSizeEvent(*this); }
+
+public:
+ // For internal usage only. Will be converted to protected members.
+ wxSize m_size;
+ wxRect m_rect; // Used for wxEVT_SIZING
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent)
+};
+
+// Move event class
+
+/*
+ wxEVT_MOVE
+ */
+
+class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
+{
+public:
+ wxMoveEvent()
+ : wxEvent(0, wxEVT_MOVE)
+ { }
+ wxMoveEvent(const wxPoint& pos, int winid = 0)
+ : wxEvent(winid, wxEVT_MOVE),
+ m_pos(pos)
+ { }
+ wxMoveEvent(const wxMoveEvent& event)
+ : wxEvent(event),
+ m_pos(event.m_pos)
+ { }
+ wxMoveEvent(const wxRect& rect, int id = 0)
+ : m_pos(rect.GetPosition()), m_rect(rect)
+ { m_eventType = wxEVT_MOVING; m_id = id; }
+
+ wxPoint GetPosition() const { return m_pos; }
+ void SetPosition(const wxPoint& pos) { m_pos = pos; }
+ wxRect GetRect() const { return m_rect; }
+ void SetRect(const wxRect& rect) { m_rect = rect; }
+
+ virtual wxEvent *Clone() const { return new wxMoveEvent(*this); }
+
+protected:
+ wxPoint m_pos;
+ wxRect m_rect;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent)
+};
+
+// Paint event class
+/*
+ wxEVT_PAINT
+ wxEVT_NC_PAINT
+ */
+
+#if wxDEBUG_LEVEL && (defined(__WXMSW__) || defined(__WXPM__))
+ #define wxHAS_PAINT_DEBUG
+
+ // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
+ extern WXDLLIMPEXP_CORE int g_isPainting;
+#endif // debug
+
+class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
+{
+public:
+ wxPaintEvent(int Id = 0)
+ : wxEvent(Id, wxEVT_PAINT)
+ {
+#ifdef wxHAS_PAINT_DEBUG
+ // set the internal flag for the duration of redrawing
+ g_isPainting++;
+#endif // debug
+ }
+
+ // default copy ctor and dtor are normally fine, we only need them to keep
+ // g_isPainting updated in debug build
+#ifdef wxHAS_PAINT_DEBUG
+ wxPaintEvent(const wxPaintEvent& event)
+ : wxEvent(event)
+ {
+ g_isPainting++;
+ }
+
+ virtual ~wxPaintEvent()
+ {
+ g_isPainting--;
+ }
+#endif // debug
+
+ virtual wxEvent *Clone() const { return new wxPaintEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent)
+};
+
+class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
+{
+public:
+ wxNcPaintEvent(int winid = 0)
+ : wxEvent(winid, wxEVT_NC_PAINT)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent)
+};
+
+// Erase background event class
+/*
+ wxEVT_ERASE_BACKGROUND
+ */
+
+class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
+{
+public:
+ wxEraseEvent(int Id = 0, wxDC *dc = NULL)
+ : wxEvent(Id, wxEVT_ERASE_BACKGROUND),
+ m_dc(dc)
+ { }
+
+ wxEraseEvent(const wxEraseEvent& event)
+ : wxEvent(event),
+ m_dc(event.m_dc)
+ { }
+
+ wxDC *GetDC() const { return m_dc; }
+
+ virtual wxEvent *Clone() const { return new wxEraseEvent(*this); }
+
+protected:
+ wxDC *m_dc;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent)
+};
+
+// Focus event class
+/*
+ wxEVT_SET_FOCUS
+ wxEVT_KILL_FOCUS
+ */
+
+class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
+{
+public:
+ wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0)
+ : wxEvent(winid, type)
+ { m_win = NULL; }
+
+ wxFocusEvent(const wxFocusEvent& event)
+ : wxEvent(event)
+ { m_win = event.m_win; }
+
+ // The window associated with this event is the window which had focus
+ // before for SET event and the window which will have focus for the KILL
+ // one. NB: it may be NULL in both cases!
+ wxWindow *GetWindow() const { return m_win; }
+ void SetWindow(wxWindow *win) { m_win = win; }
+
+ virtual wxEvent *Clone() const { return new wxFocusEvent(*this); }
+
+private:
+ wxWindow *m_win;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent)
+};
+
+// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
+// wxFocusEvent it is propagated upwards the window chain
+class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent
+{
+public:
+ wxChildFocusEvent(wxWindow *win = NULL);
+
+ wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
+
+ virtual wxEvent *Clone() const { return new wxChildFocusEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent)
+};
+
+// Activate event class
+/*
+ wxEVT_ACTIVATE
+ wxEVT_ACTIVATE_APP
+ wxEVT_HIBERNATE
+ */
+
+class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent
+{
+public:
+ wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0)
+ : wxEvent(Id, type)
+ { m_active = active; }
+ wxActivateEvent(const wxActivateEvent& event)
+ : wxEvent(event)
+ { m_active = event.m_active; }
+
+ bool GetActive() const { return m_active; }
+
+ virtual wxEvent *Clone() const { return new wxActivateEvent(*this); }
+
+private:
+ bool m_active;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent)
+};
+
+// InitDialog event class
+/*
+ wxEVT_INIT_DIALOG
+ */
+
+class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent
+{
+public:
+ wxInitDialogEvent(int Id = 0)
+ : wxEvent(Id, wxEVT_INIT_DIALOG)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxInitDialogEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent)
+};
+
+// Miscellaneous menu event class
+/*
+ wxEVT_MENU_OPEN,
+ wxEVT_MENU_CLOSE,
+ wxEVT_MENU_HIGHLIGHT,
+*/
+
+class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent
+{
+public:
+ wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL)
+ : wxEvent(winid, type)
+ { m_menuId = winid; m_menu = menu; }
+ wxMenuEvent(const wxMenuEvent& event)
+ : wxEvent(event)
+ { m_menuId = event.m_menuId; m_menu = event.m_menu; }
+
+ // only for wxEVT_MENU_HIGHLIGHT
+ int GetMenuId() const { return m_menuId; }
+
+ // only for wxEVT_MENU_OPEN/CLOSE
+ bool IsPopup() const { return m_menuId == wxID_ANY; }
+
+ // only for wxEVT_MENU_OPEN/CLOSE
+ wxMenu* GetMenu() const { return m_menu; }
+
+ virtual wxEvent *Clone() const { return new wxMenuEvent(*this); }
+
+private:
+ int m_menuId;
+ wxMenu* m_menu;
+
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent)
+};
+
+// Window close or session close event class
+/*
+ wxEVT_CLOSE_WINDOW,
+ wxEVT_END_SESSION,
+ wxEVT_QUERY_END_SESSION
+ */
+
+class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent
+{
+public:
+ wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0)
+ : wxEvent(winid, type),
+ m_loggingOff(true),
+ m_veto(false), // should be false by default
+ m_canVeto(true) {}
+
+ wxCloseEvent(const wxCloseEvent& event)
+ : wxEvent(event),
+ m_loggingOff(event.m_loggingOff),
+ m_veto(event.m_veto),
+ m_canVeto(event.m_canVeto) {}
+
+ void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
+ 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,
+ wxT("this flag is for end session events only") );
+
+ return m_loggingOff;
+ }
+
+ void Veto(bool veto = true)
+ {
+ // GetVeto() will return false anyhow...
+ wxCHECK_RET( m_canVeto,
+ wxT("call to Veto() ignored (can't veto this event)") );
+
+ m_veto = veto;
+ }
+ void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
+ 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,
+ m_veto,
+ m_canVeto;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent)
+};
+
+/*
+ wxEVT_SHOW
+ */
+
+class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent
+{
+public:
+ wxShowEvent(int winid = 0, bool show = false)
+ : wxEvent(winid, wxEVT_SHOW)
+ { m_show = show; }
+ wxShowEvent(const wxShowEvent& event)
+ : wxEvent(event)
+ { m_show = event.m_show; }
+
+ void SetShow(bool show) { m_show = show; }
+
+ // return true if the window was shown, false if hidden
+ bool IsShown() const { return m_show; }
+
+#if WXWIN_COMPATIBILITY_2_8
+ wxDEPRECATED( bool GetShow() const { return IsShown(); } )
+#endif
+
+ virtual wxEvent *Clone() const { return new wxShowEvent(*this); }
+
+protected:
+ bool m_show;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent)
+};
+
+/*
+ wxEVT_ICONIZE
+ */
+
+class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent
+{
+public:
+ wxIconizeEvent(int winid = 0, bool iconized = true)
+ : wxEvent(winid, wxEVT_ICONIZE)
+ { m_iconized = iconized; }
+ wxIconizeEvent(const wxIconizeEvent& event)
+ : wxEvent(event)
+ { m_iconized = event.m_iconized; }
+
+#if WXWIN_COMPATIBILITY_2_8
+ wxDEPRECATED( bool Iconized() const { return IsIconized(); } )
+#endif
+ // return true if the frame was iconized, false if restored
+ bool IsIconized() const { return m_iconized; }
+
+ virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); }
+
+protected:
+ bool m_iconized;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent)
+};
+/*
+ wxEVT_MAXIMIZE
+ */
+
+class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent
+{
+public:
+ wxMaximizeEvent(int winid = 0)
+ : wxEvent(winid, wxEVT_MAXIMIZE)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxMaximizeEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent)
+};
+
+// Joystick event class
+/*
+ wxEVT_JOY_BUTTON_DOWN,
+ wxEVT_JOY_BUTTON_UP,
+ wxEVT_JOY_MOVE,
+ wxEVT_JOY_ZMOVE
+*/
+
+// Which joystick? Same as Windows ids so no conversion necessary.
+enum
+{
+ wxJOYSTICK1,
+ wxJOYSTICK2
+};
+
+// Which button is down?
+enum
+{
+ wxJOY_BUTTON_ANY = -1,
+ wxJOY_BUTTON1 = 1,
+ wxJOY_BUTTON2 = 2,
+ wxJOY_BUTTON3 = 4,
+ wxJOY_BUTTON4 = 8
+};
+
+class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent
+{
+protected:
+ wxPoint m_pos;
+ int m_zPosition;
+ int m_buttonChange; // Which button changed?
+ int m_buttonState; // Which buttons are down?
+ int m_joyStick; // Which joystick?
+
+public:
+ wxJoystickEvent(wxEventType type = wxEVT_NULL,
+ int state = 0,
+ int joystick = wxJOYSTICK1,
+ int change = 0)
+ : wxEvent(0, type),
+ m_pos(),
+ m_zPosition(0),
+ m_buttonChange(change),
+ m_buttonState(state),
+ m_joyStick(joystick)
+ {
+ }
+ wxJoystickEvent(const wxJoystickEvent& event)
+ : wxEvent(event),
+ m_pos(event.m_pos),
+ m_zPosition(event.m_zPosition),
+ m_buttonChange(event.m_buttonChange),
+ m_buttonState(event.m_buttonState),
+ m_joyStick(event.m_joyStick)
+ { }
+
+ wxPoint GetPosition() const { return m_pos; }
+ int GetZPosition() const { return m_zPosition; }
+ int GetButtonState() const { return m_buttonState; }
+ int GetButtonChange() const { return m_buttonChange; }
+ int GetJoystick() const { return m_joyStick; }
+
+ void SetJoystick(int stick) { m_joyStick = stick; }
+ void SetButtonState(int state) { m_buttonState = state; }
+ void SetButtonChange(int change) { m_buttonChange = change; }
+ void SetPosition(const wxPoint& pos) { m_pos = pos; }
+ void SetZPosition(int zPos) { m_zPosition = zPos; }
+
+ // Was it a button event? (*doesn't* mean: is any button *down*?)
+ bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) ||
+ (GetEventType() == wxEVT_JOY_BUTTON_UP)); }
+
+ // Was it a move event?
+ bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); }
+
+ // Was it a zmove event?
+ bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); }
+
+ // Was it a down event from button 1, 2, 3, 4 or any?
+ bool ButtonDown(int but = wxJOY_BUTTON_ANY) const
+ { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) &&
+ ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
+
+ // Was it a up event from button 1, 2, 3 or any?
+ bool ButtonUp(int but = wxJOY_BUTTON_ANY) const
+ { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) &&
+ ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
+
+ // Was the given button 1,2,3,4 or any in Down state?
+ bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const
+ { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) ||
+ ((m_buttonState & but) == but)); }
+
+ virtual wxEvent *Clone() const { return new wxJoystickEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent)
+};
+
+// Drop files event class
+/*
+ wxEVT_DROP_FILES
+ */
+
+class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent
+{
+public:
+ int m_noFiles;
+ wxPoint m_pos;
+ wxString* m_files;
+
+ wxDropFilesEvent(wxEventType type = wxEVT_NULL,
+ int noFiles = 0,
+ wxString *files = NULL)
+ : wxEvent(0, type),
+ m_noFiles(noFiles),
+ m_pos(),
+ m_files(files)
+ { }
+
+ // we need a copy ctor to avoid deleting m_files pointer twice
+ wxDropFilesEvent(const wxDropFilesEvent& other)
+ : wxEvent(other),
+ m_noFiles(other.m_noFiles),
+ m_pos(other.m_pos),
+ m_files(NULL)
+ {
+ 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 { return new wxDropFilesEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent)
+};
+
+// Update UI event
+/*
+ wxEVT_UPDATE_UI
+ */
+
+// Whether to always send update events to windows, or
+// to only send update events to those with the
+// wxWS_EX_PROCESS_UI_UPDATES style.
+
+enum wxUpdateUIMode
+{
+ // Send UI update events to all windows
+ wxUPDATE_UI_PROCESS_ALL,
+
+ // Send UI update events to windows that have
+ // the wxWS_EX_PROCESS_UI_UPDATES flag specified
+ wxUPDATE_UI_PROCESS_SPECIFIED
+};
+
+class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
+{
+public:
+ wxUpdateUIEvent(wxWindowID commandId = 0)
+ : wxCommandEvent(wxEVT_UPDATE_UI, commandId)
+ {
+ m_checked =
+ m_enabled =
+ m_shown =
+ m_setEnabled =
+ m_setShown =
+ m_setText =
+ m_setChecked = false;
+ }
+ wxUpdateUIEvent(const wxUpdateUIEvent& event)
+ : 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)
+ { }
+
+ 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.
+ // Set to -1 to disable updates, or to 0 to update as frequently as possible.
+ static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
+
+ // Returns the current interval between updates in milliseconds
+ static long GetUpdateInterval() { return sm_updateInterval; }
+
+ // Can we update this window?
+ static bool CanUpdate(wxWindowBase *win);
+
+ // Reset the update time to provide a delay until the next
+ // time we should update
+ static void ResetUpdateTime();
+
+ // Specify how wxWidgets will send update events: to
+ // all windows, or only to those which specify that they
+ // will process the events.
+ static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
+
+ // Returns the UI update mode
+ static wxUpdateUIMode GetMode() { return sm_updateMode; }
+
+ virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); }
+
+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;
+#if wxUSE_LONGLONG
+ static wxLongLong sm_lastUpdate;
+#endif
+ static long sm_updateInterval;
+ static wxUpdateUIMode sm_updateMode;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent)
+};
+
+/*
+ wxEVT_SYS_COLOUR_CHANGED
+ */
+
+// TODO: shouldn't all events record the window ID?
+class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent
+{
+public:
+ wxSysColourChangedEvent()
+ : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxSysColourChangedEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent)
+};
+
+/*
+ wxEVT_MOUSE_CAPTURE_CHANGED
+ The window losing the capture receives this message
+ (even if it released the capture itself).
+ */
+
+class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent
+{
+public:
+ wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = NULL)
+ : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED),
+ m_gainedCapture(gainedCapture)
+ { }
+
+ wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event)
+ : wxEvent(event),
+ m_gainedCapture(event.m_gainedCapture)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); }
+
+ wxWindow* GetCapturedWindow() const { return m_gainedCapture; }
+
+private:
+ wxWindow* m_gainedCapture;
+
+ 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
+ */
+class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent
+{
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent)
+
+public:
+ wxDisplayChangedEvent()
+ : wxEvent(0, wxEVT_DISPLAY_CHANGED)
+ { }
+
+ virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); }
+};
+
+/*
+ wxEVT_PALETTE_CHANGED
+ */
+
+class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent
+{
+public:
+ wxPaletteChangedEvent(wxWindowID winid = 0)
+ : wxEvent(winid, wxEVT_PALETTE_CHANGED),
+ m_changedWindow(NULL)
+ { }
+
+ wxPaletteChangedEvent(const wxPaletteChangedEvent& event)
+ : wxEvent(event),
+ m_changedWindow(event.m_changedWindow)
+ { }
+
+ void SetChangedWindow(wxWindow* win) { m_changedWindow = win; }
+ wxWindow* GetChangedWindow() const { return m_changedWindow; }
+
+ virtual wxEvent *Clone() const { return new wxPaletteChangedEvent(*this); }
+
+protected:
+ wxWindow* m_changedWindow;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent)
+};
+
+/*
+ wxEVT_QUERY_NEW_PALETTE
+ Indicates the window is getting keyboard focus and should re-do its palette.
+ */
+
+class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent
+{
+public:
+ wxQueryNewPaletteEvent(wxWindowID winid = 0)
+ : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE),
+ m_paletteRealized(false)
+ { }
+ wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent& event)
+ : wxEvent(event),
+ m_paletteRealized(event.m_paletteRealized)
+ { }
+
+ // App sets this if it changes the palette.
+ void SetPaletteRealized(bool realized) { m_paletteRealized = realized; }
+ bool GetPaletteRealized() const { return m_paletteRealized; }
+
+ virtual wxEvent *Clone() const { return new wxQueryNewPaletteEvent(*this); }
+
+protected:
+ bool m_paletteRealized;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent)
+};
+
+/*
+ Event generated by dialog navigation keys
+ wxEVT_NAVIGATION_KEY
+ */
+// NB: don't derive from command event to avoid being propagated to the parent
+class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent
+{
+public:
+ wxNavigationKeyEvent()
+ : wxEvent(0, wxEVT_NAVIGATION_KEY),
+ m_flags(IsForward | FromTab), // defaults are for TAB
+ m_focus(NULL)
+ {
+ m_propagationLevel = wxEVENT_PROPAGATE_NONE;
+ }
+
+ wxNavigationKeyEvent(const wxNavigationKeyEvent& event)
+ : wxEvent(event),
+ m_flags(event.m_flags),
+ m_focus(event.m_focus)
+ { }
+
+ // direction: forward (true) or backward (false)
+ bool GetDirection() const
+ { return (m_flags & IsForward) != 0; }
+ void SetDirection(bool bForward)
+ { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; }
+
+ // it may be a window change event (MDI, notebook pages...) or a control
+ // change event
+ bool IsWindowChange() const
+ { return (m_flags & WinChange) != 0; }
+ 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; }
+ void SetCurrentFocus(wxWindow *win) { m_focus = win; }
+
+ // Set flags
+ void SetFlags(long flags) { m_flags = flags; }
+
+ virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); }
+
+ enum wxNavigationKeyEventFlags
+ {
+ IsBackward = 0x0000,
+ IsForward = 0x0001,
+ WinChange = 0x0002,
+ FromTab = 0x0004
+ };
+
+ long m_flags;
+ wxWindow *m_focus;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent)
+};
+
+// Window creation/destruction events: the first is sent as soon as window is
+// created (i.e. the underlying GUI object exists), but when the C++ object is
+// fully initialized (so virtual functions may be called). The second,
+// wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
+// still safe to call virtual functions at this moment
+/*
+ wxEVT_CREATE
+ wxEVT_DESTROY
+ */
+
+class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent
+{
+public:
+ wxWindowCreateEvent(wxWindow *win = NULL);
+
+ wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
+
+ virtual wxEvent *Clone() const { return new wxWindowCreateEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent)
+};
+
+class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent
+{
+public:
+ wxWindowDestroyEvent(wxWindow *win = NULL);
+
+ wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
+
+ virtual wxEvent *Clone() const { return new wxWindowDestroyEvent(*this); }
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent)
+};
+
+// A help event is sent when the user clicks on a window in context-help mode.
+/*
+ wxEVT_HELP
+ wxEVT_DETAILED_HELP
+*/
+
+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,
+ Origin origin = Origin_Unknown)
+ : wxCommandEvent(type, winid),
+ 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_origin(event.m_origin)
+ { }
+
+ // 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; }
+
+ 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_TEXT_COPY
+wxEVT_TEXT_CUT
+wxEVT_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
+// Under other systems it may have to be generated from a right click event
+/*
+ wxEVT_CONTEXT_MENU
+*/
+
+class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent
+{
+public:
+ wxContextMenuEvent(wxEventType type = wxEVT_NULL,
+ wxWindowID winid = 0,
+ const wxPoint& pt = wxDefaultPosition)
+ : wxCommandEvent(type, winid),
+ m_pos(pt)
+ { }
+ wxContextMenuEvent(const wxContextMenuEvent& event)
+ : wxCommandEvent(event),
+ m_pos(event.m_pos)
+ { }
+
+ // Position of event (in screen coordinates)
+ const wxPoint& GetPosition() const { return m_pos; }
+ void SetPosition(const wxPoint& pos) { m_pos = pos; }
+
+ virtual wxEvent *Clone() const { return new wxContextMenuEvent(*this); }
+
+protected:
+ wxPoint m_pos;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent)
+};
+
+
+/* TODO
+ 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
+ // wxEVT_FONT_CHANGED to all other windows (maybe).
+ wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
+ wxEVT_MEASURE_ITEM,
+ wxEVT_COMPARE_ITEM
+*/
+
+#endif // wxUSE_GUI
+
+
+// ============================================================================
+// event handler and related classes
+// ============================================================================
+
+
+// struct containing the members common to static and dynamic event tables
+// entries
+struct WXDLLIMPEXP_BASE wxEventTableEntryBase
+{
+ wxEventTableEntryBase(int winid, int idLast,
+ wxEventFunctor* fn, wxObject *data)
+ : m_id(winid),
+ m_lastId(idLast),
+ m_fn(fn),
+ m_callbackUserData(data)
+ {
+ wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast,
+ "invalid IDs range: lower bound > upper bound" );
+ }
+
+ wxEventTableEntryBase( const wxEventTableEntryBase &entry )
+ : m_id( entry.m_id ),
+ m_lastId( entry.m_lastId ),
+ m_fn( entry.m_fn ),
+ m_callbackUserData( entry.m_callbackUserData )
+ {
+ // This is a 'hack' to ensure that only one instance tries to delete
+ // the functor pointer. It is safe as long as the only place where the
+ // copy constructor is being called is when the static event tables are
+ // being initialized (a temporary instance is created and then this
+ // constructor is called).
+
+ const_cast<wxEventTableEntryBase&>( entry ).m_fn = NULL;
+ }
+
+ ~wxEventTableEntryBase()
+ {
+ delete m_fn;
+ }
+
+ // the range of ids for this entry: if m_lastId == wxID_ANY, the range
+ // consists only of m_id, otherwise it is m_id..m_lastId inclusive
+ int m_id,
+ m_lastId;
+
+ // function/method/functor to call
+ wxEventFunctor* m_fn;
+
+ // arbitrary user data associated with the callback
+ wxObject* m_callbackUserData;
+
+private:
+ wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase);
+};
+
+// an entry from a static event table
+struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase
+{
+ wxEventTableEntry(const int& evType, int winid, int idLast,
+ wxEventFunctor* fn, wxObject *data)
+ : wxEventTableEntryBase(winid, idLast, fn, data),
+ m_eventType(evType)
+ { }
+
+ // the reference to event type: this allows us to not care about the
+ // (undefined) order in which the event table entries and the event types
+ // are initialized: initially the value of this reference might be
+ // invalid, but by the time it is used for the first time, all global
+ // objects will have been initialized (including the event type constants)
+ // and so it will have the correct value when it is needed
+ const int& m_eventType;
+
+private:
+ wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry);
+};
+
+// an entry used in dynamic event table managed by wxEvtHandler::Connect()
+struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
+{
+ wxDynamicEventTableEntry(int evType, int winid, int idLast,
+ wxEventFunctor* fn, wxObject *data)
+ : wxEventTableEntryBase(winid, idLast, fn, data),
+ m_eventType(evType)
+ { }
+
+ // not a reference here as we can't keep a reference to a temporary int
+ // created to wrap the constant value typically passed to Connect() - nor
+ // do we need it
+ int m_eventType;
+
+private:
+ wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry);
+};
+
+// ----------------------------------------------------------------------------
+// wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
+// ----------------------------------------------------------------------------
+
+struct WXDLLIMPEXP_BASE wxEventTable
+{
+ const wxEventTable *baseTable; // base event table (next in chain)
+ const wxEventTableEntry *entries; // bottom of entry array
+};
+
+// ----------------------------------------------------------------------------
+// wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
+// ----------------------------------------------------------------------------
+
+WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray);
+
+class WXDLLIMPEXP_BASE wxEventHashTable
+{
+private:
+ // Internal data structs
+ struct EventTypeTable
+ {
+ wxEventType eventType;
+ wxEventTableEntryPointerArray eventEntryTable;
+ };
+ typedef EventTypeTable* EventTypeTablePointer;
+
+public:
+ // Constructor, needs the event table it needs to hash later on.
+ // Note: hashing of the event table is not done in the constructor as it
+ // can be that the event table is not yet full initialize, the hash
+ // will gets initialized when handling the first event look-up request.
+ wxEventHashTable(const wxEventTable &table);
+ // Destructor.
+ ~wxEventHashTable();
+
+ // Handle the given event, in other words search the event table hash
+ // and call self->ProcessEvent() if a match was found.
+ bool HandleEvent(wxEvent& event, wxEvtHandler *self);
+
+ // Clear table
+ void Clear();
+
+#if wxUSE_MEMORY_TRACING
+ // Clear all tables: only used to work around problems in memory tracing
+ // code
+ static void ClearAll();
+#endif // wxUSE_MEMORY_TRACING
+
+protected:
+ // Init the hash table with the entries of the static event table.
+ void InitHashTable();
+ // Helper function of InitHashTable() to insert 1 entry into the hash table.
+ void AddEntry(const wxEventTableEntry &entry);
+ // Allocate and init with null pointers the base hash table.
+ void AllocEventTypeTable(size_t size);
+ // Grow the hash table in size and transfer all items currently
+ // in the table to the correct location in the new table.
+ void GrowEventTypeTable();
+
+protected:
+ const wxEventTable &m_table;
+ bool m_rebuildHash;
+
+ size_t m_size;
+ EventTypeTablePointer *m_eventTypeTable;
+
+ static wxEventHashTable* sm_first;
+ wxEventHashTable* m_previous;
+ wxEventHashTable* m_next;
+
+ wxDECLARE_NO_COPY_CLASS(wxEventHashTable);
+};
+
+// ----------------------------------------------------------------------------
+// wxEvtHandler: the base class for all objects handling wxWidgets events
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
+ , public wxTrackable
+{
+public:
+ wxEvtHandler();
+ virtual ~wxEvtHandler();
+
+
+ // Event handler chain
+ // -------------------
+
+ wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
+ wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
+ virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
+ virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
+
+ void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
+ bool GetEvtHandlerEnabled() const { return m_enabled; }
+
+ void Unlink();
+ bool IsUnlinked() const;