]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
Getting various compilers to work with wxWin again
[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,
62 const wxSize& size = wxDefaultSize, long style = 0,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxTextCtrlNameStr)
2bda0e17 65#ifndef NO_TEXT_WINDOW_STREAM
bfc6fde4 66 :streambuf()
2bda0e17 67#endif
bfc6fde4
VZ
68 {
69 Create(parent, id, value, pos, size, style, validator, name);
70 }
71
72 bool Create(wxWindow *parent, wxWindowID id,
73 const wxString& value = wxEmptyString,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
76 const wxValidator& validator = wxDefaultValidator,
77 const wxString& name = wxTextCtrlNameStr);
78
79 // accessors
80 // ---------
81 virtual wxString GetValue() const ;
82 virtual void SetValue(const wxString& value);
83
84 virtual int GetLineLength(long lineNo) const;
85 virtual wxString GetLineText(long lineNo) const;
86 virtual int GetNumberOfLines() const;
87
88 // operations
89 // ----------
90
91 // Clipboard operations
92 virtual void Copy();
93 virtual void Cut();
94 virtual void Paste();
95
ca8b28f2
JS
96 virtual bool CanCopy() const;
97 virtual bool CanCut() const;
98 virtual bool CanPaste() const;
99
100 // Undo/redo
101 virtual void Undo();
102 virtual void Redo();
103
104 virtual bool CanUndo() const;
105 virtual bool CanRedo() const;
106
bfc6fde4
VZ
107 virtual void SetInsertionPoint(long pos);
108 virtual void SetInsertionPointEnd();
109 virtual long GetInsertionPoint() const ;
110 virtual long GetLastPosition() const ;
111 virtual void Replace(long from, long to, const wxString& value);
112 virtual void Remove(long from, long to);
113 virtual void SetSelection(long from, long to);
114 virtual void SetEditable(bool editable);
115
ca8b28f2
JS
116 // If the return values from and to are the same, there is no
117 // selection.
118 virtual void GetSelection(long* from, long* to) const;
119 virtual bool IsEditable() const ;
120
bfc6fde4 121 // streambuf implementation
2bda0e17 122#ifndef NO_TEXT_WINDOW_STREAM
bfc6fde4
VZ
123 int overflow(int i);
124 int sync();
125 int underflow();
2bda0e17 126#endif
5fb9fcfc 127
bfc6fde4
VZ
128 wxTextCtrl& operator<<(const wxString& s);
129 wxTextCtrl& operator<<(int i);
130 wxTextCtrl& operator<<(long i);
131 wxTextCtrl& operator<<(float f);
132 wxTextCtrl& operator<<(double d);
133 wxTextCtrl& operator<<(const char c);
5fb9fcfc 134
bfc6fde4
VZ
135 virtual bool LoadFile(const wxString& file);
136 virtual bool SaveFile(const wxString& file);
137 virtual void WriteText(const wxString& text);
138 virtual void AppendText(const wxString& text);
139 virtual void DiscardEdits();
140 virtual bool IsModified() const;
5fb9fcfc 141
2bda0e17 142#if WXWIN_COMPATIBILITY
bfc6fde4 143 inline bool Modified() const { return IsModified(); }
2bda0e17 144#endif
5fb9fcfc 145
bfc6fde4
VZ
146 virtual long XYToPosition(long x, long y) const ;
147 virtual void PositionToXY(long pos, long *x, long *y) const ;
148 virtual void ShowPosition(long pos);
149 virtual void Clear();
5fb9fcfc 150
bfc6fde4
VZ
151 // callbacks
152 // ---------
153 void OnDropFiles(wxDropFilesEvent& event);
154 void OnChar(wxKeyEvent& event); // Process 'enter' if required
5fb9fcfc 155
e702ff0f
JS
156 void OnCut(wxCommandEvent& event);
157 void OnCopy(wxCommandEvent& event);
158 void OnPaste(wxCommandEvent& event);
159 void OnUndo(wxCommandEvent& event);
160 void OnRedo(wxCommandEvent& event);
161
162 void OnUpdateCut(wxUpdateUIEvent& event);
163 void OnUpdateCopy(wxUpdateUIEvent& event);
164 void OnUpdatePaste(wxUpdateUIEvent& event);
165 void OnUpdateUndo(wxUpdateUIEvent& event);
166 void OnUpdateRedo(wxUpdateUIEvent& event);
167
bfc6fde4
VZ
168 // Implementation
169 // --------------
170 virtual void Command(wxCommandEvent& event);
171 virtual bool MSWCommand(WXUINT param, WXWORD id);
396bdd5a
VZ
172
173#if wxUSE_RICHEDIT
bfc6fde4
VZ
174 bool IsRich() const { return m_isRich; }
175 void SetRichEdit(bool isRich) { m_isRich = isRich; }
396bdd5a
VZ
176#endif
177
bfc6fde4
VZ
178 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
179 WXUINT message, WXWPARAM wParam,
180 WXLPARAM lParam);
5fb9fcfc 181
bfc6fde4
VZ
182 virtual void AdoptAttributesFromHWND();
183 virtual void SetupColours();
184 virtual long MSWGetDlgCode();
5fb9fcfc 185
2bda0e17 186protected:
396bdd5a 187#if wxUSE_RICHEDIT
bfc6fde4 188 bool m_isRich; // Are we using rich text edit to implement this?
396bdd5a
VZ
189#endif
190
bfc6fde4 191 wxString m_fileName;
5fb9fcfc 192
789295bf
VZ
193 // call this to increase the size limit (will do nothing if the current
194 // limit is big enough)
195 void AdjustSpaceLimit();
196
bfc6fde4 197 virtual void DoSetSize(int x, int y,
789295bf
VZ
198 int width, int height,
199 int sizeFlags = wxSIZE_AUTO);
bfc6fde4
VZ
200
201private:
202 DECLARE_EVENT_TABLE()
2bda0e17
KB
203};
204
205#endif
bbcdf8bc 206 // _WX_TEXTCTRL_H_