// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(__APPLE__)
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "textctrlbase.h"
#endif
#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
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
// 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
// ----------------------------------------------------------------------------
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
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;
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
// the text style which will be used for any new text added to the control
wxTextAttr m_defaultStyle;
+
+ DECLARE_NO_COPY_CLASS(wxTextCtrlBase)
};
// ----------------------------------------------------------------------------
m_end;
private:
- DECLARE_DYNAMIC_CLASS(wxTextUrlEvent)
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent)
public:
// for wxWin RTTI only, don't use
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
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);