]> git.saurik.com Git - wxWidgets.git/blame - include/wx/textctrl.h
fixed SelectItem call with an invalid item
[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// ----------------------------------------------------------------------------
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 #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
37#endif
38
39// ----------------------------------------------------------------------------
40// constants
41// ----------------------------------------------------------------------------
42
43WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
44WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
45
46// ----------------------------------------------------------------------------
47// wxTextCtrl: a single or multiple line text zone where user can enter and
48// edit text
49// ----------------------------------------------------------------------------
50
51class WXDLLEXPORT wxTextCtrlBase : public wxControl
52#ifndef NO_TEXT_WINDOW_STREAM
53 , public streambuf
54#endif
55
56{
57public:
58 // creation
59 // --------
60
61 wxTextCtrlBase();
62
63 // accessors
64 // ---------
65
66 virtual wxString GetValue() const = 0;
67 virtual void SetValue(const wxString& value) = 0;
68
69 virtual int GetLineLength(long lineNo) const = 0;
70 virtual wxString GetLineText(long lineNo) const = 0;
71 virtual int GetNumberOfLines() const = 0;
72
73 virtual bool IsModified() const = 0;
74 virtual bool IsEditable() const = 0;
75
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;
78
79 // operations
80 // ----------
81
82 // editing
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;
86
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);
90
91 // clears the dirty flag
92 virtual void DiscardEdits() = 0;
93
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;
98
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;
104
105 virtual void ShowPosition(long pos) = 0;
106
107 // Clipboard operations
108 virtual void Copy() = 0;
109 virtual void Cut() = 0;
110 virtual void Paste() = 0;
111
112 virtual bool CanCopy() const = 0;
113 virtual bool CanCut() const = 0;
114 virtual bool CanPaste() const = 0;
115
116 // Undo/redo
117 virtual void Undo() = 0;
118 virtual void Redo() = 0;
119
120 virtual bool CanUndo() const = 0;
121 virtual bool CanRedo() const = 0;
122
123 // Insertion point
124 virtual void SetInsertionPoint(long pos) = 0;
125 virtual void SetInsertionPointEnd() = 0;
126 virtual long GetInsertionPoint() const = 0;
127 virtual long GetLastPosition() const = 0;
128
129 virtual void SetSelection(long from, long to) = 0;
130 virtual void SetEditable(bool editable) = 0;
131
132 // streambuf methods
133#ifndef NO_TEXT_WINDOW_STREAM
134 int overflow(int i);
135 int sync();
136 int underflow();
137#endif // NO_TEXT_WINDOW_STREAM
138
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);
147
148 // obsolete functions
149#if WXWIN_COMPATIBILITY
150 bool Modified() const { return IsModified(); }
151#endif
152
153private:
154 // the name of the last file loaded with LoadFile() which will be used by
155 // SaveFile() by default
156 wxString m_filename;
157};
158
159// ----------------------------------------------------------------------------
160// include the platform-dependent class definition
161// ----------------------------------------------------------------------------
162
2049ba38 163#if defined(__WXMSW__)
a1b82138 164 #include "wx/msw/textctrl.h"
2049ba38 165#elif defined(__WXMOTIF__)
a1b82138 166 #include "wx/motif/textctrl.h"
2049ba38 167#elif defined(__WXGTK__)
a1b82138 168 #include "wx/gtk/textctrl.h"
b4e76e0d 169#elif defined(__WXQT__)
a1b82138 170 #include "wx/qt/textctrl.h"
34138703 171#elif defined(__WXMAC__)
a1b82138 172 #include "wx/mac/textctrl.h"
34138703 173#elif defined(__WXSTUBS__)
a1b82138 174 #include "wx/stubs/textctrl.h"
c801d85f
KB
175#endif
176
177#endif
34138703 178 // _WX_TEXTCTRL_H_BASE_