]> git.saurik.com Git - wxWidgets.git/blame - include/wx/textctrl.h
1. wxWindow::Centre() hopefully fixed
[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
324dbfec 31 #if wxUSE_STD_IOSTREAM
bac507e0 32 #include "wx/ioswrap.h" // for iostream classes if we need them
a1b82138
VZ
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
0efe5ba7
VZ
39class WXDLLEXPORT wxTextCtrl;
40
a1b82138
VZ
41// ----------------------------------------------------------------------------
42// constants
43// ----------------------------------------------------------------------------
44
45WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
46WXDLLEXPORT_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
53class WXDLLEXPORT wxTextCtrlBase : public wxControl
54#ifndef NO_TEXT_WINDOW_STREAM
55 , public streambuf
56#endif
57
58{
59public:
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;
0efe5ba7 105 virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
a1b82138
VZ
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);
a324a7bc 148 wxTextCtrl& operator<<(const wxChar c);
a1b82138
VZ
149
150 // obsolete functions
151#if WXWIN_COMPATIBILITY
152 bool Modified() const { return IsModified(); }
153#endif
154
155private:
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
2049ba38 165#if defined(__WXMSW__)
a1b82138 166 #include "wx/msw/textctrl.h"
2049ba38 167#elif defined(__WXMOTIF__)
a1b82138 168 #include "wx/motif/textctrl.h"
2049ba38 169#elif defined(__WXGTK__)
a1b82138 170 #include "wx/gtk/textctrl.h"
b4e76e0d 171#elif defined(__WXQT__)
a1b82138 172 #include "wx/qt/textctrl.h"
34138703 173#elif defined(__WXMAC__)
a1b82138 174 #include "wx/mac/textctrl.h"
1777b9bb
DW
175#elif defined(__WXPM__)
176 #include "wx/os2/textctrl.h"
34138703 177#elif defined(__WXSTUBS__)
a1b82138 178 #include "wx/stubs/textctrl.h"
c801d85f
KB
179#endif
180
181#endif
34138703 182 // _WX_TEXTCTRL_H_BASE_