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 // ----------------------------------------------------------------------------
19 #pragma interface "textctrlbase.h"
23 #include "wx/control.h" // the base class
25 // 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow
26 // and streambuf: it complains about deriving a huge class from the huge class
27 // streambuf. !! Also, can't use streambuf if making or using a DLL :-(
29 #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
30 #define NO_TEXT_WINDOW_STREAM
33 #ifndef NO_TEXT_WINDOW_STREAM
34 #if wxUSE_STD_IOSTREAM
35 #include "wx/ioswrap.h" // for iostream classes if we need them
36 #else // !wxUSE_STD_IOSTREAM
37 // can't compile this feature in if we don't use streams at all
38 #define NO_TEXT_WINDOW_STREAM
39 #endif // wxUSE_STD_IOSTREAM/!wxUSE_STD_IOSTREAM
42 class WXDLLEXPORT wxTextCtrl
;
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
49 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
51 // ----------------------------------------------------------------------------
52 // wxTextCtrl: a single or multiple line text zone where user can enter and
54 // ----------------------------------------------------------------------------
56 class WXDLLEXPORT wxTextCtrlBase
: public wxControl
57 #ifndef NO_TEXT_WINDOW_STREAM
71 virtual wxString
GetValue() const = 0;
72 virtual void SetValue(const wxString
& value
) = 0;
74 virtual int GetLineLength(long lineNo
) const = 0;
75 virtual wxString
GetLineText(long lineNo
) const = 0;
76 virtual int GetNumberOfLines() const = 0;
78 virtual bool IsModified() const = 0;
79 virtual bool IsEditable() const = 0;
81 // If the return values from and to are the same, there is no selection.
82 virtual void GetSelection(long* from
, long* to
) const = 0;
88 virtual void Clear() = 0;
89 virtual void Replace(long from
, long to
, const wxString
& value
) = 0;
90 virtual void Remove(long from
, long to
) = 0;
92 // load/save the controls contents from/to the file
93 virtual bool LoadFile(const wxString
& file
);
94 virtual bool SaveFile(const wxString
& file
= wxEmptyString
);
96 // clears the dirty flag
97 virtual void DiscardEdits() = 0;
99 // writing text inserts it at the current position, appending always
100 // inserts it at the end
101 virtual void WriteText(const wxString
& text
) = 0;
102 virtual void AppendText(const wxString
& text
) = 0;
104 // translate between the position (which is just an index in the text ctrl
105 // considering all its contents as a single strings) and (x, y) coordinates
106 // which represent column and line.
107 virtual long XYToPosition(long x
, long y
) const = 0;
108 virtual bool PositionToXY(long pos
, long *x
, long *y
) const = 0;
110 virtual void ShowPosition(long pos
) = 0;
112 // Clipboard operations
113 virtual void Copy() = 0;
114 virtual void Cut() = 0;
115 virtual void Paste() = 0;
117 virtual bool CanCopy() const = 0;
118 virtual bool CanCut() const = 0;
119 virtual bool CanPaste() const = 0;
122 virtual void Undo() = 0;
123 virtual void Redo() = 0;
125 virtual bool CanUndo() const = 0;
126 virtual bool CanRedo() const = 0;
129 virtual void SetInsertionPoint(long pos
) = 0;
130 virtual void SetInsertionPointEnd() = 0;
131 virtual long GetInsertionPoint() const = 0;
132 virtual long GetLastPosition() const = 0;
134 virtual void SetSelection(long from
, long to
) = 0;
135 virtual void SetEditable(bool editable
) = 0;
138 #ifndef NO_TEXT_WINDOW_STREAM
142 #endif // NO_TEXT_WINDOW_STREAM
144 // stream-like insertion operators: these are always available, whether we
145 // were, or not, compiled with streambuf support
146 wxTextCtrl
& operator<<(const wxString
& s
);
147 wxTextCtrl
& operator<<(int i
);
148 wxTextCtrl
& operator<<(long i
);
149 wxTextCtrl
& operator<<(float f
);
150 wxTextCtrl
& operator<<(double d
);
151 wxTextCtrl
& operator<<(const wxChar c
);
153 // obsolete functions
154 #if WXWIN_COMPATIBILITY
155 bool Modified() const { return IsModified(); }
159 // the name of the last file loaded with LoadFile() which will be used by
160 // SaveFile() by default
164 // ----------------------------------------------------------------------------
165 // include the platform-dependent class definition
166 // ----------------------------------------------------------------------------
168 #if defined(__WXMSW__)
169 #include "wx/msw/textctrl.h"
170 #elif defined(__WXMOTIF__)
171 #include "wx/motif/textctrl.h"
172 #elif defined(__WXGTK__)
173 #include "wx/gtk/textctrl.h"
174 #elif defined(__WXQT__)
175 #include "wx/qt/textctrl.h"
176 #elif defined(__WXMAC__)
177 #include "wx/mac/textctrl.h"
178 #elif defined(__WXPM__)
179 #include "wx/os2/textctrl.h"
180 #elif defined(__WXSTUBS__)
181 #include "wx/stubs/textctrl.h"
185 // _WX_TEXTCTRL_H_BASE_