X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39af974ef7846e26686ae39d74e4696c1fef0c3..b8e7b6738fe00529fdeae26e6cfea1ccc2a00a76:/include/wx/textctrl.h diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 9e12d0a49d..340e4bf278 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -16,7 +16,7 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(__APPLE__) +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "textctrlbase.h" #endif @@ -25,14 +25,15 @@ #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 // streambuf. !! Also, can't use streambuf if making or using a DLL :-( #if (defined(__BORLANDC__)) || defined(__MWERKS__) || \ - defined(WXUSINGDLL) || defined(WXMAKINGDLL) + (defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL))) #define NO_TEXT_WINDOW_STREAM #endif @@ -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,12 +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); - // obsolete functions -#if WXWIN_COMPATIBILITY - bool Modified() const { return IsModified(); } -#endif + virtual bool ShouldInheritColours() const { return false; } protected: // the name of the last file loaded with LoadFile() which will be used by @@ -349,6 +382,8 @@ protected: // the text style which will be used for any new text added to the control wxTextAttr m_defaultStyle; + + DECLARE_NO_COPY_CLASS(wxTextCtrlBase) }; // ---------------------------------------------------------------------------- @@ -415,7 +450,7 @@ protected: m_end; private: - DECLARE_DYNAMIC_CLASS(wxTextUrlEvent) + DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent) public: // for wxWin RTTI only, don't use @@ -424,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 @@ -438,14 +473,26 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); class WXDLLEXPORT wxStreamToTextRedirector { -public: - wxStreamToTextRedirector(wxTextCtrl *text, wxSTD ostream *ostr = NULL) - : m_ostr(ostr ? *ostr : wxSTD cout) +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);