+// ----------------------------------------------------------------------------
+// wxTextCtrl events
+// ----------------------------------------------------------------------------
+
+#if !WXWIN_COMPATIBILITY_EVENT_TYPES
+
+BEGIN_DECLARE_EVENT_TYPES()
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14)
+END_DECLARE_EVENT_TYPES()
+
+#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
+
+class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent
+{
+public:
+ wxTextUrlEvent(int winid, const wxMouseEvent& evtMouse,
+ long start, long end)
+ : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid)
+ , m_evtMouse(evtMouse), m_start(start), m_end(end)
+ { }
+
+ // get the mouse event which happend over the URL
+ const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; }
+
+ // get the start of the URL
+ long GetURLStart() const { return m_start; }
+
+ // get the end of the URL
+ long GetURLEnd() const { return m_end; }
+
+protected:
+ // the corresponding mouse event
+ wxMouseEvent m_evtMouse;
+
+ // the start and end indices of the URL in the text control
+ long m_start,
+ m_end;
+
+private:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent)
+
+public:
+ // for wxWin RTTI only, don't use
+ wxTextUrlEvent() : m_evtMouse(), m_start(0), m_end(0) { }
+};
+
+typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&);
+
+#define wxTextEventHandler(func) wxCommandEventHandler(func)
+#define wxTextUrlEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTextUrlEventFunction, &func)
+
+#define wx__DECLARE_TEXTEVT(evt, id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextEventHandler(fn))
+
+#define wx__DECLARE_TEXTURLEVT(evt, id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextUrlEventHandler(fn))
+
+#define EVT_TEXT(id, fn) wx__DECLARE_TEXTEVT(UPDATED, id, fn)
+#define EVT_TEXT_ENTER(id, fn) wx__DECLARE_TEXTEVT(ENTER, id, fn)
+#define EVT_TEXT_URL(id, fn) wx__DECLARE_TEXTURLEVT(URL, id, fn)
+#define EVT_TEXT_MAXLEN(id, fn) wx__DECLARE_TEXTEVT(MAXLEN, id, fn)
+
+#if wxHAS_TEXT_WINDOW_STREAM
+
+// ----------------------------------------------------------------------------
+// wxStreamToTextRedirector: this class redirects all data sent to the given
+// C++ stream to the wxTextCtrl given to its ctor during its lifetime.
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStreamToTextRedirector
+{
+private:
+ void Init(wxTextCtrl *text)
+ {
+ m_sbufOld = m_ostr.rdbuf();
+ m_ostr.rdbuf(text);
+ }
+
+public:
+ wxStreamToTextRedirector(wxTextCtrl *text)
+ : m_ostr(wxSTD cout)
+ {
+ Init(text);
+ }
+
+ wxStreamToTextRedirector(wxTextCtrl *text, wxSTD ostream *ostr)
+ : m_ostr(*ostr)
+ {
+ Init(text);
+ }
+
+ ~wxStreamToTextRedirector()
+ {
+ m_ostr.rdbuf(m_sbufOld);
+ }
+
+private:
+ // the stream we're redirecting
+ wxSTD ostream& m_ostr;
+
+ // the old streambuf (before we changed it)
+ wxSTD streambuf *m_sbufOld;
+};
+
+#endif // wxHAS_TEXT_WINDOW_STREAM
+