+private:
+ wxEvent& m_event;
+
+ wxDECLARE_NO_COPY_CLASS(wxPropagateOnce);
+};
+
+// A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn()
+// return true for the handler passed to its ctor.
+class wxEventProcessInHandlerOnly
+{
+public:
+ wxEventProcessInHandlerOnly(wxEvent& event, wxEvtHandler *handler)
+ : m_event(event),
+ m_handlerToProcessOnlyInOld(event.m_handlerToProcessOnlyIn)
+ {
+ m_event.m_handlerToProcessOnlyIn = handler;
+ }
+
+ ~wxEventProcessInHandlerOnly()
+ {
+ m_event.m_handlerToProcessOnlyIn = m_handlerToProcessOnlyInOld;
+ }
+
+private:
+ wxEvent& m_event;
+ wxEvtHandler * const m_handlerToProcessOnlyInOld;
+
+ wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly);
+};
+
+
+class WXDLLIMPEXP_BASE wxEventBasicPayloadMixin
+{
+public:
+ wxEventBasicPayloadMixin()
+ : m_commandInt(0),
+ m_extraLong(0)
+ {
+ }
+
+ void SetString(const wxString& s) { m_cmdString = s; }
+ const wxString& GetString() const { return m_cmdString; }
+
+ void SetInt(int i) { m_commandInt = i; }
+ int GetInt() const { return m_commandInt; }
+
+ void SetExtraLong(long extraLong) { m_extraLong = extraLong; }
+ long GetExtraLong() const { return m_extraLong; }
+
+protected:
+ // Note: these variables have "cmd" or "command" in their name for backward compatibility:
+ // they used to be part of wxCommandEvent, not this mixin.
+ wxString m_cmdString; // String event argument
+ int m_commandInt;
+ long m_extraLong; // Additional information (e.g. select/deselect)
+
+ wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin);
+};
+
+class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin : public wxEventBasicPayloadMixin
+{
+public:
+ wxEventAnyPayloadMixin() : wxEventBasicPayloadMixin() {}
+
+#if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
+ template<typename T>
+ void SetPayload(const T& payload)
+ {
+ m_payload = payload;
+ }
+
+ template<typename T>
+ T GetPayload() const
+ {
+ return m_payload.As<T>();
+ }
+
+protected:
+ wxAny m_payload;
+#endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
+
+ wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin);
+};
+
+
+// Idle event
+/*
+ wxEVT_IDLE
+ */
+
+// Whether to always send idle events to windows, or
+// to only send update events to those with the
+// wxWS_EX_PROCESS_IDLE style.
+
+enum wxIdleMode
+{
+ // Send idle events to all windows
+ wxIDLE_PROCESS_ALL,
+
+ // Send idle events to windows that have
+ // the wxWS_EX_PROCESS_IDLE flag specified
+ wxIDLE_PROCESS_SPECIFIED
+};
+
+class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent
+{
+public:
+ wxIdleEvent()
+ : wxEvent(0, wxEVT_IDLE),
+ m_requestMore(false)
+ { }
+ wxIdleEvent(const wxIdleEvent& event)
+ : wxEvent(event),
+ m_requestMore(event.m_requestMore)
+ { }
+
+ void RequestMore(bool needMore = true) { m_requestMore = needMore; }
+ bool MoreRequested() const { return m_requestMore; }
+
+ virtual wxEvent *Clone() const { return new wxIdleEvent(*this); }
+
+ // Specify how wxWidgets will send idle events: to
+ // all windows, or only to those which specify that they
+ // will process the events.
+ static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
+
+ // Returns the idle event mode
+ static wxIdleMode GetMode() { return sm_idleMode; }
+
+protected:
+ bool m_requestMore;
+ static wxIdleMode sm_idleMode;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent)
+};
+
+
+// Thread event
+
+class WXDLLIMPEXP_BASE wxThreadEvent : public wxEvent,
+ public wxEventAnyPayloadMixin
+{
+public:
+ wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY)
+ : wxEvent(id, eventType)
+ { }
+
+ wxThreadEvent(const wxThreadEvent& event)
+ : wxEvent(event),
+ wxEventAnyPayloadMixin(event)
+ {
+ // make sure our string member (which uses COW, aka refcounting) is not
+ // shared by other wxString instances:
+ SetString(GetString().Clone());
+ }
+
+ virtual wxEvent *Clone() const
+ {
+ return new wxThreadEvent(*this);
+ }
+
+ // this is important to avoid that calling wxEventLoopBase::YieldFor thread events
+ // gets processed when this is unwanted:
+ virtual wxEventCategory GetEventCategory() const
+ { return wxEVT_CATEGORY_THREAD; }