]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
wxMGL update
[wxWidgets.git] / include / wx / msw / textctrl.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
d7eee191 2// Name: wx/msw/textctrl.h
2bda0e17
KB
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
a1b82138 19class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
2bda0e17 20{
ae29de83 21public:
bfc6fde4
VZ
22 // creation
23 // --------
a1b82138 24
bfc6fde4
VZ
25 wxTextCtrl();
26 wxTextCtrl(wxWindow *parent, wxWindowID id,
a1b82138
VZ
27 const wxString& value = wxEmptyString,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = 0,
31 const wxValidator& validator = wxDefaultValidator,
32 const wxString& name = wxTextCtrlNameStr)
33 {
34 Create(parent, id, value, pos, size, style, validator, name);
35 }
bfc6fde4
VZ
36
37 bool Create(wxWindow *parent, wxWindowID id,
a1b82138
VZ
38 const wxString& value = wxEmptyString,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxTextCtrlNameStr);
bfc6fde4 44
a1b82138
VZ
45 // implement base class pure virtuals
46 // ----------------------------------
4438caf4
VZ
47
48 virtual wxString GetValue() const;
bfc6fde4
VZ
49 virtual void SetValue(const wxString& value);
50
51 virtual int GetLineLength(long lineNo) const;
52 virtual wxString GetLineText(long lineNo) const;
53 virtual int GetNumberOfLines() const;
54
a1b82138
VZ
55 virtual bool IsModified() const;
56 virtual bool IsEditable() const;
57
58 // If the return values from and to are the same, there is no selection.
59 virtual void GetSelection(long* from, long* to) const;
60
bfc6fde4
VZ
61 // operations
62 // ----------
63
a1b82138
VZ
64 // editing
65 virtual void Clear();
66 virtual void Replace(long from, long to, const wxString& value);
67 virtual void Remove(long from, long to);
68
69 // load the controls contents from the file
70 virtual bool LoadFile(const wxString& file);
71
72 // clears the dirty flag
73 virtual void DiscardEdits();
74
d7eee191
VZ
75 virtual void SetMaxLength(unsigned long len);
76
a1b82138
VZ
77 // writing text inserts it at the current position, appending always
78 // inserts it at the end
79 virtual void WriteText(const wxString& text);
80 virtual void AppendText(const wxString& text);
81
4bc1afd5
VZ
82#if wxUSE_RICHEDIT
83 // apply text attribute to the range of text (only works with richedit
84 // controls)
85 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
86#endif // wxUSE_RICHEDIT
87
a1b82138
VZ
88 // translate between the position (which is just an index in the text ctrl
89 // considering all its contents as a single strings) and (x, y) coordinates
90 // which represent column and line.
91 virtual long XYToPosition(long x, long y) const;
0efe5ba7 92 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
93
94 virtual void ShowPosition(long pos);
95
bfc6fde4
VZ
96 // Clipboard operations
97 virtual void Copy();
98 virtual void Cut();
99 virtual void Paste();
100
ca8b28f2
JS
101 virtual bool CanCopy() const;
102 virtual bool CanCut() const;
103 virtual bool CanPaste() const;
104
105 // Undo/redo
106 virtual void Undo();
107 virtual void Redo();
108
109 virtual bool CanUndo() const;
110 virtual bool CanRedo() const;
111
a1b82138 112 // Insertion point
bfc6fde4
VZ
113 virtual void SetInsertionPoint(long pos);
114 virtual void SetInsertionPointEnd();
a1b82138
VZ
115 virtual long GetInsertionPoint() const;
116 virtual long GetLastPosition() const;
117
bfc6fde4
VZ
118 virtual void SetSelection(long from, long to);
119 virtual void SetEditable(bool editable);
120
4438caf4
VZ
121 // Implementation from now on
122 // --------------------------
e702ff0f 123
bfc6fde4
VZ
124 virtual void Command(wxCommandEvent& event);
125 virtual bool MSWCommand(WXUINT param, WXWORD id);
f6bcfd97
BP
126 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
127 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
128
129 // In WIN16, need to override normal erasing because
130 // Ctl3D doesn't use the wxWindows background colour.
131#ifdef __WIN16__
132 void OnEraseBackground(wxEraseEvent& event);
133#endif
396bdd5a
VZ
134
135#if wxUSE_RICHEDIT
c57e3339
VZ
136 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
137
bfc6fde4
VZ
138 bool IsRich() const { return m_isRich; }
139 void SetRichEdit(bool isRich) { m_isRich = isRich; }
f6bcfd97
BP
140
141 // rich edit controls are not compatible with normal ones and wem ust set
142 // the colours for them otherwise
143 virtual bool SetBackgroundColour(const wxColour& colour);
144 virtual bool SetForegroundColour(const wxColour& colour);
a1b82138 145#endif // wxUSE_RICHEDIT
396bdd5a 146
bfc6fde4
VZ
147 virtual void AdoptAttributesFromHWND();
148 virtual void SetupColours();
5fb9fcfc 149
c50f1fb9
VZ
150 virtual bool AcceptsFocus() const;
151
4438caf4 152 // callbacks
4438caf4
VZ
153 void OnDropFiles(wxDropFilesEvent& event);
154 void OnChar(wxKeyEvent& event); // Process 'enter' if required
155
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
2bda0e17 168protected:
789295bf
VZ
169 // call this to increase the size limit (will do nothing if the current
170 // limit is big enough)
d7eee191
VZ
171 //
172 // returns true if we increased the limit to allow entering more text,
173 // false if we hit the limit set by SetMaxLength() and so didn't change it
174 bool AdjustSpaceLimit();
789295bf 175
a37d422a
VZ
176 // override some base class virtuals
177 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
f68586e5 178 virtual wxSize DoGetBestSize() const;
bfc6fde4 179
d7eee191
VZ
180#if wxUSE_RICHEDIT
181 bool m_isRich; // Are we using rich text edit to implement this?
182#endif
183
bfc6fde4
VZ
184private:
185 DECLARE_EVENT_TABLE()
a1b82138 186 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
2bda0e17
KB
187};
188
189#endif
bbcdf8bc 190 // _WX_TEXTCTRL_H_