]> git.saurik.com Git - wxWidgets.git/blame - include/wx/textctrl.h
applied patch 410892 (wxCopyFile uses ::CopyFile under Win32, has overwrite parameter)
[wxWidgets.git] / include / wx / textctrl.h
CommitLineData
a1b82138
VZ
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
34138703
JS
12#ifndef _WX_TEXTCTRL_H_BASE_
13#define _WX_TEXTCTRL_H_BASE_
c801d85f 14
a1b82138
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
bf3e0fbd
KB
18#ifdef __GNUG__
19 #pragma interface "textctrlbase.h"
20#endif
a1b82138
VZ
21
22#include "wx/defs.h"
23#include "wx/control.h" // the base class
24
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 :-(
28
29#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
30 #define NO_TEXT_WINDOW_STREAM
31#endif
32
33#ifndef NO_TEXT_WINDOW_STREAM
324dbfec 34 #if wxUSE_STD_IOSTREAM
bac507e0 35 #include "wx/ioswrap.h" // for iostream classes if we need them
a1b82138
VZ
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
40#endif
41
0efe5ba7
VZ
42class WXDLLEXPORT wxTextCtrl;
43
a1b82138
VZ
44// ----------------------------------------------------------------------------
45// constants
46// ----------------------------------------------------------------------------
47
48WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
49WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
50
51// ----------------------------------------------------------------------------
52// wxTextCtrl: a single or multiple line text zone where user can enter and
53// edit text
54// ----------------------------------------------------------------------------
55
56class WXDLLEXPORT wxTextCtrlBase : public wxControl
57#ifndef NO_TEXT_WINDOW_STREAM
58 , public streambuf
59#endif
60
61{
62public:
63 // creation
64 // --------
65
66 wxTextCtrlBase();
fa40e7a1 67 ~wxTextCtrlBase();
a1b82138
VZ
68
69 // accessors
70 // ---------
71
72 virtual wxString GetValue() const = 0;
73 virtual void SetValue(const wxString& value) = 0;
74
75 virtual int GetLineLength(long lineNo) const = 0;
76 virtual wxString GetLineText(long lineNo) const = 0;
77 virtual int GetNumberOfLines() const = 0;
78
79 virtual bool IsModified() const = 0;
80 virtual bool IsEditable() const = 0;
81
82 // If the return values from and to are the same, there is no selection.
83 virtual void GetSelection(long* from, long* to) const = 0;
84
85 // operations
86 // ----------
87
88 // editing
89 virtual void Clear() = 0;
90 virtual void Replace(long from, long to, const wxString& value) = 0;
91 virtual void Remove(long from, long to) = 0;
92
93 // load/save the controls contents from/to the file
94 virtual bool LoadFile(const wxString& file);
95 virtual bool SaveFile(const wxString& file = wxEmptyString);
96
97 // clears the dirty flag
98 virtual void DiscardEdits() = 0;
99
100 // writing text inserts it at the current position, appending always
101 // inserts it at the end
102 virtual void WriteText(const wxString& text) = 0;
103 virtual void AppendText(const wxString& text) = 0;
104
105 // translate between the position (which is just an index in the text ctrl
106 // considering all its contents as a single strings) and (x, y) coordinates
107 // which represent column and line.
108 virtual long XYToPosition(long x, long y) const = 0;
0efe5ba7 109 virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
a1b82138
VZ
110
111 virtual void ShowPosition(long pos) = 0;
112
113 // Clipboard operations
114 virtual void Copy() = 0;
115 virtual void Cut() = 0;
116 virtual void Paste() = 0;
117
118 virtual bool CanCopy() const = 0;
119 virtual bool CanCut() const = 0;
120 virtual bool CanPaste() const = 0;
121
122 // Undo/redo
123 virtual void Undo() = 0;
124 virtual void Redo() = 0;
125
126 virtual bool CanUndo() const = 0;
127 virtual bool CanRedo() const = 0;
128
129 // Insertion point
130 virtual void SetInsertionPoint(long pos) = 0;
131 virtual void SetInsertionPointEnd() = 0;
132 virtual long GetInsertionPoint() const = 0;
133 virtual long GetLastPosition() const = 0;
134
135 virtual void SetSelection(long from, long to) = 0;
136 virtual void SetEditable(bool editable) = 0;
137
138 // streambuf methods
139#ifndef NO_TEXT_WINDOW_STREAM
140 int overflow(int i);
141 int sync();
142 int underflow();
143#endif // NO_TEXT_WINDOW_STREAM
144
145 // stream-like insertion operators: these are always available, whether we
146 // were, or not, compiled with streambuf support
147 wxTextCtrl& operator<<(const wxString& s);
148 wxTextCtrl& operator<<(int i);
149 wxTextCtrl& operator<<(long i);
150 wxTextCtrl& operator<<(float f);
151 wxTextCtrl& operator<<(double d);
a324a7bc 152 wxTextCtrl& operator<<(const wxChar c);
a1b82138
VZ
153
154 // obsolete functions
155#if WXWIN_COMPATIBILITY
156 bool Modified() const { return IsModified(); }
157#endif
158
5bd3a2da 159protected:
a1b82138
VZ
160 // the name of the last file loaded with LoadFile() which will be used by
161 // SaveFile() by default
162 wxString m_filename;
fa40e7a1
SB
163
164private:
165#ifndef NO_TEXT_WINDOW_STREAM
166#if !wxUSE_IOSTREAMH
167 char *m_streambuf;
168#endif
169#endif
a1b82138
VZ
170};
171
172// ----------------------------------------------------------------------------
173// include the platform-dependent class definition
174// ----------------------------------------------------------------------------
175
2049ba38 176#if defined(__WXMSW__)
a1b82138 177 #include "wx/msw/textctrl.h"
2049ba38 178#elif defined(__WXMOTIF__)
a1b82138 179 #include "wx/motif/textctrl.h"
2049ba38 180#elif defined(__WXGTK__)
a1b82138 181 #include "wx/gtk/textctrl.h"
b4e76e0d 182#elif defined(__WXQT__)
a1b82138 183 #include "wx/qt/textctrl.h"
34138703 184#elif defined(__WXMAC__)
a1b82138 185 #include "wx/mac/textctrl.h"
1777b9bb
DW
186#elif defined(__WXPM__)
187 #include "wx/os2/textctrl.h"
34138703 188#elif defined(__WXSTUBS__)
a1b82138 189 #include "wx/stubs/textctrl.h"
c801d85f
KB
190#endif
191
192#endif
34138703 193 // _WX_TEXTCTRL_H_BASE_