X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e00a5d3ca15eec8db3e231d79d82ff6965e3466b..b8e7b6738fe00529fdeae26e6cfea1ccc2a00a76:/include/wx/textctrl.h?ds=sidebyside diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index c43869e819..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,12 +49,22 @@ 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 // ---------------------------------------------------------------------------- WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; // ---------------------------------------------------------------------------- // wxTextCtrl style flags @@ -103,6 +114,21 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; // 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 // ---------------------------------------------------------------------------- @@ -263,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 @@ -295,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,10 +370,10 @@ public: wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const wxChar c); - // obsolete functions -#if WXWIN_COMPATIBILITY - bool Modified() const { return IsModified(); } -#endif + // do the window-specific processing after processing the update 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 @@ -347,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) }; // ---------------------------------------------------------------------------- @@ -413,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 @@ -422,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,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);