X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9806a823b04b05f1f07121526e5a9fafb74689cd..86adc75813eedc3eabf746e30c8a571d528439a3:/include/wx/textctrl.h?ds=sidebyside diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index eb69adfdc4..33bb8b47d0 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -25,7 +25,8 @@ #if wxUSE_TEXTCTRL #include "wx/control.h" // the base class -#include "wx/dynarray.h" +#include "wx/dynarray.h" // wxArrayInt +#include "wx/gdicmn.h" // wxPoint // 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow // and streambuf: it complains about deriving a huge class from the huge class @@ -48,6 +49,17 @@ class WXDLLEXPORT wxTextCtrl; class WXDLLEXPORT wxTextCtrlBase; +// ---------------------------------------------------------------------------- +// wxTextCtrl types +// ---------------------------------------------------------------------------- + +// wxTextPos is the position in the text +typedef long wxTextPos; + +// wxTextCoord is the line or row number (which should have been unsigned but +// is long for backwards compatibility) +typedef long wxTextCoord; + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -102,6 +114,21 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; // wxTE_RICH controls - can be used together with or instead of wxTE_RICH #define wxTE_RICH2 0x8000 +// ---------------------------------------------------------------------------- +// wxTextCtrl::HitTest return values +// ---------------------------------------------------------------------------- + +// the point asked is ... +enum wxTextCtrlHitTestResult +{ + wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented + wxTE_HT_BEFORE, // either to the left or upper + wxTE_HT_ON_TEXT, // directly on + wxTE_HT_BELOW, // below [the last line] + wxTE_HT_BEYOND // after [the end of line] +}; +// ... the character returned + // ---------------------------------------------------------------------------- // Types for wxTextAttr // ---------------------------------------------------------------------------- @@ -262,7 +289,8 @@ public: virtual bool LoadFile(const wxString& file); virtual bool SaveFile(const wxString& file = wxEmptyString); - // clears the dirty flag + // sets/clears the dirty flag + virtual void MarkDirty() = 0; virtual void DiscardEdits() = 0; // set the max number of characters which may be entered in a single line @@ -294,6 +322,14 @@ public: virtual void ShowPosition(long pos) = 0; + // find the character at position given in pixels + // + // NB: pt is in device coords (not adjusted for the client area origin nor + // scrolling) + virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, + wxTextCoord *col, + wxTextCoord *row) const; + // Clipboard operations virtual void Copy() = 0; virtual void Cut() = 0; @@ -335,7 +371,9 @@ public: wxTextCtrl& operator<<(const wxChar c); // do the window-specific processing after processing the update event - virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; + virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); + + virtual bool ShouldInheritColours() const { return false; } protected: // the name of the last file loaded with LoadFile() which will be used by @@ -421,10 +459,10 @@ public: typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); -#define EVT_TEXT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), -#define EVT_TEXT_ENTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), -#define EVT_TEXT_URL(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_URL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxTextUrlEventFunction) & fn, (wxObject *) NULL ), -#define EVT_TEXT_MAXLEN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_MAXLEN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ), +#define EVT_TEXT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, & fn ), (wxObject *) NULL ), +#define EVT_TEXT_ENTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, & fn ), (wxObject *) NULL ), +#define EVT_TEXT_URL(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_URL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) wxStaticCastEvent( wxTextUrlEventFunction, & fn ), (wxObject *) NULL ), +#define EVT_TEXT_MAXLEN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_MAXLEN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, & fn ), (wxObject *) NULL ), #ifndef NO_TEXT_WINDOW_STREAM @@ -436,7 +474,7 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); class WXDLLEXPORT wxStreamToTextRedirector { private: - void Init() + void Init(wxTextCtrl *text) { m_sbufOld = m_ostr.rdbuf(); m_ostr.rdbuf(text); @@ -446,13 +484,13 @@ public: wxStreamToTextRedirector(wxTextCtrl *text) : m_ostr(wxSTD cout) { - Init(); + Init(text); } wxStreamToTextRedirector(wxTextCtrl *text, wxSTD ostream *ostr) : m_ostr(*ostr) { - Init(); + Init(text); } ~wxStreamToTextRedirector()