1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextCtrlBase class - the interface of wxTextCtrl
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_BASE_
13 #define _WX_TEXTCTRL_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #include "wx/control.h" // the base class
22 // 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow
23 // and streambuf: it complains about deriving a huge class from the huge class
24 // streambuf. !! Also, can't use streambuf if making or using a DLL :-(
26 #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
27 #define NO_TEXT_WINDOW_STREAM
30 #ifndef NO_TEXT_WINDOW_STREAM
31 #ifdef wxUSE_STD_IOSTREAM
32 #include "ioswrap.h" // for iostream classes if we need them
33 #else // !wxUSE_STD_IOSTREAM
34 // can't compile this feature in if we don't use streams at all
35 #define NO_TEXT_WINDOW_STREAM
36 #endif // wxUSE_STD_IOSTREAM/!wxUSE_STD_IOSTREAM
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
44 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
46 // ----------------------------------------------------------------------------
47 // wxTextCtrl: a single or multiple line text zone where user can enter and
49 // ----------------------------------------------------------------------------
51 class WXDLLEXPORT wxTextCtrlBase
: public wxControl
52 #ifndef NO_TEXT_WINDOW_STREAM
66 virtual wxString
GetValue() const = 0;
67 virtual void SetValue(const wxString
& value
) = 0;
69 virtual int GetLineLength(long lineNo
) const = 0;
70 virtual wxString
GetLineText(long lineNo
) const = 0;
71 virtual int GetNumberOfLines() const = 0;
73 virtual bool IsModified() const = 0;
74 virtual bool IsEditable() const = 0;
76 // If the return values from and to are the same, there is no selection.
77 virtual void GetSelection(long* from
, long* to
) const = 0;
83 virtual void Clear() = 0;
84 virtual void Replace(long from
, long to
, const wxString
& value
) = 0;
85 virtual void Remove(long from
, long to
) = 0;
87 // load/save the controls contents from/to the file
88 virtual bool LoadFile(const wxString
& file
);
89 virtual bool SaveFile(const wxString
& file
= wxEmptyString
);
91 // clears the dirty flag
92 virtual void DiscardEdits() = 0;
94 // writing text inserts it at the current position, appending always
95 // inserts it at the end
96 virtual void WriteText(const wxString
& text
) = 0;
97 virtual void AppendText(const wxString
& text
) = 0;
99 // translate between the position (which is just an index in the text ctrl
100 // considering all its contents as a single strings) and (x, y) coordinates
101 // which represent column and line.
102 virtual long XYToPosition(long x
, long y
) const = 0;
103 virtual void PositionToXY(long pos
, long *x
, long *y
) const = 0;
105 virtual void ShowPosition(long pos
) = 0;
107 // Clipboard operations
108 virtual void Copy() = 0;
109 virtual void Cut() = 0;
110 virtual void Paste() = 0;
112 virtual bool CanCopy() const = 0;
113 virtual bool CanCut() const = 0;
114 virtual bool CanPaste() const = 0;
117 virtual void Undo() = 0;
118 virtual void Redo() = 0;
120 virtual bool CanUndo() const = 0;
121 virtual bool CanRedo() const = 0;
124 virtual void SetInsertionPoint(long pos
) = 0;
125 virtual void SetInsertionPointEnd() = 0;
126 virtual long GetInsertionPoint() const = 0;
127 virtual long GetLastPosition() const = 0;
129 virtual void SetSelection(long from
, long to
) = 0;
130 virtual void SetEditable(bool editable
) = 0;
133 #ifndef NO_TEXT_WINDOW_STREAM
137 #endif // NO_TEXT_WINDOW_STREAM
139 // stream-like insertion operators: these are always available, whether we
140 // were, or not, compiled with streambuf support
141 wxTextCtrl
& operator<<(const wxString
& s
);
142 wxTextCtrl
& operator<<(int i
);
143 wxTextCtrl
& operator<<(long i
);
144 wxTextCtrl
& operator<<(float f
);
145 wxTextCtrl
& operator<<(double d
);
146 wxTextCtrl
& operator<<(const char c
);
148 // obsolete functions
149 #if WXWIN_COMPATIBILITY
150 bool Modified() const { return IsModified(); }
154 // the name of the last file loaded with LoadFile() which will be used by
155 // SaveFile() by default
159 // ----------------------------------------------------------------------------
160 // include the platform-dependent class definition
161 // ----------------------------------------------------------------------------
163 #if defined(__WXMSW__)
164 #include "wx/msw/textctrl.h"
165 #elif defined(__WXMOTIF__)
166 #include "wx/motif/textctrl.h"
167 #elif defined(__WXGTK__)
168 #include "wx/gtk/textctrl.h"
169 #elif defined(__WXQT__)
170 #include "wx/qt/textctrl.h"
171 #elif defined(__WXMAC__)
172 #include "wx/mac/textctrl.h"
173 #elif defined(__WXSTUBS__)
174 #include "wx/stubs/textctrl.h"
178 // _WX_TEXTCTRL_H_BASE_