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 #if wxUSE_STD_IOSTREAM
32 #include "wx/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 class WXDLLEXPORT wxTextCtrl
;
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
46 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
48 // ----------------------------------------------------------------------------
49 // wxTextCtrl: a single or multiple line text zone where user can enter and
51 // ----------------------------------------------------------------------------
53 class WXDLLEXPORT wxTextCtrlBase
: public wxControl
54 #ifndef NO_TEXT_WINDOW_STREAM
68 virtual wxString
GetValue() const = 0;
69 virtual void SetValue(const wxString
& value
) = 0;
71 virtual int GetLineLength(long lineNo
) const = 0;
72 virtual wxString
GetLineText(long lineNo
) const = 0;
73 virtual int GetNumberOfLines() const = 0;
75 virtual bool IsModified() const = 0;
76 virtual bool IsEditable() const = 0;
78 // If the return values from and to are the same, there is no selection.
79 virtual void GetSelection(long* from
, long* to
) const = 0;
85 virtual void Clear() = 0;
86 virtual void Replace(long from
, long to
, const wxString
& value
) = 0;
87 virtual void Remove(long from
, long to
) = 0;
89 // load/save the controls contents from/to the file
90 virtual bool LoadFile(const wxString
& file
);
91 virtual bool SaveFile(const wxString
& file
= wxEmptyString
);
93 // clears the dirty flag
94 virtual void DiscardEdits() = 0;
96 // writing text inserts it at the current position, appending always
97 // inserts it at the end
98 virtual void WriteText(const wxString
& text
) = 0;
99 virtual void AppendText(const wxString
& text
) = 0;
101 // translate between the position (which is just an index in the text ctrl
102 // considering all its contents as a single strings) and (x, y) coordinates
103 // which represent column and line.
104 virtual long XYToPosition(long x
, long y
) const = 0;
105 virtual bool PositionToXY(long pos
, long *x
, long *y
) const = 0;
107 virtual void ShowPosition(long pos
) = 0;
109 // Clipboard operations
110 virtual void Copy() = 0;
111 virtual void Cut() = 0;
112 virtual void Paste() = 0;
114 virtual bool CanCopy() const = 0;
115 virtual bool CanCut() const = 0;
116 virtual bool CanPaste() const = 0;
119 virtual void Undo() = 0;
120 virtual void Redo() = 0;
122 virtual bool CanUndo() const = 0;
123 virtual bool CanRedo() const = 0;
126 virtual void SetInsertionPoint(long pos
) = 0;
127 virtual void SetInsertionPointEnd() = 0;
128 virtual long GetInsertionPoint() const = 0;
129 virtual long GetLastPosition() const = 0;
131 virtual void SetSelection(long from
, long to
) = 0;
132 virtual void SetEditable(bool editable
) = 0;
135 #ifndef NO_TEXT_WINDOW_STREAM
139 #endif // NO_TEXT_WINDOW_STREAM
141 // stream-like insertion operators: these are always available, whether we
142 // were, or not, compiled with streambuf support
143 wxTextCtrl
& operator<<(const wxString
& s
);
144 wxTextCtrl
& operator<<(int i
);
145 wxTextCtrl
& operator<<(long i
);
146 wxTextCtrl
& operator<<(float f
);
147 wxTextCtrl
& operator<<(double d
);
148 wxTextCtrl
& operator<<(const wxChar c
);
150 // obsolete functions
151 #if WXWIN_COMPATIBILITY
152 bool Modified() const { return IsModified(); }
156 // the name of the last file loaded with LoadFile() which will be used by
157 // SaveFile() by default
161 // ----------------------------------------------------------------------------
162 // include the platform-dependent class definition
163 // ----------------------------------------------------------------------------
165 #if defined(__WXMSW__)
166 #include "wx/msw/textctrl.h"
167 #elif defined(__WXMOTIF__)
168 #include "wx/motif/textctrl.h"
169 #elif defined(__WXGTK__)
170 #include "wx/gtk/textctrl.h"
171 #elif defined(__WXQT__)
172 #include "wx/qt/textctrl.h"
173 #elif defined(__WXMAC__)
174 #include "wx/mac/textctrl.h"
175 #elif defined(__WXPM__)
176 #include "wx/os2/textctrl.h"
177 #elif defined(__WXSTUBS__)
178 #include "wx/stubs/textctrl.h"
182 // _WX_TEXTCTRL_H_BASE_