]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
*** empty log message ***
[wxWidgets.git] / include / wx / msw / textctrl.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.h
3// Purpose: wxTextCtrl class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
5fb9fcfc 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
2bda0e17
KB
14
15#ifdef __GNUG__
396bdd5a 16 #pragma interface "textctrl.h"
2bda0e17
KB
17#endif
18
396bdd5a 19#include "wx/setup.h"
2bda0e17
KB
20#include "wx/control.h"
21
47d67540 22#if wxUSE_IOSTREAMH
396bdd5a 23 #include <iostream.h>
2bda0e17 24#else
396bdd5a
VZ
25 #include <iostream>
26#endif
27
5ea105e0 28#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
396bdd5a
VZ
29 #define wxUSE_RICHEDIT 1
30#else
31 #define wxUSE_RICHEDIT 0
2bda0e17
KB
32#endif
33
39ca6d79
OK
34WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
35WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
2bda0e17
KB
36
37// Single-line text item
bfc6fde4 38class WXDLLEXPORT wxTextCtrl : public wxControl
2bda0e17
KB
39
40// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow and streambuf:
41// it complains about deriving a huge class from the huge class streambuf. !!
42// Also, can't use streambuf if making or using a DLL :-(
43
3f1af920 44#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
2bda0e17
KB
45#define NO_TEXT_WINDOW_STREAM
46#endif
47
48#ifndef NO_TEXT_WINDOW_STREAM
49, public streambuf
50#endif
51
52{
53 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
5fb9fcfc 54
ae29de83 55public:
bfc6fde4
VZ
56 // creation
57 // --------
58 wxTextCtrl();
59 wxTextCtrl(wxWindow *parent, wxWindowID id,
60 const wxString& value = wxEmptyString,
61 const wxPoint& pos = wxDefaultPosition,
4438caf4
VZ
62 const wxSize& size = wxDefaultSize,
63 long style = 0,
bfc6fde4
VZ
64 const wxValidator& validator = wxDefaultValidator,
65 const wxString& name = wxTextCtrlNameStr)
2bda0e17 66#ifndef NO_TEXT_WINDOW_STREAM
bfc6fde4 67 :streambuf()
2bda0e17 68#endif
bfc6fde4
VZ
69 {
70 Create(parent, id, value, pos, size, style, validator, name);
71 }
72
73 bool Create(wxWindow *parent, wxWindowID id,
74 const wxString& value = wxEmptyString,
75 const wxPoint& pos = wxDefaultPosition,
4438caf4
VZ
76 const wxSize& size = wxDefaultSize,
77 long style = 0,
bfc6fde4
VZ
78 const wxValidator& validator = wxDefaultValidator,
79 const wxString& name = wxTextCtrlNameStr);
80
81 // accessors
82 // ---------
4438caf4
VZ
83
84 virtual wxString GetValue() const;
bfc6fde4
VZ
85 virtual void SetValue(const wxString& value);
86
87 virtual int GetLineLength(long lineNo) const;
88 virtual wxString GetLineText(long lineNo) const;
89 virtual int GetNumberOfLines() const;
90
91 // operations
92 // ----------
93
94 // Clipboard operations
95 virtual void Copy();
96 virtual void Cut();
97 virtual void Paste();
98
ca8b28f2
JS
99 virtual bool CanCopy() const;
100 virtual bool CanCut() const;
101 virtual bool CanPaste() const;
102
103 // Undo/redo
104 virtual void Undo();
105 virtual void Redo();
106
107 virtual bool CanUndo() const;
108 virtual bool CanRedo() const;
109
bfc6fde4
VZ
110 virtual void SetInsertionPoint(long pos);
111 virtual void SetInsertionPointEnd();
112 virtual long GetInsertionPoint() const ;
113 virtual long GetLastPosition() const ;
114 virtual void Replace(long from, long to, const wxString& value);
115 virtual void Remove(long from, long to);
116 virtual void SetSelection(long from, long to);
117 virtual void SetEditable(bool editable);
118
ca8b28f2
JS
119 // If the return values from and to are the same, there is no
120 // selection.
121 virtual void GetSelection(long* from, long* to) const;
122 virtual bool IsEditable() const ;
123
bfc6fde4 124 // streambuf implementation
2bda0e17 125#ifndef NO_TEXT_WINDOW_STREAM
bfc6fde4
VZ
126 int overflow(int i);
127 int sync();
128 int underflow();
2bda0e17 129#endif
5fb9fcfc 130
bfc6fde4
VZ
131 wxTextCtrl& operator<<(const wxString& s);
132 wxTextCtrl& operator<<(int i);
133 wxTextCtrl& operator<<(long i);
134 wxTextCtrl& operator<<(float f);
135 wxTextCtrl& operator<<(double d);
136 wxTextCtrl& operator<<(const char c);
5fb9fcfc 137
bfc6fde4
VZ
138 virtual bool LoadFile(const wxString& file);
139 virtual bool SaveFile(const wxString& file);
140 virtual void WriteText(const wxString& text);
141 virtual void AppendText(const wxString& text);
142 virtual void DiscardEdits();
143 virtual bool IsModified() const;
5fb9fcfc 144
2bda0e17 145#if WXWIN_COMPATIBILITY
bfc6fde4 146 inline bool Modified() const { return IsModified(); }
2bda0e17 147#endif
5fb9fcfc 148
bfc6fde4
VZ
149 virtual long XYToPosition(long x, long y) const ;
150 virtual void PositionToXY(long pos, long *x, long *y) const ;
151 virtual void ShowPosition(long pos);
152 virtual void Clear();
5fb9fcfc 153
4438caf4
VZ
154 // Implementation from now on
155 // --------------------------
e702ff0f 156
bfc6fde4
VZ
157 virtual void Command(wxCommandEvent& event);
158 virtual bool MSWCommand(WXUINT param, WXWORD id);
396bdd5a
VZ
159
160#if wxUSE_RICHEDIT
bfc6fde4
VZ
161 bool IsRich() const { return m_isRich; }
162 void SetRichEdit(bool isRich) { m_isRich = isRich; }
396bdd5a
VZ
163#endif
164
bfc6fde4
VZ
165 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
166 WXUINT message, WXWPARAM wParam,
167 WXLPARAM lParam);
5fb9fcfc 168
bfc6fde4
VZ
169 virtual void AdoptAttributesFromHWND();
170 virtual void SetupColours();
5fb9fcfc 171
c50f1fb9
VZ
172 virtual bool AcceptsFocus() const;
173
4438caf4
VZ
174 // callbacks
175 // ---------
176 void OnDropFiles(wxDropFilesEvent& event);
177 void OnChar(wxKeyEvent& event); // Process 'enter' if required
178
179 void OnCut(wxCommandEvent& event);
180 void OnCopy(wxCommandEvent& event);
181 void OnPaste(wxCommandEvent& event);
182 void OnUndo(wxCommandEvent& event);
183 void OnRedo(wxCommandEvent& event);
184
185 void OnUpdateCut(wxUpdateUIEvent& event);
186 void OnUpdateCopy(wxUpdateUIEvent& event);
187 void OnUpdatePaste(wxUpdateUIEvent& event);
188 void OnUpdateUndo(wxUpdateUIEvent& event);
189 void OnUpdateRedo(wxUpdateUIEvent& event);
190
2bda0e17 191protected:
396bdd5a 192#if wxUSE_RICHEDIT
bfc6fde4 193 bool m_isRich; // Are we using rich text edit to implement this?
396bdd5a
VZ
194#endif
195
bfc6fde4 196 wxString m_fileName;
5fb9fcfc 197
789295bf
VZ
198 // call this to increase the size limit (will do nothing if the current
199 // limit is big enough)
200 void AdjustSpaceLimit();
201
4438caf4 202 virtual wxSize DoGetBestSize();
bfc6fde4
VZ
203
204private:
205 DECLARE_EVENT_TABLE()
2bda0e17
KB
206};
207
208#endif
bbcdf8bc 209 // _WX_TEXTCTRL_H_