]> git.saurik.com Git - wxWidgets.git/blob - include/wx/textctrl.h
converted to 16 colors
[wxWidgets.git] / include / wx / textctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: textctrl.h
3 // Purpose: wxTextCtrlBase class - the interface of wxTextCtrl
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 13.07.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_BASE_
13 #define _WX_TEXTCTRL_H_BASE_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20 #include "wx/control.h" // the base class
21
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 :-(
25
26 #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
27 #define NO_TEXT_WINDOW_STREAM
28 #endif
29
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
37 #endif
38
39 class WXDLLEXPORT wxTextCtrl;
40
41 // ----------------------------------------------------------------------------
42 // constants
43 // ----------------------------------------------------------------------------
44
45 WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
46 WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
47
48 // ----------------------------------------------------------------------------
49 // wxTextCtrl: a single or multiple line text zone where user can enter and
50 // edit text
51 // ----------------------------------------------------------------------------
52
53 class WXDLLEXPORT wxTextCtrlBase : public wxControl
54 #ifndef NO_TEXT_WINDOW_STREAM
55 , public streambuf
56 #endif
57
58 {
59 public:
60 // creation
61 // --------
62
63 wxTextCtrlBase();
64
65 // accessors
66 // ---------
67
68 virtual wxString GetValue() const = 0;
69 virtual void SetValue(const wxString& value) = 0;
70
71 virtual int GetLineLength(long lineNo) const = 0;
72 virtual wxString GetLineText(long lineNo) const = 0;
73 virtual int GetNumberOfLines() const = 0;
74
75 virtual bool IsModified() const = 0;
76 virtual bool IsEditable() const = 0;
77
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;
80
81 // operations
82 // ----------
83
84 // editing
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;
88
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);
92
93 // clears the dirty flag
94 virtual void DiscardEdits() = 0;
95
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;
100
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;
106
107 virtual void ShowPosition(long pos) = 0;
108
109 // Clipboard operations
110 virtual void Copy() = 0;
111 virtual void Cut() = 0;
112 virtual void Paste() = 0;
113
114 virtual bool CanCopy() const = 0;
115 virtual bool CanCut() const = 0;
116 virtual bool CanPaste() const = 0;
117
118 // Undo/redo
119 virtual void Undo() = 0;
120 virtual void Redo() = 0;
121
122 virtual bool CanUndo() const = 0;
123 virtual bool CanRedo() const = 0;
124
125 // Insertion point
126 virtual void SetInsertionPoint(long pos) = 0;
127 virtual void SetInsertionPointEnd() = 0;
128 virtual long GetInsertionPoint() const = 0;
129 virtual long GetLastPosition() const = 0;
130
131 virtual void SetSelection(long from, long to) = 0;
132 virtual void SetEditable(bool editable) = 0;
133
134 // streambuf methods
135 #ifndef NO_TEXT_WINDOW_STREAM
136 int overflow(int i);
137 int sync();
138 int underflow();
139 #endif // NO_TEXT_WINDOW_STREAM
140
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);
149
150 // obsolete functions
151 #if WXWIN_COMPATIBILITY
152 bool Modified() const { return IsModified(); }
153 #endif
154
155 private:
156 // the name of the last file loaded with LoadFile() which will be used by
157 // SaveFile() by default
158 wxString m_filename;
159 };
160
161 // ----------------------------------------------------------------------------
162 // include the platform-dependent class definition
163 // ----------------------------------------------------------------------------
164
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"
179 #endif
180
181 #endif
182 // _WX_TEXTCTRL_H_BASE_